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

Commit bc544ac4 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove manual freezing screen" into main

parents 81705f17 d570a556
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -227,9 +227,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);
+1 −2
Original line number Diff line number Diff line
@@ -4062,8 +4062,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);
            }
        }
+2 −44
Original line number Diff line number Diff line
@@ -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);
    }
}
+3 −73
Original line number Diff line number Diff line
@@ -753,8 +753,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
@@ -3354,60 +3352,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(),
@@ -5669,7 +5613,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;
@@ -5759,17 +5702,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) {
@@ -6552,14 +6484,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;
        }

@@ -6589,7 +6521,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();
        }
@@ -7096,7 +7027,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());