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

Commit 622ea7db authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Switched ActivityStackSupervisor.mService to ActivityTaskManagerService (8/n)"

parents 84915eec c9e57de5
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -140,7 +140,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
                + " to displayId=" + mDisplayId + " position=" + position);
                + " to displayId=" + mDisplayId + " position=" + position);
        addStackReferenceIfNeeded(stack);
        addStackReferenceIfNeeded(stack);
        positionChildAt(stack, position);
        positionChildAt(stack, position);
        mSupervisor.mService.updateSleepIfNeededLocked();
        mSupervisor.mService.mAm.updateSleepIfNeededLocked();
    }
    }


    void removeChild(ActivityStack stack) {
    void removeChild(ActivityStack stack) {
@@ -148,7 +148,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
                + " from displayId=" + mDisplayId);
                + " from displayId=" + mDisplayId);
        mStacks.remove(stack);
        mStacks.remove(stack);
        removeStackReferenceIfNeeded(stack);
        removeStackReferenceIfNeeded(stack);
        mSupervisor.mService.updateSleepIfNeededLocked();
        mSupervisor.mService.mAm.updateSleepIfNeededLocked();
        onStackOrderChanged();
        onStackOrderChanged();
    }
    }


@@ -300,7 +300,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
            }
            }
        }
        }


        final ActivityManagerService service = mSupervisor.mService;
        final ActivityManagerService service = mSupervisor.mService.mAm;
        if (!isWindowingModeSupported(windowingMode, service.mSupportsMultiWindow,
        if (!isWindowingModeSupported(windowingMode, service.mSupportsMultiWindow,
                service.mSupportsSplitScreenMultiWindow, service.mSupportsFreeformWindowManagement,
                service.mSupportsSplitScreenMultiWindow, service.mSupportsFreeformWindowManagement,
                service.mSupportsPictureInPicture, activityType)) {
                service.mSupportsPictureInPicture, activityType)) {
@@ -536,7 +536,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        }
        }


        // Make sure the windowing mode we are trying to use makes sense for what is supported.
        // 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 supportsMultiWindow = service.mSupportsMultiWindow;
        boolean supportsSplitScreen = service.mSupportsSplitScreenMultiWindow;
        boolean supportsSplitScreen = service.mSupportsSplitScreenMultiWindow;
        boolean supportsFreeform = service.mSupportsFreeformWindowManagement;
        boolean supportsFreeform = service.mSupportsFreeformWindowManagement;
@@ -714,7 +714,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>


    boolean shouldSleep() {
    boolean shouldSleep() {
        return (mStacks.isEmpty() || !mAllSleepTokens.isEmpty())
        return (mStacks.isEmpty() || !mAllSleepTokens.isEmpty())
                && (mSupervisor.mService.mRunningVoice == null);
                && (mSupervisor.mService.mAm.mRunningVoice == null);
    }
    }


    /**
    /**
+25 −47
Original line number Original line Diff line number Diff line
@@ -615,8 +615,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    private Installer mInstaller;
    private Installer mInstaller;
    /** Run all ActivityStacks through this */
    /** Run all ActivityStacks through this */
    final ActivityStackSupervisor mStackSupervisor;
    ActivityStackSupervisor mStackSupervisor;
    final KeyguardController mKeyguardController;
    final InstrumentationReporter mInstrumentationReporter = new InstrumentationReporter();
    final InstrumentationReporter mInstrumentationReporter = new InstrumentationReporter();
@@ -734,7 +733,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    public boolean canShowErrorDialogs() {
    public boolean canShowErrorDialogs() {
        return mShowDialogs && !mSleeping && !mShuttingDown
        return mShowDialogs && !mSleeping && !mShuttingDown
                && !mKeyguardController.isKeyguardOrAodShowing(DEFAULT_DISPLAY)
                && !mActivityTaskManager.mKeyguardController.isKeyguardOrAodShowing(DEFAULT_DISPLAY)
                && !mUserController.hasUserRestriction(UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS,
                && !mUserController.hasUserRestriction(UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS,
                        mUserController.getCurrentUserId())
                        mUserController.getCurrentUserId())
                && !(UserManager.isDeviceInDemoMode(mContext)
                && !(UserManager.isDeviceInDemoMode(mContext)
@@ -1286,16 +1285,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
     */
    final AppOpsService mAppOpsService;
    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.
     * Hardware-reported OpenGLES version.
     */
     */
@@ -2595,8 +2584,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void setActivityTaskManager(ActivityTaskManagerService atm) {
    public void setActivityTaskManager(ActivityTaskManagerService atm) {
        synchronized (this) {
        synchronized (this) {
            mActivityTaskManager = atm;
            mActivityTaskManager = atm;
            mStackSupervisor.setActivityTaskManager(atm);
            mActivityTaskManager.setActivityManagerService(this);
            mActivityTaskManager.setActivityManagerService(this);
            mStackSupervisor = mActivityTaskManager.mStackSupervisor;
        }
        }
    }
    }
@@ -2845,13 +2834,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        mHandler = null;
        mHandler = null;
        mHandlerThread = null;
        mHandlerThread = null;
        mIntentFirewall = null;
        mIntentFirewall = null;
        mKeyguardController = null;
        mPermissionReviewRequired = false;
        mPermissionReviewRequired = false;
        mProcessCpuThread = null;
        mProcessCpuThread = null;
        mProcessStats = null;
        mProcessStats = null;
        mProviderMap = null;
        mProviderMap = null;
        mServices = null;
        mServices = null;
        mStackSupervisor = null;
        mSystemThread = null;
        mSystemThread = null;
        mUiHandler = injector.getUiHandler(null);
        mUiHandler = injector.getUiHandler(null);
        mUserController = null;
        mUserController = null;
@@ -2938,12 +2925,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        }
        mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations"));
        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);
        mCompatModePackages = new CompatModePackages(this, systemDir, mHandler);
        mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), 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) {
    public void setSystemServiceManager(SystemServiceManager mgr) {
        mSystemServiceManager = mgr;
        mSystemServiceManager = mgr;
    }
    }
