Use WindowProcessController configuration for process
This patch is to replace the process configuration map in WindowManagerService with the map in ActivityTaskManagerService. To do so, we pass the ActivityTaskManagerService instance to WindowManaserService. Adjust test base accordingly. Test: WmTests Test: go/wm-smoke Bug: 117877476 Bug: 113253755 Change-Id: Ica93c3ad402e1cab682466fd16a8226176f9bae8
This commit is contained in:
@@ -863,6 +863,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
*/
|
||||
Configuration getGlobalConfigurationForCallingPid() {
|
||||
final int pid = Binder.getCallingPid();
|
||||
return getGlobalConfigurationForPid(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the global configuration used by the process corresponding to the given pid.
|
||||
*/
|
||||
Configuration getGlobalConfigurationForPid(int pid) {
|
||||
if (pid == MY_PID || pid < 0) {
|
||||
return getGlobalConfiguration();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.wm;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ClipData;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.hardware.display.DisplayManagerInternal;
|
||||
@@ -449,11 +448,4 @@ public abstract class WindowManagerInternal {
|
||||
* Return the display Id for given window.
|
||||
*/
|
||||
public abstract int getDisplayIdForWindow(IBinder windowToken);
|
||||
|
||||
// TODO: use WindowProcessController once go/wm-unified is done.
|
||||
/**
|
||||
* Notifies the window manager that configuration of the process associated with the input pid
|
||||
* changed.
|
||||
*/
|
||||
public abstract void onProcessConfigurationChanged(int pid, Configuration newConfig);
|
||||
}
|
||||
|
||||
@@ -735,6 +735,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
final InputManagerService mInputManager;
|
||||
final DisplayManagerInternal mDisplayManagerInternal;
|
||||
final DisplayManager mDisplayManager;
|
||||
final ActivityTaskManagerService mAtmService;
|
||||
|
||||
// Indicates whether this device supports wide color gamut / HDR rendering
|
||||
private boolean mHasWideColorGamutSupport;
|
||||
@@ -897,11 +898,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
public static WindowManagerService main(final Context context, final InputManagerService im,
|
||||
final boolean showBootMsgs, final boolean onlyCore, WindowManagerPolicy policy,
|
||||
final WindowManagerGlobalLock globalLock) {
|
||||
ActivityTaskManagerService atm) {
|
||||
DisplayThread.getHandler().runWithScissors(() ->
|
||||
sInstance = new WindowManagerService(context, im, showBootMsgs, onlyCore, policy,
|
||||
globalLock),
|
||||
0);
|
||||
atm), 0);
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@@ -923,9 +923,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
private WindowManagerService(Context context, InputManagerService inputManager,
|
||||
boolean showBootMsgs, boolean onlyCore, WindowManagerPolicy policy,
|
||||
WindowManagerGlobalLock globalLock) {
|
||||
ActivityTaskManagerService atm) {
|
||||
installLock(this, INDEX_WINDOW);
|
||||
mGlobalLock = globalLock;
|
||||
mGlobalLock = atm.getGlobalLock();
|
||||
mAtmService = atm;
|
||||
mContext = context;
|
||||
mAllowBootMessages = showBootMsgs;
|
||||
mOnlyCore = onlyCore;
|
||||
@@ -7281,19 +7282,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return Display.INVALID_DISPLAY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProcessConfigurationChanged(int pid, Configuration newConfig) {
|
||||
synchronized (mGlobalLock) {
|
||||
Configuration currentConfig = mProcessConfigurations.get(pid);
|
||||
if (currentConfig == null) {
|
||||
currentConfig = new Configuration(newConfig);
|
||||
} else {
|
||||
currentConfig.setTo(newConfig);
|
||||
}
|
||||
mProcessConfigurations.put(pid, currentConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void registerAppFreezeListener(AppFreezeListener listener) {
|
||||
|
||||
@@ -2268,8 +2268,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
// For child windows we want to use the pid for the parent window in case the the child
|
||||
// window was added from another process.
|
||||
final int pid = getParentWindow() != null ? getParentWindow().mSession.mPid : mSession.mPid;
|
||||
mTempConfiguration.setTo(mWmService.mProcessConfigurations.get(
|
||||
pid, mWmService.mRoot.getConfiguration()));
|
||||
final Configuration processConfig =
|
||||
mWmService.mAtmService.getGlobalConfigurationForPid(pid);
|
||||
mTempConfiguration.setTo(processConfig == null
|
||||
? mWmService.mRoot.getConfiguration() : processConfig);
|
||||
return mTempConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@@ -925,7 +925,7 @@ public final class SystemServer {
|
||||
ConcurrentUtils.waitForFutureNoInterrupt(mSensorServiceStart, START_SENSOR_SERVICE);
|
||||
mSensorServiceStart = null;
|
||||
wm = WindowManagerService.main(context, inputManager, !mFirstBoot, mOnlyCore,
|
||||
new PhoneWindowManager(), mWindowManagerGlobalLock);
|
||||
new PhoneWindowManager(), mActivityManagerService.mActivityTaskManager);
|
||||
ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,
|
||||
DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO);
|
||||
ServiceManager.addService(Context.INPUT_SERVICE, inputManager,
|
||||
|
||||
@@ -30,6 +30,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.ActivityManagerInternal;
|
||||
import android.content.Context;
|
||||
@@ -125,11 +126,12 @@ public class WindowManagerServiceRule implements TestRule {
|
||||
if (input != null && input.length > 1) {
|
||||
doReturn(input[1]).when(ims).monitorInput(anyString(), anyInt());
|
||||
}
|
||||
ActivityTaskManagerService atms = mock(ActivityTaskManagerService.class);
|
||||
when(atms.getGlobalLock()).thenReturn(new WindowManagerGlobalLock());
|
||||
|
||||
mService = WindowManagerService.main(context, ims, false, false,
|
||||
mPolicy = new TestWindowManagerPolicy(
|
||||
WindowManagerServiceRule.this::getWindowManagerService),
|
||||
new WindowManagerGlobalLock());
|
||||
WindowManagerServiceRule.this::getWindowManagerService), atms);
|
||||
mService.mTransactionFactory = () -> {
|
||||
final SurfaceControl.Transaction transaction = new SurfaceControl.Transaction();
|
||||
mSurfaceTransactions.add(new WeakReference<>(transaction));
|
||||
|
||||
Reference in New Issue
Block a user