OSDN Git Service

Introduce AMS.getLastResumedActivityUserId to fix work profile icon issue
authorTony Mak <tonymak@google.com>
Tue, 28 Mar 2017 17:50:01 +0000 (18:50 +0100)
committerTony Mak <tonymak@google.com>
Wed, 29 Mar 2017 10:03:39 +0000 (10:03 +0000)
commitec319aba34deb91f89ec4e15004eee62d5f2801c
tree5300d7e858a180d131e6f4034923943e94a506ea
parent76c32a35a956fa3a4559c6ed9512f4083ec011b7
Introduce AMS.getLastResumedActivityUserId to fix work profile icon issue

Problem:
Work profile status bar icon feeature is relied on two callbacks
1. onForegroundProfileSwitch  (AMS.setResumedActivityLocked)
2. appTransitionStarting (WMS)

We assume callback 1 is always called before 2, but it is not the case.
These two callbacks are triggered by two handlers in two different threads,
and hence race condition happens.

Solution:
Not rely on onForegroundProfileSwitch to update mManagedProfileFocused
flag anymore. Query getLastResumedActivityUserId in appTransitionStarting.
Also, make sure mLastResumedActivity is updated before sending message
to WMS in setResumedActivityLocked.

Test: Start a work app, observe that the work icon is shown.
Test: Start a personal app, observe that work icon is gone.
Test: Dock the work app, tap on it (give it focus), observe that work
      icon is shown.
Test: Start a work app, switch user, can see the icon is gone. Switch back,
      icon is back.

Bug: 34159089

Change-Id: I2cee141d18e8b7d5607b26dd7a2fd5bc9cd0ebb3
core/java/android/app/IActivityManager.aidl
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
services/core/java/com/android/server/am/ActivityManagerService.java