From 0d595f374face4f421805fda88c11e19d4e27bc6 Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Wed, 21 Feb 2018 15:47:33 -0800 Subject: [PATCH] Resume when keyguard start going away When keyguard is present we can start resuming when AM receives a callback that it starts going away and not wait until animation finishes. This CL also fixes an issue with mKeyguardGoingAway being removed too early in case there is no transition. Plus it brings back a fix for pausing stopped activities after keyguard goes away and they become visible again. Bug: 73003134 Bug: 73062280 Bug: 71582913 Test: Go to launcher or launch an app, lock and unlock, observe Change-Id: I541cf1c942526e844a02fe4e69b690ba0008fe0d --- .../android/server/am/ActivityManagerService.java | 1 - .../java/com/android/server/am/ActivityRecord.java | 14 ++++++++++++++ .../com/android/server/am/KeyguardController.java | 10 ++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index e8f0113ac2aba..698ab00c1e9b9 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -25749,7 +25749,6 @@ public class ActivityManagerService extends IActivityManager.Stub public void notifyAppTransitionFinished() { synchronized (ActivityManagerService.this) { mStackSupervisor.notifyAppTransitionDone(); - mKeyguardController.notifyAppTransitionDone(); } } diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 4e609241238e7..e6c1cd5ccfc0b 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -1625,6 +1625,20 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo // The activity may be waiting for stop, but that is no longer appropriate for it. mStackSupervisor.mStoppingActivities.remove(this); mStackSupervisor.mGoingToSleepActivities.remove(this); + + // If the activity is stopped or stopping, cycle to the paused state. + if (state == STOPPED || state == STOPPING) { + // Capture reason before state change + final String reason = getLifecycleDescription("makeVisibleIfNeeded"); + + // An activity must be in the {@link PAUSING} state for the system to validate + // the move to {@link PAUSED}. + state = PAUSING; + service.mLifecycleManager.scheduleTransaction(app.thread, appToken, + PauseActivityItem.obtain(finishing, false /* userLeaving */, + configChangeFlags, false /* dontReport */) + .setDescription(reason)); + } } catch (Exception e) { // Just skip on any failure; we'll make it visible when it next restarts. Slog.w(TAG, "Exception thrown making visibile: " + intent.getComponent(), e); diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java index e361a7028539d..6b8b38073998d 100644 --- a/services/core/java/com/android/server/am/KeyguardController.java +++ b/services/core/java/com/android/server/am/KeyguardController.java @@ -117,14 +117,11 @@ class KeyguardController { mSecondaryDisplayShowing = secondaryDisplayShowing; if (showingChanged) { dismissDockedStackIfNeeded(); + setKeyguardGoingAway(false); if (showing) { - setKeyguardGoingAway(false); mDismissalRequested = false; } } - if (!showing) { - mStackSupervisor.resumeFocusedStackTopActivityLocked(); - } mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS); updateKeyguardSleepToken(); } @@ -149,6 +146,7 @@ class KeyguardController { updateKeyguardSleepToken(); // Some stack visibility might change (e.g. docked stack) + mStackSupervisor.resumeFocusedStackTopActivityLocked(); mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS); mStackSupervisor.addStartingWindowsForVisibleActivities(true /* taskSwitch */); mWindowManager.executeAppTransition(); @@ -395,8 +393,4 @@ class KeyguardController { proto.write(KEYGUARD_OCCLUDED, mOccluded); proto.end(token); } - - public void notifyAppTransitionDone() { - setKeyguardGoingAway(false); - } }