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

Commit 3e766c67 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce lock contention when starting process (2/N)

The isFactoryTestProcess doesn't need to be locked because
mFactoryTest is final and mTopComponent is only set when booting.

Bug: 204870457
Test: CtsWindowManagerDeviceTestCases
Change-Id: I2f98edb7b64ea05ffca78f35b74a46b94e694f12
parent 099f8243
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1723,7 +1723,7 @@ public final class ProcessList {
            }
            app.setMountMode(mountExternal);
            checkSlow(startUptime, "startProcess: building args");
            if (mService.mAtmInternal.isFactoryTestProcess(app.getWindowProcessController())) {
            if (app.getWindowProcessController().isFactoryTestProcess()) {
                uid = 0;
            }
            int runtimeFlags = 0;
+0 −2
Original line number Diff line number Diff line
@@ -437,8 +437,6 @@ public abstract class ActivityTaskManagerInternal {
            boolean allowInstrumenting, boolean fromHomeKey);
    /** Start home activities on all displays that support system decorations. */
    public abstract boolean startHomeOnAllDisplays(int userId, String reason);
    /** @return true if the given process is the factory test process. */
    public abstract boolean isFactoryTestProcess(WindowProcessController wpc);
    public abstract void updateTopComponentForFactoryTest();
    public abstract void handleAppDied(WindowProcessController wpc, boolean restarting,
            Runnable finishInstrumentationCallback);
+0 −19
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import static android.app.sdksandbox.SdkSandboxManager.ACTION_START_SANDBOXED_AC
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.ApplicationInfo.FLAG_FACTORY_TEST;
import static android.content.pm.ConfigurationInfo.GL_ES_VERSION_UNDEFINED;
import static android.content.pm.PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS;
import static android.content.pm.PackageManager.FEATURE_CANT_SAVE_STATE;
@@ -50,9 +49,7 @@ import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEME
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.FactoryTest.FACTORY_TEST_HIGH_LEVEL;
import static android.os.FactoryTest.FACTORY_TEST_LOW_LEVEL;
import static android.os.FactoryTest.FACTORY_TEST_OFF;
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
import static android.os.Process.FIRST_APPLICATION_UID;
import static android.os.Process.SYSTEM_UID;
@@ -6088,22 +6085,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
        }

        @HotPath(caller = HotPath.PROCESS_CHANGE)
        @Override
        public boolean isFactoryTestProcess(WindowProcessController wpc) {
            synchronized (mGlobalLockWithoutBoost) {
                if (mFactoryTest == FACTORY_TEST_OFF) {
                    return false;
                }
                if (mFactoryTest == FACTORY_TEST_LOW_LEVEL && mTopComponent != null
                        && wpc.mName.equals(mTopComponent.getPackageName())) {
                    return true;
                }
                return mFactoryTest == FACTORY_TEST_HIGH_LEVEL
                        && (wpc.mInfo.flags & FLAG_FACTORY_TEST) != 0;
            }
        }

        @Override
        public void updateTopComponentForFactoryTest() {
            synchronized (mGlobalLock) {
+18 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.app.IApplicationThread;
import android.app.ProfilerInfo;
import android.app.servertransaction.ConfigurationChangeItem;
import android.companion.virtual.VirtualDeviceManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -61,6 +62,7 @@ import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.Build;
import android.os.FactoryTest;
import android.os.IBinder;
import android.os.LocaleList;
import android.os.Message;
@@ -1715,6 +1717,22 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        return this == mAtm.mHeavyWeightProcess;
    }

    @HotPath(caller = HotPath.PROCESS_CHANGE)
    public boolean isFactoryTestProcess() {
        final int factoryTestMode = mAtm.mFactoryTest;
        if (factoryTestMode == FactoryTest.FACTORY_TEST_OFF) {
            return false;
        }
        if (factoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
            final ComponentName topComponent = mAtm.mTopComponent;
            if (topComponent != null && mName.equals(topComponent.getPackageName())) {
                return true;
            }
        }
        return factoryTestMode == FactoryTest.FACTORY_TEST_HIGH_LEVEL
                && (mInfo.flags & ApplicationInfo.FLAG_FACTORY_TEST) != 0;
    }

    void setRunningRecentsAnimation(boolean running) {
        if (mRunningRecentsAnimation == running) {
            return;