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

Commit dfdc6aa7 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce unnecessary process lookup by pid

Since the process record of window is stored in Session, it can be
accessed directly. That reduces binary search from all processes.

Bug: 163976519
Test: WindowManagerServiceTests
Change-Id: Ice8d971e66afbd9896087efb787df60ec554e69f
parent ce8d4a38
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -1134,23 +1134,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
     * Return the global configuration used by the process corresponding to the input pid. This is
     * usually the global configuration with some overrides specific to that process.
     */
    Configuration getGlobalConfigurationForCallingPid() {
    private 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();
        }
        synchronized (mGlobalLock) {
        final WindowProcessController app = mProcessMap.getProcess(pid);
        return app != null ? app.getConfiguration() : getGlobalConfiguration();
    }
    }

    /**
     * Return the device configuration info used by the process corresponding to the input pid.
+3 −4
Original line number Diff line number Diff line
@@ -2835,10 +2835,9 @@ 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 WindowState parentWindow = getParentWindow();
        final int pid = parentWindow != null ? parentWindow.mSession.mPid : mSession.mPid;
        final Configuration processConfig =
                mWmService.mAtmService.getGlobalConfigurationForPid(pid);
        return processConfig;
        final Session session = parentWindow != null ? parentWindow.mSession : mSession;
        return session.mPid == MY_PID ? mWmService.mRoot.getConfiguration()
                : session.mProcess.getConfiguration();
    }

    private Configuration getLastReportedConfiguration() {