summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wale Ogunwale <ogunwale@google.com> 2017-04-25 07:44:21 -0700
committer Wale Ogunwale <ogunwale@google.com> 2017-04-25 08:41:31 -0700
commitec95064ded280616277be44cd5460f07c43631ef (patch)
tree1d58ba330f584cc6c96029b36e21f24245c12ec6
parenta31f49a0df23ffbb27f018900a181693e6c32d9e (diff)
Fixed issue with turn-screen-on activities
Regression introduced by ag/2147938 where we set the visibility of an app to false after pausing because it might have been previously defered. However, the change did it for all activities regardless of if it was previously deferred or not. We now only do the visibility change to false if we previouly deferred. Change-Id: Ifde46587e1ddf38304b73cec45c56f0acd955f37 Fixes: 37657105 Test: cts.ActivityManagerActivityVisibilityTests#testTurnScreenOnActivity
-rw-r--r--services/core/java/com/android/server/am/ActivityRecord.java28
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java9
2 files changed, 26 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index eeedab8856e5..3e0734f07059 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -274,11 +274,13 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
// completed
boolean preserveWindowOnDeferredRelaunch; // activity windows are preserved on deferred relaunch
int configChangeFlags; // which config values have changed
- boolean keysPaused; // has key dispatching been paused for it?
+ private boolean keysPaused; // has key dispatching been paused for it?
int launchMode; // the launch mode activity attribute.
boolean visible; // does this activity's window need to be shown?
boolean visibleIgnoringKeyguard; // is this activity visible, ignoring the fact that Keyguard
// might hide this activity?
+ private boolean mDeferHidingClient; // If true we told WM to defer reporting to the client
+ // process that it is hidden.
boolean sleeping; // have we told the activity to sleep?
boolean nowVisible; // is this activity's window visible?
boolean idle; // has the activity gone idle?
@@ -523,6 +525,9 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
else TimeUtils.formatDuration(lastVisibleTime, now, pw);
pw.println();
}
+ if (mDeferHidingClient) {
+ pw.println(prefix + "mDeferHidingClient=" + mDeferHidingClient);
+ }
if (deferRelaunchUntilPaused || configChangeFlags != 0) {
pw.print(prefix); pw.print("deferRelaunchUntilPaused="); pw.print(deferRelaunchUntilPaused);
pw.print(" configChangeFlags=");
@@ -1567,22 +1572,31 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
return mWindowContainerController.screenshotApplications(getDisplayId(), w, h, scale);
}
- void setVisibility(boolean visible) {
- mWindowContainerController.setVisibility(visible, false /* deferHidingClient */);
+ void setDeferHidingClient(boolean deferHidingClient) {
+ if (mDeferHidingClient == deferHidingClient) {
+ return;
+ }
+ mDeferHidingClient = deferHidingClient;
+ if (!mDeferHidingClient && !visible) {
+ // Hiding the client is no longer deferred and the app isn't visible still, go ahead and
+ // update the visibility.
+ setVisibility(false);
+ }
}
- void setVisible(boolean newVisible) {
- setVisible(newVisible, false /* deferHidingClient */);
+ void setVisibility(boolean visible) {
+ mWindowContainerController.setVisibility(visible, mDeferHidingClient);
}
// TODO: Look into merging with #setVisibility()
- void setVisible(boolean newVisible, boolean deferHidingClient) {
+ void setVisible(boolean newVisible) {
visible = newVisible;
+ mDeferHidingClient = !visible && mDeferHidingClient;
if (!visible && mUpdateTaskThumbnailWhenHidden) {
updateThumbnailLocked(screenshotActivityLocked(), null /* description */);
mUpdateTaskThumbnailWhenHidden = false;
}
- mWindowContainerController.setVisibility(visible, deferHidingClient);
+ setVisibility(visible);
final ArrayList<ActivityContainer> containers = mChildContainers;
for (int containerNdx = containers.size() - 1; containerNdx >= 0; --containerNdx) {
final ActivityContainer container = containers.get(containerNdx);
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 1e8a5878649c..728a3b98e638 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1406,10 +1406,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
prev.state = STOPPING;
} else if ((!prev.visible && !hasVisibleBehindActivity())
|| mService.isSleepingOrShuttingDownLocked()) {
+ // Clear out any deferred client hide we might currently have.
+ prev.setDeferHidingClient(false);
// If we were visible then resumeTopActivities will release resources before
- // stopping. Also, set visibility to false to flush any client hide that might have
- // been deferred.
- prev.setVisibility(false);
+ // stopping.
addToStopping(prev, true /* scheduleIdle */, false /* idleDelayed */);
}
} else {
@@ -2030,7 +2030,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
// or stopping. This gives it a chance to enter Pip in onPause().
final boolean deferHidingClient = canEnterPictureInPicture
&& r.state != STOPPING && r.state != STOPPED;
- r.setVisible(false, deferHidingClient);
+ r.setDeferHidingClient(deferHidingClient);
+ r.setVisible(false);
switch (r.state) {
case STOPPING: