Merge "Reduce lock contention when starting process (2/N)"

This commit is contained in:
Riddle Hsu
2023-01-07 09:11:36 +00:00
committed by Android (Google) Code Review
4 changed files with 19 additions and 22 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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) {

View File

@@ -54,6 +54,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;
@@ -62,6 +63,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;
@@ -1718,6 +1720,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;