Merge "Consider processes embedding content to be "interesting"" into rvc-dev am: 03b8a41461 am: 8f0bf82157
Change-Id: Id617f89159fb22c184e359170b771989ab0a68d9
This commit is contained in:
@@ -3150,7 +3150,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
|
|
||||||
// Reset the last saved PiP snap fraction on removal.
|
// Reset the last saved PiP snap fraction on removal.
|
||||||
mDisplayContent.mPinnedStackControllerLocked.resetReentryBounds(mActivityComponent);
|
mDisplayContent.mPinnedStackControllerLocked.resetReentryBounds(mActivityComponent);
|
||||||
|
mWmService.mEmbeddedWindowController.onActivityRemoved(this);
|
||||||
mRemovingFromDisplay = false;
|
mRemovingFromDisplay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
package com.android.server.wm;
|
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.annotation.Nullable;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
import android.util.Slog;
|
||||||
import android.view.IWindow;
|
import android.view.IWindow;
|
||||||
import android.view.InputApplicationHandle;
|
import android.view.InputApplicationHandle;
|
||||||
|
|
||||||
@@ -33,12 +37,15 @@ import android.view.InputApplicationHandle;
|
|||||||
* the host window to send pointerDownOutsideFocus.
|
* the host window to send pointerDownOutsideFocus.
|
||||||
*/
|
*/
|
||||||
class EmbeddedWindowController {
|
class EmbeddedWindowController {
|
||||||
|
private static final String TAG = TAG_WITH_CLASS_NAME ? "EmbeddedWindowController" : TAG_WM;
|
||||||
/* maps input token to an embedded window */
|
/* maps input token to an embedded window */
|
||||||
private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>();
|
private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>();
|
||||||
private final Object mWmLock;
|
private final Object mGlobalLock;
|
||||||
|
private final ActivityTaskManagerService mAtmService;
|
||||||
|
|
||||||
EmbeddedWindowController(Object wmLock) {
|
EmbeddedWindowController(ActivityTaskManagerService atmService) {
|
||||||
mWmLock = wmLock;
|
mAtmService = atmService;
|
||||||
|
mGlobalLock = atmService.getGlobalLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,13 +53,14 @@ class EmbeddedWindowController {
|
|||||||
*
|
*
|
||||||
* @param inputToken input channel token passed in by the embedding process when it requests
|
* @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.
|
* 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 {
|
try {
|
||||||
mWindows.put(inputToken, embeddedWindow);
|
mWindows.put(inputToken, window);
|
||||||
embeddedWindow.mClient.asBinder().linkToDeath(()-> {
|
updateProcessController(window);
|
||||||
synchronized (mWmLock) {
|
window.mClient.asBinder().linkToDeath(()-> {
|
||||||
|
synchronized (mGlobalLock) {
|
||||||
mWindows.remove(inputToken);
|
mWindows.remove(inputToken);
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
@@ -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) {
|
WindowState getHostWindow(IBinder inputToken) {
|
||||||
EmbeddedWindow embeddedWindow = mWindows.get(inputToken);
|
EmbeddedWindow embeddedWindow = mWindows.get(inputToken);
|
||||||
return embeddedWindow != null ? embeddedWindow.mHostWindowState : null;
|
return embeddedWindow != null ? embeddedWindow.mHostWindowState : null;
|
||||||
@@ -76,7 +101,7 @@ class EmbeddedWindowController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeWindowsWithHost(WindowState host) {
|
void onWindowRemoved(WindowState host) {
|
||||||
for (int i = mWindows.size() - 1; i >= 0; i--) {
|
for (int i = mWindows.size() - 1; i >= 0; i--) {
|
||||||
if (mWindows.valueAt(i).mHostWindowState == host) {
|
if (mWindows.valueAt(i).mHostWindowState == host) {
|
||||||
mWindows.removeAt(i);
|
mWindows.removeAt(i);
|
||||||
@@ -88,9 +113,23 @@ class EmbeddedWindowController {
|
|||||||
return mWindows.get(inputToken);
|
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 {
|
static class EmbeddedWindow {
|
||||||
final IWindow mClient;
|
final IWindow mClient;
|
||||||
@Nullable final WindowState mHostWindowState;
|
@Nullable final WindowState mHostWindowState;
|
||||||
|
@Nullable final ActivityRecord mHostActivityRecord;
|
||||||
final int mOwnerUid;
|
final int mOwnerUid;
|
||||||
final int mOwnerPid;
|
final int mOwnerPid;
|
||||||
|
|
||||||
@@ -107,6 +146,8 @@ class EmbeddedWindowController {
|
|||||||
int ownerPid) {
|
int ownerPid) {
|
||||||
mClient = clientToken;
|
mClient = clientToken;
|
||||||
mHostWindowState = hostWindowState;
|
mHostWindowState = hostWindowState;
|
||||||
|
mHostActivityRecord = (mHostWindowState != null) ? mHostWindowState.mActivityRecord
|
||||||
|
: null;
|
||||||
mOwnerUid = ownerUid;
|
mOwnerUid = ownerUid;
|
||||||
mOwnerPid = ownerPid;
|
mOwnerPid = ownerPid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1287,7 +1287,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mConstants.start(new HandlerExecutor(mH));
|
mConstants.start(new HandlerExecutor(mH));
|
||||||
|
|
||||||
LocalServices.addService(WindowManagerInternal.class, new LocalService());
|
LocalServices.addService(WindowManagerInternal.class, new LocalService());
|
||||||
mEmbeddedWindowController = new EmbeddedWindowController(mGlobalLock);
|
mEmbeddedWindowController = new EmbeddedWindowController(mAtmService);
|
||||||
|
|
||||||
mDisplayAreaPolicyProvider = DisplayAreaPolicy.Provider.fromResources(
|
mDisplayAreaPolicyProvider = DisplayAreaPolicy.Provider.fromResources(
|
||||||
mContext.getResources());
|
mContext.getResources());
|
||||||
@@ -1900,7 +1900,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
if (dc.mCurrentFocus == null) {
|
if (dc.mCurrentFocus == null) {
|
||||||
dc.mWinRemovedSinceNullFocus.add(win);
|
dc.mWinRemovedSinceNullFocus.add(win);
|
||||||
}
|
}
|
||||||
mEmbeddedWindowController.removeWindowsWithHost(win);
|
mEmbeddedWindowController.onWindowRemoved(win);
|
||||||
mPendingRemove.remove(win);
|
mPendingRemove.remove(win);
|
||||||
mResizingWindows.remove(win);
|
mResizingWindows.remove(win);
|
||||||
updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */);
|
updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */);
|
||||||
|
|||||||
@@ -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 static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.app.IApplicationThread;
|
import android.app.IApplicationThread;
|
||||||
import android.app.ProfilerInfo;
|
import android.app.ProfilerInfo;
|
||||||
@@ -185,6 +186,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
// Registered display id as a listener to override config change
|
// Registered display id as a listener to override config change
|
||||||
private int mDisplayId;
|
private int mDisplayId;
|
||||||
private ActivityRecord mConfigActivityRecord;
|
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} */
|
/** Whether our process is currently running a {@link RecentsAnimation} */
|
||||||
private boolean mRunningRecentsAnimation;
|
private boolean mRunningRecentsAnimation;
|
||||||
@@ -672,6 +680,23 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -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 {
|
public interface ComputeOomAdjCallback {
|
||||||
void onVisibleActivity();
|
void onVisibleActivity();
|
||||||
void onPausedActivity();
|
void onPausedActivity();
|
||||||
|
|||||||
Reference in New Issue
Block a user