diff options
| author | 2025-01-13 15:57:02 +0800 | |
|---|---|---|
| committer | 2025-01-14 22:22:39 -0800 | |
| commit | d570a556beafe9f79ad077f1db338a861716b3d3 (patch) | |
| tree | 01de543be6b4f9b997fc946ae6f9f25b47320d64 | |
| parent | e4046a28f899abfd82ef4f1a002eac28fce72f2b (diff) | |
Remove manual freezing screen
Currently this is only used when switching to a new user. That was a
workaround of bug 279773661. In the case, the UserSwitchingDialog
looks flickering because the animation incorrectly put the top activity
(setupwizard) at a higher z-order than the overlay window, which causes
dialog (cover on top) -> activity (animating wrong z-order)
-> dialog (animation finished) -> activity (dialog dismissed)
The incorrect z-order was fixed by the change
If6c12d4c4ee3b19abbe1fe4307dd4acae35e5cf8 (wm.Transition)
Which makes the transition recognize that the top activity is
a dependent change which shouldn't be put at transition root.
So now UserSwitchingDialog can always stay on top during switching
user, then startFreezingScreen/stopFreezingScreen are no longer needed.
Bug: 389860816
Flag: EXEMPT bugfix
Test: Switch to a new user. The animation appearance is the same as
before this change.
Change-Id: I73685cbfc1beb1fc4066daa870408a23c731f551
4 files changed, 6 insertions, 122 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 2b4087439323..49247f433071 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -208,9 +208,6 @@ interface IWindowManager @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) void endProlongedAnimations(); - void startFreezingScreen(int exitAnim, int enterAnim); - void stopFreezingScreen(); - // these require DISABLE_KEYGUARD permission /** @deprecated use Activity.setShowWhenLocked instead. */ void disableKeyguard(IBinder token, String tag, int userId); diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index c31b9ef60bd2..61f4fb0aae2b 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -4060,8 +4060,7 @@ class UserController implements Handler.Callback { synchronized (mUserSwitchingDialogLock) { dismissUserSwitchingDialog(null); mUserSwitchingDialog = new UserSwitchingDialog(mService.mContext, fromUser, toUser, - switchingFromSystemUserMessage, switchingToSystemUserMessage, - getWindowManager()); + switchingFromSystemUserMessage, switchingToSystemUserMessage); mUserSwitchingDialog.show(onShown); } } diff --git a/services/core/java/com/android/server/am/UserSwitchingDialog.java b/services/core/java/com/android/server/am/UserSwitchingDialog.java index 2d7456471be4..d1fcb9d1ca37 100644 --- a/services/core/java/com/android/server/am/UserSwitchingDialog.java +++ b/services/core/java/com/android/server/am/UserSwitchingDialog.java @@ -39,7 +39,6 @@ import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; -import android.provider.Settings; import android.util.Slog; import android.util.TypedValue; import android.view.View; @@ -53,7 +52,6 @@ import android.widget.TextView; import com.android.internal.R; import com.android.internal.util.ObjectUtils; import com.android.internal.util.UserIcons; -import com.android.server.wm.WindowManagerService; import java.util.concurrent.atomic.AtomicBoolean; @@ -80,14 +78,11 @@ class UserSwitchingDialog extends Dialog { protected final UserInfo mNewUser; private final String mSwitchingFromSystemUserMessage; private final String mSwitchingToSystemUserMessage; - private final WindowManagerService mWindowManager; protected final Context mContext; private final int mTraceCookie; - private final boolean mNeedToFreezeScreen; UserSwitchingDialog(Context context, UserInfo oldUser, UserInfo newUser, - String switchingFromSystemUserMessage, String switchingToSystemUserMessage, - WindowManagerService windowManager) { + String switchingFromSystemUserMessage, String switchingToSystemUserMessage) { super(context, R.style.Theme_Material_NoActionBar_Fullscreen); mContext = context; @@ -97,8 +92,6 @@ class UserSwitchingDialog extends Dialog { mSwitchingToSystemUserMessage = switchingToSystemUserMessage; mDisableAnimations = SystemProperties.getBoolean( "debug.usercontroller.disable_user_switching_dialog_animations", false); - mWindowManager = windowManager; - mNeedToFreezeScreen = !mDisableAnimations && !isUserSetupComplete(newUser); mTraceCookie = UserHandle.MAX_SECONDARY_USER_ID * oldUser.id + newUser.id; inflateContent(); @@ -183,11 +176,6 @@ class UserSwitchingDialog extends Dialog { : res.getString(R.string.user_switching_message, mNewUser.name); } - private boolean isUserSetupComplete(UserInfo user) { - return Settings.Secure.getIntForUser(mContext.getContentResolver(), - Settings.Secure.USER_SETUP_COMPLETE, /* default= */ 0, user.id) == 1; - } - @Override public void show() { asyncTraceBegin("dialog", 0); @@ -197,7 +185,6 @@ class UserSwitchingDialog extends Dialog { @Override public void dismiss() { super.dismiss(); - stopFreezingScreen(); asyncTraceEnd("dialog", 0); } @@ -205,7 +192,6 @@ class UserSwitchingDialog extends Dialog { if (DEBUG) Slog.d(TAG, "show called"); show(); startShowAnimation(() -> { - startFreezingScreen(); onShown.run(); }); } @@ -223,24 +209,6 @@ class UserSwitchingDialog extends Dialog { } } - private void startFreezingScreen() { - if (!mNeedToFreezeScreen) { - return; - } - traceBegin("startFreezingScreen"); - mWindowManager.startFreezingScreen(0, 0); - traceEnd("startFreezingScreen"); - } - - private void stopFreezingScreen() { - if (!mNeedToFreezeScreen) { - return; - } - traceBegin("stopFreezingScreen"); - mWindowManager.stopFreezingScreen(); - traceEnd("stopFreezingScreen"); - } - private void startShowAnimation(Runnable onAnimationEnd) { if (mDisableAnimations) { onAnimationEnd.run(); @@ -260,7 +228,7 @@ class UserSwitchingDialog extends Dialog { } private void startDismissAnimation(Runnable onAnimationEnd) { - if (mDisableAnimations || mNeedToFreezeScreen) { + if (mDisableAnimations) { // animations are disabled or screen is frozen, no need to play an animation onAnimationEnd.run(); return; @@ -352,14 +320,4 @@ class UserSwitchingDialog extends Dialog { Trace.asyncTraceEnd(TRACE_TAG, TAG + subTag, mTraceCookie + subCookie); if (DEBUG) Slog.d(TAG, "asyncTraceEnd-" + subTag); } - - private void traceBegin(String msg) { - if (DEBUG) Slog.d(TAG, "traceBegin-" + msg); - Trace.traceBegin(TRACE_TAG, msg); - } - - private void traceEnd(String msg) { - Trace.traceEnd(TRACE_TAG); - if (DEBUG) Slog.d(TAG, "traceEnd-" + msg); - } } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 965b22473a2c..83cc763e0a6c 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -751,8 +751,6 @@ public class WindowManagerService extends IWindowManager.Stub final static int WINDOWS_FREEZING_SCREENS_TIMEOUT = 2; int mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE; - /** Indicates that the system server is actively demanding the screen be frozen. */ - boolean mClientFreezingScreen = false; int mAppsFreezingScreen = 0; @VisibleForTesting @@ -3356,60 +3354,6 @@ public class WindowManagerService extends IWindowManager.Stub return getDefaultDisplayContentLocked().mAppTransition.isIdle(); } - - // ------------------------------------------------------------- - // Misc IWindowSession methods - // ------------------------------------------------------------- - - /** Freeze the screen during a user-switch event. Called by UserController. */ - @Override - public void startFreezingScreen(int exitAnim, int enterAnim) { - if (!checkCallingPermission(android.Manifest.permission.FREEZE_SCREEN, - "startFreezingScreen()")) { - throw new SecurityException("Requires FREEZE_SCREEN permission"); - } - - synchronized (mGlobalLock) { - if (!mClientFreezingScreen) { - mClientFreezingScreen = true; - final long origId = Binder.clearCallingIdentity(); - try { - startFreezingDisplay(exitAnim, enterAnim); - mH.removeMessages(H.CLIENT_FREEZE_TIMEOUT); - mH.sendEmptyMessageDelayed(H.CLIENT_FREEZE_TIMEOUT, 5000); - } finally { - Binder.restoreCallingIdentity(origId); - } - } - } - } - - /** - * No longer actively demand that the screen remain frozen. - * Called by UserController after a user-switch. - * This doesn't necessarily immediately unlock the screen; it just allows it if we're ready. - */ - @Override - public void stopFreezingScreen() { - if (!checkCallingPermission(android.Manifest.permission.FREEZE_SCREEN, - "stopFreezingScreen()")) { - throw new SecurityException("Requires FREEZE_SCREEN permission"); - } - - synchronized (mGlobalLock) { - if (mClientFreezingScreen) { - mClientFreezingScreen = false; - mLastFinishedFreezeSource = "client"; - final long origId = Binder.clearCallingIdentity(); - try { - stopFreezingDisplayLocked(); - } finally { - Binder.restoreCallingIdentity(origId); - } - } - } - } - @Override public void disableKeyguard(IBinder token, String tag, int userId) { userId = mAmInternal.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), @@ -5671,7 +5615,6 @@ public class WindowManagerService extends IWindowManager.Stub public static final int WAITING_FOR_DRAWN_TIMEOUT = 24; public static final int SHOW_STRICT_MODE_VIOLATION = 25; - public static final int CLIENT_FREEZE_TIMEOUT = 30; public static final int NOTIFY_ACTIVITY_DRAWN = 32; public static final int NEW_ANIMATOR_SCALE = 34; @@ -5761,17 +5704,6 @@ public class WindowManagerService extends IWindowManager.Stub break; } - case CLIENT_FREEZE_TIMEOUT: { - synchronized (mGlobalLock) { - if (mClientFreezingScreen) { - mClientFreezingScreen = false; - mLastFinishedFreezeSource = "client-timeout"; - stopFreezingDisplayLocked(); - } - } - break; - } - case REPORT_WINDOWS_CHANGE: { if (mWindowsChanged) { synchronized (mGlobalLock) { @@ -6509,14 +6441,14 @@ public class WindowManagerService extends IWindowManager.Stub } if (waitingForConfig || waitingForRemoteDisplayChange || mAppsFreezingScreen > 0 || mWindowsFreezingScreen == WINDOWS_FREEZING_SCREENS_ACTIVE - || mClientFreezingScreen || numOpeningApps > 0) { + || numOpeningApps > 0) { ProtoLog.d(WM_DEBUG_ORIENTATION, "stopFreezingDisplayLocked: Returning " + "waitingForConfig=%b, waitingForRemoteDisplayChange=%b, " + "mAppsFreezingScreen=%d, mWindowsFreezingScreen=%d, " - + "mClientFreezingScreen=%b, mOpeningApps.size()=%d", + + "mOpeningApps.size()=%d", waitingForConfig, waitingForRemoteDisplayChange, mAppsFreezingScreen, mWindowsFreezingScreen, - mClientFreezingScreen, numOpeningApps); + numOpeningApps); return; } @@ -6546,7 +6478,6 @@ public class WindowManagerService extends IWindowManager.Stub } ProtoLog.i(WM_ERROR, "%s", sb.toString()); mH.removeMessages(H.APP_FREEZE_TIMEOUT); - mH.removeMessages(H.CLIENT_FREEZE_TIMEOUT); if (PROFILE_ORIENTATION) { Debug.stopMethodTracing(); } @@ -7053,7 +6984,6 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mTransactionSequence="); pw.println(mTransactionSequence); pw.print(" mDisplayFrozen="); pw.print(mDisplayFrozen); pw.print(" windows="); pw.print(mWindowsFreezingScreen); - pw.print(" client="); pw.print(mClientFreezingScreen); pw.print(" apps="); pw.println(mAppsFreezingScreen); final DisplayContent defaultDisplayContent = getDefaultDisplayContentLocked(); pw.print(" mRotation="); pw.println(defaultDisplayContent.getRotation()); |