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

Commit fb287dc6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Start logging rotation lock history + include caller information" into main

parents 7110a03a 670fb7f5
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -207,9 +207,10 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        final long identity = Binder.clearCallingIdentity();
        try {
            if (rotation == UiAutomation.ROTATION_UNFREEZE) {
                mWindowManager.thawRotation();
                mWindowManager.thawRotation(/* caller= */ "UiAutomationConnection#setRotation");
            } else {
                mWindowManager.freezeRotation(rotation);
                mWindowManager.freezeRotation(rotation,
                        /* caller= */ "UiAutomationConnection#setRotation");
            }
            return true;
        } catch (RemoteException re) {
@@ -615,11 +616,13 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
            if (mInitialFrozenRotation != INITIAL_FROZEN_ROTATION_UNSPECIFIED) {
                // Calling out with a lock held is fine since if the system
                // process is gone the client calling in will be killed.
                mWindowManager.freezeRotation(mInitialFrozenRotation);
                mWindowManager.freezeRotation(mInitialFrozenRotation,
                        /* caller= */ "UiAutomationConnection#restoreRotationStateLocked");
            } else {
                // Calling out with a lock held is fine since if the system
                // process is gone the client calling in will be killed.
                mWindowManager.thawRotation();
                mWindowManager.thawRotation(
                        /* caller= */ "UiAutomationConnection#restoreRotationStateLocked");
            }
        } catch (RemoteException re) {
            /* ignore */
+4 −4
Original line number Diff line number Diff line
@@ -316,14 +316,14 @@ interface IWindowManager
     * android.view.Display#DEFAULT_DISPLAY} and given rotation.
     */
    @UnsupportedAppUsage
    void freezeRotation(int rotation);
    void freezeRotation(int rotation, String caller);

    /**
     * Equivalent to calling {@link #thawDisplayRotation(int)} with {@link
     * android.view.Display#DEFAULT_DISPLAY}.
     */
    @UnsupportedAppUsage
    void thawRotation();
    void thawRotation(String caller);

    /**
     * Equivelant to call {@link #isDisplayRotationFrozen(int)} with {@link
@@ -341,7 +341,7 @@ interface IWindowManager
     *        {@link android.view.Surface#ROTATION_270} or -1 to freeze it to current rotation.
     * @hide
     */
    void freezeDisplayRotation(int displayId, int rotation);
    void freezeDisplayRotation(int displayId, int rotation, String caller);

    /**
     * Release the orientation lock imposed by freezeRotation() on the display.
@@ -349,7 +349,7 @@ interface IWindowManager
     * @param displayId the ID of display which rotation should be thawed.
     * @hide
     */
    void thawDisplayRotation(int displayId);
    void thawDisplayRotation(int displayId, String caller);

    /**
     * Gets whether the rotation is frozen on the display.
+11 −9
Original line number Diff line number Diff line
@@ -105,23 +105,23 @@ public final class RotationPolicy {
    /**
     * Enables or disables rotation lock from the system UI toggle.
     */
    public static void setRotationLock(Context context, final boolean enabled) {
    public static void setRotationLock(Context context, final boolean enabled, String caller) {
        final int rotation = areAllRotationsAllowed(context)
                || useCurrentRotationOnRotationLockChange(context) ? CURRENT_ROTATION
                : NATURAL_ROTATION;
        setRotationLockAtAngle(context, enabled, rotation);
        setRotationLockAtAngle(context, enabled, rotation, caller);
    }

    /**
     * Enables or disables rotation lock at a specific rotation from system UI.
     */
    public static void setRotationLockAtAngle(Context context, final boolean enabled,
            final int rotation) {
            final int rotation, String caller) {
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0,
                UserHandle.USER_CURRENT);

        setRotationLock(enabled, rotation);
        setRotationLock(enabled, rotation, caller);
    }

    /**
@@ -129,12 +129,13 @@ public final class RotationPolicy {
     *
     * If rotation is locked for accessibility, the system UI toggle is hidden to avoid confusion.
     */
    public static void setRotationLockForAccessibility(Context context, final boolean enabled) {
    public static void setRotationLockForAccessibility(Context context, final boolean enabled,
            String caller) {
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, enabled ? 1 : 0,
                        UserHandle.USER_CURRENT);

        setRotationLock(enabled, NATURAL_ROTATION);
        setRotationLock(enabled, NATURAL_ROTATION, caller);
    }

    private static boolean areAllRotationsAllowed(Context context) {
@@ -146,16 +147,17 @@ public final class RotationPolicy {
                R.bool.config_useCurrentRotationOnRotationLockChange);
    }

    private static void setRotationLock(final boolean enabled, final int rotation) {
    private static void setRotationLock(final boolean enabled, final int rotation,
            final String caller) {
        AsyncTask.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
                    if (enabled) {
                        wm.freezeRotation(rotation);
                        wm.freezeRotation(rotation, caller);
                    } else {
                        wm.thawRotation();
                        wm.thawRotation(caller);
                    }
                } catch (RemoteException exc) {
                    Log.w(TAG, "Unable to save auto-rotate setting");
+12 −6
Original line number Diff line number Diff line
@@ -1123,12 +1123,6 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "-1076978367": {
      "message": "thawRotation: mRotation=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1075136930": {
      "message": "startLockTaskMode: Can't lock due to auth",
      "level": "WARN",
@@ -1231,6 +1225,12 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "-962760979": {
      "message": "thawRotation: mRotation=%d, caller=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-961053385": {
      "message": "attachWindowContextToDisplayArea: calling from non-existing process pid=%d uid=%d",
      "level": "WARN",
@@ -2779,6 +2779,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "364992694": {
      "message": "freezeDisplayRotation: current rotation=%d, new rotation=%d, caller=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "371173718": {
      "message": "finishSync cancel=%b for %s",
      "level": "VERBOSE",
+6 −4
Original line number Diff line number Diff line
@@ -282,9 +282,9 @@ public class RotationButtonController {
        TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
    }

    public void setRotationLockedAtAngle(int rotationSuggestion) {
    public void setRotationLockedAtAngle(int rotationSuggestion, String caller) {
        RotationPolicy.setRotationLockAtAngle(mContext, /* enabled= */ isRotationLocked(),
                /* rotation= */ rotationSuggestion);
                /* rotation= */ rotationSuggestion, caller);
    }

    public boolean isRotationLocked() {
@@ -468,7 +468,8 @@ public class RotationButtonController {
        if (rotationLocked || mRotationButton.isVisible()) {
            // Do not allow a change in rotation to set user rotation when docked.
            if (shouldOverrideUserLockPrefs(rotation) && rotationLocked && !mDocked) {
                setRotationLockedAtAngle(rotation);
                setRotationLockedAtAngle(rotation, /* caller= */
                        "RotationButtonController#onRotationWatcherChanged");
            }
            setRotateSuggestionButtonState(false /* visible */, true /* forced */);
        }
@@ -572,7 +573,8 @@ public class RotationButtonController {
    private void onRotateSuggestionClick(View v) {
        mUiEventLogger.log(RotationButtonEvent.ROTATION_SUGGESTION_ACCEPTED);
        incrementNumAcceptedRotationSuggestionsIfNeeded();
        setRotationLockedAtAngle(mLastRotationSuggestion);
        setRotationLockedAtAngle(mLastRotationSuggestion,
                /* caller= */ "RotationButtonController#onRotateSuggestionClick");
        Log.i(TAG, "onRotateSuggestionClick() mLastRotationSuggestion=" + mLastRotationSuggestion);
        v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }
Loading