Loading services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -3150,7 +3150,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Reset the last saved PiP snap fraction on removal. mDisplayContent.mPinnedStackControllerLocked.resetReentryBounds(mActivityComponent); mWmService.mEmbeddedWindowController.onActivityRemoved(this); mRemovingFromDisplay = false; } Loading services/core/java/com/android/server/wm/EmbeddedWindowController.java +50 −9 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ package com.android.server.wm; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.Nullable; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Slog; import android.view.IWindow; import android.view.InputApplicationHandle; Loading @@ -33,12 +37,15 @@ import android.view.InputApplicationHandle; * the host window to send pointerDownOutsideFocus. */ class EmbeddedWindowController { private static final String TAG = TAG_WITH_CLASS_NAME ? "EmbeddedWindowController" : TAG_WM; /* maps input token to an embedded window */ private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>(); private final Object mWmLock; private final Object mGlobalLock; private final ActivityTaskManagerService mAtmService; EmbeddedWindowController(Object wmLock) { mWmLock = wmLock; EmbeddedWindowController(ActivityTaskManagerService atmService) { mAtmService = atmService; mGlobalLock = atmService.getGlobalLock(); } /** Loading @@ -46,13 +53,14 @@ class EmbeddedWindowController { * * @param inputToken input channel token passed in by the embedding process when it requests * the server to add an input channel to the embedded surface. * @param embeddedWindow An {@link EmbeddedWindow} object to add to this controller. * @param window An {@link EmbeddedWindow} object to add to this controller. */ void add(IBinder inputToken, EmbeddedWindow embeddedWindow) { void add(IBinder inputToken, EmbeddedWindow window) { try { mWindows.put(inputToken, embeddedWindow); embeddedWindow.mClient.asBinder().linkToDeath(()-> { synchronized (mWmLock) { mWindows.put(inputToken, window); updateProcessController(window); window.mClient.asBinder().linkToDeath(()-> { synchronized (mGlobalLock) { mWindows.remove(inputToken); } }, 0); Loading @@ -62,6 +70,23 @@ class EmbeddedWindowController { } } /** * Track the host activity in the embedding process so we can determine if the * process is currently showing any UI to the user. */ private void updateProcessController(EmbeddedWindow window) { if (window.mHostActivityRecord == null) { return; } final WindowProcessController processController = mAtmService.getProcessController(window.mOwnerPid, window.mOwnerUid); if (processController == null) { Slog.w(TAG, "Could not find the embedding process."); } else { processController.addHostActivity(window.mHostActivityRecord); } } WindowState getHostWindow(IBinder inputToken) { EmbeddedWindow embeddedWindow = mWindows.get(inputToken); return embeddedWindow != null ? embeddedWindow.mHostWindowState : null; Loading @@ -76,7 +101,7 @@ class EmbeddedWindowController { } } void removeWindowsWithHost(WindowState host) { void onWindowRemoved(WindowState host) { for (int i = mWindows.size() - 1; i >= 0; i--) { if (mWindows.valueAt(i).mHostWindowState == host) { mWindows.removeAt(i); Loading @@ -88,9 +113,23 @@ class EmbeddedWindowController { return mWindows.get(inputToken); } void onActivityRemoved(ActivityRecord activityRecord) { for (int i = mWindows.size() - 1; i >= 0; i--) { final EmbeddedWindow window = mWindows.valueAt(i); if (window.mHostActivityRecord == activityRecord) { final WindowProcessController processController = mAtmService.getProcessController(window.mOwnerPid, window.mOwnerUid); if (processController != null) { processController.removeHostActivity(activityRecord); } } } } static class EmbeddedWindow { final IWindow mClient; @Nullable final WindowState mHostWindowState; @Nullable final ActivityRecord mHostActivityRecord; final int mOwnerUid; final int mOwnerPid; Loading @@ -107,6 +146,8 @@ class EmbeddedWindowController { int ownerPid) { mClient = clientToken; mHostWindowState = hostWindowState; mHostActivityRecord = (mHostWindowState != null) ? mHostWindowState.mActivityRecord : null; mOwnerUid = ownerUid; mOwnerPid = ownerPid; } Loading services/core/java/com/android/server/wm/WindowManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -1287,7 +1287,7 @@ public class WindowManagerService extends IWindowManager.Stub mConstants.start(new HandlerExecutor(mH)); LocalServices.addService(WindowManagerInternal.class, new LocalService()); mEmbeddedWindowController = new EmbeddedWindowController(mGlobalLock); mEmbeddedWindowController = new EmbeddedWindowController(mAtmService); mDisplayAreaPolicyProvider = DisplayAreaPolicy.Provider.fromResources( mContext.getResources()); Loading Loading @@ -1900,7 +1900,7 @@ public class WindowManagerService extends IWindowManager.Stub if (dc.mCurrentFocus == null) { dc.mWinRemovedSinceNullFocus.add(win); } mEmbeddedWindowController.removeWindowsWithHost(win); mEmbeddedWindowController.onWindowRemoved(win); mPendingRemove.remove(win); mResizingWindows.remove(win); updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */); Loading services/core/java/com/android/server/wm/WindowProcessController.java +38 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static com.android.server.wm.ActivityTaskManagerService.KEY_DISPATCHING_T import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.IApplicationThread; import android.app.ProfilerInfo; Loading Loading @@ -185,6 +186,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio // Registered display id as a listener to override config change private int mDisplayId; private ActivityRecord mConfigActivityRecord; /** * Activities that hosts some UI drawn by the current process. The activities live * in another process. This is used to check if the process is currently showing anything * visible to the user. */ @Nullable private final ArrayList<ActivityRecord> mHostActivities = new ArrayList<>(); /** Whether our process is currently running a {@link RecentsAnimation} */ private boolean mRunningRecentsAnimation; Loading Loading @@ -672,6 +680,23 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return true; } } if (isEmbedded()) { return true; } } return false; } /** * @return {@code true} if this process is rendering content on to a window shown by * another process. */ private boolean isEmbedded() { for (int i = mHostActivities.size() - 1; i >= 0; --i) { final ActivityRecord r = mHostActivities.get(i); if (r.isInterestingToUserLocked()) { return true; } } return false; } Loading Loading @@ -814,6 +839,19 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } } /** Adds an activity that hosts UI drawn by the current process. */ void addHostActivity(ActivityRecord r) { if (mHostActivities.contains(r)) { return; } mHostActivities.add(r); } /** Removes an activity that hosts UI drawn by the current process. */ void removeHostActivity(ActivityRecord r) { mHostActivities.remove(r); } public interface ComputeOomAdjCallback { void onVisibleActivity(); void onPausedActivity(); Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -3150,7 +3150,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Reset the last saved PiP snap fraction on removal. mDisplayContent.mPinnedStackControllerLocked.resetReentryBounds(mActivityComponent); mWmService.mEmbeddedWindowController.onActivityRemoved(this); mRemovingFromDisplay = false; } Loading
services/core/java/com/android/server/wm/EmbeddedWindowController.java +50 −9 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ package com.android.server.wm; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.Nullable; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Slog; import android.view.IWindow; import android.view.InputApplicationHandle; Loading @@ -33,12 +37,15 @@ import android.view.InputApplicationHandle; * the host window to send pointerDownOutsideFocus. */ class EmbeddedWindowController { private static final String TAG = TAG_WITH_CLASS_NAME ? "EmbeddedWindowController" : TAG_WM; /* maps input token to an embedded window */ private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>(); private final Object mWmLock; private final Object mGlobalLock; private final ActivityTaskManagerService mAtmService; EmbeddedWindowController(Object wmLock) { mWmLock = wmLock; EmbeddedWindowController(ActivityTaskManagerService atmService) { mAtmService = atmService; mGlobalLock = atmService.getGlobalLock(); } /** Loading @@ -46,13 +53,14 @@ class EmbeddedWindowController { * * @param inputToken input channel token passed in by the embedding process when it requests * the server to add an input channel to the embedded surface. * @param embeddedWindow An {@link EmbeddedWindow} object to add to this controller. * @param window An {@link EmbeddedWindow} object to add to this controller. */ void add(IBinder inputToken, EmbeddedWindow embeddedWindow) { void add(IBinder inputToken, EmbeddedWindow window) { try { mWindows.put(inputToken, embeddedWindow); embeddedWindow.mClient.asBinder().linkToDeath(()-> { synchronized (mWmLock) { mWindows.put(inputToken, window); updateProcessController(window); window.mClient.asBinder().linkToDeath(()-> { synchronized (mGlobalLock) { mWindows.remove(inputToken); } }, 0); Loading @@ -62,6 +70,23 @@ class EmbeddedWindowController { } } /** * Track the host activity in the embedding process so we can determine if the * process is currently showing any UI to the user. */ private void updateProcessController(EmbeddedWindow window) { if (window.mHostActivityRecord == null) { return; } final WindowProcessController processController = mAtmService.getProcessController(window.mOwnerPid, window.mOwnerUid); if (processController == null) { Slog.w(TAG, "Could not find the embedding process."); } else { processController.addHostActivity(window.mHostActivityRecord); } } WindowState getHostWindow(IBinder inputToken) { EmbeddedWindow embeddedWindow = mWindows.get(inputToken); return embeddedWindow != null ? embeddedWindow.mHostWindowState : null; Loading @@ -76,7 +101,7 @@ class EmbeddedWindowController { } } void removeWindowsWithHost(WindowState host) { void onWindowRemoved(WindowState host) { for (int i = mWindows.size() - 1; i >= 0; i--) { if (mWindows.valueAt(i).mHostWindowState == host) { mWindows.removeAt(i); Loading @@ -88,9 +113,23 @@ class EmbeddedWindowController { return mWindows.get(inputToken); } void onActivityRemoved(ActivityRecord activityRecord) { for (int i = mWindows.size() - 1; i >= 0; i--) { final EmbeddedWindow window = mWindows.valueAt(i); if (window.mHostActivityRecord == activityRecord) { final WindowProcessController processController = mAtmService.getProcessController(window.mOwnerPid, window.mOwnerUid); if (processController != null) { processController.removeHostActivity(activityRecord); } } } } static class EmbeddedWindow { final IWindow mClient; @Nullable final WindowState mHostWindowState; @Nullable final ActivityRecord mHostActivityRecord; final int mOwnerUid; final int mOwnerPid; Loading @@ -107,6 +146,8 @@ class EmbeddedWindowController { int ownerPid) { mClient = clientToken; mHostWindowState = hostWindowState; mHostActivityRecord = (mHostWindowState != null) ? mHostWindowState.mActivityRecord : null; mOwnerUid = ownerUid; mOwnerPid = ownerPid; } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -1287,7 +1287,7 @@ public class WindowManagerService extends IWindowManager.Stub mConstants.start(new HandlerExecutor(mH)); LocalServices.addService(WindowManagerInternal.class, new LocalService()); mEmbeddedWindowController = new EmbeddedWindowController(mGlobalLock); mEmbeddedWindowController = new EmbeddedWindowController(mAtmService); mDisplayAreaPolicyProvider = DisplayAreaPolicy.Provider.fromResources( mContext.getResources()); Loading Loading @@ -1900,7 +1900,7 @@ public class WindowManagerService extends IWindowManager.Stub if (dc.mCurrentFocus == null) { dc.mWinRemovedSinceNullFocus.add(win); } mEmbeddedWindowController.removeWindowsWithHost(win); mEmbeddedWindowController.onWindowRemoved(win); mPendingRemove.remove(win); mResizingWindows.remove(win); updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */); Loading
services/core/java/com/android/server/wm/WindowProcessController.java +38 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static com.android.server.wm.ActivityTaskManagerService.KEY_DISPATCHING_T import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.IApplicationThread; import android.app.ProfilerInfo; Loading Loading @@ -185,6 +186,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio // Registered display id as a listener to override config change private int mDisplayId; private ActivityRecord mConfigActivityRecord; /** * Activities that hosts some UI drawn by the current process. The activities live * in another process. This is used to check if the process is currently showing anything * visible to the user. */ @Nullable private final ArrayList<ActivityRecord> mHostActivities = new ArrayList<>(); /** Whether our process is currently running a {@link RecentsAnimation} */ private boolean mRunningRecentsAnimation; Loading Loading @@ -672,6 +680,23 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return true; } } if (isEmbedded()) { return true; } } return false; } /** * @return {@code true} if this process is rendering content on to a window shown by * another process. */ private boolean isEmbedded() { for (int i = mHostActivities.size() - 1; i >= 0; --i) { final ActivityRecord r = mHostActivities.get(i); if (r.isInterestingToUserLocked()) { return true; } } return false; } Loading Loading @@ -814,6 +839,19 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } } /** Adds an activity that hosts UI drawn by the current process. */ void addHostActivity(ActivityRecord r) { if (mHostActivities.contains(r)) { return; } mHostActivities.add(r); } /** Removes an activity that hosts UI drawn by the current process. */ void removeHostActivity(ActivityRecord r) { mHostActivities.remove(r); } public interface ComputeOomAdjCallback { void onVisibleActivity(); void onPausedActivity(); Loading