diff options
| author | 2024-07-12 11:20:16 +0800 | |
|---|---|---|
| committer | 2024-07-18 07:42:53 +0000 | |
| commit | 8238f202c2cd77771436b093f6fc07c1086a7172 (patch) | |
| tree | cefe9994f2f60fba5fba7124c052873c277eac4b | |
| parent | ce8e50cfcea0756066a739a6390907770949b1b0 (diff) | |
Consolidate logging of global configuration
Post statsd logging to handler to reduce overhead in wm lock.
Also centralize the operations that should execute on handler.
BTW, post a lambda directly is more efficient than PooledLambda.
Bug: 163976519
Flag: EXEMPT simple refactor
Test: CtsWindowManagerDeviceActivity
Change-Id: Ib6276501871ef8a88cb8f300fd1bd7e6b090dda3
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityTaskManagerService.java | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index ff46b33571f3..90d645bfb1f8 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -4605,7 +4605,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return kept; } - /** Update default (global) configuration and notify listeners about changes. */ + /** + * Updates default (global) configuration and notifies listeners about changes. + * + * @param values The new configuration. It must always be a new instance from the caller, and + * it won't be modified after calling this method. + */ int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId) { @@ -4619,24 +4624,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { ProtoLog.i(WM_DEBUG_CONFIGURATION, "Updating global configuration " + "to: %s", values); writeConfigurationChanged(changes); - FrameworkStatsLog.write(FrameworkStatsLog.RESOURCE_CONFIGURATION_CHANGED, - values.colorMode, - values.densityDpi, - values.fontScale, - values.hardKeyboardHidden, - values.keyboard, - values.keyboardHidden, - values.mcc, - values.mnc, - values.navigation, - values.navigationHidden, - values.orientation, - values.screenHeightDp, - values.screenLayout, - values.screenWidthDp, - values.smallestScreenWidthDp, - values.touchscreen, - values.uiMode); // Note: certain tests currently run as platform_app which is not allowed // to set debug system properties. To ensure that system properties are set @@ -4684,13 +4671,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // resources have that config before following boot code is executed. mSystemThread.applyConfigurationToResources(mTempConfig); - if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) { - final Message msg = PooledLambda.obtainMessage( - ActivityTaskManagerService::sendPutConfigurationForUserMsg, - this, userId, new Configuration(mTempConfig)); - mH.sendMessage(msg); - } - SparseArray<WindowProcessController> pidMap = mProcessMap.getPidMap(); for (int i = pidMap.size() - 1; i >= 0; i--) { final int pid = pidMap.keyAt(i); @@ -4700,19 +4680,32 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { app.onConfigurationChanged(mTempConfig); } - final Message msg = PooledLambda.obtainMessage( - ActivityManagerInternal::broadcastGlobalConfigurationChanged, - mAmInternal, changes, initLocale); - mH.sendMessage(msg); + final Configuration configurationForSettings = + persistent && Settings.System.hasInterestingConfigurationChanges(changes) + ? new Configuration(mTempConfig) : null; + mH.post(() -> { + FrameworkStatsLog.write(FrameworkStatsLog.RESOURCE_CONFIGURATION_CHANGED, + values.colorMode, values.densityDpi, values.fontScale, + values.hardKeyboardHidden, values.keyboard, values.keyboardHidden, + values.mcc, values.mnc, values.navigation, values.navigationHidden, + values.orientation, values.screenHeightDp, values.screenLayout, + values.screenWidthDp, values.smallestScreenWidthDp, values.touchscreen, + values.uiMode); + if ((changes & ActivityInfo.CONFIG_ORIENTATION) != 0) { + FrameworkStatsLog.write(FrameworkStatsLog.DEVICE_ORIENTATION_CHANGED, + values.orientation); + } + if (configurationForSettings != null) { + Settings.System.putConfigurationForUser(mContext.getContentResolver(), + configurationForSettings, userId); + } + mAmInternal.broadcastGlobalConfigurationChanged(changes, initLocale); + }); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "RootConfigChange"); // Update stored global config and notify everyone about the change. mRootWindowContainer.onConfigurationChanged(mTempConfig); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); - if ((changes & ActivityInfo.CONFIG_ORIENTATION) != 0) { - FrameworkStatsLog.write(FrameworkStatsLog.DEVICE_ORIENTATION_CHANGED, - values.orientation); - } Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); return changes; @@ -4862,11 +4855,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mWindowManager.setEventDispatching(booted && !mShuttingDown); } - private void sendPutConfigurationForUserMsg(int userId, Configuration config) { - final ContentResolver resolver = mContext.getContentResolver(); - Settings.System.putConfigurationForUser(resolver, config, userId); - } - boolean isActivityStartsLoggingEnabled() { return mAmInternal.isActivityStartsLoggingEnabled(); } |