From be7d8b28595879d0722624d9dd3479782f8976d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6llner?= Date: Fri, 10 Dec 2021 12:53:05 +0100 Subject: [PATCH] Enables the rotation suggestion button during setup wizard Fixes: 204945507 Bug: 204945507 Test: StatusBarManagerTest in a separate CL + Manually Change-Id: If73caa69b8f923b01e60472a33ba034c2f682075 --- core/api/test-current.txt | 4 ++++ core/java/android/app/StatusBarManager.java | 25 +++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/api/test-current.txt b/core/api/test-current.txt index a92150079ec9f..fd115676d169c 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -353,6 +353,10 @@ package android.app { method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void togglePanel(); } + public static final class StatusBarManager.DisableInfo { + method public boolean isRotationSuggestionDisabled(); + } + public final class SyncNotedAppOp implements android.os.Parcelable { ctor public SyncNotedAppOp(int, @IntRange(from=0L) int, @Nullable String, @NonNull String); } diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java index 2392c9aa185c1..ae578f5e60ed0 100644 --- a/core/java/android/app/StatusBarManager.java +++ b/core/java/android/app/StatusBarManager.java @@ -165,7 +165,7 @@ public class StatusBarManager { * * @hide */ - public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_ROTATE_SUGGESTIONS; + public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_NONE; /** * disable flags to be applied when the device is sim-locked. @@ -712,6 +712,7 @@ public class StatusBarManager { private boolean mSystemIcons; private boolean mClock; private boolean mNotificationIcons; + private boolean mRotationSuggestion; /** @hide */ public DisableInfo(int flags1, int flags2) { @@ -723,6 +724,7 @@ public class StatusBarManager { mSystemIcons = (flags1 & DISABLE_SYSTEM_INFO) != 0; mClock = (flags1 & DISABLE_CLOCK) != 0; mNotificationIcons = (flags1 & DISABLE_NOTIFICATION_ICONS) != 0; + mRotationSuggestion = (flags2 & DISABLE2_ROTATE_SUGGESTIONS) != 0; } /** @hide */ @@ -846,14 +848,24 @@ public class StatusBarManager { } /** - * @return {@code true} if no components are disabled (default state) + * Returns whether the rotation suggestion is disabled. * * @hide */ + @TestApi + public boolean isRotationSuggestionDisabled() { + return mRotationSuggestion; + } + + /** + * @return {@code true} if no components are disabled (default state) + * @hide + */ @SystemApi public boolean areAllComponentsEnabled() { return !mStatusBarExpansion && !mNavigateHome && !mNotificationPeeking && !mRecents - && !mSearch && !mSystemIcons && !mClock && !mNotificationIcons; + && !mSearch && !mSystemIcons && !mClock && !mNotificationIcons + && !mRotationSuggestion; } /** @hide */ @@ -866,6 +878,7 @@ public class StatusBarManager { mSystemIcons = false; mClock = false; mNotificationIcons = false; + mRotationSuggestion = false; } /** @@ -875,7 +888,8 @@ public class StatusBarManager { */ public boolean areAllComponentsDisabled() { return mStatusBarExpansion && mNavigateHome && mNotificationPeeking - && mRecents && mSearch && mSystemIcons && mClock && mNotificationIcons; + && mRecents && mSearch && mSystemIcons && mClock && mNotificationIcons + && mRotationSuggestion; } /** @hide */ @@ -888,6 +902,7 @@ public class StatusBarManager { mSystemIcons = true; mClock = true; mNotificationIcons = true; + mRotationSuggestion = true; } @NonNull @@ -904,6 +919,7 @@ public class StatusBarManager { sb.append(" mSystemIcons=").append(mSystemIcons ? "disabled" : "enabled"); sb.append(" mClock=").append(mClock ? "disabled" : "enabled"); sb.append(" mNotificationIcons=").append(mNotificationIcons ? "disabled" : "enabled"); + sb.append(" mRotationSuggestion=").append(mRotationSuggestion ? "disabled" : "enabled"); return sb.toString(); @@ -927,6 +943,7 @@ public class StatusBarManager { if (mSystemIcons) disable1 |= DISABLE_SYSTEM_INFO; if (mClock) disable1 |= DISABLE_CLOCK; if (mNotificationIcons) disable1 |= DISABLE_NOTIFICATION_ICONS; + if (mRotationSuggestion) disable2 |= DISABLE2_ROTATE_SUGGESTIONS; return new Pair(disable1, disable2); }