Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2ff6cf1 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

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
parent b53030f9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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();
        }
+0 −8
Original line number Diff line number Diff line
@@ -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);
}
+6 −18
Original line number Diff line number Diff line
@@ -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) {
+4 −2
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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,
Loading