Loading services/core/java/com/android/server/am/ActiveUids.java +2 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ final class ActiveUids { void clear() { mActiveUids.clear(); if (mPostChangesToAtm) { mService.mAtmInternal.onActiveUidsCleared(); } // It is only called for a temporal container with mPostChangesToAtm == false or test case. // So there is no need to notify activity task manager. } UidRecord get(int uid) { Loading services/core/java/com/android/server/wm/ActivityRecord.java +21 −8 Original line number Diff line number Diff line Loading @@ -1558,10 +1558,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } // Application tokens start out hidden. setVisible(false); mVisibleRequested = false; ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService( ColorDisplayService.ColorDisplayServiceInternal.class); cds.attachColorTransformController(packageName, mUserId, Loading Loading @@ -3507,7 +3503,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } if (fromActivity.isVisible()) { setVisible(true); mVisibleRequested = true; setVisibleRequested(true); mVisibleSetFromTransferredStartingWindow = true; } setClientVisible(fromActivity.mClientVisible); Loading Loading @@ -4123,10 +4119,27 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void setVisible(boolean visible) { if (visible != mVisible) { mVisible = visible; if (app != null) { mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } scheduleAnimation(); } } /** * This is the only place that writes {@link #mVisibleRequested} (except unit test). The caller * outside of this class should use {@link #setVisibility}. */ private void setVisibleRequested(boolean visible) { if (visible == mVisibleRequested) { return; } mVisibleRequested = visible; if (app != null) { mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } } /** * Set visibility on this {@link ActivityRecord} * Loading Loading @@ -4190,7 +4203,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A displayContent.mOpeningApps.remove(this); displayContent.mClosingApps.remove(this); waitingToShow = false; mVisibleRequested = visible; setVisibleRequested(visible); mLastDeferHidingClient = deferHidingClient; if (!visible) { Loading Loading @@ -4332,7 +4345,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ANIMATION_TYPE_APP_TRANSITION)); } setVisible(visible); mVisibleRequested = visible; setVisibleRequested(visible); if (!visible) { stopFreezingScreen(true, true); } else { Loading Loading @@ -4520,7 +4533,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A detachChildren(); } if (app != null) { app.computeProcessActivityState(); mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } switch (state) { Loading services/core/java/com/android/server/wm/ActivityStarter.java +4 −5 Original line number Diff line number Diff line Loading @@ -1297,9 +1297,8 @@ class ActivityStarter { final boolean appSwitchAllowed = mService.getBalAppSwitchesAllowed(); // don't abort if the callingUid has a visible window or is a persistent system process final int callingUidProcState = mService.getUidState(callingUid); final boolean callingUidHasAnyVisibleWindow = mService.mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(callingUid); final int callingUidProcState = mService.mActiveUids.getUidState(callingUid); final boolean callingUidHasAnyVisibleWindow = mService.hasActiveVisibleWindow(callingUid); final boolean isCallingUidForeground = callingUidHasAnyVisibleWindow || callingUidProcState == ActivityManager.PROCESS_STATE_TOP || callingUidProcState == ActivityManager.PROCESS_STATE_BOUND_TOP; Loading @@ -1317,10 +1316,10 @@ class ActivityStarter { // take realCallingUid into consideration final int realCallingUidProcState = (callingUid == realCallingUid) ? callingUidProcState : mService.getUidState(realCallingUid); : mService.mActiveUids.getUidState(realCallingUid); final boolean realCallingUidHasAnyVisibleWindow = (callingUid == realCallingUid) ? callingUidHasAnyVisibleWindow : mService.mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(realCallingUid); : mService.hasActiveVisibleWindow(realCallingUid); final boolean isRealCallingUidForeground = (callingUid == realCallingUid) ? isCallingUidForeground : realCallingUidHasAnyVisibleWindow Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +0 −1 Original line number Diff line number Diff line Loading @@ -514,7 +514,6 @@ public abstract class ActivityTaskManagerInternal { public abstract void onUidActive(int uid, int procState); public abstract void onUidInactive(int uid); public abstract void onActiveUidsCleared(); public abstract void onUidProcStateChanged(int uid, int procState); public abstract void onUidAddedToPendingTempAllowlist(int uid, String tag); Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +10 −17 Original line number Diff line number Diff line Loading @@ -390,7 +390,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private UserManagerService mUserManager; private AppOpsManager mAppOpsManager; /** All active uids in the system. */ private final MirrorActiveUids mActiveUids = new MirrorActiveUids(); final MirrorActiveUids mActiveUids = new MirrorActiveUids(); private final SparseArray<String> mPendingTempAllowlist = new SparseArray<>(); /** All processes currently running that might have a window organized by name. */ final ProcessMap<WindowProcessController> mProcessNames = new ProcessMap<>(); Loading Loading @@ -4956,6 +4956,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { printedAnything = true; mTaskSupervisor.dump(pw, " "); mTaskOrganizerController.dump(pw, " "); mVisibleActivityProcessTracker.dump(pw, " "); mActiveUids.dump(pw, " "); } if (!printedAnything) { Loading Loading @@ -5986,13 +5988,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return null; } int getUidState(int uid) { return mActiveUids.getUidState(uid); /** A uid is considered to be foreground if it has a visible non-toast window. */ boolean hasActiveVisibleWindow(int uid) { if (mVisibleActivityProcessTracker.hasVisibleActivity(uid)) { return true; } boolean isUidForeground(int uid) { // A uid is considered to be foreground if it has a visible non-toast window. return mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(uid); return mActiveUids.hasNonAppVisibleWindow(uid); } boolean isDeviceOwner(int uid) { Loading Loading @@ -7281,12 +7282,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mActiveUids.onUidInactive(uid); } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @Override public void onActiveUidsCleared() { mActiveUids.onActiveUidsCleared(); } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @Override public void onUidProcStateChanged(int uid, int procState) { Loading Loading @@ -7432,9 +7427,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean isUidForeground(int uid) { synchronized (mGlobalLock) { return ActivityTaskManagerService.this.isUidForeground(uid); } return ActivityTaskManagerService.this.hasActiveVisibleWindow(uid); } @Override Loading Loading
services/core/java/com/android/server/am/ActiveUids.java +2 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ final class ActiveUids { void clear() { mActiveUids.clear(); if (mPostChangesToAtm) { mService.mAtmInternal.onActiveUidsCleared(); } // It is only called for a temporal container with mPostChangesToAtm == false or test case. // So there is no need to notify activity task manager. } UidRecord get(int uid) { Loading
services/core/java/com/android/server/wm/ActivityRecord.java +21 −8 Original line number Diff line number Diff line Loading @@ -1558,10 +1558,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } // Application tokens start out hidden. setVisible(false); mVisibleRequested = false; ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService( ColorDisplayService.ColorDisplayServiceInternal.class); cds.attachColorTransformController(packageName, mUserId, Loading Loading @@ -3507,7 +3503,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } if (fromActivity.isVisible()) { setVisible(true); mVisibleRequested = true; setVisibleRequested(true); mVisibleSetFromTransferredStartingWindow = true; } setClientVisible(fromActivity.mClientVisible); Loading Loading @@ -4123,10 +4119,27 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void setVisible(boolean visible) { if (visible != mVisible) { mVisible = visible; if (app != null) { mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } scheduleAnimation(); } } /** * This is the only place that writes {@link #mVisibleRequested} (except unit test). The caller * outside of this class should use {@link #setVisibility}. */ private void setVisibleRequested(boolean visible) { if (visible == mVisibleRequested) { return; } mVisibleRequested = visible; if (app != null) { mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } } /** * Set visibility on this {@link ActivityRecord} * Loading Loading @@ -4190,7 +4203,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A displayContent.mOpeningApps.remove(this); displayContent.mClosingApps.remove(this); waitingToShow = false; mVisibleRequested = visible; setVisibleRequested(visible); mLastDeferHidingClient = deferHidingClient; if (!visible) { Loading Loading @@ -4332,7 +4345,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ANIMATION_TYPE_APP_TRANSITION)); } setVisible(visible); mVisibleRequested = visible; setVisibleRequested(visible); if (!visible) { stopFreezingScreen(true, true); } else { Loading Loading @@ -4520,7 +4533,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A detachChildren(); } if (app != null) { app.computeProcessActivityState(); mTaskSupervisor.onProcessActivityStateChanged(app, false /* forceBatch */); } switch (state) { Loading
services/core/java/com/android/server/wm/ActivityStarter.java +4 −5 Original line number Diff line number Diff line Loading @@ -1297,9 +1297,8 @@ class ActivityStarter { final boolean appSwitchAllowed = mService.getBalAppSwitchesAllowed(); // don't abort if the callingUid has a visible window or is a persistent system process final int callingUidProcState = mService.getUidState(callingUid); final boolean callingUidHasAnyVisibleWindow = mService.mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(callingUid); final int callingUidProcState = mService.mActiveUids.getUidState(callingUid); final boolean callingUidHasAnyVisibleWindow = mService.hasActiveVisibleWindow(callingUid); final boolean isCallingUidForeground = callingUidHasAnyVisibleWindow || callingUidProcState == ActivityManager.PROCESS_STATE_TOP || callingUidProcState == ActivityManager.PROCESS_STATE_BOUND_TOP; Loading @@ -1317,10 +1316,10 @@ class ActivityStarter { // take realCallingUid into consideration final int realCallingUidProcState = (callingUid == realCallingUid) ? callingUidProcState : mService.getUidState(realCallingUid); : mService.mActiveUids.getUidState(realCallingUid); final boolean realCallingUidHasAnyVisibleWindow = (callingUid == realCallingUid) ? callingUidHasAnyVisibleWindow : mService.mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(realCallingUid); : mService.hasActiveVisibleWindow(realCallingUid); final boolean isRealCallingUidForeground = (callingUid == realCallingUid) ? isCallingUidForeground : realCallingUidHasAnyVisibleWindow Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +0 −1 Original line number Diff line number Diff line Loading @@ -514,7 +514,6 @@ public abstract class ActivityTaskManagerInternal { public abstract void onUidActive(int uid, int procState); public abstract void onUidInactive(int uid); public abstract void onActiveUidsCleared(); public abstract void onUidProcStateChanged(int uid, int procState); public abstract void onUidAddedToPendingTempAllowlist(int uid, String tag); Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +10 −17 Original line number Diff line number Diff line Loading @@ -390,7 +390,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private UserManagerService mUserManager; private AppOpsManager mAppOpsManager; /** All active uids in the system. */ private final MirrorActiveUids mActiveUids = new MirrorActiveUids(); final MirrorActiveUids mActiveUids = new MirrorActiveUids(); private final SparseArray<String> mPendingTempAllowlist = new SparseArray<>(); /** All processes currently running that might have a window organized by name. */ final ProcessMap<WindowProcessController> mProcessNames = new ProcessMap<>(); Loading Loading @@ -4956,6 +4956,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { printedAnything = true; mTaskSupervisor.dump(pw, " "); mTaskOrganizerController.dump(pw, " "); mVisibleActivityProcessTracker.dump(pw, " "); mActiveUids.dump(pw, " "); } if (!printedAnything) { Loading Loading @@ -5986,13 +5988,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return null; } int getUidState(int uid) { return mActiveUids.getUidState(uid); /** A uid is considered to be foreground if it has a visible non-toast window. */ boolean hasActiveVisibleWindow(int uid) { if (mVisibleActivityProcessTracker.hasVisibleActivity(uid)) { return true; } boolean isUidForeground(int uid) { // A uid is considered to be foreground if it has a visible non-toast window. return mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(uid); return mActiveUids.hasNonAppVisibleWindow(uid); } boolean isDeviceOwner(int uid) { Loading Loading @@ -7281,12 +7282,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mActiveUids.onUidInactive(uid); } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @Override public void onActiveUidsCleared() { mActiveUids.onActiveUidsCleared(); } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @Override public void onUidProcStateChanged(int uid, int procState) { Loading Loading @@ -7432,9 +7427,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean isUidForeground(int uid) { synchronized (mGlobalLock) { return ActivityTaskManagerService.this.isUidForeground(uid); } return ActivityTaskManagerService.this.hasActiveVisibleWindow(uid); } @Override Loading