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

Commit 64821125 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add device config for experiment of ignoring activity orientation

With command:
 adb shell device_config put window_manager \
     ignore_activity_orientation_request true
Activity's orientation will be always "unspecified".

Flag: EXEMPT disabled code
Test: presubmit
Bug: 357141415
Change-Id: Ib84af6637fca45323c3064ca92e715dcd1c7040f
parent 4cc6b39f
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -8139,6 +8139,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     */
     */
    @Override
    @Override
    protected int getOverrideOrientation() {
    protected int getOverrideOrientation() {
        if (mWmService.mConstants.mIgnoreActivityOrientationRequest) {
            return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        }
        return mAppCompatController.getOrientationPolicy()
        return mAppCompatController.getOrientationPolicy()
                .overrideOrientationIfNeeded(super.getOverrideOrientation());
                .overrideOrientationIfNeeded(super.getOverrideOrientation());
    }
    }
+19 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,10 @@ import java.util.concurrent.Executor;
 */
 */
final class WindowManagerConstants {
final class WindowManagerConstants {


    /** The orientation of activity will be always "unspecified". */
    private static final String KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST =
            "ignore_activity_orientation_request";

    /**
    /**
     * The minimum duration between gesture exclusion logging for a given window in
     * The minimum duration between gesture exclusion logging for a given window in
     * milliseconds.
     * milliseconds.
@@ -58,6 +62,9 @@ final class WindowManagerConstants {
    /** @see AndroidDeviceConfig#KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE */
    /** @see AndroidDeviceConfig#KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE */
    boolean mSystemGestureExcludedByPreQStickyImmersive;
    boolean mSystemGestureExcludedByPreQStickyImmersive;


    /** @see #KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST */
    boolean mIgnoreActivityOrientationRequest;

    private final WindowManagerGlobalLock mGlobalLock;
    private final WindowManagerGlobalLock mGlobalLock;
    private final Runnable mUpdateSystemGestureExclusionCallback;
    private final Runnable mUpdateSystemGestureExclusionCallback;
    private final DeviceConfigInterface mDeviceConfig;
    private final DeviceConfigInterface mDeviceConfig;
@@ -89,6 +96,7 @@ final class WindowManagerConstants {
        updateSystemGestureExclusionLogDebounceMillis();
        updateSystemGestureExclusionLogDebounceMillis();
        updateSystemGestureExclusionLimitDp();
        updateSystemGestureExclusionLimitDp();
        updateSystemGestureExcludedByPreQStickyImmersive();
        updateSystemGestureExcludedByPreQStickyImmersive();
        updateIgnoreActivityOrientationRequest();
    }
    }


    private void onAndroidPropertiesChanged(DeviceConfig.Properties properties) {
    private void onAndroidPropertiesChanged(DeviceConfig.Properties properties) {
@@ -127,6 +135,9 @@ final class WindowManagerConstants {
                    case KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS:
                    case KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS:
                        updateSystemGestureExclusionLogDebounceMillis();
                        updateSystemGestureExclusionLogDebounceMillis();
                        break;
                        break;
                    case KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST:
                        updateIgnoreActivityOrientationRequest();
                        break;
                    default:
                    default:
                        break;
                        break;
                }
                }
@@ -152,6 +163,12 @@ final class WindowManagerConstants {
                KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE, false);
                KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE, false);
    }
    }


    private void updateIgnoreActivityOrientationRequest() {
        mIgnoreActivityOrientationRequest = mDeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_WINDOW_MANAGER,
                KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST, false);
    }

    void dump(PrintWriter pw) {
    void dump(PrintWriter pw) {
        pw.println("WINDOW MANAGER CONSTANTS (dumpsys window constants):");
        pw.println("WINDOW MANAGER CONSTANTS (dumpsys window constants):");


@@ -161,6 +178,8 @@ final class WindowManagerConstants {
        pw.print("="); pw.println(mSystemGestureExclusionLimitDp);
        pw.print("="); pw.println(mSystemGestureExclusionLimitDp);
        pw.print("  "); pw.print(KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE);
        pw.print("  "); pw.print(KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE);
        pw.print("="); pw.println(mSystemGestureExcludedByPreQStickyImmersive);
        pw.print("="); pw.println(mSystemGestureExcludedByPreQStickyImmersive);
        pw.print("  "); pw.print(KEY_IGNORE_ACTIVITY_ORIENTATION_REQUEST);
        pw.print("="); pw.println(mIgnoreActivityOrientationRequest);
        pw.println();
        pw.println();
    }
    }
}
}