Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c5067ea authored by Kenny Guy's avatar Kenny Guy
Browse files

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
parent c4aa3c78
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -412,6 +412,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.
     */
@@ -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");
        }
    }