From c9e57de5ac6214c34323611c93d743e6251fac99 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Tue, 8 May 2018 14:28:07 -0700 Subject: [PATCH] Switched ActivityStackSupervisor.mService to ActivityTaskManagerService (8/n) Objects that contain or represent activities like ActivityStackSupervisor can no longer rely on ActivityManagerService as it is going to be in a different package. Test: Existing tests pass Test: go/wm-smoke-auto Bug: 80414790 Change-Id: I9fd5564f69170201c560bd3325594541db146106 --- .../com/android/server/am/ActivityDisplay.java | 10 +- .../android/server/am/ActivityManagerService.java | 72 +++--- .../android/server/am/ActivityMetricsLogger.java | 6 +- .../java/com/android/server/am/ActivityRecord.java | 8 +- .../java/com/android/server/am/ActivityStack.java | 2 +- .../android/server/am/ActivityStackSupervisor.java | 250 ++++++++++----------- .../android/server/am/ActivityStartController.java | 26 +-- .../server/am/ActivityStartInterceptor.java | 15 +- .../com/android/server/am/ActivityStarter.java | 90 ++++---- .../server/am/ActivityTaskManagerService.java | 27 ++- .../server/am/PendingRemoteAnimationRegistry.java | 6 +- .../com/android/server/am/SafeActivityOptions.java | 6 +- .../am/TaskChangeNotificationController.java | 17 +- .../java/com/android/server/am/TaskRecord.java | 2 +- .../server/am/ActivityStackSupervisorTests.java | 2 +- .../server/am/ActivityStartControllerTests.java | 6 +- .../server/am/ActivityStartInterceptorTest.java | 14 +- .../android/server/am/ActivityStarterTests.java | 8 +- .../com/android/server/am/ActivityTestsBase.java | 49 ++-- .../am/PendingRemoteAnimationRegistryTest.java | 2 +- .../src/com/android/server/am/RecentTasksTest.java | 13 +- 21 files changed, 318 insertions(+), 313 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityDisplay.java b/services/core/java/com/android/server/am/ActivityDisplay.java index 6de43def3660..ee93fc8db06e 100644 --- a/services/core/java/com/android/server/am/ActivityDisplay.java +++ b/services/core/java/com/android/server/am/ActivityDisplay.java @@ -140,7 +140,7 @@ class ActivityDisplay extends ConfigurationContainer + " to displayId=" + mDisplayId + " position=" + position); addStackReferenceIfNeeded(stack); positionChildAt(stack, position); - mSupervisor.mService.updateSleepIfNeededLocked(); + mSupervisor.mService.mAm.updateSleepIfNeededLocked(); } void removeChild(ActivityStack stack) { @@ -148,7 +148,7 @@ class ActivityDisplay extends ConfigurationContainer + " from displayId=" + mDisplayId); mStacks.remove(stack); removeStackReferenceIfNeeded(stack); - mSupervisor.mService.updateSleepIfNeededLocked(); + mSupervisor.mService.mAm.updateSleepIfNeededLocked(); onStackOrderChanged(); } @@ -300,7 +300,7 @@ class ActivityDisplay extends ConfigurationContainer } } - final ActivityManagerService service = mSupervisor.mService; + final ActivityManagerService service = mSupervisor.mService.mAm; if (!isWindowingModeSupported(windowingMode, service.mSupportsMultiWindow, service.mSupportsSplitScreenMultiWindow, service.mSupportsFreeformWindowManagement, service.mSupportsPictureInPicture, activityType)) { @@ -536,7 +536,7 @@ class ActivityDisplay extends ConfigurationContainer } // Make sure the windowing mode we are trying to use makes sense for what is supported. - final ActivityManagerService service = mSupervisor.mService; + final ActivityManagerService service = mSupervisor.mService.mAm; boolean supportsMultiWindow = service.mSupportsMultiWindow; boolean supportsSplitScreen = service.mSupportsSplitScreenMultiWindow; boolean supportsFreeform = service.mSupportsFreeformWindowManagement; @@ -714,7 +714,7 @@ class ActivityDisplay extends ConfigurationContainer boolean shouldSleep() { return (mStacks.isEmpty() || !mAllSleepTokens.isEmpty()) - && (mSupervisor.mService.mRunningVoice == null); + && (mSupervisor.mService.mAm.mRunningVoice == null); } /** diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index c49ec34b8773..ac4f6ab47801 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -615,8 +615,7 @@ public class ActivityManagerService extends IActivityManager.Stub private Installer mInstaller; /** Run all ActivityStacks through this */ - final ActivityStackSupervisor mStackSupervisor; - final KeyguardController mKeyguardController; + ActivityStackSupervisor mStackSupervisor; final InstrumentationReporter mInstrumentationReporter = new InstrumentationReporter(); @@ -734,7 +733,7 @@ public class ActivityManagerService extends IActivityManager.Stub public boolean canShowErrorDialogs() { return mShowDialogs && !mSleeping && !mShuttingDown - && !mKeyguardController.isKeyguardOrAodShowing(DEFAULT_DISPLAY) + && !mActivityTaskManager.mKeyguardController.isKeyguardOrAodShowing(DEFAULT_DISPLAY) && !mUserController.hasUserRestriction(UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS, mUserController.getCurrentUserId()) && !(UserManager.isDeviceInDemoMode(mContext) @@ -1286,16 +1285,6 @@ public class ActivityManagerService extends IActivityManager.Stub */ final AppOpsService mAppOpsService; - /** Current sequencing integer of the configuration, for skipping old configurations. */ - private int mConfigurationSeq; - - /** - * Temp object used when global and/or display override configuration is updated. It is also - * sent to outer world instead of {@link #getGlobalConfiguration} because we don't trust - * anyone... - */ - private Configuration mTempConfig = new Configuration(); - /** * Hardware-reported OpenGLES version. */ @@ -2595,8 +2584,8 @@ public class ActivityManagerService extends IActivityManager.Stub public void setActivityTaskManager(ActivityTaskManagerService atm) { synchronized (this) { mActivityTaskManager = atm; - mStackSupervisor.setActivityTaskManager(atm); mActivityTaskManager.setActivityManagerService(this); + mStackSupervisor = mActivityTaskManager.mStackSupervisor; } } @@ -2845,13 +2834,11 @@ public class ActivityManagerService extends IActivityManager.Stub mHandler = null; mHandlerThread = null; mIntentFirewall = null; - mKeyguardController = null; mPermissionReviewRequired = false; mProcessCpuThread = null; mProcessStats = null; mProviderMap = null; mServices = null; - mStackSupervisor = null; mSystemThread = null; mUiHandler = injector.getUiHandler(null); mUserController = null; @@ -2938,12 +2925,6 @@ public class ActivityManagerService extends IActivityManager.Stub } mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations")); - mTempConfig.setToDefaults(); - mTempConfig.setLocales(LocaleList.getDefault()); - mConfigurationSeq = mTempConfig.seq = 1; - mStackSupervisor = createStackSupervisor(); - mStackSupervisor.onConfigurationChanged(mTempConfig); - mKeyguardController = mStackSupervisor.getKeyguardController(); mCompatModePackages = new CompatModePackages(this, systemDir, mHandler); mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler); @@ -2999,12 +2980,6 @@ public class ActivityManagerService extends IActivityManager.Stub } - protected ActivityStackSupervisor createStackSupervisor() { - final ActivityStackSupervisor supervisor = new ActivityStackSupervisor(this, mHandler.getLooper()); - supervisor.initialize(); - return supervisor; - } - public void setSystemServiceManager(SystemServiceManager mgr) { mSystemServiceManager = mgr; } @@ -10963,7 +10938,7 @@ public class ActivityManagerService extends IActivityManager.Stub final long ident = Binder.clearCallingIdentity(); try { if (mUserController.shouldConfirmCredentials(userId)) { - if (mKeyguardController.isKeyguardLocked()) { + if (mActivityTaskManager.mKeyguardController.isKeyguardLocked()) { // Showing launcher to avoid user entering credential twice. final int currentUserId = mUserController.getCurrentUserId(); startHomeActivityLocked(currentUserId, "notifyLockedProfile"); @@ -19525,8 +19500,8 @@ public class ActivityManagerService extends IActivityManager.Stub /** Update default (global) configuration and notify listeners about changes. */ private int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId, boolean deferResume) { - mTempConfig.setTo(getGlobalConfiguration()); - final int changes = mTempConfig.updateFrom(values); + mActivityTaskManager.mTempConfig.setTo(getGlobalConfiguration()); + final int changes = mActivityTaskManager.mTempConfig.updateFrom(values); if (changes == 0) { // Since calling to Activity.setRequestedOrientation leads to freezing the window with // setting WindowManagerService.mWaitingForConfig to true, it is important that we call @@ -19576,34 +19551,34 @@ public class ActivityManagerService extends IActivityManager.Stub locales.get(bestLocaleIndex))); } - mConfigurationSeq = Math.max(++mConfigurationSeq, 1); - mTempConfig.seq = mConfigurationSeq; + mActivityTaskManager.mConfigurationSeq = Math.max(++mActivityTaskManager.mConfigurationSeq, 1); + mActivityTaskManager.mTempConfig.seq = mActivityTaskManager.mConfigurationSeq; // Update stored global config and notify everyone about the change. - mStackSupervisor.onConfigurationChanged(mTempConfig); + mStackSupervisor.onConfigurationChanged(mActivityTaskManager.mTempConfig); - Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + mTempConfig); + Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + mActivityTaskManager.mTempConfig); // TODO(multi-display): Update UsageEvents#Event to include displayId. - mUsageStatsService.reportConfigurationChange(mTempConfig, + mUsageStatsService.reportConfigurationChange(mActivityTaskManager.mTempConfig, mUserController.getCurrentUserId()); // TODO: If our config changes, should we auto dismiss any currently showing dialogs? - updateShouldShowDialogsLocked(mTempConfig); + updateShouldShowDialogsLocked(mActivityTaskManager.mTempConfig); AttributeCache ac = AttributeCache.instance(); if (ac != null) { - ac.updateConfiguration(mTempConfig); + ac.updateConfiguration(mActivityTaskManager.mTempConfig); } // Make sure all resources in our process are updated right now, so that anyone who is going // to retrieve resource values after we return will be sure to get the new ones. This is // especially important during boot, where the first config change needs to guarantee all // resources have that config before following boot code is executed. - mSystemThread.applyConfigurationToResources(mTempConfig); + mSystemThread.applyConfigurationToResources(mActivityTaskManager.mTempConfig); // We need another copy of global config because we're scheduling some calls instead of // running them in place. We need to be sure that object we send will be handled unchanged. - final Configuration configCopy = new Configuration(mTempConfig); + final Configuration configCopy = new Configuration(mActivityTaskManager.mTempConfig); if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) { Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG); msg.obj = configCopy; @@ -19714,12 +19689,12 @@ public class ActivityManagerService extends IActivityManager.Stub private int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume, int displayId) { - mTempConfig.setTo(mStackSupervisor.getDisplayOverrideConfiguration(displayId)); - final int changes = mTempConfig.updateFrom(values); + mActivityTaskManager.mTempConfig.setTo(mStackSupervisor.getDisplayOverrideConfiguration(displayId)); + final int changes = mActivityTaskManager.mTempConfig.updateFrom(values); if (changes != 0) { Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " " - + mTempConfig + " for displayId=" + displayId); - mStackSupervisor.setDisplayOverrideConfiguration(mTempConfig, displayId); + + mActivityTaskManager.mTempConfig + " for displayId=" + displayId); + mStackSupervisor.setDisplayOverrideConfiguration(mActivityTaskManager.mTempConfig, displayId); final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0; if (isDensityChange && displayId == DEFAULT_DISPLAY) { @@ -19736,7 +19711,7 @@ public class ActivityManagerService extends IActivityManager.Stub // ensureActivityConfiguration(). if (mWindowManager != null) { final int[] resizedStacks = - mWindowManager.setNewDisplayOverrideConfiguration(mTempConfig, displayId); + mWindowManager.setNewDisplayOverrideConfiguration(mActivityTaskManager.mTempConfig, displayId); if (resizedStacks != null) { for (int stackId : resizedStacks) { resizeStackWithBoundsFromWindowManager(stackId, deferResume); @@ -21778,7 +21753,8 @@ public class ActivityManagerService extends IActivityManager.Stub } private final ActivityRecord resumedAppLocked() { - ActivityRecord act = mStackSupervisor.getResumedActivityLocked(); + final ActivityRecord act = + mStackSupervisor != null ? mStackSupervisor.getResumedActivityLocked() : null; String pkg; int uid; if (act != null) { @@ -21860,7 +21836,9 @@ public class ActivityManagerService extends IActivityManager.Stub uidRec.reset(); } - mStackSupervisor.rankTaskLayersIfNeeded(); + if (mStackSupervisor != null) { + mStackSupervisor.rankTaskLayersIfNeeded(); + } mAdjSeq++; mNewNumServiceProcs = 0; diff --git a/services/core/java/com/android/server/am/ActivityMetricsLogger.java b/services/core/java/com/android/server/am/ActivityMetricsLogger.java index 9e9f6388c63a..6618830a127a 100644 --- a/services/core/java/com/android/server/am/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/am/ActivityMetricsLogger.java @@ -407,7 +407,7 @@ class ActivityMetricsLogger { } private void checkVisibility(TaskRecord t, ActivityRecord r) { - synchronized (mSupervisor.mService) { + synchronized (mSupervisor.mService.mGlobalLock) { final WindowingModeTransitionInfo info = mWindowingModeTransitionInfo.get( r.getWindowingMode()); @@ -663,8 +663,8 @@ class ActivityMetricsLogger { private ProcessRecord findProcessForActivity(ActivityRecord launchedActivity) { return launchedActivity != null - ? mSupervisor.mService.mProcessNames.get(launchedActivity.processName, - launchedActivity.appInfo.uid) + ? mSupervisor.mService.mAm.mProcessNames.get( + launchedActivity.processName, launchedActivity.appInfo.uid) : null; } diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index a55ffdb0ac52..0e427d667af4 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -1098,7 +1098,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return true; } // Allow the recents component to launch the home activity. - final RecentTasks recentTasks = mStackSupervisor.mService.mActivityTaskManager.getRecentTasks(); + final RecentTasks recentTasks = mStackSupervisor.mService.getRecentTasks(); if (recentTasks != null && recentTasks.isCallerRecents(uid)) { return true; } @@ -2930,16 +2930,16 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo throw new XmlPullParserException("restoreActivity error intent=" + intent); } - final ActivityManagerService service = stackSupervisor.mService; + final ActivityTaskManagerService service = stackSupervisor.mService; final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null, userId, Binder.getCallingUid()); if (aInfo == null) { throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent + " resolvedType=" + resolvedType); } - final ActivityRecord r = new ActivityRecord(service.mActivityTaskManager, null /* caller */, + final ActivityRecord r = new ActivityRecord(service, null /* caller */, 0 /* launchedFromPid */, launchedFromUid, launchedFromPackage, intent, resolvedType, - aInfo, service.getConfiguration(), null /* resultTo */, null /* resultWho */, + aInfo, service.mAm.getConfiguration(), null /* resultTo */, null /* resultWho */, 0 /* reqCode */, componentSpecified, false /* rootVoiceInteraction */, stackSupervisor, null /* options */, null /* sourceRecord */); diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 64f62eda4500..6118131cd2b2 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -453,7 +453,7 @@ class ActivityStack extends ConfigurationContai ActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor, int windowingMode, int activityType, boolean onTop) { mStackSupervisor = supervisor; - mService = supervisor.mService.mActivityTaskManager; + mService = supervisor.mService; mHandler = new ActivityStackHandler(supervisor.mLooper); mWindowManager = mService.mWindowManager; mStackId = stackId; diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 08e19e27a4fb..c37226680d54 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -304,7 +304,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** The number of distinct task ids that can be assigned to the tasks of a single user */ private static final int MAX_TASK_IDS_PER_USER = UserHandle.PER_USER_RANGE; - ActivityManagerService mService; + ActivityTaskManagerService mService; /** The historial list of recent tasks including inactive tasks */ RecentTasks mRecentTasks; @@ -318,7 +318,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** Short cut */ WindowManagerService mWindowManager; DisplayManager mDisplayManager; - ActivityTaskManagerService mAtm; private LaunchParamsController mLaunchParamsController; @@ -489,7 +488,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // No restrictions for the default display. return true; } - if (!mService.mSupportsMultiDisplay) { + if (!mService.mAm.mSupportsMultiDisplay) { // Can't launch on secondary displays if feature is not supported. return false; } @@ -604,14 +603,14 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } - public ActivityStackSupervisor(ActivityManagerService service, Looper looper) { + public ActivityStackSupervisor(ActivityTaskManagerService service, Looper looper) { mService = service; mLooper = looper; mHandler = new ActivityStackSupervisorHandler(looper); } @VisibleForTesting - void setService(ActivityManagerService service) { + void setService(ActivityTaskManagerService service) { mService = service; } @@ -622,11 +621,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D mInitialized = true; mRunningTasks = createRunningTasks(); - mActivityMetricsLogger = new ActivityMetricsLogger(this, mService.mContext, - mHandler.getLooper()); - mKeyguardController = new KeyguardController(mService, this); + mActivityMetricsLogger = new ActivityMetricsLogger(this, mService.mContext, mHandler.getLooper()); + mKeyguardController = new KeyguardController(mService.mAm, this); - mLaunchParamsController = new LaunchParamsController(mService); + mLaunchParamsController = new LaunchParamsController(mService.mAm); mLaunchParamsController.registerDefaultModifiers(this); } @@ -665,10 +663,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D mLaunchingActivity.setReferenceCounted(false); } - void setActivityTaskManager(ActivityTaskManagerService atm) { - mAtm = atm; - } - void setWindowManager(WindowManagerService wm) { mWindowManager = wm; getKeyguardController().setWindowManager(wm); @@ -727,7 +721,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } final ActivityRecord r = topRunningActivityLocked(); - if (mService.mBooting || !mService.mBooted) { + if (mService.mAm.mBooting || !mService.mAm.mBooted) { if (r != null && r.idle) { checkFinishBootingLocked(); } @@ -759,7 +753,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } boolean resumeHomeStackTask(ActivityRecord prev, String reason) { - if (!mService.mBooting && !mService.mBooted) { + if (!mService.mAm.mBooting && !mService.mAm.mBooted) { // Not ready yet! return false; } @@ -773,7 +767,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D moveFocusableActivityStackToFrontLocked(r, myReason); return resumeFocusedStackTopActivityLocked(mHomeStack, prev, null); } - return mService.startHomeActivityLocked(mCurrentUser, myReason); + return mService.mAm.startHomeActivityLocked(mCurrentUser, myReason); } TaskRecord anyTaskForIdLocked(int id) { @@ -911,7 +905,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // result to an activity belonging to userId. Example case: a document // picker for personal files, opened by a work app, should still get locked. if (taskTopActivityIsUser(task, userId)) { - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyTaskProfileLocked( + mService.mAm.mActivityTaskManager.getTaskChangeNotificationController().notifyTaskProfileLocked( task.taskId, userId); } } @@ -1166,7 +1160,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } if (changed) { - mService.notifyAll(); + mService.mAm.notifyAll(); } } @@ -1196,7 +1190,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } if (changed) { - mService.notifyAll(); + mService.mAm.notifyAll(); } } @@ -1217,7 +1211,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } if (changed) { - mService.notifyAll(); + mService.mAm.notifyAll(); } } @@ -1322,19 +1316,19 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Don't debug things in the system process if (!aInfo.processName.equals("system")) { if ((startFlags & ActivityManager.START_FLAG_DEBUG) != 0) { - mService.setDebugApp(aInfo.processName, true, false); + mService.mAm.setDebugApp(aInfo.processName, true, false); } if ((startFlags & ActivityManager.START_FLAG_NATIVE_DEBUGGING) != 0) { - mService.setNativeDebuggingAppLocked(aInfo.applicationInfo, aInfo.processName); + mService.mAm.setNativeDebuggingAppLocked(aInfo.applicationInfo, aInfo.processName); } if ((startFlags & ActivityManager.START_FLAG_TRACK_ALLOCATION) != 0) { - mService.setTrackAllocationApp(aInfo.applicationInfo, aInfo.processName); + mService.mAm.setTrackAllocationApp(aInfo.applicationInfo, aInfo.processName); } if (profilerInfo != null) { - mService.setProfileApp(aInfo.applicationInfo, aInfo.processName, profilerInfo); + mService.mAm.setProfileApp(aInfo.applicationInfo, aInfo.processName, profilerInfo); } } final String intentLaunchToken = intent.getLaunchToken(); @@ -1347,7 +1341,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D ResolveInfo resolveIntent(Intent intent, String resolvedType, int userId, int flags, int filterCallingUid) { - synchronized (mService) { + synchronized (mService.mGlobalLock) { try { Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "resolveIntent"); int modifiedFlags = flags @@ -1364,7 +1358,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // (e.g. AMS.startActivityAsUser). final long token = Binder.clearCallingIdentity(); try { - return mService.getPackageManagerInternalLocked().resolveIntent( + return mService.mAm.getPackageManagerInternalLocked().resolveIntent( intent, resolvedType, modifiedFlags, userId, true, filterCallingUid); } finally { Binder.restoreCallingIdentity(token); @@ -1453,10 +1447,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (idx < 0) { app.activities.add(r); } - mService.updateLruProcessLocked(app, true, null); - mService.updateOomAdjLocked(); + mService.mAm.updateLruProcessLocked(app, true, null); + mService.mAm.updateOomAdjLocked(); - final LockTaskController lockTaskController = mService.mActivityTaskManager.getLockTaskController(); + final LockTaskController lockTaskController = mService.getLockTaskController(); if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV || (task.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED @@ -1484,20 +1478,20 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D System.identityHashCode(r), task.taskId, r.shortComponentName); if (r.isActivityTypeHome()) { // Home process is the root process of the task. - mService.mHomeProcess = task.mActivities.get(0).app; + mService.mAm.mHomeProcess = task.mActivities.get(0).app; } - mService.notifyPackageUse(r.intent.getComponent().getPackageName(), + mService.mAm.notifyPackageUse(r.intent.getComponent().getPackageName(), PackageManager.NOTIFY_PACKAGE_USE_ACTIVITY); r.sleeping = false; r.forceNewConfig = false; - mService.getAppWarningsLocked().onStartActivity(r); - mService.showAskCompatModeDialogLocked(r); - r.compat = mService.compatibilityInfoForPackageLocked(r.info.applicationInfo); + mService.mAm.getAppWarningsLocked().onStartActivity(r); + mService.mAm.showAskCompatModeDialogLocked(r); + r.compat = mService.mAm.compatibilityInfoForPackageLocked(r.info.applicationInfo); ProfilerInfo profilerInfo = null; - if (mService.mProfileApp != null && mService.mProfileApp.equals(app.processName)) { - if (mService.mProfileProc == null || mService.mProfileProc == app) { - mService.mProfileProc = app; - ProfilerInfo profilerInfoSvc = mService.mProfilerInfo; + if (mService.mAm.mProfileApp != null && mService.mAm.mProfileApp.equals(app.processName)) { + if (mService.mAm.mProfileProc == null || mService.mAm.mProfileProc == app) { + mService.mAm.mProfileProc = app; + ProfilerInfo profilerInfoSvc = mService.mAm.mProfilerInfo; if (profilerInfoSvc != null && profilerInfoSvc.profileFile != null) { if (profilerInfoSvc.profileFd != null) { try { @@ -1514,13 +1508,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D app.hasShownUi = true; app.pendingUiClean = true; - app.forceProcessStateUpTo(mService.mTopProcessState); + app.forceProcessStateUpTo(mService.mAm.mTopProcessState); // Because we could be starting an Activity in the system process this may not go // across a Binder interface which would create a new Configuration. Consequently // we have to always create a new Configuration here. final MergedConfiguration mergedConfiguration = new MergedConfiguration( - mService.getGlobalConfiguration(), r.getMergedOverrideConfiguration()); + mService.mAm.getGlobalConfiguration(), r.getMergedOverrideConfiguration()); r.setLastReportedConfiguration(mergedConfiguration); logIfTransactionTooLarge(r.intent, r.icicle); @@ -1536,39 +1530,39 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D mergedConfiguration.getGlobalConfiguration(), mergedConfiguration.getOverrideConfiguration(), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, - r.persistentState, results, newIntents, mService.mActivityTaskManager.isNextTransitionForward(), + r.persistentState, results, newIntents, mService.isNextTransitionForward(), profilerInfo)); // Set desired final state. final ActivityLifecycleItem lifecycleItem; if (andResume) { - lifecycleItem = ResumeActivityItem.obtain(mService.mActivityTaskManager.isNextTransitionForward()); + lifecycleItem = ResumeActivityItem.obtain(mService.isNextTransitionForward()); } else { lifecycleItem = PauseActivityItem.obtain(); } clientTransaction.setLifecycleStateRequest(lifecycleItem); // Schedule transaction. - mService.mActivityTaskManager.getLifecycleManager().scheduleTransaction(clientTransaction); + mService.getLifecycleManager().scheduleTransaction(clientTransaction); if ((app.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0 - && mService.mHasHeavyWeightFeature) { + && mService.mAm.mHasHeavyWeightFeature) { // This may be a heavy-weight process! Note that the package // manager will ensure that only activity can run in the main // process of the .apk, which is the only thing that will be // considered heavy-weight. if (app.processName.equals(app.info.packageName)) { - if (mService.mHeavyWeightProcess != null - && mService.mHeavyWeightProcess != app) { + if (mService.mAm.mHeavyWeightProcess != null + && mService.mAm.mHeavyWeightProcess != app) { Slog.w(TAG, "Starting new heavy weight process " + app + " when already running " - + mService.mHeavyWeightProcess); + + mService.mAm.mHeavyWeightProcess); } - mService.mHeavyWeightProcess = app; - Message msg = mService.mHandler.obtainMessage( + mService.mAm.mHeavyWeightProcess = app; + Message msg = mService.mAm.mHandler.obtainMessage( ActivityManagerService.POST_HEAVY_NOTIFICATION_MSG); msg.obj = r; - mService.mHandler.sendMessage(msg); + mService.mAm.mHandler.sendMessage(msg); } } @@ -1579,7 +1573,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D Slog.e(TAG, "Second failure launching " + r.intent.getComponent().flattenToShortString() + ", giving up", e); - mService.appDiedLocked(app); + mService.mAm.appDiedLocked(app); stack.requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "2nd-crash", false); return false; @@ -1620,13 +1614,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // a chance to initialize itself while in the background, making the // switch back to it faster and look better. if (isFocusedStack(stack)) { - mService.mActivityTaskManager.getActivityStartController().startSetupActivity(); + mService.getActivityStartController().startSetupActivity(); } // Update any services we are bound to that might care about whether // their client may have activities. if (r.app != null) { - mService.mServices.updateServiceConnectionActivitiesLocked(r.app); + mService.mAm.mServices.updateServiceConnectionActivitiesLocked(r.app); } return true; @@ -1662,7 +1656,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } // Update the configuration of the activities on the display. - return mService.updateDisplayOverrideConfigurationLocked(config, starting, deferResume, + return mService.mAm.updateDisplayOverrideConfigurationLocked(config, starting, deferResume, displayId); } @@ -1684,7 +1678,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void startSpecificActivityLocked(ActivityRecord r, boolean andResume, boolean checkConfig) { // Is this activity's application already running? - ProcessRecord app = mService.getProcessRecordLocked(r.processName, + ProcessRecord app = mService.mAm.getProcessRecordLocked(r.processName, r.info.applicationInfo.uid, true); getLaunchTimeTracker().setLaunchTime(r); @@ -1698,7 +1692,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // part of the framework so doesn't make sense to track as a // separate apk in the process. app.addPackage(r.info.packageName, r.info.applicationInfo.longVersionCode, - mService.mProcessStats); + mService.mAm.mProcessStats); } realStartActivityLocked(r, app, andResume, checkConfig); return; @@ -1711,7 +1705,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // restart the application. } - mService.startProcessLocked(r.processName, r.info.applicationInfo, true, 0, + mService.mAm.startProcessLocked(r.processName, r.info.applicationInfo, true, 0, "activity", r.intent.getComponent(), false, false, true); } @@ -1727,16 +1721,16 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D || !resumedActivity.app.equals(targetActivity.app); } - if (sendHint && mService.mLocalPowerManager != null) { - mService.mLocalPowerManager.powerHint(PowerHint.LAUNCH, 1); + if (sendHint && mService.mAm.mLocalPowerManager != null) { + mService.mAm.mLocalPowerManager.powerHint(PowerHint.LAUNCH, 1); mPowerHintSent = true; } } void sendPowerHintForLaunchEndIfNeeded() { // Trigger launch power hint if activity is launched - if (mPowerHintSent && mService.mLocalPowerManager != null) { - mService.mLocalPowerManager.powerHint(PowerHint.LAUNCH, 0); + if (mPowerHintSent && mService.mAm.mLocalPowerManager != null) { + mService.mAm.mLocalPowerManager.powerHint(PowerHint.LAUNCH, 0); mPowerHintSent = false; } } @@ -1745,9 +1739,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D String resultWho, int requestCode, int callingPid, int callingUid, String callingPackage, boolean ignoreTargetSecurity, boolean launchingInTask, ProcessRecord callerApp, ActivityRecord resultRecord, ActivityStack resultStack) { - final boolean isCallerRecents = mService.mActivityTaskManager.getRecentTasks() != null - && mService.mActivityTaskManager.getRecentTasks().isCallerRecents(callingUid); - final int startAnyPerm = mService.checkPermission(START_ANY_ACTIVITY, callingPid, + final boolean isCallerRecents = mService.getRecentTasks() != null + && mService.getRecentTasks().isCallerRecents(callingUid); + final int startAnyPerm = mService.mAm.checkPermission(START_ANY_ACTIVITY, callingPid, callingUid); if (startAnyPerm == PERMISSION_GRANTED || (isCallerRecents && launchingInTask)) { // If the caller has START_ANY_ACTIVITY, ignore all checks below. In addition, if the @@ -1826,7 +1820,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Check if the caller has enough privileges to embed activities and launch to private // displays. - final int startAnyPerm = mService.checkPermission(INTERNAL_SYSTEM_WINDOW, callingPid, + final int startAnyPerm = mService.mAm.checkPermission(INTERNAL_SYSTEM_WINDOW, callingPid, callingUid); if (startAnyPerm == PERMISSION_GRANTED) { if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:" @@ -1848,7 +1842,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return false; } // Check if the caller is allowed to embed activities from other apps. - if (mService.checkPermission(ACTIVITY_EMBEDDING, callingPid, callingUid) + if (mService.mAm.checkPermission(ACTIVITY_EMBEDDING, callingPid, callingUid) == PERMISSION_DENIED && !uidPresentOnDisplay) { if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:" + " disallow activity embedding without permission."); @@ -1906,7 +1900,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D private int getComponentRestrictionForCallingPackage(ActivityInfo activityInfo, String callingPackage, int callingPid, int callingUid, boolean ignoreTargetSecurity) { - if (!ignoreTargetSecurity && mService.checkComponentPermission(activityInfo.permission, + if (!ignoreTargetSecurity && mService.mAm.checkComponentPermission(activityInfo.permission, callingPid, callingUid, activityInfo.applicationInfo.uid, activityInfo.exported) == PERMISSION_DENIED) { return ACTIVITY_RESTRICTION_PERMISSION; @@ -1921,7 +1915,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return ACTIVITY_RESTRICTION_NONE; } - if (mService.mAppOpsService.noteOperation(opCode, callingUid, + if (mService.mAm.mAppOpsService.noteOperation(opCode, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) { if (!ignoreTargetSecurity) { return ACTIVITY_RESTRICTION_APPOP; @@ -1955,7 +1949,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return ACTIVITY_RESTRICTION_NONE; } - if (mService.checkPermission(permission, callingPid, callingUid) == PERMISSION_DENIED) { + if (mService.mAm.checkPermission(permission, callingPid, callingUid) == PERMISSION_DENIED) { return ACTIVITY_RESTRICTION_PERMISSION; } @@ -1964,7 +1958,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return ACTIVITY_RESTRICTION_NONE; } - if (mService.mAppOpsService.noteOperation(opCode, callingUid, + if (mService.mAm.mAppOpsService.noteOperation(opCode, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) { return ACTIVITY_RESTRICTION_APPOP; } @@ -1989,19 +1983,19 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** * Called when the frontmost task is idle. - * @return the state of mService.mBooting before this was called. + * @return the state of mService.mAm.mBooting before this was called. */ @GuardedBy("mService") private boolean checkFinishBootingLocked() { - final boolean booting = mService.mBooting; + final boolean booting = mService.mAm.mBooting; boolean enableScreen = false; - mService.mBooting = false; - if (!mService.mBooted) { - mService.mBooted = true; + mService.mAm.mBooting = false; + if (!mService.mAm.mBooted) { + mService.mAm.mBooted = true; enableScreen = true; } if (booting || enableScreen) { - mService.postFinishBooting(booting, enableScreen); + mService.mAm.postFinishBooting(booting, enableScreen); } return booting; } @@ -2050,7 +2044,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (allResumedActivitiesIdle()) { if (r != null) { - mService.scheduleAppGcsLocked(); + mService.mAm.scheduleAppGcsLocked(); } if (mLaunchingActivity.isHeld()) { @@ -2107,12 +2101,12 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Complete user switch if (startingUsers != null) { for (int i = 0; i < startingUsers.size(); i++) { - mService.mUserController.finishUserSwitch(startingUsers.get(i)); + mService.mAm.mUserController.finishUserSwitch(startingUsers.get(i)); } } } - mService.trimApplications(); + mService.mAm.trimApplications(); //dump(); //mWindowManager.dump(); @@ -2206,10 +2200,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Now set this one as the previous process, only if that really // makes sense to. if (r.app != null && fgApp != null && r.app != fgApp - && r.lastVisibleTime > mService.mPreviousProcessVisibleTime - && r.app != mService.mHomeProcess) { - mService.mPreviousProcess = r.app; - mService.mPreviousProcessVisibleTime = r.lastVisibleTime; + && r.lastVisibleTime > mService.mAm.mPreviousProcessVisibleTime + && r.app != mService.mAm.mHomeProcess) { + mService.mAm.mPreviousProcess = r.app; + mService.mAm.mPreviousProcessVisibleTime = r.lastVisibleTime; } } @@ -2348,9 +2342,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (options == null || options.getLaunchBounds() == null) { return false; } - return (mService.mSupportsPictureInPicture + return (mService.mAm.mSupportsPictureInPicture && options.getLaunchWindowingMode() == WINDOWING_MODE_PINNED) - || mService.mSupportsFreeformWindowManagement; + || mService.mAm.mSupportsFreeformWindowManagement; } LaunchParamsController getLaunchParamsController() { @@ -3076,9 +3070,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (tr != null) { tr.removeTaskActivitiesLocked(pauseImmediately, reason); cleanUpRemovedTaskLocked(tr, killProcess, removeFromRecents); - mService.mActivityTaskManager.getLockTaskController().clearLockedTask(tr); + mService.getLockTaskController().clearLockedTask(tr); if (tr.isPersistable) { - mService.mActivityTaskManager.notifyTaskPersisterLocked(null, true); + mService.notifyTaskPersisterLocked(null, true); } return true; } @@ -3097,7 +3091,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } // Find any running services associated with this app and stop if needed. - mService.mServices.cleanUpRemovedTaskLocked(tr, component, new Intent(tr.getBaseIntent())); + mService.mAm.mServices.cleanUpRemovedTaskLocked(tr, component, new Intent(tr.getBaseIntent())); if (!killProcess) { return; @@ -3106,7 +3100,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Determine if the process(es) for this task should be killed. final String pkg = component.getPackageName(); ArrayList procsToKill = new ArrayList<>(); - ArrayMap> pmap = mService.mProcessNames.getMap(); + ArrayMap> pmap = mService.mAm.mProcessNames.getMap(); for (int i = 0; i < pmap.size(); i++) { SparseArray uids = pmap.valueAt(i); @@ -3116,7 +3110,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Don't kill process for a different user. continue; } - if (proc == mService.mHomeProcess) { + if (proc == mService.mAm.mHomeProcess) { // Don't kill the home process along with tasks from the same package. continue; } @@ -3259,21 +3253,21 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Ensure that we aren't trying to move into a multi-window stack without multi-window // support - if (inMultiWindowMode && !mService.mSupportsMultiWindow) { + if (inMultiWindowMode && !mService.mAm.mSupportsMultiWindow) { throw new IllegalArgumentException("Device doesn't support multi-window, can not" + " reparent task=" + task + " to stack=" + stack); } // Ensure that we're not moving a task to a dynamic stack if device doesn't support // multi-display. - if (stack.mDisplayId != DEFAULT_DISPLAY && !mService.mSupportsMultiDisplay) { + if (stack.mDisplayId != DEFAULT_DISPLAY && !mService.mAm.mSupportsMultiDisplay) { throw new IllegalArgumentException("Device doesn't support multi-display, can not" + " reparent task=" + task + " to stackId=" + stackId); } // Ensure that we aren't trying to move into a freeform stack without freeform support if (stack.getWindowingMode() == WINDOWING_MODE_FREEFORM - && !mService.mSupportsFreeformWindowManagement) { + && !mService.mAm.mSupportsFreeformWindowManagement) { throw new IllegalArgumentException("Device doesn't support freeform, can not reparent" + " task=" + task); } @@ -3306,7 +3300,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return false; } - if (!mService.mForceResizableActivities && !r.supportsPictureInPicture()) { + if (!mService.mAm.mForceResizableActivities && !r.supportsPictureInPicture()) { Slog.w(TAG, "moveTopStackActivityToPinnedStackLocked: Picture-In-Picture not supported for " + " r=" + r); @@ -3387,7 +3381,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS); resumeFocusedStackTopActivityLocked(); - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyActivityPinned(r); + mService.getTaskChangeNotificationController().notifyActivityPinned(r); } /** Move activity with its stack to front and make the stack focused. */ @@ -3494,7 +3488,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D throw new IllegalStateException("Calling must be system uid"); } mLaunchingActivity.release(); - mService.mHandler.removeMessages(LAUNCH_TIMEOUT_MSG); + mService.mAm.mHandler.removeMessages(LAUNCH_TIMEOUT_MSG); } } @@ -3519,7 +3513,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D long timeRemaining = endTime - System.currentTimeMillis(); if (timeRemaining > 0) { try { - mService.wait(timeRemaining); + mService.mAm.wait(timeRemaining); } catch (InterruptedException e) { } } else { @@ -3601,7 +3595,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } void checkReadyForSleepLocked(boolean allowDelay) { - if (!mService.isSleepingOrShuttingDownLocked()) { + if (!mService.mAm.isSleepingOrShuttingDownLocked()) { // Do not care. return; } @@ -3618,8 +3612,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (mGoingToSleep.isHeld()) { mGoingToSleep.release(); } - if (mService.mShuttingDown) { - mService.notifyAll(); + if (mService.mAm.mShuttingDown) { + mService.mAm.notifyAll(); } } @@ -3647,7 +3641,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D final ActivityStack stack = r.getStack(); if (isFocusedStack(stack)) { - mService.updateUsageStats(r, true); + mService.mAm.updateUsageStats(r, true); } if (allResumedActivitiesComplete()) { ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS); @@ -3674,7 +3668,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D r.mLaunchTaskBehind = false; mRecentTasks.add(task); - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyTaskStackChanged(); + mService.getTaskChangeNotificationController().notifyTaskStackChanged(); r.setVisibility(false); // When launching tasks behind, update the last active time of the top task after the new @@ -3874,7 +3868,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** Checks whether the userid is a profile of the current user. */ boolean isCurrentProfileLocked(int userId) { if (userId == mCurrentUser) return true; - return mService.mUserController.isCurrentProfile(userId); + return mService.mAm.mUserController.isCurrentProfile(userId); } /** @@ -3921,7 +3915,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D final ActivityStack stack = s.getStack(); final boolean shouldSleepOrShutDown = stack != null ? stack.shouldSleepOrShutDownActivities() - : mService.isSleepingOrShuttingDownLocked(); + : mService.mAm.isSleepingOrShuttingDownLocked(); if (!waitingVisible || shouldSleepOrShutDown) { if (!processPausingActivities && s.isState(PAUSING)) { // Defer processing pausing activities in this iteration and reschedule @@ -4004,7 +3998,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D pw.print(mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser)); getKeyguardController().dump(pw, prefix); - mService.mActivityTaskManager.getLockTaskController().dump(pw, prefix); + mService.getLockTaskController().dump(pw, prefix); } public void writeToProto(ProtoOutputStream proto, long fieldId) { @@ -4275,7 +4269,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } private void handleDisplayAdded(int displayId) { - synchronized (mService) { + synchronized (mService.mGlobalLock) { getActivityDisplayOrCreateLocked(displayId); } } @@ -4338,7 +4332,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D throw new IllegalArgumentException("Can't remove the primary display."); } - synchronized (mService) { + synchronized (mService.mGlobalLock) { final ActivityDisplay activityDisplay = mActivityDisplays.get(displayId); if (activityDisplay == null) { return; @@ -4353,7 +4347,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } private void handleDisplayChanged(int displayId) { - synchronized (mService) { + synchronized (mService.mGlobalLock) { ActivityDisplay activityDisplay = mActivityDisplays.get(displayId); // TODO: The following code block should be moved into {@link ActivityDisplay}. if (activityDisplay != null) { @@ -4362,7 +4356,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D int displayState = activityDisplay.mDisplay.getState(); if (displayState == Display.STATE_OFF && activityDisplay.mOffToken == null) { activityDisplay.mOffToken = - mService.acquireSleepToken("Display-off", displayId); + mService.mAm.acquireSleepToken("Display-off", displayId); } else if (displayState == Display.STATE_ON && activityDisplay.mOffToken != null) { activityDisplay.mOffToken.release(); @@ -4395,7 +4389,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (display != null) { display.mAllSleepTokens.remove(token); if (display.mAllSleepTokens.isEmpty()) { - mService.updateSleepIfNeededLocked(); + mService.mAm.updateSleepIfNeededLocked(); } } } @@ -4409,7 +4403,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } display.mAllSleepTokens.clear(); - mService.updateSleepIfNeededLocked(); + mService.mAm.updateSleepIfNeededLocked(); } private StackInfo getStackInfo(ActivityStack stack) { @@ -4502,12 +4496,12 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } // The task might have landed on a display different from requested. // TODO(multi-display): Find proper stack for the task on the default display. - mAtm.setTaskWindowingMode(task.taskId, + mService.setTaskWindowingMode(task.taskId, WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */); if (preferredDisplayId != actualDisplayId) { // Display a warning toast that we tried to put a non-resizeable task on a secondary // display with config different from global config. - mService.mActivityTaskManager.getTaskChangeNotificationController() + mService.getTaskChangeNotificationController() .notifyActivityLaunchOnSecondaryDisplayFailed(); return; } @@ -4516,7 +4510,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (!task.supportsSplitScreenWindowingMode() || forceNonResizable) { // Display a warning toast that we tried to put an app that doesn't support split-screen // in split-screen. - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyActivityDismissingDockedStack(); + mService.getTaskChangeNotificationController().notifyActivityDismissingDockedStack(); // Dismiss docked stack. If task appeared to be in docked stack but is not resizable - // we need to move it to top of fullscreen stack, otherwise it will be covered. @@ -4536,7 +4530,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D final int reason = isSecondaryDisplayPreferred ? FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY : FORCED_RESIZEABLE_REASON_SPLIT_SCREEN; - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyActivityForcedResizable( + mService.getTaskChangeNotificationController().notifyActivityForcedResizable( task.taskId, reason, packageName); } } @@ -4660,7 +4654,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } void activityIdleInternal(ActivityRecord r, boolean processPausingActivities) { - synchronized (mService) { + synchronized (mService.mGlobalLock) { activityIdleInternalLocked(r != null ? r.appToken : null, true /* fromTimeout */, processPausingActivities, null); } @@ -4670,7 +4664,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D public void handleMessage(Message msg) { switch (msg.what) { case REPORT_MULTI_WINDOW_MODE_CHANGED_MSG: { - synchronized (mService) { + synchronized (mService.mGlobalLock) { for (int i = mMultiWindowModeChangedActivities.size() - 1; i >= 0; i--) { final ActivityRecord r = mMultiWindowModeChangedActivities.remove(i); r.updateMultiWindowMode(); @@ -4678,7 +4672,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } break; case REPORT_PIP_MODE_CHANGED_MSG: { - synchronized (mService) { + synchronized (mService.mGlobalLock) { for (int i = mPipModeChangedActivities.size() - 1; i >= 0; i--) { final ActivityRecord r = mPipModeChangedActivities.remove(i); r.updatePictureInPictureMode(mPipModeChangedTargetStackBounds, @@ -4700,20 +4694,20 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D false /* processPausingActivities */); } break; case RESUME_TOP_ACTIVITY_MSG: { - synchronized (mService) { + synchronized (mService.mGlobalLock) { resumeFocusedStackTopActivityLocked(); } } break; case SLEEP_TIMEOUT_MSG: { - synchronized (mService) { - if (mService.isSleepingOrShuttingDownLocked()) { + synchronized (mService.mGlobalLock) { + if (mService.mAm.isSleepingOrShuttingDownLocked()) { Slog.w(TAG, "Sleep timeout! Sleeping now."); checkReadyForSleepLocked(false /* allowDelay */); } } } break; case LAUNCH_TIMEOUT_MSG: { - synchronized (mService) { + synchronized (mService.mGlobalLock) { if (mLaunchingActivity.isHeld()) { Slog.w(TAG, "Launch timeout has expired, giving up wake lock!"); if (VALIDATE_WAKE_LOCK_CALLER @@ -4734,7 +4728,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D handleDisplayRemoved(msg.arg1); } break; case LAUNCH_TASK_BEHIND_COMPLETE: { - synchronized (mService) { + synchronized (mService.mGlobalLock) { ActivityRecord r = ActivityRecord.forTokenLocked((IBinder) msg.obj); if (r != null) { handleLaunchTaskBehindCompleteLocked(r); @@ -4822,21 +4816,21 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // If the user must confirm credentials (e.g. when first launching a work app and the // Work Challenge is present) let startActivityInPackage handle the intercepting. - if (!mService.mUserController.shouldConfirmCredentials(task.userId) + if (!mService.mAm.mUserController.shouldConfirmCredentials(task.userId) && task.getRootActivity() != null) { final ActivityRecord targetActivity = task.getTopActivity(); sendPowerHintForLaunchStartIfNeeded(true /* forceSend */, targetActivity); mActivityMetricsLogger.notifyActivityLaunching(); try { - mService.mActivityTaskManager.moveTaskToFrontLocked(task.taskId, 0, options, + mService.moveTaskToFrontLocked(task.taskId, 0, options, true /* fromRecents */); } finally { mActivityMetricsLogger.notifyActivityLaunched(START_TASK_TO_FRONT, targetActivity); } - mService.mActivityTaskManager.getActivityStartController().postStartActivityProcessingForLastStarter( + mService.getActivityStartController().postStartActivityProcessingForLastStarter( task.getTopActivity(), ActivityManager.START_TASK_TO_FRONT, task.getStack()); return ActivityManager.START_TASK_TO_FRONT; @@ -4845,7 +4839,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D intent = task.intent; intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); userId = task.userId; - return mService.mActivityTaskManager.getActivityStartController().startActivityInPackage( + return mService.getActivityStartController().startActivityInPackage( task.mCallingUid, callingPid, callingUid, callingPackage, intent, null, null, null, 0, 0, options, userId, task, "startActivityFromRecents", false /* validateIncomingUser */); @@ -4950,7 +4944,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D @Override public void release() { - synchronized (mService) { + synchronized (mService.mGlobalLock) { removeSleepTokenLocked(this); } } diff --git a/services/core/java/com/android/server/am/ActivityStartController.java b/services/core/java/com/android/server/am/ActivityStartController.java index a7c32009a4c4..fa001dfadefa 100644 --- a/services/core/java/com/android/server/am/ActivityStartController.java +++ b/services/core/java/com/android/server/am/ActivityStartController.java @@ -65,7 +65,7 @@ public class ActivityStartController { private static final int DO_PENDING_ACTIVITY_LAUNCHES_MSG = 1; - private final ActivityManagerService mService; + private final ActivityTaskManagerService mService; private final ActivityStackSupervisor mSupervisor; /** Last home activity record we attempted to start. */ @@ -96,7 +96,7 @@ public class ActivityStartController { public void handleMessage(Message msg) { switch(msg.what) { case DO_PENDING_ACTIVITY_LAUNCHES_MSG: - synchronized (mService) { + synchronized (mService.mGlobalLock) { doPendingActivityLaunches(true); } break; @@ -111,22 +111,22 @@ public class ActivityStartController { */ private ActivityStarter mLastStarter; - ActivityStartController(ActivityManagerService service) { + ActivityStartController(ActivityTaskManagerService service) { this(service, service.mStackSupervisor, new DefaultFactory(service, service.mStackSupervisor, new ActivityStartInterceptor(service, service.mStackSupervisor))); } @VisibleForTesting - ActivityStartController(ActivityManagerService service, ActivityStackSupervisor supervisor, + ActivityStartController(ActivityTaskManagerService service, ActivityStackSupervisor supervisor, Factory factory) { mService = service; mSupervisor = supervisor; - mHandler = new StartHandler(mService.mHandlerThread.getLooper()); + mHandler = new StartHandler(mService.mH.getLooper()); mFactory = factory; mFactory.setController(this); mPendingRemoteAnimationRegistry = new PendingRemoteAnimationRegistry(service, - service.mHandler); + service.mH); } /** @@ -182,7 +182,7 @@ public class ActivityStartController { */ void startSetupActivity() { // Only do this once per boot. - if (mService.getCheckedForSetup()) { + if (mService.mAm.getCheckedForSetup()) { return; } @@ -190,10 +190,10 @@ public class ActivityStartController { // version than the last one shown, and we are not running in // low-level factory test mode. final ContentResolver resolver = mService.mContext.getContentResolver(); - if (mService.mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL && + if (mService.mAm.mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL && Settings.Global.getInt(resolver, Settings.Global.DEVICE_PROVISIONED, 0) != 0) { - mService.setCheckedForSetup(true); + mService.mAm.setCheckedForSetup(true); // See if we should be showing the platform update setup UI. final Intent intent = new Intent(Intent.ACTION_UPGRADE_SETUP); @@ -237,10 +237,10 @@ public class ActivityStartController { int checkTargetUser(int targetUserId, boolean validateIncomingUser, int realCallingPid, int realCallingUid, String reason) { if (validateIncomingUser) { - return mService.mUserController.handleIncomingUser(realCallingPid, realCallingUid, + return mService.mAm.mUserController.handleIncomingUser(realCallingPid, realCallingUid, targetUserId, false, ALLOW_FULL_ONLY, reason, null); } else { - mService.mUserController.ensureNotSpecialUser(targetUserId); + mService.mAm.mUserController.ensureNotSpecialUser(targetUserId); return targetUserId; } } @@ -320,7 +320,7 @@ public class ActivityStartController { } final long origId = Binder.clearCallingIdentity(); try { - synchronized (mService) { + synchronized (mService.mGlobalLock) { ActivityRecord[] outActivity = new ActivityRecord[1]; for (int i=0; i < intents.length; i++) { Intent intent = intents[i]; @@ -343,7 +343,7 @@ public class ActivityStartController { null, userId, ActivityStarter.computeResolveFilterUid( callingUid, realCallingUid, UserHandle.USER_NULL)); // TODO: New, check if this is correct - aInfo = mService.getActivityInfoForUser(aInfo, userId); + aInfo = mService.mAm.getActivityInfoForUser(aInfo, userId); if (aInfo != null && (aInfo.applicationInfo.privateFlags diff --git a/services/core/java/com/android/server/am/ActivityStartInterceptor.java b/services/core/java/com/android/server/am/ActivityStartInterceptor.java index ff97db83766e..171c0bbd1812 100644 --- a/services/core/java/com/android/server/am/ActivityStartInterceptor.java +++ b/services/core/java/com/android/server/am/ActivityStartInterceptor.java @@ -66,7 +66,7 @@ import com.android.server.LocalServices; */ class ActivityStartInterceptor { - private final ActivityManagerService mService; + private final ActivityTaskManagerService mService; private final ActivityStackSupervisor mSupervisor; private final Context mServiceContext; private final UserController mUserController; @@ -99,12 +99,13 @@ class ActivityStartInterceptor { TaskRecord mInTask; ActivityOptions mActivityOptions; - ActivityStartInterceptor(ActivityManagerService service, ActivityStackSupervisor supervisor) { - this(service, supervisor, service.mContext, service.mUserController); + ActivityStartInterceptor( + ActivityTaskManagerService service, ActivityStackSupervisor supervisor) { + this(service, supervisor, service.mContext, service.mAm.mUserController); } @VisibleForTesting - ActivityStartInterceptor(ActivityManagerService service, ActivityStackSupervisor supervisor, + ActivityStartInterceptor(ActivityTaskManagerService service, ActivityStackSupervisor supervisor, Context context, UserController userController) { mService = service; mSupervisor = supervisor; @@ -127,7 +128,7 @@ class ActivityStartInterceptor { private IntentSender createIntentSenderForOriginalIntent(int callingUid, int flags) { Bundle activityOptions = deferCrossProfileAppsAnimationIfNecessary(); - final IIntentSender target = mService.getIntentSenderLocked( + final IIntentSender target = mService.mAm.getIntentSenderLocked( INTENT_SENDER_ACTIVITY, mCallingPackage, callingUid, mUserId, null /*token*/, null /*resultCode*/, 0 /*requestCode*/, new Intent[] { mIntent }, new String[] { mResolvedType }, @@ -238,7 +239,7 @@ class ActivityStartInterceptor { (mAInfo.applicationInfo.flags & FLAG_SUSPENDED) == 0) { return false; } - final PackageManagerInternal pmi = mService.getPackageManagerInternalLocked(); + final PackageManagerInternal pmi = mService.mAm.getPackageManagerInternalLocked(); if (pmi == null) { return false; } @@ -319,7 +320,7 @@ class ActivityStartInterceptor { private boolean interceptHarmfulAppIfNeeded() { CharSequence harmfulAppWarning; try { - harmfulAppWarning = mService.getPackageManager() + harmfulAppWarning = mService.mAm.getPackageManager() .getHarmfulAppWarning(mAInfo.packageName, mUserId); } catch (RemoteException ex) { return false; diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index d2becb1f9bdd..f50bb3789b96 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -132,7 +132,7 @@ class ActivityStarter { private static final String TAG_USER_LEAVING = TAG + POSTFIX_USER_LEAVING; private static final int INVALID_LAUNCH_MODE = -1; - private final ActivityManagerService mService; + private final ActivityTaskManagerService mService; private final ActivityStackSupervisor mSupervisor; private final ActivityStartInterceptor mInterceptor; private final ActivityStartController mController; @@ -233,14 +233,14 @@ class ActivityStarter { private final int MAX_STARTER_COUNT = 3; private ActivityStartController mController; - private ActivityManagerService mService; + private ActivityTaskManagerService mService; private ActivityStackSupervisor mSupervisor; private ActivityStartInterceptor mInterceptor; private SynchronizedPool mStarterPool = new SynchronizedPool<>(MAX_STARTER_COUNT); - DefaultFactory(ActivityManagerService service, + DefaultFactory(ActivityTaskManagerService service, ActivityStackSupervisor supervisor, ActivityStartInterceptor interceptor) { mService = service; mSupervisor = supervisor; @@ -410,7 +410,7 @@ class ActivityStarter { } } - ActivityStarter(ActivityStartController controller, ActivityManagerService service, + ActivityStarter(ActivityStartController controller, ActivityTaskManagerService service, ActivityStackSupervisor supervisor, ActivityStartInterceptor interceptor) { mController = controller; mService = service; @@ -583,7 +583,7 @@ class ActivityStarter { ProcessRecord callerApp = null; if (caller != null) { - callerApp = mService.getRecordForAppLocked(caller); + callerApp = mService.mAm.getRecordForAppLocked(caller); if (callerApp != null) { callingPid = callerApp.pid; callingUid = callerApp.info.uid; @@ -672,7 +672,7 @@ class ActivityStarter { && sourceRecord.info.applicationInfo.uid != aInfo.applicationInfo.uid) { try { intent.addCategory(Intent.CATEGORY_VOICE); - if (!mService.getPackageManager().activitySupportsIntent( + if (!mService.mAm.getPackageManager().activitySupportsIntent( intent.getComponent(), intent, resolvedType)) { Slog.w(TAG, "Activity being started in current voice task does not support voice: " @@ -690,7 +690,7 @@ class ActivityStarter { // If the caller is starting a new voice session, just make sure the target // is actually allowing it to run this way. try { - if (!mService.getPackageManager().activitySupportsIntent(intent.getComponent(), + if (!mService.mAm.getPackageManager().activitySupportsIntent(intent.getComponent(), intent, resolvedType)) { Slog.w(TAG, "Activity being started in new voice task does not support: " @@ -717,7 +717,7 @@ class ActivityStarter { boolean abort = !mSupervisor.checkStartAnyActivityPermission(intent, aInfo, resultWho, requestCode, callingPid, callingUid, callingPackage, ignoreTargetSecurity, inTask != null, callerApp, resultRecord, resultStack); - abort |= !mService.mIntentFirewall.checkStartActivity(intent, callingUid, + abort |= !mService.mAm.mIntentFirewall.checkStartActivity(intent, callingUid, callingPid, resolvedType, aInfo.applicationInfo); // Merge the two options bundles, while realCallerOptions takes precedence. @@ -725,19 +725,19 @@ class ActivityStarter { ? options.getOptions(intent, aInfo, callerApp, mSupervisor) : null; if (allowPendingRemoteAnimationRegistryLookup) { - checkedOptions = mService.mActivityTaskManager.getActivityStartController() + checkedOptions = mService.getActivityStartController() .getPendingRemoteAnimationRegistry() .overrideOptionsIfNeeded(callingPackage, checkedOptions); } - if (mService.mController != null) { + if (mService.mAm.mController != null) { try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); - abort |= !mService.mController.activityStarting(watchIntent, + abort |= !mService.mAm.mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { - mService.mController = null; + mService.mAm.mController = null; } } @@ -770,10 +770,10 @@ class ActivityStarter { // If permissions need a review before any of the app components can run, we // launch the review activity and pass a pending intent to start the activity // we are to launching now after the review is completed. - if (mService.mPermissionReviewRequired && aInfo != null) { - if (mService.getPackageManagerInternalLocked().isPermissionsReviewRequired( + if (mService.mAm.mPermissionReviewRequired && aInfo != null) { + if (mService.mAm.getPackageManagerInternalLocked().isPermissionsReviewRequired( aInfo.packageName, userId)) { - IIntentSender target = mService.getIntentSenderLocked( + IIntentSender target = mService.mAm.getIntentSenderLocked( ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, callingUid, userId, null, null, 0, new Intent[]{intent}, new String[]{resolvedType}, PendingIntent.FLAG_CANCEL_CURRENT @@ -823,9 +823,9 @@ class ActivityStarter { aInfo = mSupervisor.resolveActivity(intent, rInfo, startFlags, null /*profilerInfo*/); } - ActivityRecord r = new ActivityRecord(mService.mActivityTaskManager, callerApp, callingPid, + ActivityRecord r = new ActivityRecord(mService, callerApp, callingPid, callingUid, - callingPackage, intent, resolvedType, aInfo, mService.getGlobalConfiguration(), + callingPackage, intent, resolvedType, aInfo, mService.mAm.getGlobalConfiguration(), resultRecord, resultWho, requestCode, componentSpecified, voiceSession != null, mSupervisor, checkedOptions, sourceRecord); if (outActivity != null) { @@ -844,7 +844,7 @@ class ActivityStarter { // one, check whether app switches are allowed. if (voiceSession == null && (stack.getResumedActivity() == null || stack.getResumedActivity().info.applicationInfo.uid != realCallingUid)) { - if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, + if (!mService.mAm.checkAppSwitchAllowedLocked(callingPid, callingUid, realCallingPid, realCallingUid, "Activity start")) { mController.addPendingActivityLaunch(new PendingActivityLaunch(r, sourceRecord, startFlags, stack, callerApp)); @@ -853,15 +853,15 @@ class ActivityStarter { } } - if (mService.mDidAppSwitch) { + if (mService.mAm.mDidAppSwitch) { // This is the second allowed switch since we stopped switches, // so now just generally allow switches. Use case: user presses // home (switches disabled, switch to home, mDidAppSwitch now true); // user taps a home icon (coming from home so allowed, we hit here // and now allow anyone to switch again). - mService.mAppSwitchesAllowedTime = 0; + mService.mAm.mAppSwitchesAllowedTime = 0; } else { - mService.mDidAppSwitch = true; + mService.mAm.mDidAppSwitch = true; } mController.doPendingActivityLaunches(false); @@ -879,7 +879,7 @@ class ActivityStarter { String resolvedType, int userId) { if (auxiliaryResponse != null && auxiliaryResponse.needsPhaseTwo) { // request phase two resolution - mService.getPackageManagerInternalLocked().requestInstantAppResolutionPhaseTwo( + mService.mAm.getPackageManagerInternalLocked().requestInstantAppResolutionPhaseTwo( auxiliaryResponse, originalIntent, resolvedType, callingPackage, verificationBundle, userId); } @@ -930,7 +930,7 @@ class ActivityStarter { // anyone interested in this piece of information. switch (startedActivityStack.getWindowingMode()) { case WINDOWING_MODE_PINNED: - mService.mActivityTaskManager.getTaskChangeNotificationController().notifyPinnedActivityRestartAttempt( + mService.getTaskChangeNotificationController().notifyPinnedActivityRestartAttempt( clearedTask); break; case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: @@ -979,7 +979,7 @@ class ActivityStarter { && !(Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() == null) && !Intent.ACTION_INSTALL_INSTANT_APP_PACKAGE.equals(intent.getAction()) && !Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE.equals(intent.getAction()) - && mService.getPackageManagerInternalLocked() + && mService.mAm.getPackageManagerInternalLocked() .isInstantAppInstallerComponent(intent.getComponent())) { // intercept intents targeted directly to the ephemeral installer the // ephemeral installer should never be started with a raw Intent; instead @@ -1021,10 +1021,10 @@ class ActivityStarter { // Collect information about the target of the Intent. ActivityInfo aInfo = mSupervisor.resolveActivity(intent, rInfo, startFlags, profilerInfo); - synchronized (mService) { + synchronized (mService.mGlobalLock) { final ActivityStack stack = mSupervisor.mFocusedStack; stack.mConfigWillChange = globalConfig != null - && mService.getGlobalConfiguration().diff(globalConfig) != 0; + && mService.mAm.getGlobalConfiguration().diff(globalConfig) != 0; if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Starting activity when config will change = " + stack.mConfigWillChange); @@ -1033,16 +1033,16 @@ class ActivityStarter { if (aInfo != null && (aInfo.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0 && - mService.mHasHeavyWeightFeature) { + mService.mAm.mHasHeavyWeightFeature) { // This may be a heavy-weight process! Check to see if we already // have another, different heavy-weight process running. if (aInfo.processName.equals(aInfo.applicationInfo.packageName)) { - final ProcessRecord heavy = mService.mHeavyWeightProcess; + final ProcessRecord heavy = mService.mAm.mHeavyWeightProcess; if (heavy != null && (heavy.info.uid != aInfo.applicationInfo.uid || !heavy.processName.equals(aInfo.processName))) { int appCallingUid = callingUid; if (caller != null) { - ProcessRecord callerApp = mService.getRecordForAppLocked(caller); + ProcessRecord callerApp = mService.mAm.getRecordForAppLocked(caller); if (callerApp != null) { appCallingUid = callerApp.info.uid; } else { @@ -1054,7 +1054,7 @@ class ActivityStarter { } } - IIntentSender target = mService.getIntentSenderLocked( + IIntentSender target = mService.mAm.getIntentSenderLocked( ActivityManager.INTENT_SENDER_ACTIVITY, "android", appCallingUid, userId, null, null, 0, new Intent[] { intent }, new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT @@ -1090,7 +1090,7 @@ class ActivityStarter { callingUid, realCallingUid, mRequest.filterCallingUid)); aInfo = rInfo != null ? rInfo.activityInfo : null; if (aInfo != null) { - aInfo = mService.getActivityInfoForUser(aInfo, userId); + aInfo = mService.mAm.getActivityInfoForUser(aInfo, userId); } } } @@ -1110,12 +1110,12 @@ class ActivityStarter { // do so now. This allows a clean switch, as we are waiting // for the current activity to pause (so we will not destroy // it), and have not yet started the next activity. - mService.enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION, + mService.mAm.enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION, "updateConfiguration()"); stack.mConfigWillChange = false; if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Updating to new configuration after starting activity."); - mService.updateConfigurationLocked(globalConfig, null, false); + mService.mAm.updateConfigurationLocked(globalConfig, null, false); } if (outResult != null) { @@ -1128,7 +1128,7 @@ class ActivityStarter { mSupervisor.mWaitingActivityLaunched.add(outResult); do { try { - mService.wait(); + mService.mGlobalLock.wait(); } catch (InterruptedException e) { } } while (outResult.result != START_TASK_TO_FRONT @@ -1159,7 +1159,7 @@ class ActivityStarter { // Note: the timeout variable is not currently not ever set. do { try { - mService.wait(); + mService.mGlobalLock.wait(); } catch (InterruptedException e) { } } while (!outResult.timeout && outResult.who == null); @@ -1257,7 +1257,7 @@ class ActivityStarter { // When the flags NEW_TASK and CLEAR_TASK are set, then the task gets reused but // still needs to be a lock task mode violation since the task gets cleared out and // the device would otherwise leave the locked task. - if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(), + if (mService.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(), (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))) { Slog.e(TAG, "startActivityUnchecked: Attempt to violate Lock Task Mode"); @@ -1423,9 +1423,9 @@ class ActivityStarter { return result; } - mService.grantUriPermissionFromIntentLocked(mCallingUid, mStartActivity.packageName, + mService.mAm.grantUriPermissionFromIntentLocked(mCallingUid, mStartActivity.packageName, mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.userId); - mService.grantEphemeralAccessLocked(mStartActivity.userId, mIntent, + mService.mAm.grantEphemeralAccessLocked(mStartActivity.userId, mIntent, mStartActivity.appInfo.uid, UserHandle.getAppId(mCallingUid)); if (newTask) { EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, mStartActivity.userId, @@ -1821,7 +1821,7 @@ class ActivityStarter { } // Get the virtual display id from ActivityManagerService. - int displayId = mService.mVr2dDisplayId; + int displayId = mService.mAm.mVr2dDisplayId; if (displayId != INVALID_DISPLAY) { if (DEBUG_STACK) { Slog.d(TAG, "getSourceDisplayId :" + displayId); @@ -2070,7 +2070,7 @@ class ActivityStarter { mStartActivity.setTaskToAffiliateWith(taskToAffiliate); } - if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) { + if (mService.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) { Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity); return START_RETURN_LOCK_TASK_MODE_VIOLATION; } @@ -2093,7 +2093,7 @@ class ActivityStarter { } private int setTaskFromSourceRecord() { - if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) { + if (mService.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) { Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity); return START_RETURN_LOCK_TASK_MODE_VIOLATION; } @@ -2115,13 +2115,13 @@ class ActivityStarter { // be not suitable. Let's check other displays. if (mTargetStack == null && targetDisplayId != sourceStack.mDisplayId) { // Can't use target display, lets find a stack on the source display. - mTargetStack = mService.mStackSupervisor.getValidLaunchStackOnDisplay( + mTargetStack = mSupervisor.getValidLaunchStackOnDisplay( sourceStack.mDisplayId, mStartActivity); } if (mTargetStack == null) { // There are no suitable stacks on the target and source display(s). Look on all // displays. - mTargetStack = mService.mStackSupervisor.getNextValidLaunchStackLocked( + mTargetStack = mSupervisor.getNextValidLaunchStackLocked( mStartActivity, -1 /* currentFocus */); } } @@ -2187,7 +2187,7 @@ class ActivityStarter { private int setTaskFromInTask() { // The caller is asking that the new activity be started in an explicit // task it has provided to us. - if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mInTask)) { + if (mService.getLockTaskController().isLockTaskModeViolation(mInTask)) { Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity); return START_RETURN_LOCK_TASK_MODE_VIOLATION; } @@ -2252,7 +2252,7 @@ class ActivityStarter { final ActivityStack stack = task.getStack(); if (stack != null && stack.resizeStackWithLaunchBounds()) { - mService.mActivityTaskManager.resizeStack( + mService.resizeStack( stack.mStackId, bounds, true, !PRESERVE_WINDOWS, ANIMATE, -1); } else { task.updateOverrideConfiguration(bounds); diff --git a/services/core/java/com/android/server/am/ActivityTaskManagerService.java b/services/core/java/com/android/server/am/ActivityTaskManagerService.java index b27c4802e84c..90097fd976e2 100644 --- a/services/core/java/com/android/server/am/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/am/ActivityTaskManagerService.java @@ -128,6 +128,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import android.os.LocaleList; import android.os.Looper; import android.os.Message; import android.os.PersistableBundle; @@ -243,6 +244,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } + /** Current sequencing integer of the configuration, for skipping old configurations. */ + int mConfigurationSeq; + + /** + * Temp object used when global and/or display override configuration is updated. It is also + * sent to outer world instead of {@link #getGlobalConfiguration} because we don't trust + * anyone... + */ + Configuration mTempConfig = new Configuration(); + ActivityTaskManagerService(Context context) { mContext = context; mLifecycleManager = new ClientLifecycleManager(); @@ -259,17 +270,29 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mAm = am; mGlobalLock = mAm; mH = new H(mAm.mHandlerThread.getLooper()); - mStackSupervisor = mAm.mStackSupervisor; + + mTempConfig.setToDefaults(); + mTempConfig.setLocales(LocaleList.getDefault()); + mConfigurationSeq = mTempConfig.seq = 1; + mStackSupervisor = createStackSupervisor(); + mStackSupervisor.onConfigurationChanged(mTempConfig); + mTaskChangeNotificationController = new TaskChangeNotificationController(mAm, mStackSupervisor, mH); mLockTaskController = new LockTaskController(mContext, mStackSupervisor, mH); - mActivityStartController = new ActivityStartController(mAm); + mActivityStartController = new ActivityStartController(this); mRecentTasks = createRecentTasks(); mStackSupervisor.setRecentTasks(mRecentTasks); mVrController = new VrController(mAm); mKeyguardController = mStackSupervisor.getKeyguardController(); } + protected ActivityStackSupervisor createStackSupervisor() { + final ActivityStackSupervisor supervisor = new ActivityStackSupervisor(this, mH.getLooper()); + supervisor.initialize(); + return supervisor; + } + void setWindowManager(WindowManagerService wm) { mWindowManager = wm; mLockTaskController.setWindowManager(wm); diff --git a/services/core/java/com/android/server/am/PendingRemoteAnimationRegistry.java b/services/core/java/com/android/server/am/PendingRemoteAnimationRegistry.java index 77713f57d017..877d896d433d 100644 --- a/services/core/java/com/android/server/am/PendingRemoteAnimationRegistry.java +++ b/services/core/java/com/android/server/am/PendingRemoteAnimationRegistry.java @@ -33,9 +33,9 @@ class PendingRemoteAnimationRegistry { private final ArrayMap mEntries = new ArrayMap<>(); private final Handler mHandler; - private final ActivityManagerService mService; + private final ActivityTaskManagerService mService; - PendingRemoteAnimationRegistry(ActivityManagerService service, Handler handler) { + PendingRemoteAnimationRegistry(ActivityTaskManagerService service, Handler handler) { mService = service; mHandler = handler; } @@ -74,7 +74,7 @@ class PendingRemoteAnimationRegistry { this.packageName = packageName; this.adapter = adapter; mHandler.postDelayed(() -> { - synchronized (mService) { + synchronized (mService.mGlobalLock) { final Entry entry = mEntries.get(packageName); if (entry == this) { mEntries.remove(packageName); diff --git a/services/core/java/com/android/server/am/SafeActivityOptions.java b/services/core/java/com/android/server/am/SafeActivityOptions.java index 837432d0aed6..778990bf6c6a 100644 --- a/services/core/java/com/android/server/am/SafeActivityOptions.java +++ b/services/core/java/com/android/server/am/SafeActivityOptions.java @@ -192,7 +192,7 @@ class SafeActivityOptions { // component or has the START_TASKS_FROM_RECENTS permission if (options.getLaunchTaskId() != INVALID_TASK_ID && !supervisor.mRecentTasks.isCallerRecents(callingUid)) { - final int startInTaskPerm = supervisor.mService.checkPermission( + final int startInTaskPerm = supervisor.mService.mAm.checkPermission( START_TASKS_FROM_RECENTS, callingPid, callingUid); if (startInTaskPerm == PERMISSION_DENIED) { final String msg = "Permission Denial: starting " + getIntentString(intent) @@ -219,7 +219,7 @@ class SafeActivityOptions { // Check if someone tries to launch an unwhitelisted activity into LockTask mode. final boolean lockTaskMode = options.getLockTaskMode(); if (aInfo != null && lockTaskMode - && !supervisor.mService.mActivityTaskManager.getLockTaskController().isPackageWhitelisted( + && !supervisor.mService.getLockTaskController().isPackageWhitelisted( UserHandle.getUserId(callingUid), aInfo.packageName)) { final String msg = "Permission Denial: starting " + getIntentString(intent) + " from " + callerApp + " (pid=" + callingPid @@ -230,7 +230,7 @@ class SafeActivityOptions { // Check permission for remote animations final RemoteAnimationAdapter adapter = options.getRemoteAnimationAdapter(); - if (adapter != null && supervisor.mService.checkPermission( + if (adapter != null && supervisor.mService.mAm.checkPermission( CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS, callingPid, callingUid) != PERMISSION_GRANTED) { final String msg = "Permission Denial: starting " + getIntentString(intent) diff --git a/services/core/java/com/android/server/am/TaskChangeNotificationController.java b/services/core/java/com/android/server/am/TaskChangeNotificationController.java index 7896e2dd9883..efb80bee5d6f 100644 --- a/services/core/java/com/android/server/am/TaskChangeNotificationController.java +++ b/services/core/java/com/android/server/am/TaskChangeNotificationController.java @@ -52,7 +52,8 @@ class TaskChangeNotificationController { // Delay in notifying task stack change listeners (in millis) private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100; - private final ActivityManagerService mService; + // Global lock used by the service the instantiate objects of this class. + private final Object mServiceLock; private final ActivityStackSupervisor mStackSupervisor; private final Handler mHandler; @@ -149,7 +150,7 @@ class TaskChangeNotificationController { public void handleMessage(Message msg) { switch (msg.what) { case LOG_STACK_STATE_MSG: { - synchronized (mService) { + synchronized (mServiceLock) { mStackSupervisor.logStackState(); } break; @@ -209,15 +210,15 @@ class TaskChangeNotificationController { } } - public TaskChangeNotificationController(ActivityManagerService service, + public TaskChangeNotificationController(Object serviceLock, ActivityStackSupervisor stackSupervisor, Handler handler) { - mService = service; + mServiceLock = serviceLock; mStackSupervisor = stackSupervisor; mHandler = new MainHandler(handler.getLooper()); } public void registerTaskStackListener(ITaskStackListener listener) { - synchronized (mService) { + synchronized (mServiceLock) { if (listener != null) { if (Binder.getCallingPid() == android.os.Process.myPid()) { if (!mLocalTaskStackListeners.contains(listener)) { @@ -231,7 +232,7 @@ class TaskChangeNotificationController { } public void unregisterTaskStackListener(ITaskStackListener listener) { - synchronized (mService) { + synchronized (mServiceLock) { if (listener != null) { if (Binder.getCallingPid() == android.os.Process.myPid()) { mLocalTaskStackListeners.remove(listener); @@ -243,7 +244,7 @@ class TaskChangeNotificationController { } private void forAllRemoteListeners(TaskStackConsumer callback, Message message) { - synchronized (mService) { + synchronized (mServiceLock) { for (int i = mRemoteTaskStackListeners.beginBroadcast() - 1; i >= 0; i--) { try { // Make a one-way callback to the listener @@ -257,7 +258,7 @@ class TaskChangeNotificationController { } private void forAllLocalListeners(TaskStackConsumer callback, Message message) { - synchronized (mService) { + synchronized (mServiceLock) { for (int i = mLocalTaskStackListeners.size() - 1; i >= 0; i--) { try { callback.accept(mLocalTaskStackListeners.get(i), message); diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index d984016ee2ae..6eac4bcb0a33 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -2469,7 +2469,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi } } - final TaskRecord task = create(stackSupervisor.mService.mActivityTaskManager, + final TaskRecord task = create(stackSupervisor.mService, taskId, intent, affinityIntent, affinity, rootAffinity, realActivity, origActivity, rootHasReset, autoRemoveRecents, askedCompatMode, userId, effectiveUid, lastDescription, diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java index 1ce41a641935..0674d851a7f5 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java @@ -174,7 +174,7 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase { // #notifyAll will be called on the ActivityManagerService. we must hold the object lock // when this happens. - synchronized (mSupervisor.mService) { + synchronized (mSupervisor.mService.mGlobalLock) { final WaitResult taskToFrontWait = new WaitResult(); mSupervisor.mWaitingActivityLaunched.add(taskToFrontWait); mSupervisor.reportWaitingActivityLaunchedIfNeeded(firstActivity, START_TASK_TO_FRONT); diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java index 7948e4cfcaaa..a86372a51900 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java @@ -59,8 +59,8 @@ public class ActivityStartControllerTests extends ActivityTestsBase { super.setUp(); mService = createActivityManagerService(); mFactory = mock(Factory.class); - mController = new ActivityStartController(mService, mService.mStackSupervisor, mFactory); - mStarter = spy(new ActivityStarter(mController, mService, mService.mStackSupervisor, + mController = new ActivityStartController(mService.mActivityTaskManager, mService.mStackSupervisor, mFactory); + mStarter = spy(new ActivityStarter(mController, mService.mActivityTaskManager, mService.mStackSupervisor, mock(ActivityStartInterceptor.class))); doReturn(mStarter).when(mFactory).obtain(); } @@ -96,7 +96,7 @@ public class ActivityStartControllerTests extends ActivityTestsBase { @Test public void testRecycling() throws Exception { final Intent intent = new Intent(); - final ActivityStarter optionStarter = new ActivityStarter(mController, mService, + final ActivityStarter optionStarter = new ActivityStarter(mController, mService.mActivityTaskManager, mService.mStackSupervisor, mock(ActivityStartInterceptor.class)); optionStarter .setIntent(intent) diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java index 9d35ef113d7e..7f55824b3082 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java @@ -57,7 +57,7 @@ import org.mockito.MockitoAnnotations; * Unit tests for {@link ActivityStartInterceptorTest}. * * Build/Install/Run: - * bit FrameworksServicesTests:com.android.server.am.ActivityStartInterceptorTest + * atest FrameworksServicesTests:com.android.server.am.ActivityStartInterceptorTest */ @Presubmit @SmallTest @@ -82,7 +82,9 @@ public class ActivityStartInterceptorTest { @Mock private Context mContext; @Mock - private ActivityManagerService mService; + private ActivityManagerService mAm; + @Mock + private ActivityTaskManagerService mService; @Mock private ActivityStackSupervisor mSupervisor; @Mock @@ -104,6 +106,7 @@ public class ActivityStartInterceptorTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mService.mAm = mAm; mInterceptor = new ActivityStartInterceptor(mService, mSupervisor, mContext, mUserController); mInterceptor.setStates(TEST_USER_ID, TEST_REAL_CALLING_PID, TEST_REAL_CALLING_UID, @@ -113,10 +116,9 @@ public class ActivityStartInterceptorTest { LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); LocalServices.addService(DevicePolicyManagerInternal.class, mDevicePolicyManager); - when(mDevicePolicyManager - .createShowAdminSupportIntent(TEST_USER_ID, true)) + when(mDevicePolicyManager.createShowAdminSupportIntent(TEST_USER_ID, true)) .thenReturn(ADMIN_SUPPORT_INTENT); - when(mService.getPackageManagerInternalLocked()).thenReturn(mPackageManagerInternal); + when(mAm.getPackageManagerInternalLocked()).thenReturn(mPackageManagerInternal); // Mock UserManager when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); @@ -129,7 +131,7 @@ public class ActivityStartInterceptorTest { thenReturn(CONFIRM_CREDENTIALS_INTENT); // Mock PackageManager - when(mService.getPackageManager()).thenReturn(mPackageManager); + when(mAm.getPackageManager()).thenReturn(mPackageManager); when(mPackageManager.getHarmfulAppWarning(TEST_PACKAGE_NAME, TEST_USER_ID)) .thenReturn(null); diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java index 686f57135cc5..10d255e7e283 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java @@ -109,7 +109,7 @@ public class ActivityStarterTests extends ActivityTestsBase { super.setUp(); mService = createActivityManagerService(); mController = mock(ActivityStartController.class); - mStarter = new ActivityStarter(mController, mService, mService.mStackSupervisor, + mStarter = new ActivityStarter(mController, mService.mActivityTaskManager, mService.mStackSupervisor, mock(ActivityStartInterceptor.class)); } @@ -193,7 +193,7 @@ public class ActivityStarterTests extends ActivityTestsBase { final IPackageManager packageManager = mock(IPackageManager.class); final ActivityStartController controller = mock(ActivityStartController.class); - final ActivityStarter starter = new ActivityStarter(controller, service, + final ActivityStarter starter = new ActivityStarter(controller, service.mActivityTaskManager, service.mStackSupervisor, mock(ActivityStartInterceptor.class)); final IApplicationThread caller = mock(IApplicationThread.class); @@ -282,7 +282,7 @@ public class ActivityStarterTests extends ActivityTestsBase { // Ensure that {@link ActivityOptions} are aborted with unsuccessful result. if (expectedResult != START_SUCCESS) { - final ActivityStarter optionStarter = new ActivityStarter(mController, mService, + final ActivityStarter optionStarter = new ActivityStarter(mController, mService.mActivityTaskManager, mService.mStackSupervisor, mock(ActivityStartInterceptor.class)); final ActivityOptions options = spy(ActivityOptions.makeBasic()); @@ -336,7 +336,7 @@ public class ActivityStarterTests extends ActivityTestsBase { info.applicationInfo = new ApplicationInfo(); info.applicationInfo.packageName = ActivityBuilder.getDefaultComponent().getPackageName(); - return new ActivityStarter(mController, mService, + return new ActivityStarter(mController, mService.mActivityTaskManager, mService.mStackSupervisor, mock(ActivityStartInterceptor.class)) .setIntent(intent) .setActivityInfo(info); diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java index dda52e14575b..06ac3b0213ec 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java @@ -111,10 +111,11 @@ public class ActivityTestsBase { protected ActivityManagerService setupActivityManagerService( ActivityManagerService service, ActivityTaskManagerService atm) { service = spy(service); + // Makes sure activity task is created with the spy object. atm = spy(atm); - // Makes sure the supervisor is using with the spy object. - service.mStackSupervisor.setService(service); service.setActivityTaskManager(atm); + // Makes sure the supervisor is using with the spy object. + atm.mStackSupervisor.setService(atm); doReturn(mock(IPackageManager.class)).when(service).getPackageManager(); doNothing().when(service).grantEphemeralAccessLocked(anyInt(), any(), anyInt(), anyInt()); service.mWindowManager = prepareMockWindowManager(); @@ -311,7 +312,7 @@ public class ActivityTestsBase { intent.setComponent(mComponent); intent.setFlags(mFlags); - final TestTaskRecord task = new TestTaskRecord(mSupervisor.mService.mActivityTaskManager, mTaskId, aInfo, + final TestTaskRecord task = new TestTaskRecord(mSupervisor.mService, mTaskId, aInfo, intent /*intent*/, mVoiceSession, null /*_voiceInteractor*/); task.userId = mUserId; @@ -360,23 +361,6 @@ public class ActivityTestsBase { return mLockTaskController; } - } - - /** - * An {@link ActivityManagerService} subclass which provides a test - * {@link ActivityStackSupervisor}. - */ - protected static class TestActivityManagerService extends ActivityManagerService { - - TestActivityManagerService(Context context) { - super(context); - mSupportsMultiWindow = true; - mSupportsMultiDisplay = true; - mSupportsSplitScreenMultiWindow = true; - mSupportsFreeformWindowManagement = true; - mSupportsPictureInPicture = true; - mWindowManager = WindowTestUtils.getMockWindowManagerService(); - } @Override final protected ActivityStackSupervisor createStackSupervisor() { @@ -404,12 +388,33 @@ public class ActivityTestsBase { } protected ActivityStackSupervisor createTestSupervisor() { - return new TestActivityStackSupervisor(this, mHandlerThread.getLooper()); + return new TestActivityStackSupervisor(this, mH.getLooper()); + } + } + + /** + * An {@link ActivityManagerService} subclass which provides a test + * {@link ActivityStackSupervisor}. + */ + protected static class TestActivityManagerService extends ActivityManagerService { + + TestActivityManagerService(Context context) { + super(context); + mSupportsMultiWindow = true; + mSupportsMultiDisplay = true; + mSupportsSplitScreenMultiWindow = true; + mSupportsFreeformWindowManagement = true; + mSupportsPictureInPicture = true; } @Override void updateUsageStats(ActivityRecord component, boolean resumed) { } + + @Override + Configuration getGlobalConfiguration() { + return mContext.getResources().getConfiguration(); + } } /** @@ -420,7 +425,7 @@ public class ActivityTestsBase { private ActivityDisplay mDisplay; private KeyguardController mKeyguardController; - public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) { + public TestActivityStackSupervisor(ActivityTaskManagerService service, Looper looper) { super(service, looper); mDisplayManager = (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE); diff --git a/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java index 2baf9952cb9e..e73661b0557b 100644 --- a/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java +++ b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java @@ -62,7 +62,7 @@ public class PendingRemoteAnimationRegistryTest extends ActivityTestsBase { mService.mHandlerThread.getThreadHandler().runWithScissors(() -> { mHandler = new TestHandler(null, mClock); }, 0); - mRegistry = new PendingRemoteAnimationRegistry(mService, mHandler); + mRegistry = new PendingRemoteAnimationRegistry(mService.mActivityTaskManager, mHandler); } @Test diff --git a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java index f98c50a2c874..cd7067755ea7 100644 --- a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java @@ -837,6 +837,12 @@ public class RecentTasksTest extends ActivityTestsBase { protected RecentTasks createRecentTasks() { return new TestRecentTasks(this, mTaskPersister, new TestUserController(mAm)); } + + @Override + protected ActivityStackSupervisor createTestSupervisor() { + return new MyTestActivityStackSupervisor(this, mH.getLooper()); + } + } private class MyTestActivityManagerService extends TestActivityManagerService { @@ -845,18 +851,13 @@ public class RecentTasksTest extends ActivityTestsBase { } @Override - protected ActivityStackSupervisor createTestSupervisor() { - return new MyTestActivityStackSupervisor(this, mHandlerThread.getLooper()); - } - - @Override public boolean isUserRunning(int userId, int flags) { return true; } } private class MyTestActivityStackSupervisor extends TestActivityStackSupervisor { - public MyTestActivityStackSupervisor(ActivityManagerService service, Looper looper) { + public MyTestActivityStackSupervisor(ActivityTaskManagerService service, Looper looper) { super(service, looper); } -- 2.11.0