@@ -10963,7 +10938,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            final long ident = Binder.clearCallingIdentity();
            final long ident = Binder.clearCallingIdentity();
            try {
            try {
                if (mUserController.shouldConfirmCredentials(userId)) {
                if (mUserController.shouldConfirmCredentials(userId)) {
                    if (mKeyguardController.isKeyguardLocked()) {
                    if (mActivityTaskManager.mKeyguardController.isKeyguardLocked()) {
                        // Showing launcher to avoid user entering credential twice.
                        // Showing launcher to avoid user entering credential twice.
                        final int currentUserId = mUserController.getCurrentUserId();
                        final int currentUserId = mUserController.getCurrentUserId();
                        startHomeActivityLocked(currentUserId, "notifyLockedProfile");
                        startHomeActivityLocked(currentUserId, "notifyLockedProfile");
@@ -19525,8 +19500,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** Update default (global) configuration and notify listeners about changes. */
    /** Update default (global) configuration and notify listeners about changes. */
    private int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale,
    private int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale,
            boolean persistent, int userId, boolean deferResume) {
            boolean persistent, int userId, boolean deferResume) {
        mTempConfig.setTo(getGlobalConfiguration());
        mActivityTaskManager.mTempConfig.setTo(getGlobalConfiguration());
        final int changes = mTempConfig.updateFrom(values);
        final int changes = mActivityTaskManager.mTempConfig.updateFrom(values);
        if (changes == 0) {
        if (changes == 0) {
            // Since calling to Activity.setRequestedOrientation leads to freezing the window with
            // Since calling to Activity.setRequestedOrientation leads to freezing the window with
            // setting WindowManagerService.mWaitingForConfig to true, it is important that we call
            // setting WindowManagerService.mWaitingForConfig to true, it is important that we call
@@ -19576,34 +19551,34 @@ public class ActivityManagerService extends IActivityManager.Stub
                    locales.get(bestLocaleIndex)));
                    locales.get(bestLocaleIndex)));
        }
        }
        mConfigurationSeq = Math.max(++mConfigurationSeq, 1);
        mActivityTaskManager.mConfigurationSeq = Math.max(++mActivityTaskManager.mConfigurationSeq, 1);
        mTempConfig.seq = mConfigurationSeq;
        mActivityTaskManager.mTempConfig.seq = mActivityTaskManager.mConfigurationSeq;
        // Update stored global config and notify everyone about the change.
        // 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.
        // TODO(multi-display): Update UsageEvents#Event to include displayId.
        mUsageStatsService.reportConfigurationChange(mTempConfig,
        mUsageStatsService.reportConfigurationChange(mActivityTaskManager.mTempConfig,
                mUserController.getCurrentUserId());
                mUserController.getCurrentUserId());
        // TODO: If our config changes, should we auto dismiss any currently showing dialogs?
        // TODO: If our config changes, should we auto dismiss any currently showing dialogs?
        updateShouldShowDialogsLocked(mTempConfig);
        updateShouldShowDialogsLocked(mActivityTaskManager.mTempConfig);
        AttributeCache ac = AttributeCache.instance();
        AttributeCache ac = AttributeCache.instance();
        if (ac != null) {
        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
        // 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
        // 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
        // especially important during boot, where the first config change needs to guarantee all
        // resources have that config before following boot code is executed.
        // 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
        // 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.
        // 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)) {
        if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
            Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
            Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
            msg.obj = configCopy;
            msg.obj = configCopy;
@@ -19714,12 +19689,12 @@ public class ActivityManagerService extends IActivityManager.Stub
    private int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume,
    private int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume,
            int displayId) {
            int displayId) {
        mTempConfig.setTo(mStackSupervisor.getDisplayOverrideConfiguration(displayId));
        mActivityTaskManager.mTempConfig.setTo(mStackSupervisor.getDisplayOverrideConfiguration(displayId));
        final int changes = mTempConfig.updateFrom(values);
        final int changes = mActivityTaskManager.mTempConfig.updateFrom(values);
        if (changes != 0) {
        if (changes != 0) {
            Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " "
            Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " "
                    + mTempConfig + " for displayId=" + displayId);
                    + mActivityTaskManager.mTempConfig + " for displayId=" + displayId);
            mStackSupervisor.setDisplayOverrideConfiguration(mTempConfig, displayId);
            mStackSupervisor.setDisplayOverrideConfiguration(mActivityTaskManager.mTempConfig, displayId);
            final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
            final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
            if (isDensityChange && displayId == DEFAULT_DISPLAY) {
            if (isDensityChange && displayId == DEFAULT_DISPLAY) {
@@ -19736,7 +19711,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        // ensureActivityConfiguration().
        // ensureActivityConfiguration().
        if (mWindowManager != null) {
        if (mWindowManager != null) {
            final int[] resizedStacks =
            final int[] resizedStacks =
                    mWindowManager.setNewDisplayOverrideConfiguration(mTempConfig, displayId);
                    mWindowManager.setNewDisplayOverrideConfiguration(mActivityTaskManager.mTempConfig, displayId);
            if (resizedStacks != null) {
            if (resizedStacks != null) {
                for (int stackId : resizedStacks) {
                for (int stackId : resizedStacks) {
                    resizeStackWithBoundsFromWindowManager(stackId, deferResume);
                    resizeStackWithBoundsFromWindowManager(stackId, deferResume);
@@ -21778,7 +21753,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    }
    private final ActivityRecord resumedAppLocked() {
    private final ActivityRecord resumedAppLocked() {
        ActivityRecord act = mStackSupervisor.getResumedActivityLocked();
        final ActivityRecord act =
                mStackSupervisor != null ? mStackSupervisor.getResumedActivityLocked() : null;
        String pkg;
        String pkg;
        int uid;
        int uid;
        if (act != null) {
        if (act != null) {
@@ -21860,7 +21836,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            uidRec.reset();
            uidRec.reset();
        }
        }
        if (mStackSupervisor != null) {
            mStackSupervisor.rankTaskLayersIfNeeded();
            mStackSupervisor.rankTaskLayersIfNeeded();
        }
        mAdjSeq++;
        mAdjSeq++;
        mNewNumServiceProcs = 0;
        mNewNumServiceProcs = 0;
+3 −3
Original line number Original line Diff line number Diff line
@@ -407,7 +407,7 @@ class ActivityMetricsLogger {
    }
    }


    private void checkVisibility(TaskRecord t, ActivityRecord r) {
    private void checkVisibility(TaskRecord t, ActivityRecord r) {
        synchronized (mSupervisor.mService) {
        synchronized (mSupervisor.mService.mGlobalLock) {


            final WindowingModeTransitionInfo info = mWindowingModeTransitionInfo.get(
            final WindowingModeTransitionInfo info = mWindowingModeTransitionInfo.get(
                    r.getWindowingMode());
                    r.getWindowingMode());
@@ -663,8 +663,8 @@ class ActivityMetricsLogger {


    private ProcessRecord findProcessForActivity(ActivityRecord launchedActivity) {
    private ProcessRecord findProcessForActivity(ActivityRecord launchedActivity) {
        return launchedActivity != null
        return launchedActivity != null
                ? mSupervisor.mService.mProcessNames.get(launchedActivity.processName,
                ? mSupervisor.mService.mAm.mProcessNames.get(
                        launchedActivity.appInfo.uid)
                        launchedActivity.processName, launchedActivity.appInfo.uid)
                : null;
                : null;
    }
    }


+4 −4
Original line number Original line Diff line number Diff line
@@ -1098,7 +1098,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            return true;
            return true;
        }
        }
        // Allow the recents component to launch the home activity.
        // 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)) {
        if (recentTasks != null && recentTasks.isCallerRecents(uid)) {
            return true;
            return true;
        }
        }
@@ -2930,16 +2930,16 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            throw new XmlPullParserException("restoreActivity error intent=" + intent);
            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,
        final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null,
                userId, Binder.getCallingUid());
                userId, Binder.getCallingUid());
        if (aInfo == null) {
        if (aInfo == null) {
            throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent +
            throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent +
                    " resolvedType=" + resolvedType);
                    " 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,
                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 */,
                0 /* reqCode */, componentSpecified, false /* rootVoiceInteraction */,
                stackSupervisor, null /* options */, null /* sourceRecord */);
                stackSupervisor, null /* options */, null /* sourceRecord */);


+1 −1
Original line number Original line Diff line number Diff line
@@ -453,7 +453,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    ActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor,
    ActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor,
            int windowingMode, int activityType, boolean onTop) {
            int windowingMode, int activityType, boolean onTop) {
        mStackSupervisor = supervisor;
        mStackSupervisor = supervisor;
        mService = supervisor.mService.mActivityTaskManager;
        mService = supervisor.mService;
        mHandler = new ActivityStackHandler(supervisor.mLooper);
        mHandler = new ActivityStackHandler(supervisor.mLooper);
        mWindowManager = mService.mWindowManager;
        mWindowManager = mService.mWindowManager;
        mStackId = stackId;
        mStackId = stackId;
Loading