diff options
author | Kenny Guy <kennyguy@google.com> | 2015-04-30 19:39:00 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2015-04-30 19:39:00 +0100 |
commit | 4c5067ea8e33974c81fb69f3565dd93634bea132 (patch) | |
tree | 3a820ac5a7b6e50cc9a958c92b6047b25712653b | |
parent | c4aa3c781a0ddce64853cd5d88bf97f8a9faf98b (diff) | |
download | frameworks_base-4c5067ea8e33974c81fb69f3565dd93634bea132.zip frameworks_base-4c5067ea8e33974c81fb69f3565dd93634bea132.tar.gz frameworks_base-4c5067ea8e33974c81fb69f3565dd93634bea132.tar.bz2 |
Call profile changed in cases were focused activity is nulled.
Fix case where profile changed listener isn't called as
focused acitivity is set to null due to app crash.
Bug: 20254760
Change-Id: Ifc296682b9f7cb85c05137e8ad6ad74d31bf6eff
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 15d7367..bc3711f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -413,6 +413,11 @@ public final class ActivityManagerService extends ActivityManagerNative ActivityRecord mFocusedActivity = null; /** + * User id of the last activity mFocusedActivity was set to. + */ + private int mLastFocusedUserId; + + /** * List of intents that were used to start the most recent tasks. */ private final RecentTasks mRecentTasks; @@ -2562,19 +2567,32 @@ public final class ActivityManagerService extends ActivityManagerNative mWindowManager.setFocusedApp(r.appToken, true); } applyUpdateLockStateLocked(r); - if (last != null && last.userId != mFocusedActivity.userId) { + if (mFocusedActivity.userId != mLastFocusedUserId) { mHandler.removeMessages(FOREGROUND_PROFILE_CHANGED_MSG); mHandler.sendMessage(mHandler.obtainMessage(FOREGROUND_PROFILE_CHANGED_MSG, mFocusedActivity.userId, 0)); + mLastFocusedUserId = mFocusedActivity.userId; } } - EventLog.writeEvent(EventLogTags.AM_FOCUSED_ACTIVITY, mCurrentUserId, + EventLog.writeEvent(EventLogTags.AM_FOCUSED_ACTIVITY, + mFocusedActivity == null ? -1 : mFocusedActivity.userId, mFocusedActivity == null ? "NULL" : mFocusedActivity.shortComponentName); } final void clearFocusedActivity(ActivityRecord r) { if (mFocusedActivity == r) { + ActivityStack stack = mStackSupervisor.getFocusedStack(); + if (stack != null) { + ActivityRecord top = stack.topActivity(); + if (top != null && top.userId != mLastFocusedUserId) { + mHandler.removeMessages(FOREGROUND_PROFILE_CHANGED_MSG); + mHandler.sendMessage(mHandler.obtainMessage(FOREGROUND_PROFILE_CHANGED_MSG, + top.userId, 0)); + mLastFocusedUserId = top.userId; + } + } mFocusedActivity = null; + EventLog.writeEvent(EventLogTags.AM_FOCUSED_ACTIVITY, -1, "NULL"); } } |