From 1db1cf3cb69e0690c6de6dcf4b36a48498703685 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Thu, 25 May 2023 17:38:28 +0900 Subject: [PATCH] Move ImmersiveModeConfirmation to system UI (4/n) This change move the WM side immersive mode confirmation window to the system UI side. The major change of the immersive mode confirmation mode to accomodate system UI side logic includes: 1. Power key panic is handled purely in DisplayPolicy, with a tracking of existance of the immersive confirmation window. 2. Introduce another layout params private flag to identify the immersive mode confiramtion mode. 3. CLIENT_* flags handling. 4. Vr and release handling, and most of the settings and display change handling moved to system UI. 5. Updated the text color of the window to match the themed background color. Introduce CLIENT_IMMERSIVE_CONFIRMATION flag to control whether client or the server side of immersive confirmation window shall be used. The flag will only be in effect if the CLIENT_TRANSIENT flag is not true, otherwise, the client side confirmation window will always be used. Bug: 277290737 Test: build Test: enable CLIENT_TRANSIENT and check the existance of the immersive mode confirmation window. Change-Id: I99f6097cb867f9808aecf4c7105289550001f452 --- core/java/android/view/ViewRootImpl.java | 10 + core/java/android/view/WindowManager.java | 15 + .../internal/statusbar/IStatusBar.aidl | 13 + .../res/drawable/immersive_cling_bg_circ.xml | 2 +- .../immersive_cling_light_bg_circ.xml | 2 +- .../res/layout/immersive_mode_cling.xml | 6 +- .../dagger/SystemUICoreStartableModule.kt | 7 + .../systemui/statusbar/CommandQueue.java | 45 +- .../statusbar/ImmersiveModeConfirmation.java | 590 ++++++++++++++++++ .../systemui/statusbar/CommandQueueTest.java | 15 + .../statusbar/StatusBarManagerInternal.java | 14 + .../statusbar/StatusBarManagerService.java | 26 + .../com/android/server/wm/DisplayPolicy.java | 88 ++- .../server/wm/ImmersiveModeConfirmation.java | 7 +- 14 files changed, 819 insertions(+), 21 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9d2bb58cdf0f6..2f12fecb7fd04 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -310,6 +310,16 @@ public final class ViewRootImpl implements ViewParent, public static final boolean CLIENT_TRANSIENT = SystemProperties.getBoolean("persist.wm.debug.client_transient", false); + /** + * Whether the client (system UI) is handling the immersive confirmation window. If + * {@link CLIENT_TRANSIENT} is set to true, the immersive confirmation window will always be the + * client instance and this flag will be ignored. Otherwise, the immersive confirmation window + * can be switched freely by this flag. + * @hide + */ + public static final boolean CLIENT_IMMERSIVE_CONFIRMATION = + SystemProperties.getBoolean("persist.wm.debug.client_immersive_confirmation", false); + /** * Whether the client should compute the window frame on its own. * @hide diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index d702367965a1a..f5a5c40070554 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -3097,6 +3097,16 @@ public interface WindowManager extends ViewManager { */ public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 1 << 16; + /** + * Flag to indicate that this window is a immersive mode confirmation window. The window + * should be ignored when calculating insets control. This is used for prompt window + * triggered by insets visibility changes. If it can take over the insets control, the + * visibility will change unexpectedly and the window may dismiss itself. Power button panic + * handling will be disabled when this window exists. + * @hide + */ + public static final int PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW = 1 << 17; + /** * Flag to indicate that any window added by an application process that is of type * {@link #TYPE_TOAST} or that requires @@ -3241,6 +3251,7 @@ public interface WindowManager extends ViewManager { PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS, PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, + PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION, @@ -3324,6 +3335,10 @@ public interface WindowManager extends ViewManager { mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, name = "SUSTAINED_PERFORMANCE_MODE"), + @ViewDebug.FlagToString( + mask = PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, + equals = PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, + name = "IMMERSIVE_CONFIRMATION_WINDOW"), @ViewDebug.FlagToString( mask = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, equals = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index d2564fb9c268f..c6f5086b83468 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -63,6 +63,19 @@ oneway interface IStatusBar void cancelPreloadRecentApps(); void showScreenPinningRequest(int taskId); + /** + * Notify system UI the immersive prompt should be dismissed as confirmed, and the confirmed + * status should be saved without user clicking on the button. This could happen when a user + * swipe on the edge with the confirmation prompt showing. + */ + void confirmImmersivePrompt(); + + /** + * Notify system UI the immersive mode changed. This shall be removed when client immersive is + * enabled. + */ + void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode); + void dismissKeyboardShortcutsMenu(); void toggleKeyboardShortcutsMenu(int deviceId); diff --git a/packages/SystemUI/res/drawable/immersive_cling_bg_circ.xml b/packages/SystemUI/res/drawable/immersive_cling_bg_circ.xml index 4029702ec6b4d..32e88ab22b911 100644 --- a/packages/SystemUI/res/drawable/immersive_cling_bg_circ.xml +++ b/packages/SystemUI/res/drawable/immersive_cling_bg_circ.xml @@ -17,7 +17,7 @@ - + - +