Loading services/core/java/com/android/server/am/ActivityManagerService.java +43 −45 Original line number Diff line number Diff line Loading @@ -1121,18 +1121,12 @@ public final class ActivityManagerService extends ActivityManagerNative */ final AppOpsService mAppOpsService; /** * Current global configuration information. Contains general settings for the entire system, * also corresponds to the merged configuration of the default display. */ Configuration mGlobalConfiguration = new Configuration(); /** Current sequencing integer of the configuration, for skipping old configurations. */ private int mConfigurationSeq; /** * Temp object used when global configuration is updated. It is also sent to outer world * instead of {@link #mGlobalConfiguration} because we don't trust anyone... * instead of {@link #getGlobalConfiguration} because we don't trust anyone... */ private Configuration mTempGlobalConfig = new Configuration(); Loading Loading @@ -1582,6 +1576,14 @@ public final class ActivityManagerService extends ActivityManagerNative final boolean mPermissionReviewRequired; /** * Current global configuration information. Contains general settings for the entire system, * also corresponds to the merged configuration of the default display. */ Configuration getGlobalConfiguration() { return mStackSupervisor.getConfiguration(); } final class KillHandler extends Handler { static final int KILL_PROCESS_GROUP_MSG = 4000; Loading Loading @@ -2329,7 +2331,7 @@ public final class ActivityManagerService extends ActivityManagerNative callingPackage = r.info.getComponentName(); if (mInVrMode != vrMode) { mInVrMode = vrMode; mShowDialogs = shouldShowDialogs(mGlobalConfiguration, mInVrMode); mShowDialogs = shouldShowDialogs(getGlobalConfiguration(), mInVrMode); if (r.app != null) { ProcessRecord proc = r.app; if (proc.vrThreadTid > 0) { Loading Loading @@ -2705,15 +2707,16 @@ public final class ActivityManagerService extends ActivityManagerNative mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations")); mGlobalConfiguration.setToDefaults(); mGlobalConfiguration.setLocales(LocaleList.getDefault()); mTempGlobalConfig.setToDefaults(); mTempGlobalConfig.setLocales(LocaleList.getDefault()); mConfigurationSeq = mTempGlobalConfig.seq = 1; mConfigurationSeq = mGlobalConfiguration.seq = 1; mProcessCpuTracker.init(); mStackSupervisor = new ActivityStackSupervisor(this); mStackSupervisor.onConfigurationChanged(mTempGlobalConfig); mCompatModePackages = new CompatModePackages(this, systemDir, mHandler); mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler); mStackSupervisor = new ActivityStackSupervisor(this); mActivityStarter = new ActivityStarter(this, mStackSupervisor); mRecentTasks = new RecentTasks(this, mStackSupervisor); Loading Loading @@ -3145,8 +3148,9 @@ public final class ActivityManagerService extends ActivityManagerNative } final void showUnsupportedZoomDialogIfNeededLocked(ActivityRecord r) { if (mGlobalConfiguration.densityDpi != DisplayMetrics.DENSITY_DEVICE_STABLE && r.appInfo.requiresSmallestWidthDp > mGlobalConfiguration.smallestScreenWidthDp) { final Configuration globalConfig = getGlobalConfiguration(); if (globalConfig.densityDpi != DisplayMetrics.DENSITY_DEVICE_STABLE && r.appInfo.requiresSmallestWidthDp > globalConfig.smallestScreenWidthDp) { final Message msg = Message.obtain(); msg.what = SHOW_UNSUPPORTED_DISPLAY_SIZE_DIALOG_MSG; msg.obj = r; Loading Loading @@ -4757,7 +4761,7 @@ public final class ActivityManagerService extends ActivityManagerNative final long origId = Binder.clearCallingIdentity(); mWindowManager.setAppOrientation(r.appToken, requestedOrientation); Configuration config = mWindowManager.updateOrientationFromAppTokens( mGlobalConfiguration, r.mayFreezeScreenLocked(r.app) ? r.appToken : null); getGlobalConfiguration(), r.mayFreezeScreenLocked(r.app) ? r.appToken : null); if (config != null) { r.frozenBeforeDestroy = true; if (!updateConfigurationLocked(config, r, false)) { Loading Loading @@ -6544,7 +6548,7 @@ public final class ActivityManagerService extends ActivityManagerNative PackageManager.NOTIFY_PACKAGE_USE_INSTRUMENTATION); } if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Binding proc " + processName + " with config " + mGlobalConfiguration); + processName + " with config " + getGlobalConfiguration()); ApplicationInfo appInfo = app.instrumentationInfo != null ? app.instrumentationInfo : app.info; app.compat = compatibilityInfoForPackageLocked(appInfo); Loading @@ -6569,7 +6573,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.instrumentationUiAutomationConnection, testMode, mBinderTransactionTrackingEnabled, enableTrackAllocation, isRestrictedBackupMode || !normalMode, app.persistent, new Configuration(mGlobalConfiguration), app.compat, new Configuration(getGlobalConfiguration()), app.compat, getCommonServicesLocked(app.isolated), mCoreSettingsObserver.getCoreSettingsLocked(), buildSerial); Loading Loading @@ -9325,17 +9329,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } // Use the full screen as the context for the task thumbnail final Point displaySize = new Point(); final TaskThumbnailInfo thumbnailInfo = new TaskThumbnailInfo(); r.getStack().getDisplaySize(displaySize); thumbnailInfo.taskWidth = displaySize.x; thumbnailInfo.taskHeight = displaySize.y; thumbnailInfo.screenOrientation = mGlobalConfiguration.orientation; TaskRecord task = new TaskRecord(this, mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent, description, thumbnailInfo); ainfo, intent, description, new TaskThumbnailInfo()); int trimIdx = mRecentTasks.trimForTaskLocked(task, false); if (trimIdx >= 0) { Loading Loading @@ -13170,8 +13166,8 @@ public final class ActivityManagerService extends ActivityManagerNative // This happens before any activities are started, so we can change global configuration // in-place. updateConfigurationLocked(configuration, null, true); if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Initial config: " + mGlobalConfiguration); final Configuration globalConfig = getGlobalConfiguration(); if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Initial config: " + globalConfig); // Load resources only after the current configuration has been set. final Resources res = mContext.getResources(); Loading @@ -13186,11 +13182,10 @@ public final class ActivityManagerService extends ActivityManagerNative com.android.internal.R.string.config_appsNotReportingCrashes)); mUserController.mUserSwitchUiEnabled = !res.getBoolean( com.android.internal.R.bool.config_customUserSwitchUi); if ((mGlobalConfiguration.uiMode & UI_MODE_TYPE_TELEVISION) == UI_MODE_TYPE_TELEVISION) { if ((globalConfig.uiMode & UI_MODE_TYPE_TELEVISION) == UI_MODE_TYPE_TELEVISION) { mFullscreenThumbnailScale = (float) res .getInteger(com.android.internal.R.integer.thumbnail_width_tv) / (float) mGlobalConfiguration.screenWidthDp; (float) globalConfig.screenWidthDp; } else { mFullscreenThumbnailScale = res.getFraction( com.android.internal.R.fraction.thumbnail_fullscreen_scale, 1, 1); Loading Loading @@ -14785,7 +14780,7 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println(" mHeavyWeightProcess: " + mHeavyWeightProcess); } if (dumpPackage == null) { pw.println(" mGlobalConfiguration: " + mGlobalConfiguration); pw.println(" mGlobalConfiguration: " + getGlobalConfiguration()); } if (dumpAll) { pw.println(" mConfigWillChange: " + getFocusedStack().mConfigWillChange); Loading Loading @@ -18768,15 +18763,16 @@ public final class ActivityManagerService extends ActivityManagerNative public ConfigurationInfo getDeviceConfigurationInfo() { ConfigurationInfo config = new ConfigurationInfo(); synchronized (this) { config.reqTouchScreen = mGlobalConfiguration.touchscreen; config.reqKeyboardType = mGlobalConfiguration.keyboard; config.reqNavigation = mGlobalConfiguration.navigation; if (mGlobalConfiguration.navigation == Configuration.NAVIGATION_DPAD || mGlobalConfiguration.navigation == Configuration.NAVIGATION_TRACKBALL) { final Configuration globalConfig = getGlobalConfiguration(); config.reqTouchScreen = globalConfig.touchscreen; config.reqKeyboardType = globalConfig.keyboard; config.reqNavigation = globalConfig.navigation; if (globalConfig.navigation == Configuration.NAVIGATION_DPAD || globalConfig.navigation == Configuration.NAVIGATION_TRACKBALL) { config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV; } if (mGlobalConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED && mGlobalConfiguration.keyboard != Configuration.KEYBOARD_NOKEYS) { if (globalConfig.keyboard != Configuration.KEYBOARD_UNDEFINED && globalConfig.keyboard != Configuration.KEYBOARD_NOKEYS) { config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD; } config.reqGlEsVersion = GL_ES_VERSION; Loading @@ -18800,7 +18796,7 @@ public final class ActivityManagerService extends ActivityManagerNative public Configuration getConfiguration() { Configuration ci; synchronized(this) { ci = new Configuration(mGlobalConfiguration); ci = new Configuration(getGlobalConfiguration()); ci.userSetLocale = false; } return ci; Loading Loading @@ -18858,7 +18854,7 @@ public final class ActivityManagerService extends ActivityManagerNative private void updateFontScaleIfNeeded(@UserIdInt int userId) { final float scaleFactor = Settings.System.getFloatForUser(mContext.getContentResolver(), FONT_SCALE, 1.0f, userId); if (mGlobalConfiguration.fontScale != scaleFactor) { if (getGlobalConfiguration().fontScale != scaleFactor) { final Configuration configuration = mWindowManager.computeNewConfiguration(); configuration.fontScale = scaleFactor; synchronized (this) { Loading Loading @@ -18918,7 +18914,7 @@ public final class ActivityManagerService extends ActivityManagerNative } void updateUserConfigurationLocked() { final Configuration configuration = new Configuration(mGlobalConfiguration); final Configuration configuration = new Configuration(getGlobalConfiguration()); final int currentUserId = mUserController.getCurrentUserIdLocked(); Settings.System.adjustConfigurationForUser(mContext.getContentResolver(), configuration, currentUserId, Settings.System.canWrite(mContext)); Loading Loading @@ -18989,7 +18985,7 @@ public final class ActivityManagerService extends ActivityManagerNative /** Update default (global) configuration and notify listeners about changes. */ private int updateGlobalConfiguration(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId, boolean deferResume) { mTempGlobalConfig.setTo(mGlobalConfiguration); mTempGlobalConfig.setTo(getGlobalConfiguration()); final int changes = mTempGlobalConfig.updateFrom(values); if (changes == 0) { return 0; Loading Loading @@ -19019,7 +19015,9 @@ public final class ActivityManagerService extends ActivityManagerNative mConfigurationSeq = Math.max(++mConfigurationSeq, 1); mTempGlobalConfig.seq = mConfigurationSeq; mGlobalConfiguration.setTo(mTempGlobalConfig); // Update stored global config and notify everyone about the change. mStackSupervisor.onConfigurationChanged(mTempGlobalConfig); Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + mTempGlobalConfig); // TODO(multi-display): Update UsageEvents#Event to include displayId. mUsageStatsService.reportConfigurationChange(mTempGlobalConfig, Loading @@ -19041,7 +19039,7 @@ public final class ActivityManagerService extends ActivityManagerNative // 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(mGlobalConfiguration); final Configuration configCopy = new Configuration(mTempGlobalConfig); if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) { Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG); msg.obj = configCopy; services/core/java/com/android/server/am/ActivityRecord.java +12 −10 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.server.am; import static android.app.ActivityManager.StackId; import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER; Loading Loading @@ -150,11 +149,11 @@ final class ActivityRecord { long cpuTimeAtResume; // the cpu time of host process at the time of resuming activity long pauseTime; // last time we started pausing the activity long launchTickTime; // base time for launch tick messages Configuration configuration; // configuration activity was last running in Configuration mLastReportedConfiguration; // configuration activity was last running in // Overridden configuration by the activity task // WARNING: Reference points to {@link TaskRecord#mOverrideConfig}, so its internal state // should never be altered directly. Configuration taskConfigOverride; // WARNING: Reference points to {@link TaskRecord#getMergedOverrideConfig}, so its internal // state should never be altered directly. Configuration mLastReportedOverrideConfiguration; CompatibilityInfo compat;// last used compatibility mode ActivityRecord resultTo; // who started this entry, so will get our reply final String resultWho; // additional identifier for use by resultTo. Loading Loading @@ -279,8 +278,10 @@ final class ActivityRecord { pw.print(" labelRes=0x"); pw.print(Integer.toHexString(labelRes)); pw.print(" icon=0x"); pw.print(Integer.toHexString(icon)); pw.print(" theme=0x"); pw.println(Integer.toHexString(theme)); pw.print(prefix); pw.print("config="); pw.println(configuration); pw.print(prefix); pw.print("taskConfigOverride="); pw.println(taskConfigOverride); pw.print(prefix); pw.print("mLastReportedConfiguration="); pw.println(mLastReportedConfiguration); pw.print(prefix); pw.print("mLastReportedOverrideConfiguration="); pw.println(mLastReportedOverrideConfiguration); if (resultTo != null || resultWho != null) { pw.print(prefix); pw.print("resultTo="); pw.print(resultTo); pw.print(" resultWho="); pw.print(resultWho); Loading Loading @@ -457,7 +458,8 @@ final class ActivityRecord { if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " + "reportToActivity=" + reportToActivity + " and config: " + config); app.thread.scheduleActivityConfigurationChanged(appToken, config, reportToActivity); app.thread.scheduleActivityConfigurationChanged(appToken, new Configuration(config), reportToActivity); } catch (RemoteException e) { // If process died, whatever. } Loading Loading @@ -614,8 +616,8 @@ final class ActivityRecord { resolvedType = _resolvedType; componentSpecified = _componentSpecified; rootVoiceInteraction = _rootVoiceInteraction; configuration = _configuration; taskConfigOverride = Configuration.EMPTY; mLastReportedConfiguration = new Configuration(_configuration); mLastReportedOverrideConfiguration = new Configuration(); resultTo = _resultTo; resultWho = _resultWho; requestCode = _reqCode; Loading services/core/java/com/android/server/am/ActivityStack.java +56 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/am/ActivityStackSupervisor.java +49 −12 Original line number Diff line number Diff line Loading @@ -178,7 +178,8 @@ import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_PINNABLE; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_WHITELISTED; import static com.android.server.wm.AppTransition.TRANSIT_DOCK_TASK_FROM_RECENTS; public final class ActivityStackSupervisor implements DisplayListener { public final class ActivityStackSupervisor extends ConfigurationContainer implements DisplayListener { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStackSupervisor" : TAG_AM; private static final String TAG_CONTAINERS = TAG + POSTFIX_CONTAINERS; private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS; Loading Loading @@ -412,6 +413,21 @@ public final class ActivityStackSupervisor implements DisplayListener { private final ResizeDockedStackTimeout mResizeDockedStackTimeout; @Override protected int getChildCount() { return mActivityDisplays.size(); } @Override protected ConfigurationContainer getChildAt(int index) { return mActivityDisplays.valueAt(index); } @Override protected ConfigurationContainer getParent() { return null; } static class FindTaskResult { ActivityRecord r; boolean matchedByRootAffinity; Loading Loading @@ -1182,7 +1198,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // just restarting it anyway. if (checkConfig) { Configuration config = mWindowManager.updateOrientationFromAppTokens( mService.mGlobalConfiguration, mService.getGlobalConfiguration(), r.mayFreezeScreenLocked(app) ? r.appToken : null); // Deferring resume here because we're going to launch new activity shortly. // We don't want to perform a redundant launch of the same record while ensuring Loading Loading @@ -1272,12 +1288,16 @@ public final class ActivityStackSupervisor implements DisplayListener { app.pendingUiClean = true; } app.forceProcessStateUpTo(mService.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. app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken, System.identityHashCode(r), r.info, new Configuration(mService.mGlobalConfiguration), new Configuration(task.mOverrideConfig), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, r.persistentState, results, newIntents, !andResume, mService.isNextTransitionForward(), profilerInfo); new Configuration(mService.getGlobalConfiguration()), new Configuration(task.getMergedOverrideConfiguration()), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, r.persistentState, results, newIntents, !andResume, mService.isNextTransitionForward(), profilerInfo); if ((app.info.privateFlags&ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // This may be a heavy-weight process! Note that the package Loading Loading @@ -1599,7 +1619,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // We'll update with whatever configuration it now says // it used to launch. if (config != null) { r.configuration = config; r.mLastReportedConfiguration.setTo(config); } // We are now idle. If someone is waiting for a thumbnail from Loading Loading @@ -1865,8 +1885,9 @@ public final class ActivityStackSupervisor implements DisplayListener { // WM resizeTask must be done after the task is moved to the correct stack, // because Task's setBounds() also updates dim layer's bounds, but that has // dependency on the stack. mWindowManager.resizeTask(task.taskId, task.mBounds, task.mOverrideConfig, false /* relayout */, false /* forced */); mWindowManager.resizeTask(task.taskId, task.mBounds, task.getOverrideConfiguration(), false /* relayout */, false /* forced */); } } } Loading Loading @@ -2247,7 +2268,8 @@ public final class ActivityStackSupervisor implements DisplayListener { } } } mWindowManager.resizeTask(task.taskId, task.mBounds, task.mOverrideConfig, kept, forced); mWindowManager.resizeTask(task.taskId, task.mBounds, task.getOverrideConfiguration(), kept, forced); Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); return kept; Loading Loading @@ -2589,7 +2611,7 @@ public final class ActivityStackSupervisor implements DisplayListener { task.updateOverrideConfigurationForStack(stack); mWindowManager.positionTaskInStack( taskId, stackId, position, task.mBounds, task.mOverrideConfig); taskId, stackId, position, task.mBounds, task.getOverrideConfiguration()); stack.positionTask(task, position); // The task might have already been running and its visibility needs to be synchronized with // the visibility of the stack / windows. Loading Loading @@ -4230,7 +4252,7 @@ public final class ActivityStackSupervisor implements DisplayListener { /** Exactly one of these classes per Display in the system. Capable of holding zero or more * attached {@link ActivityStack}s */ class ActivityDisplay { class ActivityDisplay extends ConfigurationContainer { /** Actual Display this object tracks. */ int mDisplayId; Display mDisplay; Loading Loading @@ -4290,6 +4312,21 @@ public final class ActivityStackSupervisor implements DisplayListener { public String toString() { return "ActivityDisplay={" + mDisplayId + " numStacks=" + mStacks.size() + "}"; } @Override protected int getChildCount() { return mStacks.size(); } @Override protected ConfigurationContainer getChildAt(int index) { return mStacks.get(index); } @Override protected ConfigurationContainer getParent() { return ActivityStackSupervisor.this; } } class VirtualActivityDisplay extends ActivityDisplay { Loading services/core/java/com/android/server/am/ActivityStarter.java +4 −4 Original line number Diff line number Diff line Loading @@ -470,9 +470,9 @@ class ActivityStarter { } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mGlobalConfiguration, resultRecord, resultWho, requestCode, componentSpecified, voiceSession != null, mSupervisor, container, options, sourceRecord); intent, resolvedType, aInfo, mService.getGlobalConfiguration(), resultRecord, resultWho, requestCode, componentSpecified, voiceSession != null, mSupervisor, container, options, sourceRecord); if (outActivity != null) { outActivity[0] = r; } Loading Loading @@ -782,7 +782,7 @@ class ActivityStarter { stack = container.mStack; } stack.mConfigWillChange = globalConfig != null && mService.mGlobalConfiguration.diff(globalConfig) != 0; && mService.getGlobalConfiguration().diff(globalConfig) != 0; if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Starting activity when config will change = " + stack.mConfigWillChange); Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +43 −45 Original line number Diff line number Diff line Loading @@ -1121,18 +1121,12 @@ public final class ActivityManagerService extends ActivityManagerNative */ final AppOpsService mAppOpsService; /** * Current global configuration information. Contains general settings for the entire system, * also corresponds to the merged configuration of the default display. */ Configuration mGlobalConfiguration = new Configuration(); /** Current sequencing integer of the configuration, for skipping old configurations. */ private int mConfigurationSeq; /** * Temp object used when global configuration is updated. It is also sent to outer world * instead of {@link #mGlobalConfiguration} because we don't trust anyone... * instead of {@link #getGlobalConfiguration} because we don't trust anyone... */ private Configuration mTempGlobalConfig = new Configuration(); Loading Loading @@ -1582,6 +1576,14 @@ public final class ActivityManagerService extends ActivityManagerNative final boolean mPermissionReviewRequired; /** * Current global configuration information. Contains general settings for the entire system, * also corresponds to the merged configuration of the default display. */ Configuration getGlobalConfiguration() { return mStackSupervisor.getConfiguration(); } final class KillHandler extends Handler { static final int KILL_PROCESS_GROUP_MSG = 4000; Loading Loading @@ -2329,7 +2331,7 @@ public final class ActivityManagerService extends ActivityManagerNative callingPackage = r.info.getComponentName(); if (mInVrMode != vrMode) { mInVrMode = vrMode; mShowDialogs = shouldShowDialogs(mGlobalConfiguration, mInVrMode); mShowDialogs = shouldShowDialogs(getGlobalConfiguration(), mInVrMode); if (r.app != null) { ProcessRecord proc = r.app; if (proc.vrThreadTid > 0) { Loading Loading @@ -2705,15 +2707,16 @@ public final class ActivityManagerService extends ActivityManagerNative mTrackingAssociations = "1".equals(SystemProperties.get("debug.track-associations")); mGlobalConfiguration.setToDefaults(); mGlobalConfiguration.setLocales(LocaleList.getDefault()); mTempGlobalConfig.setToDefaults(); mTempGlobalConfig.setLocales(LocaleList.getDefault()); mConfigurationSeq = mTempGlobalConfig.seq = 1; mConfigurationSeq = mGlobalConfiguration.seq = 1; mProcessCpuTracker.init(); mStackSupervisor = new ActivityStackSupervisor(this); mStackSupervisor.onConfigurationChanged(mTempGlobalConfig); mCompatModePackages = new CompatModePackages(this, systemDir, mHandler); mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler); mStackSupervisor = new ActivityStackSupervisor(this); mActivityStarter = new ActivityStarter(this, mStackSupervisor); mRecentTasks = new RecentTasks(this, mStackSupervisor); Loading Loading @@ -3145,8 +3148,9 @@ public final class ActivityManagerService extends ActivityManagerNative } final void showUnsupportedZoomDialogIfNeededLocked(ActivityRecord r) { if (mGlobalConfiguration.densityDpi != DisplayMetrics.DENSITY_DEVICE_STABLE && r.appInfo.requiresSmallestWidthDp > mGlobalConfiguration.smallestScreenWidthDp) { final Configuration globalConfig = getGlobalConfiguration(); if (globalConfig.densityDpi != DisplayMetrics.DENSITY_DEVICE_STABLE && r.appInfo.requiresSmallestWidthDp > globalConfig.smallestScreenWidthDp) { final Message msg = Message.obtain(); msg.what = SHOW_UNSUPPORTED_DISPLAY_SIZE_DIALOG_MSG; msg.obj = r; Loading Loading @@ -4757,7 +4761,7 @@ public final class ActivityManagerService extends ActivityManagerNative final long origId = Binder.clearCallingIdentity(); mWindowManager.setAppOrientation(r.appToken, requestedOrientation); Configuration config = mWindowManager.updateOrientationFromAppTokens( mGlobalConfiguration, r.mayFreezeScreenLocked(r.app) ? r.appToken : null); getGlobalConfiguration(), r.mayFreezeScreenLocked(r.app) ? r.appToken : null); if (config != null) { r.frozenBeforeDestroy = true; if (!updateConfigurationLocked(config, r, false)) { Loading Loading @@ -6544,7 +6548,7 @@ public final class ActivityManagerService extends ActivityManagerNative PackageManager.NOTIFY_PACKAGE_USE_INSTRUMENTATION); } if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Binding proc " + processName + " with config " + mGlobalConfiguration); + processName + " with config " + getGlobalConfiguration()); ApplicationInfo appInfo = app.instrumentationInfo != null ? app.instrumentationInfo : app.info; app.compat = compatibilityInfoForPackageLocked(appInfo); Loading @@ -6569,7 +6573,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.instrumentationUiAutomationConnection, testMode, mBinderTransactionTrackingEnabled, enableTrackAllocation, isRestrictedBackupMode || !normalMode, app.persistent, new Configuration(mGlobalConfiguration), app.compat, new Configuration(getGlobalConfiguration()), app.compat, getCommonServicesLocked(app.isolated), mCoreSettingsObserver.getCoreSettingsLocked(), buildSerial); Loading Loading @@ -9325,17 +9329,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } // Use the full screen as the context for the task thumbnail final Point displaySize = new Point(); final TaskThumbnailInfo thumbnailInfo = new TaskThumbnailInfo(); r.getStack().getDisplaySize(displaySize); thumbnailInfo.taskWidth = displaySize.x; thumbnailInfo.taskHeight = displaySize.y; thumbnailInfo.screenOrientation = mGlobalConfiguration.orientation; TaskRecord task = new TaskRecord(this, mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent, description, thumbnailInfo); ainfo, intent, description, new TaskThumbnailInfo()); int trimIdx = mRecentTasks.trimForTaskLocked(task, false); if (trimIdx >= 0) { Loading Loading @@ -13170,8 +13166,8 @@ public final class ActivityManagerService extends ActivityManagerNative // This happens before any activities are started, so we can change global configuration // in-place. updateConfigurationLocked(configuration, null, true); if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Initial config: " + mGlobalConfiguration); final Configuration globalConfig = getGlobalConfiguration(); if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Initial config: " + globalConfig); // Load resources only after the current configuration has been set. final Resources res = mContext.getResources(); Loading @@ -13186,11 +13182,10 @@ public final class ActivityManagerService extends ActivityManagerNative com.android.internal.R.string.config_appsNotReportingCrashes)); mUserController.mUserSwitchUiEnabled = !res.getBoolean( com.android.internal.R.bool.config_customUserSwitchUi); if ((mGlobalConfiguration.uiMode & UI_MODE_TYPE_TELEVISION) == UI_MODE_TYPE_TELEVISION) { if ((globalConfig.uiMode & UI_MODE_TYPE_TELEVISION) == UI_MODE_TYPE_TELEVISION) { mFullscreenThumbnailScale = (float) res .getInteger(com.android.internal.R.integer.thumbnail_width_tv) / (float) mGlobalConfiguration.screenWidthDp; (float) globalConfig.screenWidthDp; } else { mFullscreenThumbnailScale = res.getFraction( com.android.internal.R.fraction.thumbnail_fullscreen_scale, 1, 1); Loading Loading @@ -14785,7 +14780,7 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println(" mHeavyWeightProcess: " + mHeavyWeightProcess); } if (dumpPackage == null) { pw.println(" mGlobalConfiguration: " + mGlobalConfiguration); pw.println(" mGlobalConfiguration: " + getGlobalConfiguration()); } if (dumpAll) { pw.println(" mConfigWillChange: " + getFocusedStack().mConfigWillChange); Loading Loading @@ -18768,15 +18763,16 @@ public final class ActivityManagerService extends ActivityManagerNative public ConfigurationInfo getDeviceConfigurationInfo() { ConfigurationInfo config = new ConfigurationInfo(); synchronized (this) { config.reqTouchScreen = mGlobalConfiguration.touchscreen; config.reqKeyboardType = mGlobalConfiguration.keyboard; config.reqNavigation = mGlobalConfiguration.navigation; if (mGlobalConfiguration.navigation == Configuration.NAVIGATION_DPAD || mGlobalConfiguration.navigation == Configuration.NAVIGATION_TRACKBALL) { final Configuration globalConfig = getGlobalConfiguration(); config.reqTouchScreen = globalConfig.touchscreen; config.reqKeyboardType = globalConfig.keyboard; config.reqNavigation = globalConfig.navigation; if (globalConfig.navigation == Configuration.NAVIGATION_DPAD || globalConfig.navigation == Configuration.NAVIGATION_TRACKBALL) { config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV; } if (mGlobalConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED && mGlobalConfiguration.keyboard != Configuration.KEYBOARD_NOKEYS) { if (globalConfig.keyboard != Configuration.KEYBOARD_UNDEFINED && globalConfig.keyboard != Configuration.KEYBOARD_NOKEYS) { config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD; } config.reqGlEsVersion = GL_ES_VERSION; Loading @@ -18800,7 +18796,7 @@ public final class ActivityManagerService extends ActivityManagerNative public Configuration getConfiguration() { Configuration ci; synchronized(this) { ci = new Configuration(mGlobalConfiguration); ci = new Configuration(getGlobalConfiguration()); ci.userSetLocale = false; } return ci; Loading Loading @@ -18858,7 +18854,7 @@ public final class ActivityManagerService extends ActivityManagerNative private void updateFontScaleIfNeeded(@UserIdInt int userId) { final float scaleFactor = Settings.System.getFloatForUser(mContext.getContentResolver(), FONT_SCALE, 1.0f, userId); if (mGlobalConfiguration.fontScale != scaleFactor) { if (getGlobalConfiguration().fontScale != scaleFactor) { final Configuration configuration = mWindowManager.computeNewConfiguration(); configuration.fontScale = scaleFactor; synchronized (this) { Loading Loading @@ -18918,7 +18914,7 @@ public final class ActivityManagerService extends ActivityManagerNative } void updateUserConfigurationLocked() { final Configuration configuration = new Configuration(mGlobalConfiguration); final Configuration configuration = new Configuration(getGlobalConfiguration()); final int currentUserId = mUserController.getCurrentUserIdLocked(); Settings.System.adjustConfigurationForUser(mContext.getContentResolver(), configuration, currentUserId, Settings.System.canWrite(mContext)); Loading Loading @@ -18989,7 +18985,7 @@ public final class ActivityManagerService extends ActivityManagerNative /** Update default (global) configuration and notify listeners about changes. */ private int updateGlobalConfiguration(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId, boolean deferResume) { mTempGlobalConfig.setTo(mGlobalConfiguration); mTempGlobalConfig.setTo(getGlobalConfiguration()); final int changes = mTempGlobalConfig.updateFrom(values); if (changes == 0) { return 0; Loading Loading @@ -19019,7 +19015,9 @@ public final class ActivityManagerService extends ActivityManagerNative mConfigurationSeq = Math.max(++mConfigurationSeq, 1); mTempGlobalConfig.seq = mConfigurationSeq; mGlobalConfiguration.setTo(mTempGlobalConfig); // Update stored global config and notify everyone about the change. mStackSupervisor.onConfigurationChanged(mTempGlobalConfig); Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + mTempGlobalConfig); // TODO(multi-display): Update UsageEvents#Event to include displayId. mUsageStatsService.reportConfigurationChange(mTempGlobalConfig, Loading @@ -19041,7 +19039,7 @@ public final class ActivityManagerService extends ActivityManagerNative // 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(mGlobalConfiguration); final Configuration configCopy = new Configuration(mTempGlobalConfig); if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) { Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG); msg.obj = configCopy;
services/core/java/com/android/server/am/ActivityRecord.java +12 −10 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.server.am; import static android.app.ActivityManager.StackId; import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER; Loading Loading @@ -150,11 +149,11 @@ final class ActivityRecord { long cpuTimeAtResume; // the cpu time of host process at the time of resuming activity long pauseTime; // last time we started pausing the activity long launchTickTime; // base time for launch tick messages Configuration configuration; // configuration activity was last running in Configuration mLastReportedConfiguration; // configuration activity was last running in // Overridden configuration by the activity task // WARNING: Reference points to {@link TaskRecord#mOverrideConfig}, so its internal state // should never be altered directly. Configuration taskConfigOverride; // WARNING: Reference points to {@link TaskRecord#getMergedOverrideConfig}, so its internal // state should never be altered directly. Configuration mLastReportedOverrideConfiguration; CompatibilityInfo compat;// last used compatibility mode ActivityRecord resultTo; // who started this entry, so will get our reply final String resultWho; // additional identifier for use by resultTo. Loading Loading @@ -279,8 +278,10 @@ final class ActivityRecord { pw.print(" labelRes=0x"); pw.print(Integer.toHexString(labelRes)); pw.print(" icon=0x"); pw.print(Integer.toHexString(icon)); pw.print(" theme=0x"); pw.println(Integer.toHexString(theme)); pw.print(prefix); pw.print("config="); pw.println(configuration); pw.print(prefix); pw.print("taskConfigOverride="); pw.println(taskConfigOverride); pw.print(prefix); pw.print("mLastReportedConfiguration="); pw.println(mLastReportedConfiguration); pw.print(prefix); pw.print("mLastReportedOverrideConfiguration="); pw.println(mLastReportedOverrideConfiguration); if (resultTo != null || resultWho != null) { pw.print(prefix); pw.print("resultTo="); pw.print(resultTo); pw.print(" resultWho="); pw.print(resultWho); Loading Loading @@ -457,7 +458,8 @@ final class ActivityRecord { if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " + "reportToActivity=" + reportToActivity + " and config: " + config); app.thread.scheduleActivityConfigurationChanged(appToken, config, reportToActivity); app.thread.scheduleActivityConfigurationChanged(appToken, new Configuration(config), reportToActivity); } catch (RemoteException e) { // If process died, whatever. } Loading Loading @@ -614,8 +616,8 @@ final class ActivityRecord { resolvedType = _resolvedType; componentSpecified = _componentSpecified; rootVoiceInteraction = _rootVoiceInteraction; configuration = _configuration; taskConfigOverride = Configuration.EMPTY; mLastReportedConfiguration = new Configuration(_configuration); mLastReportedOverrideConfiguration = new Configuration(); resultTo = _resultTo; resultWho = _resultWho; requestCode = _reqCode; Loading
services/core/java/com/android/server/am/ActivityStack.java +56 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/am/ActivityStackSupervisor.java +49 −12 Original line number Diff line number Diff line Loading @@ -178,7 +178,8 @@ import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_PINNABLE; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_WHITELISTED; import static com.android.server.wm.AppTransition.TRANSIT_DOCK_TASK_FROM_RECENTS; public final class ActivityStackSupervisor implements DisplayListener { public final class ActivityStackSupervisor extends ConfigurationContainer implements DisplayListener { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStackSupervisor" : TAG_AM; private static final String TAG_CONTAINERS = TAG + POSTFIX_CONTAINERS; private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS; Loading Loading @@ -412,6 +413,21 @@ public final class ActivityStackSupervisor implements DisplayListener { private final ResizeDockedStackTimeout mResizeDockedStackTimeout; @Override protected int getChildCount() { return mActivityDisplays.size(); } @Override protected ConfigurationContainer getChildAt(int index) { return mActivityDisplays.valueAt(index); } @Override protected ConfigurationContainer getParent() { return null; } static class FindTaskResult { ActivityRecord r; boolean matchedByRootAffinity; Loading Loading @@ -1182,7 +1198,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // just restarting it anyway. if (checkConfig) { Configuration config = mWindowManager.updateOrientationFromAppTokens( mService.mGlobalConfiguration, mService.getGlobalConfiguration(), r.mayFreezeScreenLocked(app) ? r.appToken : null); // Deferring resume here because we're going to launch new activity shortly. // We don't want to perform a redundant launch of the same record while ensuring Loading Loading @@ -1272,12 +1288,16 @@ public final class ActivityStackSupervisor implements DisplayListener { app.pendingUiClean = true; } app.forceProcessStateUpTo(mService.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. app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken, System.identityHashCode(r), r.info, new Configuration(mService.mGlobalConfiguration), new Configuration(task.mOverrideConfig), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, r.persistentState, results, newIntents, !andResume, mService.isNextTransitionForward(), profilerInfo); new Configuration(mService.getGlobalConfiguration()), new Configuration(task.getMergedOverrideConfiguration()), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, r.persistentState, results, newIntents, !andResume, mService.isNextTransitionForward(), profilerInfo); if ((app.info.privateFlags&ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // This may be a heavy-weight process! Note that the package Loading Loading @@ -1599,7 +1619,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // We'll update with whatever configuration it now says // it used to launch. if (config != null) { r.configuration = config; r.mLastReportedConfiguration.setTo(config); } // We are now idle. If someone is waiting for a thumbnail from Loading Loading @@ -1865,8 +1885,9 @@ public final class ActivityStackSupervisor implements DisplayListener { // WM resizeTask must be done after the task is moved to the correct stack, // because Task's setBounds() also updates dim layer's bounds, but that has // dependency on the stack. mWindowManager.resizeTask(task.taskId, task.mBounds, task.mOverrideConfig, false /* relayout */, false /* forced */); mWindowManager.resizeTask(task.taskId, task.mBounds, task.getOverrideConfiguration(), false /* relayout */, false /* forced */); } } } Loading Loading @@ -2247,7 +2268,8 @@ public final class ActivityStackSupervisor implements DisplayListener { } } } mWindowManager.resizeTask(task.taskId, task.mBounds, task.mOverrideConfig, kept, forced); mWindowManager.resizeTask(task.taskId, task.mBounds, task.getOverrideConfiguration(), kept, forced); Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); return kept; Loading Loading @@ -2589,7 +2611,7 @@ public final class ActivityStackSupervisor implements DisplayListener { task.updateOverrideConfigurationForStack(stack); mWindowManager.positionTaskInStack( taskId, stackId, position, task.mBounds, task.mOverrideConfig); taskId, stackId, position, task.mBounds, task.getOverrideConfiguration()); stack.positionTask(task, position); // The task might have already been running and its visibility needs to be synchronized with // the visibility of the stack / windows. Loading Loading @@ -4230,7 +4252,7 @@ public final class ActivityStackSupervisor implements DisplayListener { /** Exactly one of these classes per Display in the system. Capable of holding zero or more * attached {@link ActivityStack}s */ class ActivityDisplay { class ActivityDisplay extends ConfigurationContainer { /** Actual Display this object tracks. */ int mDisplayId; Display mDisplay; Loading Loading @@ -4290,6 +4312,21 @@ public final class ActivityStackSupervisor implements DisplayListener { public String toString() { return "ActivityDisplay={" + mDisplayId + " numStacks=" + mStacks.size() + "}"; } @Override protected int getChildCount() { return mStacks.size(); } @Override protected ConfigurationContainer getChildAt(int index) { return mStacks.get(index); } @Override protected ConfigurationContainer getParent() { return ActivityStackSupervisor.this; } } class VirtualActivityDisplay extends ActivityDisplay { Loading
services/core/java/com/android/server/am/ActivityStarter.java +4 −4 Original line number Diff line number Diff line Loading @@ -470,9 +470,9 @@ class ActivityStarter { } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mGlobalConfiguration, resultRecord, resultWho, requestCode, componentSpecified, voiceSession != null, mSupervisor, container, options, sourceRecord); intent, resolvedType, aInfo, mService.getGlobalConfiguration(), resultRecord, resultWho, requestCode, componentSpecified, voiceSession != null, mSupervisor, container, options, sourceRecord); if (outActivity != null) { outActivity[0] = r; } Loading Loading @@ -782,7 +782,7 @@ class ActivityStarter { stack = container.mStack; } stack.mConfigWillChange = globalConfig != null && mService.mGlobalConfiguration.diff(globalConfig) != 0; && mService.getGlobalConfiguration().diff(globalConfig) != 0; if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Starting activity when config will change = " + stack.mConfigWillChange); Loading