diff options
author | guotao.deng <guotao.deng@ck-telecom.com> | 2015-10-28 09:07:44 +0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 05:40:47 -0800 |
commit | d37480ec9e877176e56f22569eb9d99f16fd27c0 (patch) | |
tree | f4ac46c84128e504ff22773ec9cfb6af82eb1901 /services | |
parent | a9c0e5854ead8dc6d279bf4352585f8d80c83e47 (diff) | |
download | frameworks_base-d37480ec9e877176e56f22569eb9d99f16fd27c0.zip frameworks_base-d37480ec9e877176e56f22569eb9d99f16fd27c0.tar.gz frameworks_base-d37480ec9e877176e56f22569eb9d99f16fd27c0.tar.bz2 |
We should notify the foreground activity changes immediately.
For example, when device bootup, Launcher is foreground activity,
but NFC do not register the listener yet when AMS notify the changes.
So NFC cannot use beam when device just bootup.
Change-Id: I55ad7947ecbfbbf7c30dabd3b530e5b011b8cb65
Diffstat (limited to 'services')
-rwxr-xr-x[-rw-r--r--] | services/core/java/com/android/server/am/ActivityManagerService.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 74fbe74..06484e2 100644..100755 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1246,6 +1246,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean foregroundActivities; } + private Map<Integer, Object[]> mForegroundActivitiesList = new HashMap<Integer, Object[]>(); final RemoteCallbackList<IProcessObserver> mProcessObservers = new RemoteCallbackList<>(); ProcessChangeItem[] mActiveProcessChanges = new ProcessChangeItem[5]; @@ -11153,6 +11154,18 @@ public final class ActivityManagerService extends ActivityManagerNative enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER, "registerProcessObserver()"); synchronized (this) { + for (Integer key : mForegroundActivitiesList.keySet()) { + Object[] o = mForegroundActivitiesList.get(key); + if (o.length == 3) { + try { + observer.onForegroundActivitiesChanged((int) o[0], + (int) o[1], (boolean) o[2]); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } mProcessObservers.register(observer); } } @@ -19059,6 +19072,12 @@ public final class ActivityManagerService extends ActivityManagerNative item.changes |= changes; item.processState = app.repProcState; item.foregroundActivities = app.repForegroundActivities; + if (item.foregroundActivities) { + Object[] o = new Object[]{item.pid, item.uid, item.foregroundActivities}; + mForegroundActivitiesList.put(item.pid, o); + } else if (!item.foregroundActivities && mForegroundActivitiesList.get(item.pid) != null) { + mForegroundActivitiesList.remove(item.pid); + } if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Item " + Integer.toHexString(System.identityHashCode(item)) + " " + app.toShortString() + ": changes=" + item.changes |