Loading core/java/android/app/IActivityTaskManager.aidl +0 −9 Original line number Diff line number Diff line Loading @@ -386,15 +386,6 @@ interface IActivityTaskManager { */ void resizePinnedStack(in Rect pinnedBounds, in Rect tempPinnedTaskBounds); /** * Updates override configuration applied to specific display. * @param values Update values for display configuration. If null is passed it will request the * Window Manager to compute new config for the specified display. * @param displayId Id of the display to apply the config to. * @throws RemoteException * @return Returns true if the configuration was updated. */ boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId); void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback, in CharSequence message); Loading services/core/java/com/android/server/wm/ActivityDisplay.java +93 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.os.Build.VERSION_CODES.N; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.FLAG_PRIVATE; import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT; Loading @@ -55,18 +56,24 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.Point; import android.os.IBinder; import android.os.Message; import android.os.UserHandle; import android.provider.Settings; import android.util.IntArray; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.Display; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.am.EventLogTags; import java.io.PrintWriter; Loading Loading @@ -156,6 +163,9 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> // Used in updating the display size private Point mTmpDisplaySize = new Point(); // Used in updating override configurations private final Configuration mTempConfig = new Configuration(); private final FindTaskResult mTmpFindTaskResult = new FindTaskResult(); ActivityDisplay(RootActivityContainer root, Display display) { Loading Loading @@ -999,6 +1009,89 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> return mStacks.indexOf(stack); } boolean updateDisplayOverrideConfigurationLocked() { Configuration values = new Configuration(); mDisplayContent.computeScreenConfiguration(values); if (mService.mWindowManager != null) { final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::updateOomLevelsForDisplay, mService.mAmInternal, mDisplayId); mService.mH.sendMessage(msg); } Settings.System.clearConfiguration(values); updateDisplayOverrideConfigurationLocked(values, null /* starting */, false /* deferResume */, mService.mTmpUpdateConfigurationResult); return mService.mTmpUpdateConfigurationResult.changes != 0; } /** * Updates override configuration specific for the selected display. If no config is provided, * new one will be computed in WM based on current display info. */ boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, ActivityTaskManagerService.UpdateConfigurationResult result) { int changes = 0; boolean kept = true; if (mService.mWindowManager != null) { mService.mWindowManager.deferSurfaceLayout(); } try { if (values != null) { if (mDisplayId == DEFAULT_DISPLAY) { // Override configuration of the default display duplicates global config, so // we're calling global config update instead for default display. It will also // apply the correct override config. changes = mService.updateGlobalConfigurationLocked(values, false /* initLocale */, false /* persistent */, UserHandle.USER_NULL /* userId */, deferResume); } else { changes = performDisplayOverrideConfigUpdate(values, deferResume); } } kept = mService.ensureConfigAndVisibilityAfterUpdate(starting, changes); } finally { if (mService.mWindowManager != null) { mService.mWindowManager.continueSurfaceLayout(); } } if (result != null) { result.changes = changes; result.activityRelaunched = !kept; } return kept; } int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume) { mTempConfig.setTo(getRequestedOverrideConfiguration()); final int changes = mTempConfig.updateFrom(values); if (changes != 0) { Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " " + mTempConfig + " for displayId=" + mDisplayId); onRequestedOverrideConfigurationChanged(mTempConfig); final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0; if (isDensityChange && mDisplayId == DEFAULT_DISPLAY) { mService.mAppWarnings.onDensityChanged(); // Post message to start process to avoid possible deadlock of calling into AMS with // the ATMS lock held. final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::killAllBackgroundProcessesExcept, mService.mAmInternal, N, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND); mService.mH.sendMessage(msg); } } return changes; } @Override public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { final int currRotation = Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +11 −117 Original line number Diff line number Diff line Loading @@ -459,7 +459,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { boolean mSuppressResizeConfigChanges; private final UpdateConfigurationResult mTmpUpdateConfigurationResult = final UpdateConfigurationResult mTmpUpdateConfigurationResult = new UpdateConfigurationResult(); static final class UpdateConfigurationResult { Loading Loading @@ -631,7 +631,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { /** If non-null, we are tracking the time the user spends in the currently focused app. */ AppTimeTracker mCurAppTimeTracker; private AppWarnings mAppWarnings; AppWarnings mAppWarnings; /** * Packages that the user has asked to have run in screen size Loading Loading @@ -4387,46 +4387,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public boolean updateDisplayOverrideConfiguration(Configuration values, int displayId) { mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateDisplayOverrideConfiguration()"); synchronized (mGlobalLock) { // Check if display is initialized in AM. if (!mRootActivityContainer.isDisplayAdded(displayId)) { // Call might come when display is not yet added or has already been removed. if (DEBUG_CONFIGURATION) { Slog.w(TAG, "Trying to update display configuration for non-existing displayId=" + displayId); } return false; } if (values == null && mWindowManager != null) { // sentinel: fetch the current configuration from the window manager values = mWindowManager.computeNewConfiguration(displayId); } if (mWindowManager != null) { final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::updateOomLevelsForDisplay, mAmInternal, displayId); mH.sendMessage(msg); } final long origId = Binder.clearCallingIdentity(); try { if (values != null) { Settings.System.clearConfiguration(values); } updateDisplayOverrideConfigurationLocked(values, null /* starting */, false /* deferResume */, displayId, mTmpUpdateConfigurationResult); return mTmpUpdateConfigurationResult.changes != 0; } finally { Binder.restoreCallingIdentity(origId); } } } @Override public boolean updateConfiguration(Configuration values) { mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()"); Loading Loading @@ -5165,8 +5125,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } /** Update default (global) configuration and notify listeners about changes. */ private int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId, boolean deferResume) { final ActivityDisplay defaultDisplay = mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY); mTempConfig.setTo(getGlobalConfiguration()); final int changes = mTempConfig.updateFrom(values); if (changes == 0) { Loading @@ -5174,7 +5138,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // setting WindowManagerService.mWaitingForConfig to true, it is important that we call // performDisplayOverrideConfigUpdate in order to send the new display configuration // (even if there are no actual changes) to unfreeze the window. performDisplayOverrideConfigUpdate(values, deferResume, DEFAULT_DISPLAY); defaultDisplay.performDisplayOverrideConfigUpdate(values, deferResume); return 0; } Loading Loading @@ -5272,79 +5236,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // Override configuration of the default display duplicates global config, so we need to // update it also. This will also notify WindowManager about changes. performDisplayOverrideConfigUpdate(mRootActivityContainer.getConfiguration(), deferResume, DEFAULT_DISPLAY); return changes; } boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, int displayId) { return updateDisplayOverrideConfigurationLocked(values, starting, deferResume /* deferResume */, displayId, null /* result */); } /** * Updates override configuration specific for the selected display. If no config is provided, * new one will be computed in WM based on current display info. */ boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, int displayId, ActivityTaskManagerService.UpdateConfigurationResult result) { int changes = 0; boolean kept = true; if (mWindowManager != null) { mWindowManager.deferSurfaceLayout(); } try { if (values != null) { if (displayId == DEFAULT_DISPLAY) { // Override configuration of the default display duplicates global config, so // we're calling global config update instead for default display. It will also // apply the correct override config. changes = updateGlobalConfigurationLocked(values, false /* initLocale */, false /* persistent */, UserHandle.USER_NULL /* userId */, deferResume); } else { changes = performDisplayOverrideConfigUpdate(values, deferResume, displayId); } } kept = ensureConfigAndVisibilityAfterUpdate(starting, changes); } finally { if (mWindowManager != null) { mWindowManager.continueSurfaceLayout(); } } if (result != null) { result.changes = changes; result.activityRelaunched = !kept; } return kept; } private int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume, int displayId) { mTempConfig.setTo(mRootActivityContainer.getDisplayOverrideConfiguration(displayId)); final int changes = mTempConfig.updateFrom(values); if (changes != 0) { Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " " + mTempConfig + " for displayId=" + displayId); mRootActivityContainer.setDisplayOverrideConfiguration(mTempConfig, displayId); final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0; if (isDensityChange && displayId == DEFAULT_DISPLAY) { mAppWarnings.onDensityChanged(); defaultDisplay.performDisplayOverrideConfigUpdate(mRootActivityContainer.getConfiguration(), deferResume); // Post message to start process to avoid possible deadlock of calling into AMS with // the ATMS lock held. final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::killAllBackgroundProcessesExcept, mAmInternal, N, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND); mH.sendMessage(msg); } } return changes; } Loading Loading @@ -5786,7 +5680,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } /** Applies latest configuration and/or visibility updates if needed. */ private boolean ensureConfigAndVisibilityAfterUpdate(ActivityRecord starting, int changes) { boolean ensureConfigAndVisibilityAfterUpdate(ActivityRecord starting, int changes) { boolean kept = true; final ActivityStack mainStack = mRootActivityContainer.getTopDisplayFocusedStack(); // mainStack is null during startup. Loading services/core/java/com/android/server/wm/DisplayContent.java +27 −8 Original line number Diff line number Diff line Loading @@ -1213,10 +1213,29 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } /** Notify the configuration change of this display. */ void sendNewConfiguration() { void postNewConfigurationToHandler() { mWmService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget(); } void sendNewConfiguration() { synchronized (mWmService.mGlobalLock) { final boolean configUpdated = mAcitvityDisplay .updateDisplayOverrideConfigurationLocked(); if (!configUpdated) { // Something changed (E.g. device rotation), but no configuration update is needed. // E.g. changing device rotation by 180 degrees. Go ahead and perform surface // placement to unfreeze the display since we froze it when the rotation was updated // in DisplayContent#updateRotationUnchecked. if (mWaitingForConfig) { mWaitingForConfig = false; mWmService.mLastFinishedFreezeSource = "config-unchanged"; setLayoutNeeded(); mWmService.mWindowPlacerLocked.performSurfacePlacement(); } } } } @Override boolean onDescendantOrientationChanged(IBinder freezeDisplayToken, ConfigurationContainer requestingContainer) { Loading @@ -1232,8 +1251,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (handled && requestingContainer instanceof ActivityRecord) { final ActivityRecord activityRecord = (ActivityRecord) requestingContainer; final boolean kept = mWmService.mAtmService.updateDisplayOverrideConfigurationLocked( config, activityRecord, false /* deferResume */, getDisplayId()); final boolean kept = mAcitvityDisplay.updateDisplayOverrideConfigurationLocked( config, activityRecord, false /* deferResume */, null /* result */); activityRecord.frozenBeforeDestroy = true; if (!kept) { mWmService.mAtmService.mRootActivityContainer.resumeFocusedStacksTopActivities(); Loading @@ -1241,8 +1260,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } else { // We have a new configuration to push so we need to update ATMS for now. // TODO: Clean up display configuration push between ATMS and WMS after unification. mWmService.mAtmService.updateDisplayOverrideConfigurationLocked( config, null /* starting */, false /* deferResume */, getDisplayId()); mAcitvityDisplay.updateDisplayOverrideConfigurationLocked( config, null /* starting */, false /* deferResume */, null); } return handled; } Loading Loading @@ -1332,7 +1351,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo boolean updateRotationAndSendNewConfigIfNeeded() { final boolean changed = updateRotationUnchecked(false /* forceUpdate */); if (changed) { sendNewConfiguration(); postNewConfigurationToHandler(); } return changed; } Loading @@ -1351,7 +1370,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * Update rotation of the DisplayContent with an option to force the update. This updates * the container's perception of rotation and, depending on the top activities, will freeze * the screen or start seamless rotation. The display itself gets rotated in * {@link #applyRotationLocked} during {@link WindowManagerService#sendNewConfiguration}. * {@link #applyRotationLocked} during {@link DisplayContent#sendNewConfiguration}. * * @param forceUpdate Force the rotation update. Sometimes in WM we might skip updating * orientation because we're waiting for some rotation to finish or display Loading Loading @@ -3711,7 +3730,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); if (updateOrientationFromAppTokens()) { setLayoutNeeded(); sendNewConfiguration(); postNewConfigurationToHandler(); } } Loading services/core/java/com/android/server/wm/InputManagerCallback.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal @Override public void notifyConfigurationChanged() { // TODO(multi-display): Notify proper displays that are associated with this input device. mService.sendNewConfiguration(DEFAULT_DISPLAY); mService.mRoot.getDisplayContent(DEFAULT_DISPLAY).sendNewConfiguration(); synchronized (mInputDevicesReadyMonitor) { if (!mInputDevicesReady) { Loading Loading
core/java/android/app/IActivityTaskManager.aidl +0 −9 Original line number Diff line number Diff line Loading @@ -386,15 +386,6 @@ interface IActivityTaskManager { */ void resizePinnedStack(in Rect pinnedBounds, in Rect tempPinnedTaskBounds); /** * Updates override configuration applied to specific display. * @param values Update values for display configuration. If null is passed it will request the * Window Manager to compute new config for the specified display. * @param displayId Id of the display to apply the config to. * @throws RemoteException * @return Returns true if the configuration was updated. */ boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId); void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback, in CharSequence message); Loading
services/core/java/com/android/server/wm/ActivityDisplay.java +93 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.os.Build.VERSION_CODES.N; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.FLAG_PRIVATE; import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT; Loading @@ -55,18 +56,24 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.Point; import android.os.IBinder; import android.os.Message; import android.os.UserHandle; import android.provider.Settings; import android.util.IntArray; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.Display; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.am.EventLogTags; import java.io.PrintWriter; Loading Loading @@ -156,6 +163,9 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> // Used in updating the display size private Point mTmpDisplaySize = new Point(); // Used in updating override configurations private final Configuration mTempConfig = new Configuration(); private final FindTaskResult mTmpFindTaskResult = new FindTaskResult(); ActivityDisplay(RootActivityContainer root, Display display) { Loading Loading @@ -999,6 +1009,89 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> return mStacks.indexOf(stack); } boolean updateDisplayOverrideConfigurationLocked() { Configuration values = new Configuration(); mDisplayContent.computeScreenConfiguration(values); if (mService.mWindowManager != null) { final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::updateOomLevelsForDisplay, mService.mAmInternal, mDisplayId); mService.mH.sendMessage(msg); } Settings.System.clearConfiguration(values); updateDisplayOverrideConfigurationLocked(values, null /* starting */, false /* deferResume */, mService.mTmpUpdateConfigurationResult); return mService.mTmpUpdateConfigurationResult.changes != 0; } /** * Updates override configuration specific for the selected display. If no config is provided, * new one will be computed in WM based on current display info. */ boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, ActivityTaskManagerService.UpdateConfigurationResult result) { int changes = 0; boolean kept = true; if (mService.mWindowManager != null) { mService.mWindowManager.deferSurfaceLayout(); } try { if (values != null) { if (mDisplayId == DEFAULT_DISPLAY) { // Override configuration of the default display duplicates global config, so // we're calling global config update instead for default display. It will also // apply the correct override config. changes = mService.updateGlobalConfigurationLocked(values, false /* initLocale */, false /* persistent */, UserHandle.USER_NULL /* userId */, deferResume); } else { changes = performDisplayOverrideConfigUpdate(values, deferResume); } } kept = mService.ensureConfigAndVisibilityAfterUpdate(starting, changes); } finally { if (mService.mWindowManager != null) { mService.mWindowManager.continueSurfaceLayout(); } } if (result != null) { result.changes = changes; result.activityRelaunched = !kept; } return kept; } int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume) { mTempConfig.setTo(getRequestedOverrideConfiguration()); final int changes = mTempConfig.updateFrom(values); if (changes != 0) { Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " " + mTempConfig + " for displayId=" + mDisplayId); onRequestedOverrideConfigurationChanged(mTempConfig); final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0; if (isDensityChange && mDisplayId == DEFAULT_DISPLAY) { mService.mAppWarnings.onDensityChanged(); // Post message to start process to avoid possible deadlock of calling into AMS with // the ATMS lock held. final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::killAllBackgroundProcessesExcept, mService.mAmInternal, N, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND); mService.mH.sendMessage(msg); } } return changes; } @Override public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { final int currRotation = Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +11 −117 Original line number Diff line number Diff line Loading @@ -459,7 +459,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { boolean mSuppressResizeConfigChanges; private final UpdateConfigurationResult mTmpUpdateConfigurationResult = final UpdateConfigurationResult mTmpUpdateConfigurationResult = new UpdateConfigurationResult(); static final class UpdateConfigurationResult { Loading Loading @@ -631,7 +631,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { /** If non-null, we are tracking the time the user spends in the currently focused app. */ AppTimeTracker mCurAppTimeTracker; private AppWarnings mAppWarnings; AppWarnings mAppWarnings; /** * Packages that the user has asked to have run in screen size Loading Loading @@ -4387,46 +4387,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public boolean updateDisplayOverrideConfiguration(Configuration values, int displayId) { mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateDisplayOverrideConfiguration()"); synchronized (mGlobalLock) { // Check if display is initialized in AM. if (!mRootActivityContainer.isDisplayAdded(displayId)) { // Call might come when display is not yet added or has already been removed. if (DEBUG_CONFIGURATION) { Slog.w(TAG, "Trying to update display configuration for non-existing displayId=" + displayId); } return false; } if (values == null && mWindowManager != null) { // sentinel: fetch the current configuration from the window manager values = mWindowManager.computeNewConfiguration(displayId); } if (mWindowManager != null) { final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::updateOomLevelsForDisplay, mAmInternal, displayId); mH.sendMessage(msg); } final long origId = Binder.clearCallingIdentity(); try { if (values != null) { Settings.System.clearConfiguration(values); } updateDisplayOverrideConfigurationLocked(values, null /* starting */, false /* deferResume */, displayId, mTmpUpdateConfigurationResult); return mTmpUpdateConfigurationResult.changes != 0; } finally { Binder.restoreCallingIdentity(origId); } } } @Override public boolean updateConfiguration(Configuration values) { mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()"); Loading Loading @@ -5165,8 +5125,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } /** Update default (global) configuration and notify listeners about changes. */ private int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId, boolean deferResume) { final ActivityDisplay defaultDisplay = mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY); mTempConfig.setTo(getGlobalConfiguration()); final int changes = mTempConfig.updateFrom(values); if (changes == 0) { Loading @@ -5174,7 +5138,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // setting WindowManagerService.mWaitingForConfig to true, it is important that we call // performDisplayOverrideConfigUpdate in order to send the new display configuration // (even if there are no actual changes) to unfreeze the window. performDisplayOverrideConfigUpdate(values, deferResume, DEFAULT_DISPLAY); defaultDisplay.performDisplayOverrideConfigUpdate(values, deferResume); return 0; } Loading Loading @@ -5272,79 +5236,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // Override configuration of the default display duplicates global config, so we need to // update it also. This will also notify WindowManager about changes. performDisplayOverrideConfigUpdate(mRootActivityContainer.getConfiguration(), deferResume, DEFAULT_DISPLAY); return changes; } boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, int displayId) { return updateDisplayOverrideConfigurationLocked(values, starting, deferResume /* deferResume */, displayId, null /* result */); } /** * Updates override configuration specific for the selected display. If no config is provided, * new one will be computed in WM based on current display info. */ boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting, boolean deferResume, int displayId, ActivityTaskManagerService.UpdateConfigurationResult result) { int changes = 0; boolean kept = true; if (mWindowManager != null) { mWindowManager.deferSurfaceLayout(); } try { if (values != null) { if (displayId == DEFAULT_DISPLAY) { // Override configuration of the default display duplicates global config, so // we're calling global config update instead for default display. It will also // apply the correct override config. changes = updateGlobalConfigurationLocked(values, false /* initLocale */, false /* persistent */, UserHandle.USER_NULL /* userId */, deferResume); } else { changes = performDisplayOverrideConfigUpdate(values, deferResume, displayId); } } kept = ensureConfigAndVisibilityAfterUpdate(starting, changes); } finally { if (mWindowManager != null) { mWindowManager.continueSurfaceLayout(); } } if (result != null) { result.changes = changes; result.activityRelaunched = !kept; } return kept; } private int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume, int displayId) { mTempConfig.setTo(mRootActivityContainer.getDisplayOverrideConfiguration(displayId)); final int changes = mTempConfig.updateFrom(values); if (changes != 0) { Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " " + mTempConfig + " for displayId=" + displayId); mRootActivityContainer.setDisplayOverrideConfiguration(mTempConfig, displayId); final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0; if (isDensityChange && displayId == DEFAULT_DISPLAY) { mAppWarnings.onDensityChanged(); defaultDisplay.performDisplayOverrideConfigUpdate(mRootActivityContainer.getConfiguration(), deferResume); // Post message to start process to avoid possible deadlock of calling into AMS with // the ATMS lock held. final Message msg = PooledLambda.obtainMessage( ActivityManagerInternal::killAllBackgroundProcessesExcept, mAmInternal, N, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND); mH.sendMessage(msg); } } return changes; } Loading Loading @@ -5786,7 +5680,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } /** Applies latest configuration and/or visibility updates if needed. */ private boolean ensureConfigAndVisibilityAfterUpdate(ActivityRecord starting, int changes) { boolean ensureConfigAndVisibilityAfterUpdate(ActivityRecord starting, int changes) { boolean kept = true; final ActivityStack mainStack = mRootActivityContainer.getTopDisplayFocusedStack(); // mainStack is null during startup. Loading
services/core/java/com/android/server/wm/DisplayContent.java +27 −8 Original line number Diff line number Diff line Loading @@ -1213,10 +1213,29 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } /** Notify the configuration change of this display. */ void sendNewConfiguration() { void postNewConfigurationToHandler() { mWmService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget(); } void sendNewConfiguration() { synchronized (mWmService.mGlobalLock) { final boolean configUpdated = mAcitvityDisplay .updateDisplayOverrideConfigurationLocked(); if (!configUpdated) { // Something changed (E.g. device rotation), but no configuration update is needed. // E.g. changing device rotation by 180 degrees. Go ahead and perform surface // placement to unfreeze the display since we froze it when the rotation was updated // in DisplayContent#updateRotationUnchecked. if (mWaitingForConfig) { mWaitingForConfig = false; mWmService.mLastFinishedFreezeSource = "config-unchanged"; setLayoutNeeded(); mWmService.mWindowPlacerLocked.performSurfacePlacement(); } } } } @Override boolean onDescendantOrientationChanged(IBinder freezeDisplayToken, ConfigurationContainer requestingContainer) { Loading @@ -1232,8 +1251,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (handled && requestingContainer instanceof ActivityRecord) { final ActivityRecord activityRecord = (ActivityRecord) requestingContainer; final boolean kept = mWmService.mAtmService.updateDisplayOverrideConfigurationLocked( config, activityRecord, false /* deferResume */, getDisplayId()); final boolean kept = mAcitvityDisplay.updateDisplayOverrideConfigurationLocked( config, activityRecord, false /* deferResume */, null /* result */); activityRecord.frozenBeforeDestroy = true; if (!kept) { mWmService.mAtmService.mRootActivityContainer.resumeFocusedStacksTopActivities(); Loading @@ -1241,8 +1260,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } else { // We have a new configuration to push so we need to update ATMS for now. // TODO: Clean up display configuration push between ATMS and WMS after unification. mWmService.mAtmService.updateDisplayOverrideConfigurationLocked( config, null /* starting */, false /* deferResume */, getDisplayId()); mAcitvityDisplay.updateDisplayOverrideConfigurationLocked( config, null /* starting */, false /* deferResume */, null); } return handled; } Loading Loading @@ -1332,7 +1351,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo boolean updateRotationAndSendNewConfigIfNeeded() { final boolean changed = updateRotationUnchecked(false /* forceUpdate */); if (changed) { sendNewConfiguration(); postNewConfigurationToHandler(); } return changed; } Loading @@ -1351,7 +1370,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * Update rotation of the DisplayContent with an option to force the update. This updates * the container's perception of rotation and, depending on the top activities, will freeze * the screen or start seamless rotation. The display itself gets rotated in * {@link #applyRotationLocked} during {@link WindowManagerService#sendNewConfiguration}. * {@link #applyRotationLocked} during {@link DisplayContent#sendNewConfiguration}. * * @param forceUpdate Force the rotation update. Sometimes in WM we might skip updating * orientation because we're waiting for some rotation to finish or display Loading Loading @@ -3711,7 +3730,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); if (updateOrientationFromAppTokens()) { setLayoutNeeded(); sendNewConfiguration(); postNewConfigurationToHandler(); } } Loading
services/core/java/com/android/server/wm/InputManagerCallback.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal @Override public void notifyConfigurationChanged() { // TODO(multi-display): Notify proper displays that are associated with this input device. mService.sendNewConfiguration(DEFAULT_DISPLAY); mService.mRoot.getDisplayContent(DEFAULT_DISPLAY).sendNewConfiguration(); synchronized (mInputDevicesReadyMonitor) { if (!mInputDevicesReady) { Loading