diff options
| author | 2020-01-20 17:23:36 +0000 | |
|---|---|---|
| committer | 2020-01-20 17:23:36 +0000 | |
| commit | eb0ebddc1a1cfe3225679f2c6b35a1fecca4915c (patch) | |
| tree | 74faec8b545b833ad554c09afe6a5fbb6bf0ddda | |
| parent | 42132edbfdd486ca4c9334486df34cd7ad738b15 (diff) | |
| parent | e832194dd0614a9c6f496e0f2ff03fd70f037462 (diff) | |
Merge "Split status bar window (1/N)"
75 files changed, 2284 insertions, 1965 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index 16ea465027e6..8871d6723390 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -4497,7 +4497,7 @@ package android.view { field public static final int ACCESSIBILITY_TITLE_CHANGED = 33554432; // 0x2000000 field public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 64; // 0x40 field public CharSequence accessibilityTitle; - field @android.view.ViewDebug.ExportedProperty(flagMapping={@android.view.ViewDebug.FlagToString(mask=0x1, equals=0x1, name="FAKE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x2, equals=0x2, name="FORCE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x4, equals=0x4, name="WANTS_OFFSET_NOTIFICATIONS"), @android.view.ViewDebug.FlagToString(mask=0x10, equals=0x10, name="SHOW_FOR_ALL_USERS"), @android.view.ViewDebug.FlagToString(mask=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, equals=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, name="NO_MOVE_ANIMATION"), @android.view.ViewDebug.FlagToString(mask=0x80, equals=0x80, name="COMPATIBLE_WINDOW"), @android.view.ViewDebug.FlagToString(mask=0x100, equals=0x100, name="SYSTEM_ERROR"), @android.view.ViewDebug.FlagToString(mask=0x400, equals=0x400, name="KEYGUARD"), @android.view.ViewDebug.FlagToString(mask=0x800, equals=0x800, name="DISABLE_WALLPAPER_TOUCH_EVENTS"), @android.view.ViewDebug.FlagToString(mask=0x1000, equals=0x1000, name="FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), @android.view.ViewDebug.FlagToString(mask=0x2000, equals=0x2000, name="PRESERVE_GEOMETRY"), @android.view.ViewDebug.FlagToString(mask=0x4000, equals=0x4000, name="FORCE_DECOR_VIEW_VISIBILITY"), @android.view.ViewDebug.FlagToString(mask=0x8000, equals=0x8000, name="WILL_NOT_REPLACE_ON_RELAUNCH"), @android.view.ViewDebug.FlagToString(mask=0x10000, equals=0x10000, name="LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), @android.view.ViewDebug.FlagToString(mask=0x20000, equals=0x20000, name="FORCE_DRAW_STATUS_BAR_BACKGROUND"), @android.view.ViewDebug.FlagToString(mask=0x40000, equals=0x40000, name="SUSTAINED_PERFORMANCE_MODE"), @android.view.ViewDebug.FlagToString(mask=0x80000, equals=0x80000, name="HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), @android.view.ViewDebug.FlagToString(mask=0x100000, equals=0x100000, name="IS_ROUNDED_CORNERS_OVERLAY"), @android.view.ViewDebug.FlagToString(mask=0x400000, equals=0x400000, name="IS_SCREEN_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x800000, equals=0x800000, name="STATUS_FORCE_SHOW_NAVIGATION"), @android.view.ViewDebug.FlagToString(mask=0x1000000, equals=0x1000000, name="COLOR_SPACE_AGNOSTIC"), @android.view.ViewDebug.FlagToString(mask=0x4000000, equals=0x4000000, name="FIT_INSETS_CONTROLLED"), @android.view.ViewDebug.FlagToString(mask=0x8000000, equals=0x8000000, name="ONLY_DRAW_BOTTOM_BAR_BACKGROUND")}) public int privateFlags; + field @android.view.ViewDebug.ExportedProperty(flagMapping={@android.view.ViewDebug.FlagToString(mask=0x1, equals=0x1, name="FAKE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x2, equals=0x2, name="FORCE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x4, equals=0x4, name="WANTS_OFFSET_NOTIFICATIONS"), @android.view.ViewDebug.FlagToString(mask=0x10, equals=0x10, name="SHOW_FOR_ALL_USERS"), @android.view.ViewDebug.FlagToString(mask=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, equals=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, name="NO_MOVE_ANIMATION"), @android.view.ViewDebug.FlagToString(mask=0x80, equals=0x80, name="COMPATIBLE_WINDOW"), @android.view.ViewDebug.FlagToString(mask=0x100, equals=0x100, name="SYSTEM_ERROR"), @android.view.ViewDebug.FlagToString(mask=0x800, equals=0x800, name="DISABLE_WALLPAPER_TOUCH_EVENTS"), @android.view.ViewDebug.FlagToString(mask=0x1000, equals=0x1000, name="FORCE_STATUS_BAR_VISIBLE"), @android.view.ViewDebug.FlagToString(mask=0x2000, equals=0x2000, name="PRESERVE_GEOMETRY"), @android.view.ViewDebug.FlagToString(mask=0x4000, equals=0x4000, name="FORCE_DECOR_VIEW_VISIBILITY"), @android.view.ViewDebug.FlagToString(mask=0x8000, equals=0x8000, name="WILL_NOT_REPLACE_ON_RELAUNCH"), @android.view.ViewDebug.FlagToString(mask=0x10000, equals=0x10000, name="LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), @android.view.ViewDebug.FlagToString(mask=0x20000, equals=0x20000, name="FORCE_DRAW_STATUS_BAR_BACKGROUND"), @android.view.ViewDebug.FlagToString(mask=0x40000, equals=0x40000, name="SUSTAINED_PERFORMANCE_MODE"), @android.view.ViewDebug.FlagToString(mask=0x80000, equals=0x80000, name="HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), @android.view.ViewDebug.FlagToString(mask=0x100000, equals=0x100000, name="IS_ROUNDED_CORNERS_OVERLAY"), @android.view.ViewDebug.FlagToString(mask=0x400000, equals=0x400000, name="IS_SCREEN_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x800000, equals=0x800000, name="STATUS_FORCE_SHOW_NAVIGATION"), @android.view.ViewDebug.FlagToString(mask=0x1000000, equals=0x1000000, name="COLOR_SPACE_AGNOSTIC"), @android.view.ViewDebug.FlagToString(mask=0x4000000, equals=0x4000000, name="FIT_INSETS_CONTROLLED"), @android.view.ViewDebug.FlagToString(mask=0x8000000, equals=0x8000000, name="ONLY_DRAW_BOTTOM_BAR_BACKGROUND")}) public int privateFlags; } } diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 540e6ef15874..290a13d3feb1 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1131,6 +1131,15 @@ public interface WindowManager extends ViewManager { public static final int TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 39; /** + * Window type: the notification shade and keyguard. There can be only one status bar + * window; it is placed at the top of the screen, and all other + * windows are shifted down so they are below it. + * In multiuser systems shows on all users' windows. + * @hide + */ + public static final int TYPE_NOTIFICATION_SHADE = FIRST_SYSTEM_WINDOW + 40; + + /** * End of types of system windows. */ public static final int LAST_SYSTEM_WINDOW = 2999; @@ -1732,14 +1741,6 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100; /** - * Flag whether the current window is a keyguard window, meaning that it will hide all other - * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set. - * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. - * {@hide} - */ - public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400; - - /** * Flag that prevents the wallpaper behind the current window from receiving touch events. * * {@hide} @@ -1748,12 +1749,12 @@ public interface WindowManager extends ViewManager { /** * Flag to force the status bar window to be visible all the time. If the bar is hidden when - * this flag is set it will be shown again and the bar will have a transparent background. + * this flag is set it will be shown again. * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. * * {@hide} */ - public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000; + public static final int PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR = 0x00001000; /** * Flag indicating that the x, y, width, and height members should be @@ -1917,17 +1918,13 @@ public interface WindowManager extends ViewManager { equals = PRIVATE_FLAG_SYSTEM_ERROR, name = "SYSTEM_ERROR"), @ViewDebug.FlagToString( - mask = PRIVATE_FLAG_KEYGUARD, - equals = PRIVATE_FLAG_KEYGUARD, - name = "KEYGUARD"), - @ViewDebug.FlagToString( mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, name = "DISABLE_WALLPAPER_TOUCH_EVENTS"), @ViewDebug.FlagToString( - mask = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT, - equals = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT, - name = "FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), + mask = PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR, + equals = PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR, + name = "FORCE_STATUS_BAR_VISIBLE"), @ViewDebug.FlagToString( mask = PRIVATE_FLAG_PRESERVE_GEOMETRY, equals = PRIVATE_FLAG_PRESERVE_GEOMETRY, diff --git a/packages/CarSystemUI/res/layout/super_notification_shade.xml b/packages/CarSystemUI/res/layout/super_notification_shade.xml new file mode 100644 index 000000000000..3fe1ea331a07 --- /dev/null +++ b/packages/CarSystemUI/res/layout/super_notification_shade.xml @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2020, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- This is the notification shade window. --> +<com.android.systemui.statusbar.phone.NotificationShadeWindowView + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:sysui="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true"> + + <com.android.systemui.statusbar.BackDropView + android:id="@+id/backdrop" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + sysui:ignoreRightInset="true" + > + <ImageView android:id="@+id/backdrop_back" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scaleType="centerCrop"/> + <ImageView android:id="@+id/backdrop_front" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scaleType="centerCrop" + android:visibility="invisible"/> + </com.android.systemui.statusbar.BackDropView> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_for_bubble" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_behind" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/status_bar_height" + android:orientation="vertical" + > + <FrameLayout + android:id="@+id/status_bar_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + /> + + <FrameLayout + android:id="@+id/car_top_navigation_bar_container" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> + </LinearLayout> + + <include layout="@layout/brightness_mirror"/> + + <ViewStub android:id="@+id/fullscreen_user_switcher_stub" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout="@layout/car_fullscreen_user_switcher"/> + + <include layout="@layout/notification_center_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginBottom="@dimen/navigation_bar_height" + android:visibility="invisible"/> + + <include layout="@layout/headsup_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="invisible"/> + + <include layout="@layout/status_bar_expanded" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="invisible"/> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_in_front" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + +</com.android.systemui.statusbar.phone.NotificationShadeWindowView> diff --git a/packages/CarSystemUI/res/layout/super_status_bar.xml b/packages/CarSystemUI/res/layout/super_status_bar.xml index 0b346260896a..c7b22f823ba4 100644 --- a/packages/CarSystemUI/res/layout/super_status_bar.xml +++ b/packages/CarSystemUI/res/layout/super_status_bar.xml @@ -1,21 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Copyright (C) 2018 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License - --> - -<!-- This is the combined status bar / notification panel window. --> +** +** Copyright 2020, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- This is the status bar window. --> <com.android.systemui.statusbar.phone.StatusBarWindowView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto" @@ -23,87 +25,9 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> - <com.android.systemui.statusbar.BackDropView - android:id="@+id/backdrop" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - sysui:ignoreRightInset="true" - > - <ImageView android:id="@+id/backdrop_back" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop"/> - <ImageView android:id="@+id/backdrop_front" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop" - android:visibility="invisible"/> - </com.android.systemui.statusbar.BackDropView> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_for_bubble" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_behind" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="@dimen/status_bar_height" - android:orientation="vertical" - > - <FrameLayout - android:id="@+id/status_bar_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" - /> - - <FrameLayout - android:id="@+id/car_top_navigation_bar_container" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - </LinearLayout> - - <include layout="@layout/brightness_mirror"/> - - <ViewStub android:id="@+id/fullscreen_user_switcher_stub" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout="@layout/car_fullscreen_user_switcher"/> - - <include layout="@layout/notification_center_activity" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_marginBottom="@dimen/navigation_bar_height" - android:visibility="invisible"/> - - <include layout="@layout/headsup_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="invisible"/> - - <include layout="@layout/status_bar_expanded" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="invisible"/> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_in_front" + <FrameLayout + android:id="@+id/status_bar_container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> + android:layout_height="wrap_content" /> </com.android.systemui.statusbar.phone.StatusBarWindowView> diff --git a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java index d8c9d17e7179..78764dd19741 100644 --- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java @@ -235,7 +235,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks private void buildNavBarWindows() { mTopNavigationBarWindow = mSuperStatusBarViewFactory - .getStatusBarWindowView() + .getNotificationShadeWindowView() .findViewById(R.id.car_top_navigation_bar_container); mBottomNavigationBarWindow = mCarNavigationBarController.getBottomWindow(); mLeftNavigationBarWindow = mCarNavigationBarController.getLeftWindow(); diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarShadeControllerImpl.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarShadeControllerImpl.java index d1d352a08908..755ed25d64e2 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarShadeControllerImpl.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarShadeControllerImpl.java @@ -24,10 +24,10 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ShadeControllerImpl; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import javax.inject.Inject; import javax.inject.Singleton; @@ -41,13 +41,13 @@ public class CarShadeControllerImpl extends ShadeControllerImpl { @Inject public CarShadeControllerImpl(CommandQueue commandQueue, StatusBarStateController statusBarStateController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, WindowManager windowManager, Lazy<StatusBar> statusBarLazy, Lazy<AssistManager> assistManagerLazy, Lazy<BubbleController> bubbleControllerLazy) { - super(commandQueue, statusBarStateController, statusBarWindowController, + super(commandQueue, statusBarStateController, notificationShadeWindowController, statusBarKeyguardViewManager, windowManager, statusBarLazy, assistManagerLazy, bubbleControllerLazy); } @@ -61,14 +61,14 @@ public class CarShadeControllerImpl extends ShadeControllerImpl { return; } - mStatusBarWindowController.setStatusBarFocusable(false); - getCarStatusBar().getStatusBarWindowViewController().cancelExpandHelper(); + mNotificationShadeWindowController.setNotificationShadeFocusable(false); + getCarStatusBar().getNotificationShadeWindowViewController().cancelExpandHelper(); getStatusBarView().collapsePanel(true /* animate */, delayed, speedUpFactor); getCarStatusBar().animateNotificationPanel(getCarStatusBar().getClosingVelocity(), true); if (!getCarStatusBar().isTracking()) { - mStatusBarWindowController.setPanelVisible(false); + mNotificationShadeWindowController.setPanelVisible(false); getCarNotificationView().setVisibility(View.INVISIBLE); } diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index 18485dc283f0..76e9ec64e2f2 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -126,13 +126,13 @@ import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -303,7 +303,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt Lazy<AssistManager> assistManagerLazy, NotificationListener notificationListener, ConfigurationController configurationController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, LockscreenLockIconController lockscreenLockIconController, DozeParameters dozeParameters, ScrimController scrimController, @@ -391,7 +391,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt assistManagerLazy, notificationListener, configurationController, - statusBarWindowController, + notificationShadeWindowController, lockscreenLockIconController, dozeParameters, scrimController, @@ -545,7 +545,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt mNotificationPanelBackground = getDefaultWallpaper(); mScrimController.setScrimBehindDrawable(mNotificationPanelBackground); - FragmentHostManager manager = FragmentHostManager.get(mStatusBarWindow); + FragmentHostManager manager = FragmentHostManager.get(mPhoneStatusBarWindow); manager.addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> { mBatteryMeterView = fragment.getView().findViewById(R.id.battery); @@ -646,9 +646,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt carNotificationListener.registerAsSystemService(mContext, mCarUxRestrictionManagerWrapper, carHeadsUpNotificationManager, mNotificationDataManager); - mNotificationView = mStatusBarWindow.findViewById(R.id.notification_view); - View glassPane = mStatusBarWindow.findViewById(R.id.glass_pane); - mHandleBar = mStatusBarWindow.findViewById(R.id.handle_bar); + final View glassPane = mNotificationShadeWindowView.findViewById(R.id.glass_pane); + mNotificationView = mNotificationShadeWindowView.findViewById(R.id.notification_view); + mHandleBar = mNotificationShadeWindowView.findViewById(R.id.handle_bar); mNotificationView.setClickHandlerFactory(mNotificationClickHandlerFactory); mNotificationView.setNotificationDataManager(mNotificationDataManager); @@ -779,7 +779,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt } // scroll to top mNotificationList.scrollToPosition(0); - mStatusBarWindowController.setPanelVisible(true); + mNotificationShadeWindowController.setPanelVisible(true); mNotificationView.setVisibility(View.VISIBLE); animateNotificationPanel(mOpeningVelocity, false); @@ -863,7 +863,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt mOpeningVelocity = DEFAULT_FLING_VELOCITY; mClosingVelocity = DEFAULT_FLING_VELOCITY; if (isClosing) { - mStatusBarWindowController.setPanelVisible(false); + mNotificationShadeWindowController.setPanelVisible(false); mNotificationView.setVisibility(View.INVISIBLE); mNotificationView.setClipBounds(null); mNotificationViewController.onVisibilityChanged(false); @@ -1128,7 +1128,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt // when the on-scroll is called for the first time to open. mNotificationList.scrollToPosition(0); } - mStatusBarWindowController.setPanelVisible(true); + mNotificationShadeWindowController.setPanelVisible(true); mNotificationView.setVisibility(View.VISIBLE); // clips the view for the notification shade when the user scrolls to open. @@ -1294,7 +1294,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt @Override protected View createHeadsUpPanel() { // In SystemUi the view is already in the window so just return a reference. - return mStatusBarWindow.findViewById(R.id.notification_headsup); + return mNotificationShadeWindowView.findViewById(R.id.notification_headsup); } @Override @@ -1320,7 +1320,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt super.setHeadsUpVisible(); if (mHeadsUpPanel.getVisibility() == View.VISIBLE) { - mStatusBarWindowController.setHeadsUpShowing(true); + mNotificationShadeWindowController.setHeadsUpShowing(true); mStatusBarWindowController.setForceStatusBarVisible(true); } } @@ -1330,7 +1330,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt super.removeNotificationFromPanel(currentHeadsUpNotification); // If the panel ended up empty and hidden we can remove it from SystemUi if (mHeadsUpPanel.getVisibility() != View.VISIBLE) { - mStatusBarWindowController.setHeadsUpShowing(false); + mNotificationShadeWindowController.setHeadsUpShowing(false); mStatusBarWindowController.setForceStatusBarVisible(false); } } diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarKeyguardViewManager.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarKeyguardViewManager.java index 2a2eb6976653..59f9f94c4d05 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarKeyguardViewManager.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarKeyguardViewManager.java @@ -28,8 +28,8 @@ import com.android.systemui.navigationbar.car.CarNavigationBarController; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.phone.NavigationModeController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; @@ -53,14 +53,14 @@ public class CarStatusBarKeyguardViewManager extends StatusBarKeyguardViewManage KeyguardUpdateMonitor keyguardUpdateMonitor, NavigationModeController navigationModeController, DockManager dockManager, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, KeyguardStateController keyguardStateController, NotificationMediaManager notificationMediaManager, CarNavigationBarController carNavigationBarController, FullscreenUserSwitcher fullscreenUserSwitcher) { super(context, callback, lockPatternUtils, sysuiStatusBarStateController, configurationController, keyguardUpdateMonitor, navigationModeController, - dockManager, statusBarWindowController, keyguardStateController, + dockManager, notificationShadeWindowController, keyguardStateController, notificationMediaManager); mShouldHideNavBar = context.getResources() .getBoolean(R.bool.config_hideNavWhenKeyguardBouncerShown); diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java index 3abbe32df2da..45da8223943b 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java @@ -85,12 +85,12 @@ import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -173,7 +173,7 @@ public class CarStatusBarModule { Lazy<AssistManager> assistManagerLazy, NotificationListener notificationListener, ConfigurationController configurationController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, LockscreenLockIconController lockscreenLockIconController, DozeParameters dozeParameters, ScrimController scrimController, @@ -260,7 +260,7 @@ public class CarStatusBarModule { assistManagerLazy, notificationListener, configurationController, - statusBarWindowController, + notificationShadeWindowController, lockscreenLockIconController, dozeParameters, scrimController, diff --git a/packages/SystemUI/res/layout/super_notification_shade.xml b/packages/SystemUI/res/layout/super_notification_shade.xml new file mode 100644 index 000000000000..dc070cbaae26 --- /dev/null +++ b/packages/SystemUI/res/layout/super_notification_shade.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2020, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- This is the notification shade window. --> +<com.android.systemui.statusbar.phone.NotificationShadeWindowView + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:sysui="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true"> + + <com.android.systemui.statusbar.BackDropView + android:id="@+id/backdrop" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + sysui:ignoreRightInset="true" + > + <ImageView android:id="@+id/backdrop_back" + android:layout_width="match_parent" + android:scaleType="centerCrop" + android:layout_height="match_parent" /> + <ImageView android:id="@+id/backdrop_front" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scaleType="centerCrop" + android:visibility="invisible" /> + </com.android.systemui.statusbar.BackDropView> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_for_bubble" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_behind" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + + <include layout="@layout/status_bar_expanded" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="invisible" /> + + <include layout="@layout/brightness_mirror" /> + + <com.android.systemui.statusbar.ScrimView + android:id="@+id/scrim_in_front" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + sysui:ignoreRightInset="true" + /> + + <LinearLayout + android:id="@+id/lock_icon_container" + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/status_bar_height" + android:layout_gravity="top|center_horizontal"> + <com.android.systemui.statusbar.phone.LockIcon + android:id="@+id/lock_icon" + android:layout_width="@dimen/keyguard_lock_width" + android:layout_height="@dimen/keyguard_lock_height" + android:layout_gravity="center_horizontal" + android:layout_marginTop="@dimen/keyguard_lock_padding" + android:contentDescription="@string/accessibility_unlock_button" + android:src="@*android:drawable/ic_lock" + android:scaleType="center" /> + <com.android.keyguard.KeyguardMessageArea + android:id="@+id/keyguard_message_area" + style="@style/Keyguard.TextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/keyguard_lock_padding" + android:gravity="center" + android:singleLine="true" + android:ellipsize="marquee" + android:focusable="true" /> + </LinearLayout> +</com.android.systemui.statusbar.phone.NotificationShadeWindowView> diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml index 9716a00a7f72..8fee2cf9597e 100644 --- a/packages/SystemUI/res/layout/super_status_bar.xml +++ b/packages/SystemUI/res/layout/super_status_bar.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <!-- ** -** Copyright 2012, The Android Open Source Project +** Copyright 2020, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ */ --> -<!-- This is the combined status bar / notification panel window. --> +<!-- This is the status bar window. --> <com.android.systemui.statusbar.phone.StatusBarWindowView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto" @@ -25,85 +25,8 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> - <com.android.systemui.statusbar.BackDropView - android:id="@+id/backdrop" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - sysui:ignoreRightInset="true" - > - <ImageView android:id="@+id/backdrop_back" - android:layout_width="match_parent" - android:scaleType="centerCrop" - android:layout_height="match_parent" /> - <ImageView android:id="@+id/backdrop_front" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop" - android:visibility="invisible" /> - </com.android.systemui.statusbar.BackDropView> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_for_bubble" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> - <FrameLayout android:id="@+id/status_bar_container" android:layout_width="match_parent" android:layout_height="wrap_content" /> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_behind" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> - - <include layout="@layout/status_bar_expanded" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="invisible" /> - - <include layout="@layout/brightness_mirror" /> - - <com.android.systemui.statusbar.ScrimView - android:id="@+id/scrim_in_front" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:importantForAccessibility="no" - sysui:ignoreRightInset="true" - /> - - <LinearLayout - android:id="@+id/lock_icon_container" - android:orientation="vertical" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/status_bar_height" - android:layout_gravity="top|center_horizontal"> - <com.android.systemui.statusbar.phone.LockIcon - android:id="@+id/lock_icon" - android:layout_width="@dimen/keyguard_lock_width" - android:layout_height="@dimen/keyguard_lock_height" - android:layout_gravity="center_horizontal" - android:layout_marginTop="@dimen/keyguard_lock_padding" - android:contentDescription="@string/accessibility_unlock_button" - android:src="@*android:drawable/ic_lock" - android:scaleType="center" /> - <com.android.keyguard.KeyguardMessageArea - android:id="@+id/keyguard_message_area" - style="@style/Keyguard.TextView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/keyguard_lock_padding" - android:gravity="center" - android:singleLine="true" - android:ellipsize="marquee" - android:focusable="true" /> - </LinearLayout> </com.android.systemui.statusbar.phone.StatusBarWindowView> diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index d1495913d95f..aacc2c4f614b 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -89,6 +89,7 @@ import com.android.systemui.statusbar.phone.ManagedProfileController; import com.android.systemui.statusbar.phone.NavigationModeController; import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarIconController; @@ -238,7 +239,8 @@ public class Dependency { @Inject Lazy<LeakReporter> mLeakReporter; @Inject Lazy<GarbageMonitor> mGarbageMonitor; @Inject Lazy<TunerService> mTunerService; - @Inject Lazy<StatusBarWindowController> mStatusBarWindowController; + @Inject Lazy<NotificationShadeWindowController> mNotificationShadeWindowController; + @Inject Lazy<StatusBarWindowController> mTempStatusBarWindowController; @Inject Lazy<DarkIconDispatcher> mDarkIconDispatcher; @Inject Lazy<ConfigurationController> mConfigurationController; @Inject Lazy<StatusBarIconController> mStatusBarIconController; @@ -400,7 +402,10 @@ public class Dependency { mProviders.put(TunerService.class, mTunerService::get); - mProviders.put(StatusBarWindowController.class, mStatusBarWindowController::get); + mProviders.put(NotificationShadeWindowController.class, + mNotificationShadeWindowController::get); + + mProviders.put(StatusBarWindowController.class, mTempStatusBarWindowController::get); mProviders.put(DarkIconDispatcher.class, mDarkIconDispatcher::get); diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index c533755c76da..db8b5831faf1 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -455,17 +455,25 @@ public class ScreenDecorations extends SystemUI implements Tunable { private void setupStatusBarPadding(int padding) { // Add some padding to all the content near the edge of the screen. StatusBar statusBar = mStatusBarLazy.get(); - View statusBarWindow = statusBar.getStatusBarWindow(); - if (statusBarWindow != null) { - TunablePadding.addTunablePadding(statusBarWindow.findViewById(R.id.keyguard_header), + final View notificationShadeWindowView = statusBar.getNotificationShadeWindowView(); + if (notificationShadeWindowView != null) { + TunablePadding.addTunablePadding( + notificationShadeWindowView.findViewById(R.id.keyguard_header), PADDING, padding, FLAG_END); - FragmentHostManager fragmentHostManager = FragmentHostManager.get(statusBarWindow); - fragmentHostManager.addTagListener(CollapsedStatusBarFragment.TAG, - new TunablePaddingTagListener(padding, R.id.status_bar)); + final FragmentHostManager fragmentHostManager = + FragmentHostManager.get(notificationShadeWindowView); fragmentHostManager.addTagListener(QS.TAG, new TunablePaddingTagListener(padding, R.id.header)); } + + final View statusBarWindow = statusBar.getStatusBarWindow(); + if (statusBarWindow != null) { + final FragmentHostManager fragmentHostManager = + FragmentHostManager.get(statusBarWindow); + fragmentHostManager.addTagListener(CollapsedStatusBarFragment.TAG, + new TunablePaddingTagListener(padding, R.id.status_bar)); + } } @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index d835ee1865bf..644d8c48c63c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -89,9 +89,9 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.RemoteInputUriController; import com.android.systemui.statusbar.policy.ZenModeController; @@ -166,7 +166,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private final HashSet<String> mUserBlockedBubbles; // Bubbles get added to the status bar view - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private final ZenModeController mZenModeController; private StatusBarStateListener mStatusBarStateListener; private final ScreenshotHelper mScreenshotHelper; @@ -245,7 +245,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @Inject public BubbleController(Context context, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, StatusBarStateController statusBarStateController, ShadeController shadeController, BubbleData data, @@ -256,14 +256,14 @@ public class BubbleController implements ConfigurationController.ConfigurationLi NotificationGroupManager groupManager, NotificationEntryManager entryManager, RemoteInputUriController remoteInputUriController) { - this(context, statusBarWindowController, statusBarStateController, shadeController, + this(context, notificationShadeWindowController, statusBarStateController, shadeController, data, null /* synchronizer */, configurationController, interruptionStateProvider, zenModeController, notifUserManager, groupManager, entryManager, remoteInputUriController); } public BubbleController(Context context, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, StatusBarStateController statusBarStateController, ShadeController shadeController, BubbleData data, @@ -324,7 +324,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } }); - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mStatusBarStateListener = new StatusBarStateListener(); statusBarStateController.addCallback(mStatusBarStateListener); @@ -377,10 +377,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private void ensureStackViewCreated() { if (mStackView == null) { mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer); - ViewGroup sbv = mStatusBarWindowController.getStatusBarView(); - int bubbleScrimIndex = sbv.indexOfChild(sbv.findViewById(R.id.scrim_for_bubble)); + ViewGroup nsv = mNotificationShadeWindowController.getNotificationShadeView(); + int bubbleScrimIndex = nsv.indexOfChild(nsv.findViewById(R.id.scrim_for_bubble)); int stackIndex = bubbleScrimIndex + 1; // Show stack above bubble scrim. - sbv.addView(mStackView, stackIndex, + nsv.addView(mStackView, stackIndex, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); if (mExpandListener != null) { mStackView.setExpandListener(mExpandListener); @@ -473,7 +473,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi if (listener != null) { listener.onBubbleExpandChanged(isExpanding, key); } - mStatusBarWindowController.setBubbleExpanded(isExpanding); + mNotificationShadeWindowController.setBubbleExpanded(isExpanding); }); if (mStackView != null) { mStackView.setExpandListener(mExpandListener); @@ -944,9 +944,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } // Let listeners know if bubble state changed. - boolean hadBubbles = mStatusBarWindowController.getBubblesShowing(); + boolean hadBubbles = mNotificationShadeWindowController.getBubblesShowing(); boolean hasBubblesShowing = hasBubbles() && mStackView.getVisibility() == VISIBLE; - mStatusBarWindowController.setBubblesShowing(hasBubblesShowing); + mNotificationShadeWindowController.setBubblesShowing(hasBubblesShowing); if (mStateChangeListener != null && hadBubbles != hasBubblesShowing) { mStateChangeListener.onHasBubblesChanged(hasBubblesShowing); } @@ -983,7 +983,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi && context.getDisplay().getDisplayId() == DEFAULT_DISPLAY; final Bubble expandedBubble = mStackView.getExpandedBubble(); if (defaultDisplay && expandedBubble != null && isStackExpanded() - && !mStatusBarWindowController.getPanelExpanded()) { + && !mNotificationShadeWindowController.getPanelExpanded()) { return expandedBubble; } return null; diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index c138462d06c4..36a4a10b8a3f 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -97,8 +97,8 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; import com.android.systemui.plugins.GlobalActionsPanelPlugin; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.EmergencyDialerConstants; @@ -1528,7 +1528,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private float mScrimAlpha; private ResetOrientationData mResetOrientationData; private boolean mHadTopUi; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private boolean mControlsEnabled; ActionsDialog(Context context, MyAdapter adapter, @@ -1539,7 +1539,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mAdapter = adapter; mColorExtractor = Dependency.get(SysuiColorExtractor.class); mStatusBarService = Dependency.get(IStatusBarService.class); - mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); + mNotificationShadeWindowController = + Dependency.get(NotificationShadeWindowController.class); mControlsEnabled = controlsEnabled; // Window initialization @@ -1721,8 +1722,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, public void show() { super.show(); mShowing = true; - mHadTopUi = mStatusBarWindowController.getForceHasTopUi(); - mStatusBarWindowController.setForceHasTopUi(true); + mHadTopUi = mNotificationShadeWindowController.getForceHasTopUi(); + mNotificationShadeWindowController.setForceHasTopUi(true); mBackgroundDrawable.setAlpha(0); mGlobalActionsLayout.setTranslationX(mGlobalActionsLayout.getAnimationOffsetX()); mGlobalActionsLayout.setTranslationY(mGlobalActionsLayout.getAnimationOffsetY()); @@ -1775,7 +1776,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } private void completeDismiss() { - mStatusBarWindowController.setForceHasTopUi(mHadTopUi); + mNotificationShadeWindowController.setForceHasTopUi(mHadTopUi); super.dismiss(); } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index e13c3e087893..2fc7a9cf2434 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -88,9 +88,9 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.util.InjectionInflationController; import java.io.FileDescriptor; @@ -212,7 +212,7 @@ public class KeyguardViewMediator extends SystemUI { private AlarmManager mAlarmManager; private AudioManager mAudioManager; private StatusBarManager mStatusBarManager; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private final Executor mUiBgExecutor; private boolean mSystemReady; @@ -691,7 +691,7 @@ public class KeyguardViewMediator extends SystemUI { FalsingManager falsingManager, LockPatternUtils lockPatternUtils, BroadcastDispatcher broadcastDispatcher, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, Lazy<StatusBarKeyguardViewManager> statusBarKeyguardViewManagerLazy, DismissCallbackRegistry dismissCallbackRegistry, @UiBackground Executor uiBgExecutor) { @@ -699,7 +699,7 @@ public class KeyguardViewMediator extends SystemUI { mFalsingManager = falsingManager; mLockPatternUtils = lockPatternUtils; mBroadcastDispatcher = broadcastDispatcher; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mStatusBarKeyguardViewManagerLazy = statusBarKeyguardViewManagerLazy; mDismissCallbackRegistry = dismissCallbackRegistry; mUiBgExecutor = uiBgExecutor; @@ -1819,7 +1819,7 @@ public class KeyguardViewMediator extends SystemUI { adjustStatusBarLocked(); userActivity(); mUpdateMonitor.setKeyguardGoingAway(false); - mStatusBarWindowController.setKeyguardGoingAway(false); + mNotificationShadeWindowController.setKeyguardGoingAway(false); mShowKeyguardWakeLock.release(); } mKeyguardDisplayManager.show(); @@ -1852,7 +1852,7 @@ public class KeyguardViewMediator extends SystemUI { } mUpdateMonitor.setKeyguardGoingAway(true); - mStatusBarWindowController.setKeyguardGoingAway(true); + mNotificationShadeWindowController.setKeyguardGoingAway(true); // Don't actually hide the Keyguard at the moment, wait for window // manager until it tells us it's safe to do so with diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index ae48db2f4200..569f660d1797 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -68,9 +68,9 @@ import com.android.systemui.statusbar.NavigationBarController; import com.android.systemui.statusbar.phone.NavigationBarFragment; import com.android.systemui.statusbar.phone.NavigationBarView; import com.android.systemui.statusbar.phone.NavigationModeController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.CallbackController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener; @@ -109,7 +109,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis private SysUiState mSysUiState; private final Handler mHandler; private final NavigationBarController mNavBarController; - private final StatusBarWindowController mStatusBarWinController; + private final NotificationShadeWindowController mStatusBarWinController; private final Runnable mConnectionRunnable = this::internalConnectToCurrentUser; private final ComponentName mRecentsComponentName; private final DeviceProvisionedController mDeviceProvisionedController; @@ -476,8 +476,9 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis @Inject public OverviewProxyService(Context context, DeviceProvisionedController provisionController, NavigationBarController navBarController, NavigationModeController navModeController, - StatusBarWindowController statusBarWinController, SysUiState sysUiState, PipUI pipUI, - Optional<Divider> dividerOptional, Optional<Lazy<StatusBar>> statusBarOptionalLazy) { + NotificationShadeWindowController statusBarWinController, SysUiState sysUiState, + PipUI pipUI, Optional<Divider> dividerOptional, + Optional<Lazy<StatusBar>> statusBarOptionalLazy) { mContext = context; mPipUI = pipUI; mStatusBarOptionalLazy = statusBarOptionalLazy; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index 246b0f0e19ff..a4572665ebf1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -59,10 +59,10 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ScrimState; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.KeyguardStateController; import java.io.FileDescriptor; @@ -105,7 +105,7 @@ public class NotificationMediaManager implements Dumpable { private final NotificationEntryManager mEntryManager; @Nullable - private Lazy<StatusBarWindowController> mStatusBarWindowController; + private Lazy<NotificationShadeWindowController> mStatusBarWindowController; @Nullable private BiometricUnlockController mBiometricUnlockController; @@ -180,7 +180,7 @@ public class NotificationMediaManager implements Dumpable { public NotificationMediaManager( Context context, Lazy<StatusBar> statusBarLazy, - Lazy<StatusBarWindowController> statusBarWindowController, + Lazy<NotificationShadeWindowController> statusBarWindowController, NotificationEntryManager notificationEntryManager, MediaArtworkProcessor mediaArtworkProcessor, KeyguardBypassController keyguardBypassController) { @@ -525,7 +525,7 @@ public class NotificationMediaManager implements Dumpable { } } - StatusBarWindowController windowController = mStatusBarWindowController.get(); + NotificationShadeWindowController windowController = mStatusBarWindowController.get(); boolean hideBecauseOccluded = mStatusBarLazy.get().isOccluded(); final boolean hasArtwork = artworkDrawable != null; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java index 9398e6f689f6..0ab5afaab696 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java @@ -23,6 +23,7 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.NotificationPanelView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.util.InjectionInflationController; @@ -30,8 +31,8 @@ import javax.inject.Inject; import javax.inject.Singleton; /** - * Creates a single instance of super_status_bar that can be shared across various system ui - * objects. + * Creates a single instance of super_status_bar and super_notification_shade that can be shared + * across various system ui objects. */ @Singleton public class SuperStatusBarViewFactory { @@ -39,6 +40,7 @@ public class SuperStatusBarViewFactory { private final Context mContext; private final InjectionInflationController mInjectionInflationController; + private NotificationShadeWindowView mNotificationShadeWindowView; private StatusBarWindowView mStatusBarWindowView; private NotificationShelf mNotificationShelf; @@ -50,15 +52,42 @@ public class SuperStatusBarViewFactory { } /** - * Gets the inflated {@link StatusBarWindowView} from {@link R.layout#super_status_bar}. Returns - * a cached instance, if it has already been inflated. + * Gets the inflated {@link NotificationShadeWindowView} from + * {@link R.layout#super_notification_shade}. + * Returns a cached instance, if it has already been inflated. + */ + public NotificationShadeWindowView getNotificationShadeWindowView() { + if (mNotificationShadeWindowView != null) { + return mNotificationShadeWindowView; + } + + mNotificationShadeWindowView = (NotificationShadeWindowView) + mInjectionInflationController.injectable( + LayoutInflater.from(mContext)).inflate(R.layout.super_notification_shade, + /* root= */ null); + if (mNotificationShadeWindowView == null) { + throw new IllegalStateException( + "R.layout.super_notification_shade could not be properly inflated"); + } + return mNotificationShadeWindowView; + } + + /** Gets the {@link LockIcon} inside of {@link R.layout#super_status_bar}. */ + public LockIcon getLockIcon() { + return getNotificationShadeWindowView().findViewById(R.id.lock_icon); + } + + /** + * Gets the inflated {@link StatusBarWindowView} from {@link R.layout#super_status_bar}. + * Returns a cached instance, if it has already been inflated. */ public StatusBarWindowView getStatusBarWindowView() { if (mStatusBarWindowView != null) { return mStatusBarWindowView; } - mStatusBarWindowView = (StatusBarWindowView) mInjectionInflationController.injectable( + mStatusBarWindowView = + (StatusBarWindowView) mInjectionInflationController.injectable( LayoutInflater.from(mContext)).inflate(R.layout.super_status_bar, /* root= */ null); if (mStatusBarWindowView == null) { @@ -68,11 +97,6 @@ public class SuperStatusBarViewFactory { return mStatusBarWindowView; } - /** Gets the {@link LockIcon} inside of {@link R.layout#super_status_bar}. */ - public LockIcon getLockIcon() { - return getStatusBarWindowView().findViewById(R.id.lock_icon); - } - /** * Gets the inflated {@link NotificationShelf} from * {@link R.layout#status_bar_notification_shelf}. @@ -98,11 +122,11 @@ public class SuperStatusBarViewFactory { } public NotificationPanelView getNotificationPanelView() { - StatusBarWindowView statusBarWindowView = getStatusBarWindowView(); - if (statusBarWindowView == null) { + NotificationShadeWindowView notificationShadeWindowView = getNotificationShadeWindowView(); + if (notificationShadeWindowView == null) { return null; } - return mStatusBarWindowView.findViewById(R.id.notification_panel); + return mNotificationShadeWindowView.findViewById(R.id.notification_panel); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java index 66605690b106..5fc043ada22d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java @@ -38,7 +38,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBarWindowViewController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; /** * A class that allows activities to be launched in a seamless way where the notification @@ -56,7 +56,7 @@ public class ActivityLaunchAnimator { private final NotificationPanelViewController mNotificationPanel; private final NotificationListContainer mNotificationContainer; private final float mWindowCornerRadius; - private final StatusBarWindowViewController mStatusBarWindowViewController; + private final NotificationShadeWindowViewController mNotificationShadeWindowViewController; private Callback mCallback; private final Runnable mTimeoutRunnable = () -> { setAnimationPending(false); @@ -67,21 +67,23 @@ public class ActivityLaunchAnimator { private boolean mIsLaunchForActivity; public ActivityLaunchAnimator( - StatusBarWindowViewController statusBarWindowViewController, + NotificationShadeWindowViewController notificationShadeWindowViewController, Callback callback, NotificationPanelViewController notificationPanel, NotificationListContainer container) { mNotificationPanel = notificationPanel; mNotificationContainer = container; - mStatusBarWindowViewController = statusBarWindowViewController; + mNotificationShadeWindowViewController = notificationShadeWindowViewController; mCallback = callback; mWindowCornerRadius = ScreenDecorationsUtils - .getWindowCornerRadius(mStatusBarWindowViewController.getView().getResources()); + .getWindowCornerRadius(mNotificationShadeWindowViewController.getView() + .getResources()); } public RemoteAnimationAdapter getLaunchAnimation( View sourceView, boolean occluded) { - if (!(sourceView instanceof ExpandableNotificationRow) || !mCallback.areLaunchAnimationsEnabled() || occluded) { + if (!(sourceView instanceof ExpandableNotificationRow) + || !mCallback.areLaunchAnimationsEnabled() || occluded) { return null; } AnimationRunner animationRunner = new AnimationRunner( @@ -113,11 +115,12 @@ public class ActivityLaunchAnimator { private void setAnimationPending(boolean pending) { mAnimationPending = pending; - mStatusBarWindowViewController.setExpandAnimationPending(pending); + mNotificationShadeWindowViewController.setExpandAnimationPending(pending); if (pending) { - mStatusBarWindowViewController.getView().postDelayed(mTimeoutRunnable, LAUNCH_TIMEOUT); + mNotificationShadeWindowViewController.getView().postDelayed(mTimeoutRunnable, + LAUNCH_TIMEOUT); } else { - mStatusBarWindowViewController.getView().removeCallbacks(mTimeoutRunnable); + mNotificationShadeWindowViewController.getView().removeCallbacks(mTimeoutRunnable); } } @@ -247,7 +250,7 @@ public class ActivityLaunchAnimator { private void setExpandAnimationRunning(boolean running) { mNotificationPanel.setLaunchingNotification(running); mSourceNotification.setExpandAnimationRunning(running); - mStatusBarWindowViewController.setExpandAnimationRunning(running); + mNotificationShadeWindowViewController.setExpandAnimationRunning(running); mNotificationContainer.setExpandingNotification(running ? mSourceNotification : null); mAnimationRunning = running; if (!running) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java index 76fdfc6fbabc..874d81db0bd2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java @@ -47,7 +47,7 @@ import com.android.systemui.qs.QuickQSPanel; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.TransformableView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.statusbar.phone.StatusBarWindowController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.util.Utils; import java.util.Timer; @@ -181,8 +181,9 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi final int[] compactActions = mRow.getEntry().getSbn().getNotification().extras .getIntArray(Notification.EXTRA_COMPACT_ACTIONS); int tintColor = getNotificationHeader().getOriginalIconColor(); - StatusBarWindowController ctrl = Dependency.get(StatusBarWindowController.class); - QuickQSPanel panel = ctrl.getStatusBarView().findViewById( + NotificationShadeWindowController ctrl = Dependency.get( + NotificationShadeWindowController.class); + QuickQSPanel panel = ctrl.getNotificationShadeView().findViewById( com.android.systemui.R.id.quick_qs_panel); StatusBarNotification sbn = mRow.getEntry().getSbn(); Notification notif = sbn.getNotification(); @@ -193,7 +194,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi mActions, compactActions, notif.contentIntent); - QSPanel bigPanel = ctrl.getStatusBarView().findViewById( + QSPanel bigPanel = ctrl.getNotificationShadeView().findViewById( com.android.systemui.R.id.quick_settings_panel); bigPanel.addMediaSession(token, notif.getSmallIcon(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index 48805204160f..691e1c422bfe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -141,7 +141,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final KeyguardUpdateMonitor mUpdateMonitor; private final DozeParameters mDozeParameters; private final KeyguardStateController mKeyguardStateController; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private final Context mContext; private final int mWakeUpDelay; private int mMode; @@ -162,7 +162,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp public BiometricUnlockController(Context context, DozeScrimController dozeScrimController, KeyguardViewMediator keyguardViewMediator, ScrimController scrimController, StatusBar statusBar, ShadeController shadeController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, KeyguardStateController keyguardStateController, Handler handler, KeyguardUpdateMonitor keyguardUpdateMonitor, @Main Resources resources, @@ -177,7 +177,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mMediaManager = Dependency.get(NotificationMediaManager.class); Dependency.get(WakefulnessLifecycle.class).addObserver(mWakefulnessObserver); Dependency.get(ScreenLifecycle.class).addObserver(mScreenObserver); - mStatusBarWindowController = statusBarWindowController; + + mNotificationShadeWindowController = notificationShadeWindowController; mDozeScrimController = dozeScrimController; mKeyguardViewMediator = keyguardViewMediator; mScrimController = scrimController; @@ -284,7 +285,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp // notifications would light up first, creating an unpleasant animation. // Defer changing the screen brightness by forcing doze brightness on our window // until the clock and the notifications are faded out. - mStatusBarWindowController.setForceDozeBrightness(true); + mNotificationShadeWindowController.setForceDozeBrightness(true); } // During wake and unlock, we need to draw black before waking up to avoid abrupt // brightness changes due to display state transitions. @@ -340,7 +341,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp Trace.beginSection("MODE_WAKE_AND_UNLOCK_FROM_DREAM"); mUpdateMonitor.awakenFromDream(); } - mStatusBarWindowController.setStatusBarFocusable(false); + mNotificationShadeWindowController.setNotificationShadeFocusable(false); if (delayWakeUp) { mHandler.postDelayed(wakeUp, mWakeUpDelay); } else { @@ -508,7 +509,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mHandler.postDelayed(new Runnable() { @Override public void run() { - mStatusBarWindowController.setForceDozeBrightness(false); + mNotificationShadeWindowController.setForceDozeBrightness(false); } }, StatusBar.FADE_KEYGUARD_DURATION_PULSING); } @@ -522,7 +523,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private void resetMode() { mMode = MODE_NONE; - mStatusBarWindowController.setForceDozeBrightness(false); + mNotificationShadeWindowController.setForceDozeBrightness(false); if (mStatusBar.getNavigationBarView() != null) { mStatusBar.getNavigationBarView().setWakeAndUnlocking(false); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java index accd2a4fcc0d..04efc2d7558d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java @@ -85,9 +85,9 @@ public final class DozeServiceHost implements DozeHost { private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final VisualStabilityManager mVisualStabilityManager; private final PulseExpansionHandler mPulseExpansionHandler; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; - private StatusBarWindowViewController mStatusBarWindowViewController; + private NotificationShadeWindowViewController mNotificationShadeWindowViewController; private final LockscreenLockIconController mLockscreenLockIconController; private NotificationIconAreaController mNotificationIconAreaController; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @@ -108,7 +108,7 @@ public final class DozeServiceHost implements DozeHost { DozeScrimController dozeScrimController, KeyguardUpdateMonitor keyguardUpdateMonitor, VisualStabilityManager visualStabilityManager, PulseExpansionHandler pulseExpansionHandler, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, NotificationWakeUpCoordinator notificationWakeUpCoordinator, LockscreenLockIconController lockscreenLockIconController) { super(); @@ -127,7 +127,7 @@ public final class DozeServiceHost implements DozeHost { mKeyguardUpdateMonitor = keyguardUpdateMonitor; mVisualStabilityManager = visualStabilityManager; mPulseExpansionHandler = pulseExpansionHandler; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mNotificationWakeUpCoordinator = notificationWakeUpCoordinator; mLockscreenLockIconController = lockscreenLockIconController; } @@ -140,13 +140,13 @@ public final class DozeServiceHost implements DozeHost { public void initialize(StatusBar statusBar, NotificationIconAreaController notificationIconAreaController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, - StatusBarWindowViewController statusBarWindowViewController, + NotificationShadeWindowViewController notificationShadeWindowViewController, NotificationPanelViewController notificationPanel, View ambientIndicationContainer) { mStatusBar = statusBar; mNotificationIconAreaController = notificationIconAreaController; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mNotificationPanel = notificationPanel; - mStatusBarWindowViewController = statusBarWindowViewController; + mNotificationShadeWindowViewController = notificationShadeWindowViewController; mAmbientIndicationContainer = ambientIndicationContainer; mBiometricUnlockController = mBiometricUnlockControllerLazy.get(); } @@ -292,7 +292,7 @@ public final class DozeServiceHost implements DozeHost { } mIgnoreTouchWhilePulsing = ignore; if (mStatusBarStateController.isDozing() && ignore) { - mStatusBarWindowViewController.cancelCurrentTouch(); + mNotificationShadeWindowViewController.cancelCurrentTouch(); } } @@ -391,7 +391,7 @@ public final class DozeServiceHost implements DozeHost { @Override public void setDozeScreenBrightness(int value) { - mStatusBarWindowController.setDozeScreenBrightness(value); + mNotificationShadeWindowController.setDozeScreenBrightness(value); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 7b20a7b7037c..c39ee3a90230 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -92,21 +92,22 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, public HeadsUpAppearanceController( NotificationIconAreaController notificationIconAreaController, - HeadsUpManagerPhone headsUpManager, View statusbarView, + HeadsUpManagerPhone headsUpManager, + View notificationShadeView, SysuiStatusBarStateController statusBarStateController, KeyguardBypassController keyguardBypassController, KeyguardStateController keyguardStateController, NotificationWakeUpCoordinator wakeUpCoordinator, CommandQueue commandQueue, - NotificationPanelViewController notificationPanelViewController) { + NotificationPanelViewController notificationPanelViewController, View statusBarView) { this(notificationIconAreaController, headsUpManager, statusBarStateController, keyguardBypassController, wakeUpCoordinator, keyguardStateController, commandQueue, - statusbarView.findViewById(R.id.heads_up_status_bar_view), - statusbarView.findViewById(R.id.notification_stack_scroller), + statusBarView.findViewById(R.id.heads_up_status_bar_view), + notificationShadeView.findViewById(R.id.notification_stack_scroller), notificationPanelViewController, - statusbarView.findViewById(R.id.clock), - statusbarView.findViewById(R.id.operator_name_frame), - statusbarView.findViewById(R.id.centered_icon_area)); + statusBarView.findViewById(R.id.clock), + statusBarView.findViewById(R.id.operator_name_frame), + statusBarView.findViewById(R.id.centered_icon_area)); } @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 6ac6d354cfff..c6e3fdefe701 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -65,7 +65,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, private final StatusBarStateController mStatusBarStateController; private final KeyguardBypassController mBypassController; private final int mAutoHeadsUpNotificationDecay; - private View mStatusBarWindowView; + private View mNotificationShadeWindowView; private NotificationGroupManager mGroupManager; private VisualStabilityManager mVisualStabilityManager; private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; @@ -124,14 +124,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, initResources(); } - - public void setUp(@NonNull View statusBarWindowView, + public void setUp(@NonNull View notificationShadeWindowView, @NonNull NotificationGroupManager groupManager, @NonNull StatusBar bar, @NonNull VisualStabilityManager visualStabilityManager) { - mStatusBarWindowView = statusBarWindowView; - mStatusBarTouchableRegionManager = new StatusBarTouchableRegionManager(mContext, this, bar, - statusBarWindowView); + mNotificationShadeWindowView = notificationShadeWindowView; + mStatusBarTouchableRegionManager = new StatusBarTouchableRegionManager(this, bar, + notificationShadeWindowView); mGroupManager = groupManager; mVisualStabilityManager = visualStabilityManager; @@ -364,7 +363,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, // updated yet, but callbacks leading out of the headsUp manager, querying it. Let's // therefore also check if the topEntry is null. if (!hasPinnedHeadsUp() || topEntry == null) { - mTouchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight); + mTouchableRegion.set(0, 0, mNotificationShadeWindowView.getWidth(), mStatusBarHeight); updateRegionForNotch(mTouchableRegion); } else { @@ -386,7 +385,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } private void updateRegionForNotch(Region region) { - WindowInsets windowInsets = mStatusBarWindowView.getRootWindowInsets(); + WindowInsets windowInsets = mNotificationShadeWindowView.getRootWindowInsets(); if (windowInsets == null) { Log.w(TAG, "StatusBarWindowView is not attached."); return; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 3554b54db99b..707138ee8dc0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -128,7 +128,7 @@ public class NotificationIconAreaController implements DarkReceiver, mAodIcons.setAnimationsEnabled(false); mAodIcons.removeAllViews(); } - mAodIcons = mStatusBar.getStatusBarWindow().findViewById( + mAodIcons = mStatusBar.getNotificationShadeWindowView().findViewById( R.id.clock_notification_icon_container); mAodIcons.setOnLockScreen(true); updateAodIconsVisibility(false /* animate */); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 90ec2a076e87..6112ae88f634 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1367,14 +1367,7 @@ public class NotificationPanelViewController extends PanelViewController { if (mExpectingSynthesizedDown) { mExpectingSynthesizedDown = false; maybeVibrateOnOpening(); - Runnable runnable = () -> fling(velocity > 1f ? 1000f * velocity : 0, - true /* expand */); - if (mStatusBar.getStatusBarWindow().getHeight() != mStatusBar.getStatusBarHeight()) { - // The panel is already expanded to its full size, let's expand directly - runnable.run(); - } else { - mExpandAfterLayoutRunnable = runnable; - } + fling(velocity > 1f ? 1000f * velocity : 0, true /* expand */); onTrackingStopped(false); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java new file mode 100644 index 000000000000..d346d395e444 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java @@ -0,0 +1,714 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; + +import static com.android.systemui.DejankUtils.whitelistIpcs; +import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT; + +import android.app.IActivityManager; +import android.content.Context; +import android.content.pm.ActivityInfo; +import android.content.res.Resources; +import android.graphics.PixelFormat; +import android.os.Binder; +import android.os.RemoteException; +import android.os.SystemProperties; +import android.os.Trace; +import android.util.Log; +import android.view.Display; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.view.WindowManager.LayoutParams; + +import com.android.systemui.Dumpable; +import com.android.systemui.R; +import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; +import com.android.systemui.statusbar.RemoteInputController.Callback; +import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.SuperStatusBarViewFactory; +import com.android.systemui.statusbar.SysuiStatusBarStateController; +import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; + +import com.google.android.collect.Lists; + +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Encapsulates all logic for the notification shade window state management. + */ +@Singleton +public class NotificationShadeWindowController implements Callback, Dumpable, + ConfigurationListener { + + private static final String TAG = "NotificationShadeWindowController"; + private static final boolean DEBUG = false; + + private final Context mContext; + private final WindowManager mWindowManager; + private final IActivityManager mActivityManager; + private final DozeParameters mDozeParameters; + private final LayoutParams mLpChanged; + private final boolean mKeyguardScreenRotation; + private final long mLockScreenDisplayTimeout; + private final Display.Mode mKeyguardDisplayMode; + private final KeyguardBypassController mKeyguardBypassController; + private ViewGroup mNotificationShadeView; + private LayoutParams mLp; + private boolean mHasTopUi; + private boolean mHasTopUiChanged; + private float mScreenBrightnessDoze; + private final State mCurrentState = new State(); + private OtherwisedCollapsedListener mListener; + private ForcePluginOpenListener mForcePluginOpenListener; + private final ArrayList<WeakReference<StatusBarWindowCallback>> + mCallbacks = Lists.newArrayList(); + + private final SysuiColorExtractor mColorExtractor; + private final SuperStatusBarViewFactory mSuperStatusBarViewFactory; + + @Inject + public NotificationShadeWindowController(Context context, WindowManager windowManager, + IActivityManager activityManager, DozeParameters dozeParameters, + StatusBarStateController statusBarStateController, + ConfigurationController configurationController, + KeyguardBypassController keyguardBypassController, SysuiColorExtractor colorExtractor, + SuperStatusBarViewFactory superStatusBarViewFactory) { + mContext = context; + mWindowManager = windowManager; + mActivityManager = activityManager; + mKeyguardScreenRotation = shouldEnableKeyguardScreenRotation(); + mDozeParameters = dozeParameters; + mScreenBrightnessDoze = mDozeParameters.getScreenBrightnessDoze(); + mLpChanged = new LayoutParams(); + mKeyguardBypassController = keyguardBypassController; + mColorExtractor = colorExtractor; + mSuperStatusBarViewFactory = superStatusBarViewFactory; + mNotificationShadeView = mSuperStatusBarViewFactory.getNotificationShadeWindowView(); + + mLockScreenDisplayTimeout = context.getResources() + .getInteger(R.integer.config_lockScreenDisplayTimeout); + ((SysuiStatusBarStateController) statusBarStateController) + .addCallback(mStateListener, + SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER); + configurationController.addCallback(this); + + Display.Mode[] supportedModes = context.getDisplay().getSupportedModes(); + Display.Mode currentMode = context.getDisplay().getMode(); + // Running on the highest frame rate available can be expensive. + // Let's specify a preferred refresh rate, and allow higher FPS only when we + // know that we're not falsing (because we unlocked.) + int keyguardRefreshRate = context.getResources() + .getInteger(R.integer.config_keyguardRefreshRate); + // Find supported display mode with the same resolution and requested refresh rate. + mKeyguardDisplayMode = Arrays.stream(supportedModes).filter(mode -> + (int) mode.getRefreshRate() == keyguardRefreshRate + && mode.getPhysicalWidth() == currentMode.getPhysicalWidth() + && mode.getPhysicalHeight() == currentMode.getPhysicalHeight()) + .findFirst().orElse(null); + } + + /** + * Register to receive notifications about status bar window state changes. + */ + public void registerCallback(StatusBarWindowCallback callback) { + // Prevent adding duplicate callbacks + for (int i = 0; i < mCallbacks.size(); i++) { + if (mCallbacks.get(i).get() == callback) { + return; + } + } + mCallbacks.add(new WeakReference<StatusBarWindowCallback>(callback)); + } + + private boolean shouldEnableKeyguardScreenRotation() { + Resources res = mContext.getResources(); + return SystemProperties.getBoolean("lockscreen.rot_override", false) + || res.getBoolean(R.bool.config_enableLockScreenRotation); + } + + /** + * Adds the notification shade view to the window manager. + */ + public void attach() { + // Now that the notification shade encompasses the sliding panel and its + // translucent backdrop, the entire thing is made TRANSLUCENT and is + // hardware-accelerated. + mLp = new LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, + LayoutParams.TYPE_NOTIFICATION_SHADE, + LayoutParams.FLAG_NOT_FOCUSABLE + | LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING + | LayoutParams.FLAG_SPLIT_TOUCH + | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH + | LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, + PixelFormat.TRANSLUCENT); + mLp.token = new Binder(); + mLp.gravity = Gravity.TOP; + mLp.setFitWindowInsetsTypes(0 /* types */); + mLp.softInputMode = LayoutParams.SOFT_INPUT_ADJUST_RESIZE; + mLp.setTitle("NotificationShade"); + mLp.packageName = mContext.getPackageName(); + mLp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; + mWindowManager.addView(mNotificationShadeView, mLp); + mLpChanged.copyFrom(mLp); + onThemeChanged(); + } + + public ViewGroup getNotificationShadeView() { + return mNotificationShadeView; + } + + public void setDozeScreenBrightness(int value) { + mScreenBrightnessDoze = value / 255f; + } + + private void setKeyguardDark(boolean dark) { + int vis = mNotificationShadeView.getSystemUiVisibility(); + if (dark) { + vis = vis | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + vis = vis | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } else { + vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } + mNotificationShadeView.setSystemUiVisibility(vis); + } + + private void applyKeyguardFlags(State state) { + final boolean scrimsOccludingWallpaper = + state.mScrimsVisibility == ScrimController.OPAQUE; + final boolean keyguardOrAod = state.mKeyguardShowing + || (state.mDozing && mDozeParameters.getAlwaysOn()); + if (keyguardOrAod && !state.mBackdropShowing && !scrimsOccludingWallpaper) { + mLpChanged.flags |= LayoutParams.FLAG_SHOW_WALLPAPER; + } else { + mLpChanged.flags &= ~LayoutParams.FLAG_SHOW_WALLPAPER; + } + + if (state.mDozing) { + mLpChanged.privateFlags |= LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + } else { + mLpChanged.privateFlags &= ~LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + } + + if (mKeyguardDisplayMode != null) { + boolean bypassOnKeyguard = mKeyguardBypassController.getBypassEnabled() + && state.mStatusBarState == StatusBarState.KEYGUARD + && !state.mKeyguardFadingAway && !state.mKeyguardGoingAway; + if (state.mDozing || bypassOnKeyguard) { + mLpChanged.preferredDisplayModeId = mKeyguardDisplayMode.getModeId(); + } else { + mLpChanged.preferredDisplayModeId = 0; + } + Trace.setCounter("display_mode_id", mLpChanged.preferredDisplayModeId); + } + } + + private void adjustScreenOrientation(State state) { + if (state.isKeyguardShowingAndNotOccluded() || state.mDozing) { + if (mKeyguardScreenRotation) { + mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; + } else { + mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; + } + } else { + mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; + } + } + + private void applyFocusableFlag(State state) { + boolean panelFocusable = state.mNotificationShadeFocusable && state.mPanelExpanded; + if (state.mBouncerShowing && (state.mKeyguardOccluded || state.mKeyguardNeedsInput) + || ENABLE_REMOTE_INPUT && state.mRemoteInputActive + || state.mBubbleExpanded) { + mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; + mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; + } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { + mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; + mLpChanged.flags |= LayoutParams.FLAG_ALT_FOCUSABLE_IM; + } else { + mLpChanged.flags |= LayoutParams.FLAG_NOT_FOCUSABLE; + mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; + } + + mLpChanged.softInputMode = LayoutParams.SOFT_INPUT_ADJUST_RESIZE; + } + + private void applyForceShowNavigationFlag(State state) { + if (state.mPanelExpanded || state.mBouncerShowing + || ENABLE_REMOTE_INPUT && state.mRemoteInputActive) { + mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; + } else { + mLpChanged.privateFlags &= ~LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; + } + } + + private void applyVisibility(State state) { + boolean visible = isExpanded(state); + if (state.mForcePluginOpen) { + if (mListener != null) { + mListener.setWouldOtherwiseCollapse(visible); + } + visible = true; + } + if (visible) { + mNotificationShadeView.setVisibility(View.VISIBLE); + } else { + mNotificationShadeView.setVisibility(View.INVISIBLE); + } + } + + private boolean isExpanded(State state) { + return !state.mForceCollapsed && (state.isKeyguardShowingAndNotOccluded() + || state.mPanelVisible || state.mKeyguardFadingAway || state.mBouncerShowing + || state.mHeadsUpShowing || state.mBubblesShowing + || state.mScrimsVisibility != ScrimController.TRANSPARENT); + } + + private void applyFitsSystemWindows(State state) { + boolean fitsSystemWindows = !state.isKeyguardShowingAndNotOccluded(); + if (mNotificationShadeView != null + && mNotificationShadeView.getFitsSystemWindows() != fitsSystemWindows) { + mNotificationShadeView.setFitsSystemWindows(fitsSystemWindows); + mNotificationShadeView.requestApplyInsets(); + } + } + + private void applyUserActivityTimeout(State state) { + if (state.isKeyguardShowingAndNotOccluded() + && state.mStatusBarState == StatusBarState.KEYGUARD + && !state.mQsExpanded) { + mLpChanged.userActivityTimeout = state.mBouncerShowing + ? KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS : mLockScreenDisplayTimeout; + } else { + mLpChanged.userActivityTimeout = -1; + } + } + + private void applyInputFeatures(State state) { + if (state.isKeyguardShowingAndNotOccluded() + && state.mStatusBarState == StatusBarState.KEYGUARD + && !state.mQsExpanded && !state.mForceUserActivity) { + mLpChanged.inputFeatures |= + LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; + } else { + mLpChanged.inputFeatures &= + ~LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; + } + } + + private void applyStatusBarColorSpaceAgnosticFlag(State state) { + if (!isExpanded(state)) { + mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; + } else { + mLpChanged.privateFlags &= + ~LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; + } + } + + private void apply(State state) { + applyKeyguardFlags(state); + applyFocusableFlag(state); + applyForceShowNavigationFlag(state); + adjustScreenOrientation(state); + applyVisibility(state); + applyUserActivityTimeout(state); + applyInputFeatures(state); + applyFitsSystemWindows(state); + applyModalFlag(state); + applyBrightness(state); + applyHasTopUi(state); + applyNotTouchable(state); + applyStatusBarColorSpaceAgnosticFlag(state); + if (mLp != null && mLp.copyFrom(mLpChanged) != 0) { + mWindowManager.updateViewLayout(mNotificationShadeView, mLp); + } + if (mHasTopUi != mHasTopUiChanged) { + whitelistIpcs(() -> { + try { + mActivityManager.setHasTopUi(mHasTopUiChanged); + } catch (RemoteException e) { + Log.e(TAG, "Failed to call setHasTopUi", e); + } + mHasTopUi = mHasTopUiChanged; + }); + } + notifyStateChangedCallbacks(); + } + + public void notifyStateChangedCallbacks() { + for (int i = 0; i < mCallbacks.size(); i++) { + StatusBarWindowCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onStateChanged(mCurrentState.mKeyguardShowing, + mCurrentState.mKeyguardOccluded, + mCurrentState.mBouncerShowing); + } + } + } + + private void applyModalFlag(State state) { + if (state.mHeadsUpShowing) { + mLpChanged.flags |= LayoutParams.FLAG_NOT_TOUCH_MODAL; + } else { + mLpChanged.flags &= ~LayoutParams.FLAG_NOT_TOUCH_MODAL; + } + } + + private void applyBrightness(State state) { + if (state.mForceDozeBrightness) { + mLpChanged.screenBrightness = mScreenBrightnessDoze; + } else { + mLpChanged.screenBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE; + } + } + + private void applyHasTopUi(State state) { + mHasTopUiChanged = state.mForceHasTopUi || isExpanded(state); + } + + private void applyNotTouchable(State state) { + if (state.mNotTouchable) { + mLpChanged.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; + } else { + mLpChanged.flags &= ~LayoutParams.FLAG_NOT_TOUCHABLE; + } + } + + public void setKeyguardShowing(boolean showing) { + mCurrentState.mKeyguardShowing = showing; + apply(mCurrentState); + } + + public void setKeyguardOccluded(boolean occluded) { + mCurrentState.mKeyguardOccluded = occluded; + apply(mCurrentState); + } + + public void setKeyguardNeedsInput(boolean needsInput) { + mCurrentState.mKeyguardNeedsInput = needsInput; + apply(mCurrentState); + } + + public void setPanelVisible(boolean visible) { + mCurrentState.mPanelVisible = visible; + mCurrentState.mNotificationShadeFocusable = visible; + apply(mCurrentState); + } + + public void setNotificationShadeFocusable(boolean focusable) { + mCurrentState.mNotificationShadeFocusable = focusable; + apply(mCurrentState); + } + + public void setBouncerShowing(boolean showing) { + mCurrentState.mBouncerShowing = showing; + apply(mCurrentState); + } + + public void setBackdropShowing(boolean showing) { + mCurrentState.mBackdropShowing = showing; + apply(mCurrentState); + } + + public void setKeyguardFadingAway(boolean keyguardFadingAway) { + mCurrentState.mKeyguardFadingAway = keyguardFadingAway; + apply(mCurrentState); + } + + public void setQsExpanded(boolean expanded) { + mCurrentState.mQsExpanded = expanded; + apply(mCurrentState); + } + + public void setForceUserActivity(boolean forceUserActivity) { + mCurrentState.mForceUserActivity = forceUserActivity; + apply(mCurrentState); + } + + public void setScrimsVisibility(int scrimsVisibility) { + mCurrentState.mScrimsVisibility = scrimsVisibility; + apply(mCurrentState); + } + + public void setHeadsUpShowing(boolean showing) { + mCurrentState.mHeadsUpShowing = showing; + apply(mCurrentState); + } + + public void setWallpaperSupportsAmbientMode(boolean supportsAmbientMode) { + mCurrentState.mWallpaperSupportsAmbientMode = supportsAmbientMode; + apply(mCurrentState); + } + + /** + * @param state The {@link StatusBarStateController} of the status bar. + */ + private void setStatusBarState(int state) { + mCurrentState.mStatusBarState = state; + apply(mCurrentState); + } + + /** + * Force the window to be collapsed, even if it should theoretically be expanded. + * Used for when a heads-up comes in but we still need to wait for the touchable regions to + * be computed. + */ + public void setForceWindowCollapsed(boolean force) { + mCurrentState.mForceCollapsed = force; + apply(mCurrentState); + } + + public void setPanelExpanded(boolean isExpanded) { + mCurrentState.mPanelExpanded = isExpanded; + apply(mCurrentState); + } + + @Override + public void onRemoteInputActive(boolean remoteInputActive) { + mCurrentState.mRemoteInputActive = remoteInputActive; + apply(mCurrentState); + } + + /** + * Set whether the screen brightness is forced to the value we use for doze mode by the status + * bar window. + */ + public void setForceDozeBrightness(boolean forceDozeBrightness) { + mCurrentState.mForceDozeBrightness = forceDozeBrightness; + apply(mCurrentState); + } + + public void setDozing(boolean dozing) { + mCurrentState.mDozing = dozing; + apply(mCurrentState); + } + + public void setForcePluginOpen(boolean forcePluginOpen) { + mCurrentState.mForcePluginOpen = forcePluginOpen; + apply(mCurrentState); + if (mForcePluginOpenListener != null) { + mForcePluginOpenListener.onChange(forcePluginOpen); + } + } + + /** + * The forcePluginOpen state for the status bar. + */ + public boolean getForcePluginOpen() { + return mCurrentState.mForcePluginOpen; + } + + public void setNotTouchable(boolean notTouchable) { + mCurrentState.mNotTouchable = notTouchable; + apply(mCurrentState); + } + + /** + * Sets whether there are bubbles showing on the screen. + */ + public void setBubblesShowing(boolean bubblesShowing) { + mCurrentState.mBubblesShowing = bubblesShowing; + apply(mCurrentState); + } + + /** + * The bubbles showing state for the status bar. + */ + public boolean getBubblesShowing() { + return mCurrentState.mBubblesShowing; + } + + /** + * Sets if there is a bubble being expanded on the screen. + */ + public void setBubbleExpanded(boolean bubbleExpanded) { + mCurrentState.mBubbleExpanded = bubbleExpanded; + apply(mCurrentState); + } + + /** + * Whether the bubble is shown in expanded state for the status bar. + */ + public boolean getBubbleExpanded() { + return mCurrentState.mBubbleExpanded; + } + + /** + * Whether the status bar panel is expanded or not. + */ + public boolean getPanelExpanded() { + return mCurrentState.mPanelExpanded; + } + + public void setStateListener(OtherwisedCollapsedListener listener) { + mListener = listener; + } + + public void setForcePluginOpenListener(ForcePluginOpenListener listener) { + mForcePluginOpenListener = listener; + } + + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + pw.println("StatusBarWindowController:"); + pw.println(" mKeyguardDisplayMode=" + mKeyguardDisplayMode); + pw.println(mCurrentState); + } + + public boolean isShowingWallpaper() { + return !mCurrentState.mBackdropShowing; + } + + @Override + public void onThemeChanged() { + if (mNotificationShadeView == null) { + return; + } + + final boolean useDarkText = mColorExtractor.getNeutralColors().supportsDarkText(); + // Make sure we have the correct navbar/statusbar colors. + setKeyguardDark(useDarkText); + } + + /** + * When keyguard will be dismissed but didn't start animation yet. + */ + public void setKeyguardGoingAway(boolean goingAway) { + mCurrentState.mKeyguardGoingAway = goingAway; + apply(mCurrentState); + } + + public boolean getForceHasTopUi() { + return mCurrentState.mForceHasTopUi; + } + + public void setForceHasTopUi(boolean forceHasTopUi) { + mCurrentState.mForceHasTopUi = forceHasTopUi; + apply(mCurrentState); + } + + private static class State { + boolean mKeyguardShowing; + boolean mKeyguardOccluded; + boolean mKeyguardNeedsInput; + boolean mPanelVisible; + boolean mPanelExpanded; + boolean mNotificationShadeFocusable; + boolean mBouncerShowing; + boolean mKeyguardFadingAway; + boolean mKeyguardGoingAway; + boolean mQsExpanded; + boolean mHeadsUpShowing; + boolean mForceCollapsed; + boolean mForceDozeBrightness; + boolean mForceUserActivity; + boolean mBackdropShowing; + boolean mWallpaperSupportsAmbientMode; + boolean mNotTouchable; + boolean mBubblesShowing; + boolean mBubbleExpanded; + boolean mForceHasTopUi; + + /** + * The {@link StatusBar} state from the status bar. + */ + int mStatusBarState; + + boolean mRemoteInputActive; + boolean mForcePluginOpen; + boolean mDozing; + int mScrimsVisibility; + + private boolean isKeyguardShowingAndNotOccluded() { + return mKeyguardShowing && !mKeyguardOccluded; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + String newLine = "\n"; + result.append("Window State {"); + result.append(newLine); + + Field[] fields = this.getClass().getDeclaredFields(); + + // Print field names paired with their values + for (Field field : fields) { + result.append(" "); + try { + result.append(field.getName()); + result.append(": "); + //requires access to private field: + result.append(field.get(this)); + } catch (IllegalAccessException ex) { + } + result.append(newLine); + } + result.append("}"); + + return result.toString(); + } + } + + private final StateListener mStateListener = new StateListener() { + @Override + public void onStateChanged(int newState) { + setStatusBarState(newState); + } + + @Override + public void onDozingChanged(boolean isDozing) { + setDozing(isDozing); + } + }; + + /** + * Custom listener to pipe data back to plugins about whether or not the status bar would be + * collapsed if not for the plugin. + * TODO: Find cleaner way to do this. + */ + public interface OtherwisedCollapsedListener { + void setWouldOtherwiseCollapse(boolean otherwiseCollapse); + } + + /** + * Listener to indicate forcePluginOpen has changed + */ + public interface ForcePluginOpenListener { + /** + * Called when mState.forcePluginOpen is changed + */ + void onChange(boolean forceOpen); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java new file mode 100644 index 000000000000..6979554303b3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java @@ -0,0 +1,614 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import android.annotation.ColorInt; +import android.annotation.DrawableRes; +import android.annotation.LayoutRes; +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Insets; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.util.AttributeSet; +import android.view.ActionMode; +import android.view.DisplayCutout; +import android.view.InputQueue; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.SurfaceHolder; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.Window; +import android.view.WindowInsets; +import android.view.WindowInsetsController; +import android.widget.FrameLayout; + +import com.android.internal.view.FloatingActionMode; +import com.android.internal.widget.FloatingToolbar; +import com.android.systemui.R; + +/** + * Combined keyguard and notification panel view. Also holding backdrop and scrims. + */ +public class NotificationShadeWindowView extends FrameLayout { + public static final String TAG = "NotificationShadeWindowView"; + public static final boolean DEBUG = StatusBar.DEBUG; + + private int mRightInset = 0; + private int mLeftInset = 0; + + // Implements the floating action mode for TextView's Cut/Copy/Past menu. Normally provided by + // DecorView, but since this is a special window we have to roll our own. + private View mFloatingActionModeOriginatingView; + private ActionMode mFloatingActionMode; + private FloatingToolbar mFloatingToolbar; + private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener; + + private InteractionEventHandler mInteractionEventHandler; + + public NotificationShadeWindowView(Context context, AttributeSet attrs) { + super(context, attrs); + setMotionEventSplittingEnabled(false); + } + + public NotificationPanelView getNotificationPanelView() { + return findViewById(R.id.notification_panel); + } + + @Override + public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) { + final Insets insets = windowInsets.getMaxInsets(WindowInsets.Type.systemBars()); + if (getFitsSystemWindows()) { + boolean paddingChanged = insets.top != getPaddingTop() + || insets.bottom != getPaddingBottom(); + + int rightCutout = 0; + int leftCutout = 0; + DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout(); + if (displayCutout != null) { + leftCutout = displayCutout.getSafeInsetLeft(); + rightCutout = displayCutout.getSafeInsetRight(); + } + + int targetLeft = Math.max(insets.left, leftCutout); + int targetRight = Math.max(insets.right, rightCutout); + + // Super-special right inset handling, because scrims and backdrop need to ignore it. + if (targetRight != mRightInset || targetLeft != mLeftInset) { + mRightInset = targetRight; + mLeftInset = targetLeft; + applyMargins(); + } + // Drop top inset, and pass through bottom inset. + if (paddingChanged) { + setPadding(0, 0, 0, 0); + } + } else { + if (mRightInset != 0 || mLeftInset != 0) { + mRightInset = 0; + mLeftInset = 0; + applyMargins(); + } + boolean changed = getPaddingLeft() != 0 + || getPaddingRight() != 0 + || getPaddingTop() != 0 + || getPaddingBottom() != 0; + if (changed) { + setPadding(0, 0, 0, 0); + } + } + return windowInsets; + } + + private void applyMargins() { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + View child = getChildAt(i); + if (child.getLayoutParams() instanceof LayoutParams) { + LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if (!lp.ignoreRightInset + && (lp.rightMargin != mRightInset || lp.leftMargin != mLeftInset)) { + lp.rightMargin = mRightInset; + lp.leftMargin = mLeftInset; + child.requestLayout(); + } + } + } + } + + @Override + public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + @Override + protected FrameLayout.LayoutParams generateDefaultLayoutParams() { + return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + setWillNotDraw(!DEBUG); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (mInteractionEventHandler.interceptMediaKey(event)) { + return true; + } + + if (super.dispatchKeyEvent(event)) { + return true; + } + + return mInteractionEventHandler.dispatchKeyEvent(event); + } + + protected void setInteractionEventHandler(InteractionEventHandler listener) { + mInteractionEventHandler = listener; + } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + Boolean result = mInteractionEventHandler.handleDispatchTouchEvent(ev); + + return result != null ? result : super.dispatchTouchEvent(ev); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + boolean intercept = mInteractionEventHandler.shouldInterceptTouchEvent(ev); + if (!intercept) { + intercept = super.onInterceptTouchEvent(ev); + } + if (intercept) { + mInteractionEventHandler.didIntercept(ev); + } + + return intercept; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + boolean handled = mInteractionEventHandler.handleTouchEvent(ev); + + if (!handled) { + handled = super.onTouchEvent(ev); + } + + if (!handled) { + mInteractionEventHandler.didNotHandleTouchEvent(ev); + } + + return handled; + } + + @Override + public void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (DEBUG) { + Paint pt = new Paint(); + pt.setColor(0x80FFFF00); + pt.setStrokeWidth(12.0f); + pt.setStyle(Paint.Style.STROKE); + canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt); + } + } + + class LayoutParams extends FrameLayout.LayoutParams { + + public boolean ignoreRightInset; + + LayoutParams(int width, int height) { + super(width, height); + } + + LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + + TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.StatusBarWindowView_Layout); + ignoreRightInset = a.getBoolean( + R.styleable.StatusBarWindowView_Layout_ignoreRightInset, false); + a.recycle(); + } + } + + @Override + public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, + int type) { + if (type == ActionMode.TYPE_FLOATING) { + return startActionMode(originalView, callback, type); + } + return super.startActionModeForChild(originalView, callback, type); + } + + private ActionMode createFloatingActionMode( + View originatingView, ActionMode.Callback2 callback) { + if (mFloatingActionMode != null) { + mFloatingActionMode.finish(); + } + cleanupFloatingActionModeViews(); + mFloatingToolbar = new FloatingToolbar(mFakeWindow); + final FloatingActionMode mode = + new FloatingActionMode(mContext, callback, originatingView, mFloatingToolbar); + mFloatingActionModeOriginatingView = originatingView; + mFloatingToolbarPreDrawListener = + new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + mode.updateViewLocationInWindow(); + return true; + } + }; + return mode; + } + + private void setHandledFloatingActionMode(ActionMode mode) { + mFloatingActionMode = mode; + mFloatingActionMode.invalidate(); // Will show the floating toolbar if necessary. + mFloatingActionModeOriginatingView.getViewTreeObserver() + .addOnPreDrawListener(mFloatingToolbarPreDrawListener); + } + + private void cleanupFloatingActionModeViews() { + if (mFloatingToolbar != null) { + mFloatingToolbar.dismiss(); + mFloatingToolbar = null; + } + if (mFloatingActionModeOriginatingView != null) { + if (mFloatingToolbarPreDrawListener != null) { + mFloatingActionModeOriginatingView.getViewTreeObserver() + .removeOnPreDrawListener(mFloatingToolbarPreDrawListener); + mFloatingToolbarPreDrawListener = null; + } + mFloatingActionModeOriginatingView = null; + } + } + + private ActionMode startActionMode( + View originatingView, ActionMode.Callback callback, int type) { + ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback); + ActionMode mode = createFloatingActionMode(originatingView, wrappedCallback); + if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) { + setHandledFloatingActionMode(mode); + } else { + mode = null; + } + return mode; + } + + private class ActionModeCallback2Wrapper extends ActionMode.Callback2 { + private final ActionMode.Callback mWrapped; + + ActionModeCallback2Wrapper(ActionMode.Callback wrapped) { + mWrapped = wrapped; + } + + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + return mWrapped.onCreateActionMode(mode, menu); + } + + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + requestFitSystemWindows(); + return mWrapped.onPrepareActionMode(mode, menu); + } + + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return mWrapped.onActionItemClicked(mode, item); + } + + public void onDestroyActionMode(ActionMode mode) { + mWrapped.onDestroyActionMode(mode); + if (mode == mFloatingActionMode) { + cleanupFloatingActionModeViews(); + mFloatingActionMode = null; + } + requestFitSystemWindows(); + } + + @Override + public void onGetContentRect(ActionMode mode, View view, Rect outRect) { + if (mWrapped instanceof ActionMode.Callback2) { + ((ActionMode.Callback2) mWrapped).onGetContentRect(mode, view, outRect); + } else { + super.onGetContentRect(mode, view, outRect); + } + } + } + + interface InteractionEventHandler { + /** + * Returns a result for {@link ViewGroup#dispatchTouchEvent(MotionEvent)} or null to defer + * to the super method. + */ + Boolean handleDispatchTouchEvent(MotionEvent ev); + + /** + * Returns if the view should intercept the touch event. + * + * The touch event may still be interecepted if + * {@link ViewGroup#onInterceptTouchEvent(MotionEvent)} decides to do so. + */ + boolean shouldInterceptTouchEvent(MotionEvent ev); + + /** + * Called when the view decides to intercept the touch event. + */ + void didIntercept(MotionEvent ev); + + boolean handleTouchEvent(MotionEvent ev); + + void didNotHandleTouchEvent(MotionEvent ev); + + boolean interceptMediaKey(KeyEvent event); + + boolean dispatchKeyEvent(KeyEvent event); + } + + /** + * Minimal window to satisfy FloatingToolbar. + */ + private Window mFakeWindow = new Window(mContext) { + @Override + public void takeSurface(SurfaceHolder.Callback2 callback) { + } + + @Override + public void takeInputQueue(InputQueue.Callback callback) { + } + + @Override + public boolean isFloating() { + return false; + } + + @Override + public void alwaysReadCloseOnTouchAttr() { + } + + @Override + public void setContentView(@LayoutRes int layoutResID) { + } + + @Override + public void setContentView(View view) { + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + } + + @Override + public void clearContentView() { + } + + @Override + public View getCurrentFocus() { + return null; + } + + @Override + public LayoutInflater getLayoutInflater() { + return null; + } + + @Override + public void setTitle(CharSequence title) { + } + + @Override + public void setTitleColor(@ColorInt int textColor) { + } + + @Override + public void openPanel(int featureId, KeyEvent event) { + } + + @Override + public void closePanel(int featureId) { + } + + @Override + public void togglePanel(int featureId, KeyEvent event) { + } + + @Override + public void invalidatePanelMenu(int featureId) { + } + + @Override + public boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags) { + return false; + } + + @Override + public boolean performPanelIdentifierAction(int featureId, int id, int flags) { + return false; + } + + @Override + public void closeAllPanels() { + } + + @Override + public boolean performContextMenuIdentifierAction(int id, int flags) { + return false; + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + } + + @Override + public void setBackgroundDrawable(Drawable drawable) { + } + + @Override + public void setFeatureDrawableResource(int featureId, @DrawableRes int resId) { + } + + @Override + public void setFeatureDrawableUri(int featureId, Uri uri) { + } + + @Override + public void setFeatureDrawable(int featureId, Drawable drawable) { + } + + @Override + public void setFeatureDrawableAlpha(int featureId, int alpha) { + } + + @Override + public void setFeatureInt(int featureId, int value) { + } + + @Override + public void takeKeyEvents(boolean get) { + } + + @Override + public boolean superDispatchKeyEvent(KeyEvent event) { + return false; + } + + @Override + public boolean superDispatchKeyShortcutEvent(KeyEvent event) { + return false; + } + + @Override + public boolean superDispatchTouchEvent(MotionEvent event) { + return false; + } + + @Override + public boolean superDispatchTrackballEvent(MotionEvent event) { + return false; + } + + @Override + public boolean superDispatchGenericMotionEvent(MotionEvent event) { + return false; + } + + @Override + public View getDecorView() { + return NotificationShadeWindowView.this; + } + + @Override + public View peekDecorView() { + return null; + } + + @Override + public Bundle saveHierarchyState() { + return null; + } + + @Override + public void restoreHierarchyState(Bundle savedInstanceState) { + } + + @Override + protected void onActive() { + } + + @Override + public void setChildDrawable(int featureId, Drawable drawable) { + } + + @Override + public void setChildInt(int featureId, int value) { + } + + @Override + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return false; + } + + @Override + public void setVolumeControlStream(int streamType) { + } + + @Override + public int getVolumeControlStream() { + return 0; + } + + @Override + public int getStatusBarColor() { + return 0; + } + + @Override + public void setStatusBarColor(@ColorInt int color) { + } + + @Override + public int getNavigationBarColor() { + return 0; + } + + @Override + public void setNavigationBarColor(@ColorInt int color) { + } + + @Override + public void setDecorCaptionShade(int decorCaptionShade) { + } + + @Override + public void setResizingCaptionDrawable(Drawable drawable) { + } + + @Override + public void onMultiWindowModeChanged() { + } + + @Override + public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { + } + + @Override + public void reportActivityRelaunched() { + } + + @Override + public WindowInsetsController getInsetsController() { + return null; + } + }; + +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java index 4935f0e8dd83..c691a35b566a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java @@ -16,7 +16,10 @@ package com.android.systemui.statusbar.phone; +import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; + import android.app.StatusBarManager; +import android.graphics.RectF; import android.hardware.display.AmbientDisplayConfiguration; import android.media.AudioManager; import android.media.session.MediaSessionLegacyHelper; @@ -56,9 +59,9 @@ import java.io.PrintWriter; import javax.inject.Inject; /** - * Controller for {@link StatusBarWindowView}. + * Controller for {@link NotificationShadeWindowView}. */ -public class StatusBarWindowViewController { +public class NotificationShadeWindowViewController { private final InjectionInflationController mInjectionInflationController; private final NotificationWakeUpCoordinator mCoordinator; private final PulseExpansionHandler mPulseExpansionHandler; @@ -74,7 +77,7 @@ public class StatusBarWindowViewController { private final DozeLog mDozeLog; private final DozeParameters mDozeParameters; private final CommandQueue mCommandQueue; - private final StatusBarWindowView mView; + private final NotificationShadeWindowView mView; private final ShadeController mShadeController; private GestureDetector mGestureDetector; @@ -93,8 +96,13 @@ public class StatusBarWindowViewController { private final DockManager mDockManager; private final NotificationPanelViewController mNotificationPanelViewController; + // Used for determining view / touch intersection + private int[] mTempLocation = new int[2]; + private RectF mTempRect = new RectF(); + private boolean mIsTrackingBarGesture = false; + @Inject - public StatusBarWindowViewController( + public NotificationShadeWindowViewController( InjectionInflationController injectionInflationController, NotificationWakeUpCoordinator coordinator, PulseExpansionHandler pulseExpansionHandler, @@ -112,7 +120,7 @@ public class StatusBarWindowViewController { CommandQueue commandQueue, ShadeController shadeController, DockManager dockManager, - StatusBarWindowView statusBarWindowView, + NotificationShadeWindowView statusBarWindowView, NotificationPanelViewController notificationPanelViewController) { mInjectionInflationController = injectionInflationController; mCoordinator = coordinator; @@ -182,7 +190,7 @@ public class StatusBarWindowViewController { }; mGestureDetector = new GestureDetector(mView.getContext(), gestureListener); - mView.setInteractionEventHandler(new StatusBarWindowView.InteractionEventHandler() { + mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() { @Override public Boolean handleDispatchTouchEvent(MotionEvent ev) { boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN; @@ -244,6 +252,26 @@ public class StatusBarWindowViewController { return mStatusBarView.dispatchTouchEvent(ev); } + if (!mIsTrackingBarGesture && isDown + && mNotificationPanelViewController.isFullyCollapsed()) { + float x = ev.getRawX(); + float y = ev.getRawY(); + if (isIntersecting(mStatusBarView, x, y)) { + if (mService.isSameStatusBarState(WINDOW_STATE_SHOWING)) { + mIsTrackingBarGesture = true; + return mStatusBarView.dispatchTouchEvent(ev); + } else { // it's hidden or hiding, don't send to notification shade. + return true; + } + } + } else if (mIsTrackingBarGesture) { + final boolean sendToNotification = mStatusBarView.dispatchTouchEvent(ev); + if (isUp || isCancel) { + mIsTrackingBarGesture = false; + } + return sendToNotification; + } + return null; } @@ -357,7 +385,7 @@ public class StatusBarWindowViewController { dragDownCallback, mFalsingManager)); } - public StatusBarWindowView getView() { + public NotificationShadeWindowView getView() { return mView; } @@ -414,4 +442,11 @@ public class StatusBarWindowViewController { void setDragDownHelper(DragDownHelper dragDownHelper) { mDragDownHelper = dragDownHelper; } + + private boolean isIntersecting(View view, float x, float y) { + mTempLocation = view.getLocationOnScreen(); + mTempRect.set(mTempLocation[0], mTempLocation[1], mTempLocation[0] + view.getWidth(), + mTempLocation[1] + view.getHeight()); + return mTempRect.contains(x, y); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 3d8e09afea4d..af46f7bfa82d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -783,8 +783,7 @@ public abstract class PanelViewController { mView.getViewTreeObserver().removeOnGlobalLayoutListener(this); return; } - if (mStatusBar.getStatusBarWindow().getHeight() - != mStatusBar.getStatusBarHeight()) { + if (mStatusBar.getNotificationShadeWindowView().isVisibleToUser()) { mView.getViewTreeObserver().removeOnGlobalLayoutListener(this); if (mAnimateAfterExpanding) { notifyExpandingStarted(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 45f3bf986141..ffbbffc0d8d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -323,8 +323,7 @@ public class PhoneStatusBarView extends PanelBar { R.dimen.display_cutout_margin_consumption); ViewGroup.LayoutParams layoutParams = getLayoutParams(); - layoutParams.height = getResources().getDimensionPixelSize( - R.dimen.status_bar_height); + layoutParams.height = getResources().getDimensionPixelSize(R.dimen.status_bar_height); setLayoutParams(layoutParams); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java index 866dc2d51241..333061547d7e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java @@ -44,7 +44,7 @@ public class ShadeControllerImpl implements ShadeController { private final CommandQueue mCommandQueue; private final StatusBarStateController mStatusBarStateController; - protected final StatusBarWindowController mStatusBarWindowController; + protected final NotificationShadeWindowController mNotificationShadeWindowController; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private final int mDisplayId; protected final Lazy<StatusBar> mStatusBarLazy; @@ -57,7 +57,7 @@ public class ShadeControllerImpl implements ShadeController { public ShadeControllerImpl( CommandQueue commandQueue, StatusBarStateController statusBarStateController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, WindowManager windowManager, Lazy<StatusBar> statusBarLazy, @@ -66,7 +66,7 @@ public class ShadeControllerImpl implements ShadeController { ) { mCommandQueue = commandQueue; mStatusBarStateController = statusBarStateController; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mDisplayId = windowManager.getDefaultDisplay().getDisplayId(); // TODO: Remove circular reference to StatusBar when possible. @@ -122,14 +122,15 @@ public class ShadeControllerImpl implements ShadeController { } // TODO(b/62444020): remove when this bug is fixed - Log.v(TAG, "mStatusBarWindow: " + getStatusBarWindowView() + " canPanelBeCollapsed(): " + Log.v(TAG, "NotificationShadeWindow: " + getNotificationShadeWindowView() + + " canPanelBeCollapsed(): " + getNotificationPanelViewController().canPanelBeCollapsed()); - if (getStatusBarWindowView() != null + if (getNotificationShadeWindowView() != null && getNotificationPanelViewController().canPanelBeCollapsed()) { // release focus immediately to kick off focus change transition - mStatusBarWindowController.setStatusBarFocusable(false); + mNotificationShadeWindowController.setNotificationShadeFocusable(false); - getStatusBar().getStatusBarWindowViewController().cancelExpandHelper(); + getStatusBar().getNotificationShadeWindowViewController().cancelExpandHelper(); getStatusBarView().collapsePanel(true /* animate */, delayed, speedUpFactor); } else { mBubbleControllerLazy.get().collapseStack(); @@ -154,8 +155,7 @@ public class ShadeControllerImpl implements ShadeController { new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { - if (getStatusBar().getStatusBarWindow().getHeight() - != getStatusBar().getStatusBarHeight()) { + if (getStatusBar().getNotificationShadeWindowView().isVisibleToUser()) { getNotificationPanelViewController().removeOnGlobalLayoutListener(this); getNotificationPanelViewController().getView().post(executable); } @@ -222,8 +222,8 @@ public class ShadeControllerImpl implements ShadeController { return getStatusBar().getPresenter(); } - protected StatusBarWindowView getStatusBarWindowView() { - return getStatusBar().getStatusBarWindow(); + protected NotificationShadeWindowView getNotificationShadeWindowView() { + return getStatusBar().getNotificationShadeWindowView(); } protected PhoneStatusBarView getStatusBarView() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index dc9cf7714e7e..4e8442f14dba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -342,9 +342,11 @@ public class StatusBar extends SystemUI implements DemoMode, private final Point mCurrentDisplaySize = new Point(); - protected StatusBarWindowView mStatusBarWindow; + protected NotificationShadeWindowView mNotificationShadeWindowView; + protected StatusBarWindowView mPhoneStatusBarWindow; protected PhoneStatusBarView mStatusBarView; private int mStatusBarWindowState = WINDOW_STATE_SHOWING; + protected NotificationShadeWindowController mNotificationShadeWindowController; protected StatusBarWindowController mStatusBarWindowController; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final LockscreenLockIconController mLockscreenLockIconController; @@ -368,7 +370,7 @@ public class StatusBar extends SystemUI implements DemoMode, private final FalsingManager mFalsingManager; private final BroadcastDispatcher mBroadcastDispatcher; private final ConfigurationController mConfigurationController; - protected StatusBarWindowViewController mStatusBarWindowViewController; + protected NotificationShadeWindowViewController mNotificationShadeWindowViewController; private final DozeParameters mDozeParameters; private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy; private final Provider<StatusBarComponent.Builder> mStatusBarComponentBuilder; @@ -503,7 +505,7 @@ public class StatusBar extends SystemUI implements DemoMode, && ((info == null && imageWallpaperInAmbient) || (info != null && info.supportsAmbientMode())); - mStatusBarWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode); + mNotificationShadeWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode); mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode); } }; @@ -659,7 +661,7 @@ public class StatusBar extends SystemUI implements DemoMode, Lazy<AssistManager> assistManagerLazy, NotificationListener notificationListener, ConfigurationController configurationController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, LockscreenLockIconController lockscreenLockIconController, DozeParameters dozeParameters, ScrimController scrimController, @@ -740,7 +742,7 @@ public class StatusBar extends SystemUI implements DemoMode, mAssistManagerLazy = assistManagerLazy; mNotificationListener = notificationListener; mConfigurationController = configurationController; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mLockscreenLockIconController = lockscreenLockIconController; mDozeServiceHost = dozeServiceHost; mPowerManager = powerManager; @@ -912,7 +914,7 @@ public class StatusBar extends SystemUI implements DemoMode, mKeyguardUpdateMonitor.registerCallback(mUpdateCallback); mDozeServiceHost.initialize(this, mNotificationIconAreaController, - mStatusBarKeyguardViewManager, mStatusBarWindowViewController, + mStatusBarKeyguardViewManager, mNotificationShadeWindowViewController, mNotificationPanelViewController, mAmbientIndicationContainer); mConfigurationController.addCallback(this); @@ -930,7 +932,8 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { mMainThreadHandler.post( - () -> plugin.setup(getStatusBarWindow(), getNavigationBarView(), + () -> plugin.setup(getNotificationShadeWindowView(), + getNavigationBarView(), new Callback(plugin), mDozeParameters)); } @@ -938,7 +941,8 @@ public class StatusBar extends SystemUI implements DemoMode, public void onPluginDisconnected(OverlayPlugin plugin) { mMainThreadHandler.post(() -> { mOverlays.remove(plugin); - mStatusBarWindowController.setForcePluginOpen(mOverlays.size() != 0); + mNotificationShadeWindowController + .setForcePluginOpen(mOverlays.size() != 0); }); } @@ -957,10 +961,10 @@ public class StatusBar extends SystemUI implements DemoMode, mOverlays.remove(mPlugin); } mMainThreadHandler.post(() -> { - mStatusBarWindowController + mNotificationShadeWindowController .setStateListener(b -> mOverlays.forEach( o -> o.setCollapseDesired(b))); - mStatusBarWindowController + mNotificationShadeWindowController .setForcePluginOpen(mOverlays.size() != 0); }); } @@ -978,12 +982,13 @@ public class StatusBar extends SystemUI implements DemoMode, updateTheme(); inflateStatusBarWindow(); - mStatusBarWindowViewController.setService(this); - mStatusBarWindow.setOnTouchListener(getStatusBarWindowTouchListener()); + mNotificationShadeWindowViewController.setService(this); + mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener()); // TODO: Deal with the ugliness that comes from having some of the statusbar broken out // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot. - mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller); + mStackScroller = mNotificationShadeWindowView.findViewById( + R.id.notification_stack_scroller); NotificationListContainer notifListContainer = (NotificationListContainer) mStackScroller; mNotificationLogger.setUpWithContainer(notifListContainer); @@ -1004,17 +1009,18 @@ public class StatusBar extends SystemUI implements DemoMode, // Allow plugins to reference DarkIconDispatcher and StatusBarStateController mPluginDependencyProvider.allowPluginDependency(DarkIconDispatcher.class); mPluginDependencyProvider.allowPluginDependency(StatusBarStateController.class); - FragmentHostManager.get(mStatusBarWindow) + FragmentHostManager.get(mPhoneStatusBarWindow) .addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> { CollapsedStatusBarFragment statusBarFragment = (CollapsedStatusBarFragment) fragment; - statusBarFragment.initNotificationIconArea(mNotificationIconAreaController); + PhoneStatusBarView oldStatusBarView = mStatusBarView; - mStatusBarView = (PhoneStatusBarView) fragment.getView(); + mStatusBarView = (PhoneStatusBarView) statusBarFragment.getView(); mStatusBarView.setBar(this); mStatusBarView.setPanel(mNotificationPanelViewController); mStatusBarView.setScrimController(mScrimController); + statusBarFragment.initNotificationIconArea(mNotificationIconAreaController); // CollapsedStatusBarFragment re-inflated PhoneStatusBarView and both of // mStatusBarView.mExpanded and mStatusBarView.mBouncerShowing are false. // PhoneStatusBarView's new instance will set to be gone in @@ -1038,16 +1044,18 @@ public class StatusBar extends SystemUI implements DemoMode, mHeadsUpAppearanceController.destroy(); } // TODO: this should probably be scoped to the StatusBarComponent + // TODO (b/136993073) Separate notification shade and status bar mHeadsUpAppearanceController = new HeadsUpAppearanceController( - mNotificationIconAreaController, mHeadsUpManager, mStatusBarWindow, + mNotificationIconAreaController, mHeadsUpManager, + mNotificationShadeWindowView, mStatusBarStateController, mKeyguardBypassController, mKeyguardStateController, mWakeUpCoordinator, mCommandQueue, - mNotificationPanelViewController); + mNotificationPanelViewController, mStatusBarView); mHeadsUpAppearanceController.readFrom(oldController); mLightsOutNotifController.setLightsOutNotifView( mStatusBarView.findViewById(R.id.notification_lights_out)); - mStatusBarWindowViewController.setStatusBarView(mStatusBarView); + mNotificationShadeWindowViewController.setStatusBarView(mStatusBarView); checkBarModes(); }).getFragmentManager() .beginTransaction() @@ -1055,7 +1063,8 @@ public class StatusBar extends SystemUI implements DemoMode, CollapsedStatusBarFragment.TAG) .commit(); - mHeadsUpManager.setUp(mStatusBarWindow, mGroupManager, this, mVisualStabilityManager); + mHeadsUpManager.setUp(mNotificationShadeWindowView, mGroupManager, this, + mVisualStabilityManager); mConfigurationController.addCallback(mHeadsUpManager); mHeadsUpManager.addListener(this); mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener()); @@ -1075,12 +1084,12 @@ public class StatusBar extends SystemUI implements DemoMode, mKeyguardIndicationController = SystemUIFactory.getInstance().createKeyguardIndicationController(mContext, - mStatusBarWindow.findViewById(R.id.keyguard_indication_area), - mStatusBarWindow.findViewById(R.id.lock_icon)); + mNotificationShadeWindowView.findViewById(R.id.keyguard_indication_area), + mNotificationShadeWindowView.findViewById(R.id.lock_icon)); mNotificationPanelViewController.setKeyguardIndicationController( mKeyguardIndicationController); - mAmbientIndicationContainer = mStatusBarWindow.findViewById( + mAmbientIndicationContainer = mNotificationShadeWindowView.findViewById( R.id.ambient_indication_container); // TODO: Find better place for this callback. @@ -1101,13 +1110,13 @@ public class StatusBar extends SystemUI implements DemoMode, mAutoHideController.setStatusBar(this); - ScrimView scrimBehind = mStatusBarWindow.findViewById(R.id.scrim_behind); - ScrimView scrimInFront = mStatusBarWindow.findViewById(R.id.scrim_in_front); - ScrimView scrimForBubble = mStatusBarWindow.findViewById(R.id.scrim_for_bubble); + ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind); + ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front); + ScrimView scrimForBubble = mNotificationShadeWindowView.findViewById(R.id.scrim_for_bubble); mScrimController.setScrimVisibleListener(scrimsVisible -> { - mStatusBarWindowController.setScrimsVisibility(scrimsVisible); - if (mStatusBarWindow != null) { + mNotificationShadeWindowController.setScrimsVisibility(scrimsVisible); + if (mNotificationShadeWindowView != null) { mLockscreenLockIconController.onScrimVisibilityChanged(scrimsVisible); } }); @@ -1116,7 +1125,7 @@ public class StatusBar extends SystemUI implements DemoMode, mNotificationPanelViewController.initDependencies(this, mGroupManager, mNotificationShelf, mNotificationIconAreaController, mScrimController); - BackDropView backdrop = mStatusBarWindow.findViewById(R.id.backdrop); + BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper); @@ -1129,7 +1138,7 @@ public class StatusBar extends SystemUI implements DemoMode, mLockscreenLockIconController::onShowingLaunchAffordanceChanged); // Set up the quick settings tile panel - View container = mStatusBarWindow.findViewById(R.id.qs_frame); + final View container = mNotificationShadeWindowView.findViewById(R.id.qs_frame); if (container != null) { FragmentHostManager fragmentHostManager = FragmentHostManager.get(container); ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame, @@ -1138,7 +1147,8 @@ public class StatusBar extends SystemUI implements DemoMode, .withPlugin(QS.class) .withDefault(this::createDefaultQSFragment) .build()); - mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow, + mBrightnessMirrorController = new BrightnessMirrorController( + mNotificationShadeWindowView, mNotificationPanelViewController, (visible) -> { mBrightnessMirrorVisible = visible; @@ -1153,7 +1163,8 @@ public class StatusBar extends SystemUI implements DemoMode, }); } - mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch); + mReportRejectedTouch = mNotificationShadeWindowView + .findViewById(R.id.report_rejected_touch); if (mReportRejectedTouch != null) { updateReportRejectedTouchVisibility(); mReportRejectedTouch.setOnClickListener(v -> { @@ -1227,18 +1238,18 @@ public class StatusBar extends SystemUI implements DemoMode, } protected QS createDefaultQSFragment() { - return FragmentHostManager.get(mStatusBarWindow).create(QSFragment.class); + return FragmentHostManager.get(mNotificationShadeWindowView).create(QSFragment.class); } private void setUpPresenter() { // Set up the initial notification state. mActivityLaunchAnimator = new ActivityLaunchAnimator( - mStatusBarWindowViewController, this, mNotificationPanelViewController, + mNotificationShadeWindowViewController, this, mNotificationPanelViewController, (NotificationListContainer) mStackScroller); // TODO: inject this. mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController, - mHeadsUpManager, mStatusBarWindow, mStackScroller, mDozeScrimController, + mHeadsUpManager, mNotificationShadeWindowView, mStackScroller, mDozeScrimController, mScrimController, mActivityLaunchAnimator, mDynamicPrivacyController, mNotificationAlertingManager, mNotificationRowBinder, mKeyguardStateController, mKeyguardIndicationController, @@ -1251,7 +1262,7 @@ public class StatusBar extends SystemUI implements DemoMode, mDeviceProvisionedController); mNotificationShelf.setOnActivatedListener(mPresenter); - mRemoteInputManager.getController().addCallback(mStatusBarWindowController); + mRemoteInputManager.getController().addCallback(mNotificationShadeWindowController); mNotificationActivityStarter = mStatusBarNotificationActivityStarterBuilder @@ -1328,7 +1339,7 @@ public class StatusBar extends SystemUI implements DemoMode, mShadeController.animateCollapsePanels(); } } - return mStatusBarWindow.onTouchEvent(event); + return mNotificationShadeWindowView.onTouchEvent(event); }; } @@ -1384,17 +1395,20 @@ public class StatusBar extends SystemUI implements DemoMode, protected void createUserSwitcher() { mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, - mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), - mStatusBarWindow.findViewById(R.id.keyguard_header), + mNotificationShadeWindowView.findViewById(R.id.keyguard_user_switcher), + mNotificationShadeWindowView.findViewById(R.id.keyguard_header), mNotificationPanelViewController); } private void inflateStatusBarWindow() { - mStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView(); + mNotificationShadeWindowView = mSuperStatusBarViewFactory.getNotificationShadeWindowView(); StatusBarComponent statusBarComponent = mStatusBarComponentBuilder.get() - .statusBarWindowView(mStatusBarWindow).build(); - mStatusBarWindowViewController = statusBarComponent.getStatusBarWindowViewController(); - mStatusBarWindowViewController.setupExpandedStatusBar(); + .statusBarWindowView(mNotificationShadeWindowView).build(); + mNotificationShadeWindowViewController = statusBarComponent + .getNotificationShadeWindowViewController(); + mNotificationShadeWindowViewController.setupExpandedStatusBar(); + mStatusBarWindowController = statusBarComponent.getStatusBarWindowController(); + mPhoneStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView(); mNotificationPanelViewController = statusBarComponent.getNotificationPanelViewController(); } @@ -1404,7 +1418,8 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarKeyguardViewManager.registerStatusBar( /* statusBar= */ this, getBouncerContainer(), mNotificationPanelViewController, mBiometricUnlockController, - mDismissCallbackRegistry, mStatusBarWindow.findViewById(R.id.lock_icon_container), + mDismissCallbackRegistry, + mNotificationShadeWindowView.findViewById(R.id.lock_icon_container), mStackScroller, mKeyguardBypassController, mFalsingManager); mKeyguardIndicationController .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); @@ -1422,16 +1437,20 @@ public class StatusBar extends SystemUI implements DemoMode, return mStatusBarView; } + public NotificationShadeWindowView getNotificationShadeWindowView() { + return mNotificationShadeWindowView; + } + public StatusBarWindowView getStatusBarWindow() { - return mStatusBarWindow; + return mPhoneStatusBarWindow; } - public StatusBarWindowViewController getStatusBarWindowViewController() { - return mStatusBarWindowViewController; + public NotificationShadeWindowViewController getNotificationShadeWindowViewController() { + return mNotificationShadeWindowViewController; } protected ViewGroup getBouncerContainer() { - return mStatusBarWindow; + return mNotificationShadeWindowView; } public int getStatusBarHeight() { @@ -1641,7 +1660,7 @@ public class StatusBar extends SystemUI implements DemoMode, } public void setQsExpanded(boolean expanded) { - mStatusBarWindowController.setQsExpanded(expanded); + mNotificationShadeWindowController.setQsExpanded(expanded); mNotificationPanelViewController.setStatusAccessibilityImportance(expanded ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); @@ -1674,7 +1693,7 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) { if (inPinnedMode) { - mStatusBarWindowController.setHeadsUpShowing(true); + mNotificationShadeWindowController.setHeadsUpShowing(true); mStatusBarWindowController.setForceStatusBarVisible(true); if (mNotificationPanelViewController.isFullyCollapsed()) { // We need to ensure that the touchable region is updated before the window will be @@ -1682,9 +1701,9 @@ public class StatusBar extends SystemUI implements DemoMode, // onComputeInternalInsets will be called and after that we can resize the layout. Let's // make sure that the window stays small for one frame until the touchableRegion is set. mNotificationPanelViewController.getView().requestLayout(); - mStatusBarWindowController.setForceWindowCollapsed(true); + mNotificationShadeWindowController.setForceWindowCollapsed(true); mNotificationPanelViewController.getView().post(() -> { - mStatusBarWindowController.setForceWindowCollapsed(false); + mNotificationShadeWindowController.setForceWindowCollapsed(false); }); } } else { @@ -1694,7 +1713,7 @@ public class StatusBar extends SystemUI implements DemoMode, || mNotificationPanelViewController.isTracking() || bypassKeyguard) { // We are currently tracking or is open and the shade doesn't need to be kept // open artificially. - mStatusBarWindowController.setHeadsUpShowing(false); + mNotificationShadeWindowController.setHeadsUpShowing(false); if (bypassKeyguard) { mStatusBarWindowController.setForceStatusBarVisible(false); } @@ -1704,7 +1723,7 @@ public class StatusBar extends SystemUI implements DemoMode, mHeadsUpManager.setHeadsUpGoingAway(true); mNotificationPanelViewController.runAfterAnimationFinished(() -> { if (!mHeadsUpManager.hasPinnedHeadsUp()) { - mStatusBarWindowController.setHeadsUpShowing(false); + mNotificationShadeWindowController.setHeadsUpShowing(false); mHeadsUpManager.setHeadsUpGoingAway(false); } mRemoteInputManager.onPanelCollapsed(); @@ -1732,7 +1751,7 @@ public class StatusBar extends SystemUI implements DemoMode, public void setPanelExpanded(boolean isExpanded) { mPanelExpanded = isExpanded; updateHideIconsForBouncer(false /* animate */); - mStatusBarWindowController.setPanelExpanded(isExpanded); + mNotificationShadeWindowController.setPanelExpanded(isExpanded); mVisualStabilityManager.setPanelExpanded(isExpanded); if (isExpanded && mStatusBarStateController.getState() != StatusBarState.KEYGUARD) { if (DEBUG) { @@ -1991,7 +2010,7 @@ public class StatusBar extends SystemUI implements DemoMode, // Expand the window to encompass the full screen in anticipation of the drag. // This is only possible to do atomically because the status bar is at the top of the screen! - mStatusBarWindowController.setPanelVisible(true); + mNotificationShadeWindowController.setPanelVisible(true); visibilityChanged(true); mCommandQueue.recomputeDisableFlags(mDisplayId, !force /* animate */); @@ -2100,7 +2119,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible + " mExpandedVisible=" + mExpandedVisible); - if (!mExpandedVisible || mStatusBarWindow == null) { + if (!mExpandedVisible || mNotificationShadeWindowView == null) { return; } @@ -2113,8 +2132,8 @@ public class StatusBar extends SystemUI implements DemoMode, mExpandedVisible = false; visibilityChanged(false); - // Shrink the window to the size of the status bar only - mStatusBarWindowController.setPanelVisible(false); + // Update the visibility of notification shade and status bar window. + mNotificationShadeWindowController.setPanelVisible(false); mStatusBarWindowController.setForceStatusBarVisible(false); // Close any guts that might be visible @@ -2178,6 +2197,10 @@ public class StatusBar extends SystemUI implements DemoMode, return false; } + boolean isSameStatusBarState(int state) { + return mStatusBarWindowState == state; + } + public GestureRecorder getGestureRecorder() { return mGestureRec; } @@ -2193,7 +2216,7 @@ public class StatusBar extends SystemUI implements DemoMode, return; } boolean showing = state == WINDOW_STATE_SHOWING; - if (mStatusBarWindow != null + if (mNotificationShadeWindowView != null && window == StatusBarManager.WINDOW_STATUS_BAR && mStatusBarWindowState != state) { mStatusBarWindowState = state; @@ -2427,8 +2450,8 @@ public class StatusBar extends SystemUI implements DemoMode, dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions()); } pw.println(" StatusBarWindowView: "); - if (mStatusBarWindowViewController != null) { - mStatusBarWindowViewController.dump(fd, pw, args); + if (mNotificationShadeWindowViewController != null) { + mNotificationShadeWindowViewController.dump(fd, pw, args); } pw.println(" mMediaManager: "); @@ -2527,6 +2550,7 @@ public class StatusBar extends SystemUI implements DemoMode, public void createAndAddWindows(@Nullable RegisterStatusBarResult result) { makeStatusBarView(result); + mNotificationShadeWindowController.attach(); mStatusBarWindowController.attach(); } @@ -2690,8 +2714,8 @@ public class StatusBar extends SystemUI implements DemoMode, } } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { - if (mStatusBarWindowController != null) { - mStatusBarWindowController.setNotTouchable(false); + if (mNotificationShadeWindowController != null) { + mNotificationShadeWindowController.setNotTouchable(false); } if (mBubbleController.isStackExpanded()) { mBubbleController.collapseStack(); @@ -2808,7 +2832,9 @@ public class StatusBar extends SystemUI implements DemoMode, mQSPanel.updateResources(); } - mStatusBarWindowController.refreshStatusBarHeight(); + if (mStatusBarWindowController != null) { + mStatusBarWindowController.refreshStatusBarHeight(); + } if (mStatusBarView != null) { mStatusBarView.updateResources(); @@ -3518,7 +3544,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (!mPresenter.isPresenterFullyCollapsed()) { // if we set it not to be focusable when collapsing, we have to undo it when we aborted // the closing - mStatusBarWindowController.setStatusBarFocusable(true); + mNotificationShadeWindowController.setNotificationShadeFocusable(true); } } @@ -3631,7 +3657,7 @@ public class StatusBar extends SystemUI implements DemoMode, */ public void collapseShade() { if (mNotificationPanelViewController.isTracking()) { - mStatusBarWindowViewController.cancelCurrentTouch(); + mNotificationShadeWindowViewController.cancelCurrentTouch(); } if (mPanelExpanded && mState == StatusBarState.SHADE) { mShadeController.animateCollapsePanels(); @@ -3652,7 +3678,7 @@ public class StatusBar extends SystemUI implements DemoMode, updateVisibleToUser(); updateNotificationPanelTouchState(); - mStatusBarWindowViewController.cancelCurrentTouch(); + mNotificationShadeWindowViewController.cancelCurrentTouch(); if (mLaunchCameraOnFinishedGoingToSleep) { mLaunchCameraOnFinishedGoingToSleep = false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 407d25691798..de37cd955f9a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -92,7 +92,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private static String TAG = "StatusBarKeyguardViewManager"; protected final Context mContext; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() { @Override public void onFullyShown() { @@ -199,13 +199,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb KeyguardUpdateMonitor keyguardUpdateMonitor, NavigationModeController navigationModeController, DockManager dockManager, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, KeyguardStateController keyguardStateController, NotificationMediaManager notificationMediaManager) { mContext = context; mViewMediatorCallback = callback; mLockPatternUtils = lockPatternUtils; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mKeyguardStateController = keyguardStateController; mMediaManager = notificationMediaManager; mKeyguardUpdateManager = keyguardUpdateMonitor; @@ -315,7 +315,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb */ public void show(Bundle options) { mShowing = true; - mStatusBarWindowController.setKeyguardShowing(true); + mNotificationShadeWindowController.setKeyguardShowing(true); mKeyguardStateController.notifyKeyguardState(mShowing, mKeyguardStateController.isOccluded()); reset(true /* hideBouncerWhenShowing */); @@ -491,11 +491,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } public void setNeedsInput(boolean needsInput) { - mStatusBarWindowController.setKeyguardNeedsInput(needsInput); + mNotificationShadeWindowController.setKeyguardNeedsInput(needsInput); } public boolean isUnlockWithWallpaper() { - return mStatusBarWindowController.isShowingWallpaper(); + return mNotificationShadeWindowController.isShowingWallpaper(); } public void setOccluded(boolean occluded, boolean animate) { @@ -509,7 +509,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb new Runnable() { @Override public void run() { - mStatusBarWindowController.setKeyguardOccluded(mOccluded); + mNotificationShadeWindowController.setKeyguardOccluded(mOccluded); reset(true /* hideBouncerWhenShowing */); } }); @@ -524,7 +524,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (mShowing) { mMediaManager.updateMediaMetaData(false, animate && !occluded); } - mStatusBarWindowController.setKeyguardOccluded(occluded); + mNotificationShadeWindowController.setKeyguardOccluded(occluded); // setDozing(false) will call reset once we stop dozing. if (!mDozing) { @@ -578,8 +578,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() { @Override public void run() { - mStatusBarWindowController.setKeyguardShowing(false); - mStatusBarWindowController.setKeyguardFadingAway(true); + mNotificationShadeWindowController.setKeyguardShowing(false); + mNotificationShadeWindowController.setKeyguardFadingAway(true); hideBouncer(true /* destroyView */); updateStates(); } @@ -587,7 +587,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void run() { mStatusBar.hideKeyguard(); - mStatusBarWindowController.setKeyguardFadingAway(false); + mNotificationShadeWindowController.setKeyguardFadingAway(false); mViewMediatorCallback.keyguardGone(); executeAfterKeyguardGoneAction(); } @@ -624,7 +624,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } else { boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide(); if (!staying) { - mStatusBarWindowController.setKeyguardFadingAway(true); + mNotificationShadeWindowController.setKeyguardFadingAway(true); if (needsFading) { ViewGroupFadeHelper.fadeOutAllChildrenExcept( mNotificationPanelViewController.getView(), @@ -650,7 +650,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } updateLockIcon(); updateStates(); - mStatusBarWindowController.setKeyguardShowing(false); + mNotificationShadeWindowController.setKeyguardShowing(false); mViewMediatorCallback.keyguardGone(); } StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED, @@ -684,8 +684,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } public void onKeyguardFadedAway() { - mContainer.postDelayed(() -> mStatusBarWindowController.setKeyguardFadingAway(false), - 100); + mContainer.postDelayed(() -> mNotificationShadeWindowController + .setKeyguardFadingAway(false), 100); ViewGroupFadeHelper.reset(mNotificationPanelViewController.getView()); mStatusBar.finishKeyguardFadingAway(); mBiometricUnlockController.finishKeyguardFadingAway(); @@ -818,7 +818,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { - mStatusBarWindowController.setBouncerShowing(bouncerShowing); + mNotificationShadeWindowController.setBouncerShowing(bouncerShowing); mStatusBar.setBouncerShowing(bouncerShowing); updateLockIcon(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java index b4d5dadda5b8..7615bf826287 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java @@ -151,7 +151,7 @@ public class StatusBarModule { Lazy<AssistManager> assistManagerLazy, NotificationListener notificationListener, ConfigurationController configurationController, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, LockscreenLockIconController lockscreenLockIconController, DozeParameters dozeParameters, ScrimController scrimController, @@ -233,7 +233,7 @@ public class StatusBarModule { assistManagerLazy, notificationListener, configurationController, - statusBarWindowController, + notificationShadeWindowController, lockscreenLockIconController, dozeParameters, scrimController, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index 720f22964915..1336b2de82d3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -134,7 +134,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter, public StatusBarNotificationPresenter(Context context, NotificationPanelViewController panel, HeadsUpManagerPhone headsUp, - StatusBarWindowView statusBarWindow, + NotificationShadeWindowView statusBarWindow, ViewGroup stackScroller, DozeScrimController dozeScrimController, ScrimController scrimController, @@ -191,7 +191,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter, Dependency.get(NotificationRemoteInputManager.Callback.class), mNotificationPanel.createRemoteInputDelegate()); remoteInputManager.getController().addCallback( - Dependency.get(StatusBarWindowController.class)); + Dependency.get(NotificationShadeWindowController.class)); NotificationListContainer notifListContainer = (NotificationListContainer) stackScroller; initController.addPostInitTask(() -> { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java index 3d25749265f1..b8fb6d3ebacf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java @@ -17,15 +17,13 @@ package com.android.systemui.statusbar.phone; import android.annotation.NonNull; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.Rect; import android.view.View; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import com.android.systemui.Dependency; +import com.android.systemui.R; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; @@ -38,60 +36,62 @@ public final class StatusBarTouchableRegionManager implements OnComputeInternalInsetsListener, ConfigurationListener { private final BubbleController mBubbleController = Dependency.get(BubbleController.class); - private final Context mContext; private final HeadsUpManagerPhone mHeadsUpManager; private boolean mIsStatusBarExpanded = false; private boolean mShouldAdjustInsets = false; private final StatusBar mStatusBar; - private int mStatusBarHeight; - private final View mStatusBarWindowView; + private final View mNotificationShadeWindowView; + private View mNotificationPanelView; private boolean mForceCollapsedUntilLayout = false; - private final StatusBarWindowController mStatusBarWindowController; + private final NotificationShadeWindowController mNotificationShadeWindowController; - public StatusBarTouchableRegionManager(@NonNull Context context, - HeadsUpManagerPhone headsUpManager, + public StatusBarTouchableRegionManager(HeadsUpManagerPhone headsUpManager, @NonNull StatusBar statusBar, - @NonNull View statusBarWindowView) { - mContext = context; + @NonNull View notificationShadeWindowView) { mHeadsUpManager = headsUpManager; mStatusBar = statusBar; - mStatusBarWindowView = statusBarWindowView; - mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); - - initResources(); + mNotificationShadeWindowView = notificationShadeWindowView; + mNotificationShadeWindowController = + Dependency.get(NotificationShadeWindowController.class); mBubbleController.setBubbleStateChangeListener((hasBubbles) -> { updateTouchableRegion(); }); - mStatusBarWindowController.setForcePluginOpenListener((forceOpen) -> { + mNotificationShadeWindowController.setForcePluginOpenListener((forceOpen) -> { updateTouchableRegion(); }); Dependency.get(ConfigurationController.class).addCallback(this); + if (mNotificationShadeWindowView != null) { + mNotificationPanelView = mNotificationShadeWindowView.findViewById( + R.id.notification_panel); + } } /** * Set the touchable portion of the status bar based on what elements are visible. */ public void updateTouchableRegion() { - boolean hasCutoutInset = (mStatusBarWindowView != null) - && (mStatusBarWindowView.getRootWindowInsets() != null) - && (mStatusBarWindowView.getRootWindowInsets().getDisplayCutout() != null); + boolean hasCutoutInset = (mNotificationShadeWindowView != null) + && (mNotificationShadeWindowView.getRootWindowInsets() != null) + && (mNotificationShadeWindowView.getRootWindowInsets().getDisplayCutout() != null); boolean shouldObserve = mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpManager.isHeadsUpGoingAway() || mBubbleController.hasBubbles() || mForceCollapsedUntilLayout || hasCutoutInset - || mStatusBarWindowController.getForcePluginOpen(); + || mNotificationShadeWindowController.getForcePluginOpen(); if (shouldObserve == mShouldAdjustInsets) { return; } if (shouldObserve) { - mStatusBarWindowView.getViewTreeObserver().addOnComputeInternalInsetsListener(this); - mStatusBarWindowView.requestLayout(); + mNotificationShadeWindowView.getViewTreeObserver() + .addOnComputeInternalInsetsListener(this); + mNotificationShadeWindowView.requestLayout(); } else { - mStatusBarWindowView.getViewTreeObserver().removeOnComputeInternalInsetsListener(this); + mNotificationShadeWindowView.getViewTreeObserver() + .removeOnComputeInternalInsetsListener(this); } mShouldAdjustInsets = shouldObserve; } @@ -100,19 +100,20 @@ public final class StatusBarTouchableRegionManager implements * Calls {@code updateTouchableRegion()} after a layout pass completes. */ public void updateTouchableRegionAfterLayout() { - mForceCollapsedUntilLayout = true; - mStatusBarWindowView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, - int oldLeft, - int oldTop, int oldRight, int oldBottom) { - if (mStatusBarWindowView.getHeight() <= mStatusBarHeight) { - mStatusBarWindowView.removeOnLayoutChangeListener(this); - mForceCollapsedUntilLayout = false; - updateTouchableRegion(); + if (mNotificationPanelView != null) { + mForceCollapsedUntilLayout = true; + mNotificationPanelView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + if (!mNotificationPanelView.isVisibleToUser()) { + mNotificationPanelView.removeOnLayoutChangeListener(this); + mForceCollapsedUntilLayout = false; + updateTouchableRegion(); + } } - } - }); + }); + } } /** @@ -145,25 +146,4 @@ public final class StatusBarTouchableRegionManager implements info.touchableRegion.union(bubbleRect); } } - - @Override - public void onConfigChanged(Configuration newConfig) { - initResources(); - } - - @Override - public void onDensityOrFontScaleChanged() { - initResources(); - } - - @Override - public void onOverlayChanged() { - initResources(); - } - - private void initResources() { - Resources resources = mContext.getResources(); - mStatusBarHeight = resources.getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_height); - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java index ce498a39d941..7cf5147a9f26 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 The Android Open Source Project + * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -11,55 +11,25 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.systemui.statusbar.phone; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; -import static com.android.systemui.DejankUtils.whitelistIpcs; -import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT; - -import android.app.IActivityManager; import android.content.Context; -import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.graphics.PixelFormat; import android.os.Binder; -import android.os.RemoteException; -import android.os.SystemProperties; -import android.os.Trace; import android.util.Log; -import android.view.Display; import android.view.Gravity; -import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.view.WindowManager.LayoutParams; -import com.android.systemui.Dumpable; -import com.android.systemui.R; -import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.keyguard.KeyguardViewMediator; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; -import com.android.systemui.statusbar.RemoteInputController.Callback; -import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SuperStatusBarViewFactory; -import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; - -import com.google.android.collect.Lists; - -import java.io.FileDescriptor; -import java.io.PrintWriter; -import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; import javax.inject.Inject; import javax.inject.Singleton; @@ -68,101 +38,36 @@ import javax.inject.Singleton; * Encapsulates all logic for the status bar window state management. */ @Singleton -public class StatusBarWindowController implements Callback, Dumpable, ConfigurationListener { - +public class StatusBarWindowController { private static final String TAG = "StatusBarWindowController"; private static final boolean DEBUG = false; private final Context mContext; private final WindowManager mWindowManager; - private final IActivityManager mActivityManager; - private final DozeParameters mDozeParameters; - private final LayoutParams mLpChanged; - private final boolean mKeyguardScreenRotation; - private final long mLockScreenDisplayTimeout; - private final Display.Mode mKeyguardDisplayMode; - private final KeyguardBypassController mKeyguardBypassController; - private ViewGroup mStatusBarView; - private LayoutParams mLp; - private boolean mHasTopUi; - private boolean mHasTopUiChanged; + private final SuperStatusBarViewFactory mSuperStatusBarViewFactory; + private final Resources mResources; private int mBarHeight = -1; - private float mScreenBrightnessDoze; private final State mCurrentState = new State(); - private OtherwisedCollapsedListener mListener; - private ForcePluginOpenListener mForcePluginOpenListener; - private final ArrayList<WeakReference<StatusBarWindowCallback>> - mCallbacks = Lists.newArrayList(); - private final SysuiColorExtractor mColorExtractor; - private final SuperStatusBarViewFactory mSuperStatusBarViewFactory; - private final Resources mResources; + private ViewGroup mStatusBarView; + private WindowManager.LayoutParams mLp; + private final WindowManager.LayoutParams mLpChanged; @Inject public StatusBarWindowController(Context context, WindowManager windowManager, - IActivityManager activityManager, DozeParameters dozeParameters, - StatusBarStateController statusBarStateController, - ConfigurationController configurationController, - KeyguardBypassController keyguardBypassController, SysuiColorExtractor colorExtractor, SuperStatusBarViewFactory superStatusBarViewFactory, @Main Resources resources) { mContext = context; mWindowManager = windowManager; - mActivityManager = activityManager; - mKeyguardScreenRotation = shouldEnableKeyguardScreenRotation(); - mDozeParameters = dozeParameters; - mScreenBrightnessDoze = mDozeParameters.getScreenBrightnessDoze(); - mLpChanged = new LayoutParams(); - mKeyguardBypassController = keyguardBypassController; - mColorExtractor = colorExtractor; mSuperStatusBarViewFactory = superStatusBarViewFactory; mStatusBarView = mSuperStatusBarViewFactory.getStatusBarWindowView(); + mLpChanged = new WindowManager.LayoutParams(); mResources = resources; if (mBarHeight < 0) { mBarHeight = mResources.getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); } - - mLockScreenDisplayTimeout = context.getResources() - .getInteger(R.integer.config_lockScreenDisplayTimeout); - ((SysuiStatusBarStateController) statusBarStateController) - .addCallback(mStateListener, - SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER); - configurationController.addCallback(this); - - Display.Mode[] supportedModes = context.getDisplay().getSupportedModes(); - Display.Mode currentMode = context.getDisplay().getMode(); - // Running on the highest frame rate available can be expensive. - // Let's specify a preferred refresh rate, and allow higher FPS only when we - // know that we're not falsing (because we unlocked.) - int keyguardRefreshRate = context.getResources() - .getInteger(R.integer.config_keyguardRefreshRate); - // Find supported display mode with the same resolution and requested refresh rate. - mKeyguardDisplayMode = Arrays.stream(supportedModes).filter(mode -> - (int) mode.getRefreshRate() == keyguardRefreshRate - && mode.getPhysicalWidth() == currentMode.getPhysicalWidth() - && mode.getPhysicalHeight() == currentMode.getPhysicalHeight()) - .findFirst().orElse(null); - } - - /** - * Register to receive notifications about status bar window state changes. - */ - public void registerCallback(StatusBarWindowCallback callback) { - // Prevent adding duplicate callbacks - for (int i = 0; i < mCallbacks.size(); i++) { - if (mCallbacks.get(i).get() == callback) { - return; - } - } - mCallbacks.add(new WeakReference<StatusBarWindowCallback>(callback)); - } - - private boolean shouldEnableKeyguardScreenRotation() { - Resources res = mContext.getResources(); - return SystemProperties.getBoolean("lockscreen.rot_override", false) - || res.getBoolean(R.bool.config_enableLockScreenRotation); } public int getStatusBarHeight() { @@ -192,574 +97,46 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat // Now that the status bar window encompasses the sliding panel and its // translucent backdrop, the entire thing is made TRANSLUCENT and is // hardware-accelerated. - mLp = new LayoutParams( + mLp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, mBarHeight, - LayoutParams.TYPE_STATUS_BAR, - LayoutParams.FLAG_NOT_FOCUSABLE - | LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING - | LayoutParams.FLAG_SPLIT_TOUCH - | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH - | LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, + WindowManager.LayoutParams.TYPE_STATUS_BAR, + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH + | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, PixelFormat.TRANSLUCENT); mLp.token = new Binder(); mLp.gravity = Gravity.TOP; - mLp.setFitWindowInsetsTypes(0 /* types */); - mLp.softInputMode = LayoutParams.SOFT_INPUT_ADJUST_RESIZE; mLp.setTitle("StatusBar"); mLp.packageName = mContext.getPackageName(); mLp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; + mWindowManager.addView(mStatusBarView, mLp); mLpChanged.copyFrom(mLp); - onThemeChanged(); - } - - public ViewGroup getStatusBarView() { - return mStatusBarView; - } - - public void setDozeScreenBrightness(int value) { - mScreenBrightnessDoze = value / 255f; - } - - private void setKeyguardDark(boolean dark) { - int vis = mStatusBarView.getSystemUiVisibility(); - if (dark) { - vis = vis | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - vis = vis | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } else { - vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } - mStatusBarView.setSystemUiVisibility(vis); - } - - private void applyKeyguardFlags(State state) { - if (state.keyguardShowing) { - mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_KEYGUARD; - } else { - mLpChanged.privateFlags &= ~LayoutParams.PRIVATE_FLAG_KEYGUARD; - } - - final boolean scrimsOccludingWallpaper = - state.scrimsVisibility == ScrimController.OPAQUE; - final boolean keyguardOrAod = state.keyguardShowing - || (state.dozing && mDozeParameters.getAlwaysOn()); - if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) { - mLpChanged.flags |= LayoutParams.FLAG_SHOW_WALLPAPER; - } else { - mLpChanged.flags &= ~LayoutParams.FLAG_SHOW_WALLPAPER; - } - - if (state.dozing) { - mLpChanged.privateFlags |= LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; - } else { - mLpChanged.privateFlags &= ~LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; - } - - if (mKeyguardDisplayMode != null) { - boolean bypassOnKeyguard = mKeyguardBypassController.getBypassEnabled() - && state.statusBarState == StatusBarState.KEYGUARD && !state.keyguardFadingAway - && !state.keyguardGoingAway; - if (state.dozing || bypassOnKeyguard) { - mLpChanged.preferredDisplayModeId = mKeyguardDisplayMode.getModeId(); - } else { - mLpChanged.preferredDisplayModeId = 0; - } - Trace.setCounter("display_mode_id", mLpChanged.preferredDisplayModeId); - } - } - - private void adjustScreenOrientation(State state) { - if (state.isKeyguardShowingAndNotOccluded() || state.dozing) { - if (mKeyguardScreenRotation) { - mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; - } else { - mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; - } - } else { - mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; - } - } - - private void applyFocusableFlag(State state) { - boolean panelFocusable = state.statusBarFocusable && state.panelExpanded; - if (state.bouncerShowing && (state.keyguardOccluded || state.keyguardNeedsInput) - || ENABLE_REMOTE_INPUT && state.remoteInputActive - || state.bubbleExpanded) { - mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; - mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { - mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; - mLpChanged.flags |= LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } else { - mLpChanged.flags |= LayoutParams.FLAG_NOT_FOCUSABLE; - mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } - - mLpChanged.softInputMode = LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - } - - private void applyForceShowNavigationFlag(State state) { - if (state.panelExpanded || state.bouncerShowing - || ENABLE_REMOTE_INPUT && state.remoteInputActive) { - mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; - } else { - mLpChanged.privateFlags &= ~LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; - } - } - - private void applyHeight(State state) { - boolean expanded = isExpanded(state); - if (state.forcePluginOpen) { - if (mListener != null) { - mListener.setWouldOtherwiseCollapse(expanded); - } - expanded = true; - } - if (expanded) { - mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT; - } else { - mLpChanged.height = mBarHeight; - } - } - - private boolean isExpanded(State state) { - return !state.forceCollapsed && (state.isKeyguardShowingAndNotOccluded() - || state.panelVisible || state.keyguardFadingAway || state.bouncerShowing - || state.headsUpShowing || state.bubblesShowing - || state.scrimsVisibility != ScrimController.TRANSPARENT); } - private void applyFitsSystemWindows(State state) { - boolean fitsSystemWindows = !state.isKeyguardShowingAndNotOccluded(); - if (mStatusBarView != null && mStatusBarView.getFitsSystemWindows() != fitsSystemWindows) { - mStatusBarView.setFitsSystemWindows(fitsSystemWindows); - mStatusBarView.requestApplyInsets(); - } - } - - private void applyUserActivityTimeout(State state) { - if (state.isKeyguardShowingAndNotOccluded() - && state.statusBarState == StatusBarState.KEYGUARD - && !state.qsExpanded) { - mLpChanged.userActivityTimeout = state.bouncerShowing - ? KeyguardViewMediator.AWAKE_INTERVAL_BOUNCER_MS : mLockScreenDisplayTimeout; - } else { - mLpChanged.userActivityTimeout = -1; - } - } - - private void applyInputFeatures(State state) { - if (state.isKeyguardShowingAndNotOccluded() - && state.statusBarState == StatusBarState.KEYGUARD - && !state.qsExpanded && !state.forceUserActivity) { - mLpChanged.inputFeatures |= - LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; - } else { - mLpChanged.inputFeatures &= - ~LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; - } - } - - private void applyStatusBarColorSpaceAgnosticFlag(State state) { - if (!isExpanded(state)) { - mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; - } else { - mLpChanged.privateFlags &= - ~LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; - } + /** Set force status bar visible. */ + public void setForceStatusBarVisible(boolean forceStatusBarVisible) { + mCurrentState.mForceStatusBarVisible = forceStatusBarVisible; + apply(mCurrentState); } private void apply(State state) { - applyKeyguardFlags(state); applyForceStatusBarVisibleFlag(state); - applyFocusableFlag(state); - applyForceShowNavigationFlag(state); - adjustScreenOrientation(state); - applyHeight(state); - applyUserActivityTimeout(state); - applyInputFeatures(state); - applyFitsSystemWindows(state); - applyModalFlag(state); - applyBrightness(state); - applyHasTopUi(state); - applyNotTouchable(state); - applyStatusBarColorSpaceAgnosticFlag(state); if (mLp != null && mLp.copyFrom(mLpChanged) != 0) { mWindowManager.updateViewLayout(mStatusBarView, mLp); } - if (mHasTopUi != mHasTopUiChanged) { - whitelistIpcs(() -> { - try { - mActivityManager.setHasTopUi(mHasTopUiChanged); - } catch (RemoteException e) { - Log.e(TAG, "Failed to call setHasTopUi", e); - } - mHasTopUi = mHasTopUiChanged; - }); - } - notifyStateChangedCallbacks(); } - public void notifyStateChangedCallbacks() { - for (int i = 0; i < mCallbacks.size(); i++) { - StatusBarWindowCallback cb = mCallbacks.get(i).get(); - if (cb != null) { - cb.onStateChanged(mCurrentState.keyguardShowing, - mCurrentState.keyguardOccluded, - mCurrentState.bouncerShowing); - } - } + private static class State { + boolean mForceStatusBarVisible; } private void applyForceStatusBarVisibleFlag(State state) { - if (state.forceStatusBarVisible || state.forcePluginOpen) { - mLpChanged.privateFlags |= WindowManager - .LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; - } else { - mLpChanged.privateFlags - &= ~LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; - } - } - - private void applyModalFlag(State state) { - if (state.headsUpShowing) { - mLpChanged.flags |= LayoutParams.FLAG_NOT_TOUCH_MODAL; + if (state.mForceStatusBarVisible) { + mLpChanged.privateFlags |= PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; } else { - mLpChanged.flags &= ~LayoutParams.FLAG_NOT_TOUCH_MODAL; - } - } - - private void applyBrightness(State state) { - if (state.forceDozeBrightness) { - mLpChanged.screenBrightness = mScreenBrightnessDoze; - } else { - mLpChanged.screenBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE; - } - } - - private void applyHasTopUi(State state) { - mHasTopUiChanged = state.forceHasTopUi || isExpanded(state); - } - - private void applyNotTouchable(State state) { - if (state.notTouchable) { - mLpChanged.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; - } else { - mLpChanged.flags &= ~LayoutParams.FLAG_NOT_TOUCHABLE; - } - } - - public void setKeyguardShowing(boolean showing) { - mCurrentState.keyguardShowing = showing; - apply(mCurrentState); - } - - public void setKeyguardOccluded(boolean occluded) { - mCurrentState.keyguardOccluded = occluded; - apply(mCurrentState); - } - - public void setKeyguardNeedsInput(boolean needsInput) { - mCurrentState.keyguardNeedsInput = needsInput; - apply(mCurrentState); - } - - public void setPanelVisible(boolean visible) { - mCurrentState.panelVisible = visible; - mCurrentState.statusBarFocusable = visible; - apply(mCurrentState); - } - - public void setStatusBarFocusable(boolean focusable) { - mCurrentState.statusBarFocusable = focusable; - apply(mCurrentState); - } - - public void setBouncerShowing(boolean showing) { - mCurrentState.bouncerShowing = showing; - apply(mCurrentState); - } - - public void setBackdropShowing(boolean showing) { - mCurrentState.backdropShowing = showing; - apply(mCurrentState); - } - - public void setKeyguardFadingAway(boolean keyguardFadingAway) { - mCurrentState.keyguardFadingAway = keyguardFadingAway; - apply(mCurrentState); - } - - public void setQsExpanded(boolean expanded) { - mCurrentState.qsExpanded = expanded; - apply(mCurrentState); - } - - public void setForceUserActivity(boolean forceUserActivity) { - mCurrentState.forceUserActivity = forceUserActivity; - apply(mCurrentState); - } - - public void setScrimsVisibility(int scrimsVisibility) { - mCurrentState.scrimsVisibility = scrimsVisibility; - apply(mCurrentState); - } - - public void setHeadsUpShowing(boolean showing) { - mCurrentState.headsUpShowing = showing; - apply(mCurrentState); - } - - public void setWallpaperSupportsAmbientMode(boolean supportsAmbientMode) { - mCurrentState.wallpaperSupportsAmbientMode = supportsAmbientMode; - apply(mCurrentState); - } - - /** - * @param state The {@link StatusBarStateController} of the status bar. - */ - private void setStatusBarState(int state) { - mCurrentState.statusBarState = state; - apply(mCurrentState); - } - - public void setForceStatusBarVisible(boolean forceStatusBarVisible) { - mCurrentState.forceStatusBarVisible = forceStatusBarVisible; - apply(mCurrentState); - } - - /** - * Force the window to be collapsed, even if it should theoretically be expanded. - * Used for when a heads-up comes in but we still need to wait for the touchable regions to - * be computed. - */ - public void setForceWindowCollapsed(boolean force) { - mCurrentState.forceCollapsed = force; - apply(mCurrentState); - } - - public void setPanelExpanded(boolean isExpanded) { - mCurrentState.panelExpanded = isExpanded; - apply(mCurrentState); - } - - @Override - public void onRemoteInputActive(boolean remoteInputActive) { - mCurrentState.remoteInputActive = remoteInputActive; - apply(mCurrentState); - } - - /** - * Set whether the screen brightness is forced to the value we use for doze mode by the status - * bar window. - */ - public void setForceDozeBrightness(boolean forceDozeBrightness) { - mCurrentState.forceDozeBrightness = forceDozeBrightness; - apply(mCurrentState); - } - - public void setDozing(boolean dozing) { - mCurrentState.dozing = dozing; - apply(mCurrentState); - } - - public void setForcePluginOpen(boolean forcePluginOpen) { - mCurrentState.forcePluginOpen = forcePluginOpen; - apply(mCurrentState); - if (mForcePluginOpenListener != null) { - mForcePluginOpenListener.onChange(forcePluginOpen); + mLpChanged.privateFlags &= ~PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; } } - - /** - * The forcePluginOpen state for the status bar. - */ - public boolean getForcePluginOpen() { - return mCurrentState.forcePluginOpen; - } - - public void setNotTouchable(boolean notTouchable) { - mCurrentState.notTouchable = notTouchable; - apply(mCurrentState); - } - - /** - * Sets whether there are bubbles showing on the screen. - */ - public void setBubblesShowing(boolean bubblesShowing) { - mCurrentState.bubblesShowing = bubblesShowing; - apply(mCurrentState); - } - - /** - * The bubbles showing state for the status bar. - */ - public boolean getBubblesShowing() { - return mCurrentState.bubblesShowing; - } - - /** - * Sets if there is a bubble being expanded on the screen. - */ - public void setBubbleExpanded(boolean bubbleExpanded) { - mCurrentState.bubbleExpanded = bubbleExpanded; - apply(mCurrentState); - } - - /** - * Whether the bubble is shown in expanded state for the status bar. - */ - public boolean getBubbleExpanded() { - return mCurrentState.bubbleExpanded; - } - - /** - * Whether the status bar panel is expanded or not. - */ - public boolean getPanelExpanded() { - return mCurrentState.panelExpanded; - } - - public void setStateListener(OtherwisedCollapsedListener listener) { - mListener = listener; - } - - public void setForcePluginOpenListener(ForcePluginOpenListener listener) { - mForcePluginOpenListener = listener; - } - - public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("StatusBarWindowController:"); - pw.println(" mKeyguardDisplayMode=" + mKeyguardDisplayMode); - pw.println(mCurrentState); - } - - public boolean isShowingWallpaper() { - return !mCurrentState.backdropShowing; - } - - @Override - public void onThemeChanged() { - if (mStatusBarView == null) { - return; - } - - final boolean useDarkText = mColorExtractor.getNeutralColors().supportsDarkText(); - // Make sure we have the correct navbar/statusbar colors. - setKeyguardDark(useDarkText); - } - - /** - * When keyguard will be dismissed but didn't start animation yet. - */ - public void setKeyguardGoingAway(boolean goingAway) { - mCurrentState.keyguardGoingAway = goingAway; - apply(mCurrentState); - } - - public boolean getForceHasTopUi() { - return mCurrentState.forceHasTopUi; - } - - public void setForceHasTopUi(boolean forceHasTopUi) { - mCurrentState.forceHasTopUi = forceHasTopUi; - apply(mCurrentState); - } - - private static class State { - boolean keyguardShowing; - boolean keyguardOccluded; - boolean keyguardNeedsInput; - boolean panelVisible; - boolean panelExpanded; - boolean statusBarFocusable; - boolean bouncerShowing; - boolean keyguardFadingAway; - boolean keyguardGoingAway; - boolean qsExpanded; - boolean headsUpShowing; - boolean forceStatusBarVisible; - boolean forceCollapsed; - boolean forceDozeBrightness; - boolean forceUserActivity; - boolean backdropShowing; - boolean wallpaperSupportsAmbientMode; - boolean notTouchable; - boolean bubblesShowing; - boolean bubbleExpanded; - boolean forceHasTopUi; - - /** - * The {@link StatusBar} state from the status bar. - */ - int statusBarState; - - boolean remoteInputActive; - boolean forcePluginOpen; - boolean dozing; - int scrimsVisibility; - - private boolean isKeyguardShowingAndNotOccluded() { - return keyguardShowing && !keyguardOccluded; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - String newLine = "\n"; - result.append("Window State {"); - result.append(newLine); - - Field[] fields = this.getClass().getDeclaredFields(); - - // Print field names paired with their values - for (Field field : fields) { - result.append(" "); - try { - result.append(field.getName()); - result.append(": "); - //requires access to private field: - result.append(field.get(this)); - } catch (IllegalAccessException ex) { - } - result.append(newLine); - } - result.append("}"); - - return result.toString(); - } - } - - private final StateListener mStateListener = new StateListener() { - @Override - public void onStateChanged(int newState) { - setStatusBarState(newState); - } - - @Override - public void onDozingChanged(boolean isDozing) { - setDozing(isDozing); - } - }; - - /** - * Custom listener to pipe data back to plugins about whether or not the status bar would be - * collapsed if not for the plugin. - * TODO: Find cleaner way to do this. - */ - public interface OtherwisedCollapsedListener { - void setWouldOtherwiseCollapse(boolean otherwiseCollapse); - } - - /** - * Listener to indicate forcePluginOpen has changed - */ - public interface ForcePluginOpenListener { - /** - * Called when mState.forcePluginOpen is changed - */ - void onChange(boolean forceOpen); - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 1e3c5d608bf8..da5df6a72961 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,599 +16,19 @@ package com.android.systemui.statusbar.phone; -import android.annotation.ColorInt; -import android.annotation.DrawableRes; -import android.annotation.LayoutRes; import android.content.Context; -import android.content.res.Configuration; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Insets; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.Bundle; import android.util.AttributeSet; -import android.view.ActionMode; -import android.view.DisplayCutout; -import android.view.InputQueue; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.view.Window; -import android.view.WindowInsets; -import android.view.WindowInsetsController; import android.widget.FrameLayout; -import com.android.internal.view.FloatingActionMode; -import com.android.internal.widget.FloatingToolbar; -import com.android.systemui.R; - /** - * Combined status bar and notification panel view. Also holding backdrop and scrims. + * Status bar view. */ public class StatusBarWindowView extends FrameLayout { - public static final String TAG = "StatusBarWindowView"; - public static final boolean DEBUG = StatusBar.DEBUG; - - private int mRightInset = 0; - private int mLeftInset = 0; - - // Implements the floating action mode for TextView's Cut/Copy/Past menu. Normally provided by - // DecorView, but since this is a special window we have to roll our own. - private View mFloatingActionModeOriginatingView; - private ActionMode mFloatingActionMode; - private FloatingToolbar mFloatingToolbar; - private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener; - private InteractionEventHandler mInteractionEventHandler; + public static final String TAG = "PhoneStatusBarWindowView"; + public static final boolean DEBUG = StatusBar.DEBUG; public StatusBarWindowView(Context context, AttributeSet attrs) { super(context, attrs); - setMotionEventSplittingEnabled(false); - } - - public NotificationPanelView getNotificationPanelView() { - return findViewById(R.id.notification_panel); - } - - @Override - public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) { - final Insets insets = windowInsets.getMaxInsets(WindowInsets.Type.systemBars()); - if (getFitsSystemWindows()) { - boolean paddingChanged = insets.top != getPaddingTop() - || insets.bottom != getPaddingBottom(); - - int rightCutout = 0; - int leftCutout = 0; - DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout(); - if (displayCutout != null) { - leftCutout = displayCutout.getSafeInsetLeft(); - rightCutout = displayCutout.getSafeInsetRight(); - } - - int targetLeft = Math.max(insets.left, leftCutout); - int targetRight = Math.max(insets.right, rightCutout); - - // Super-special right inset handling, because scrims and backdrop need to ignore it. - if (targetRight != mRightInset || targetLeft != mLeftInset) { - mRightInset = targetRight; - mLeftInset = targetLeft; - applyMargins(); - } - // Drop top inset, and pass through bottom inset. - if (paddingChanged) { - setPadding(0, 0, 0, 0); - } - } else { - if (mRightInset != 0 || mLeftInset != 0) { - mRightInset = 0; - mLeftInset = 0; - applyMargins(); - } - boolean changed = getPaddingLeft() != 0 - || getPaddingRight() != 0 - || getPaddingTop() != 0 - || getPaddingBottom() != 0; - if (changed) { - setPadding(0, 0, 0, 0); - } - } - return windowInsets; - } - - private void applyMargins() { - final int N = getChildCount(); - for (int i = 0; i < N; i++) { - View child = getChildAt(i); - if (child.getLayoutParams() instanceof LayoutParams) { - LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if (!lp.ignoreRightInset - && (lp.rightMargin != mRightInset || lp.leftMargin != mLeftInset)) { - lp.rightMargin = mRightInset; - lp.leftMargin = mLeftInset; - child.requestLayout(); - } - } - } - } - - @Override - public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) { - return new LayoutParams(getContext(), attrs); - } - - @Override - protected FrameLayout.LayoutParams generateDefaultLayoutParams() { - return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); - } - - @Override - protected void onAttachedToWindow () { - super.onAttachedToWindow(); - setWillNotDraw(!DEBUG); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (mInteractionEventHandler.interceptMediaKey(event)) { - return true; - } - - if (super.dispatchKeyEvent(event)) { - return true; - } - - return mInteractionEventHandler.dispatchKeyEvent(event); - } - - protected void setInteractionEventHandler(InteractionEventHandler listener) { - mInteractionEventHandler = listener; - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - Boolean result = mInteractionEventHandler.handleDispatchTouchEvent(ev); - - return result != null ? result : super.dispatchTouchEvent(ev); - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - boolean intercept = mInteractionEventHandler.shouldInterceptTouchEvent(ev); - if (!intercept) { - intercept = super.onInterceptTouchEvent(ev); - } - if (intercept) { - mInteractionEventHandler.didIntercept(ev); - } - - return intercept; } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - boolean handled = mInteractionEventHandler.handleTouchEvent(ev); - - if (!handled) { - handled = super.onTouchEvent(ev); - } - - if (!handled) { - mInteractionEventHandler.didNotHandleTouchEvent(ev); - } - - return handled; - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (DEBUG) { - Paint pt = new Paint(); - pt.setColor(0x80FFFF00); - pt.setStrokeWidth(12.0f); - pt.setStyle(Paint.Style.STROKE); - canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt); - } - } - - public class LayoutParams extends FrameLayout.LayoutParams { - - public boolean ignoreRightInset; - - public LayoutParams(int width, int height) { - super(width, height); - } - - public LayoutParams(Context c, AttributeSet attrs) { - super(c, attrs); - - TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.StatusBarWindowView_Layout); - ignoreRightInset = a.getBoolean( - R.styleable.StatusBarWindowView_Layout_ignoreRightInset, false); - a.recycle(); - } - } - - @Override - public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, - int type) { - if (type == ActionMode.TYPE_FLOATING) { - return startActionMode(originalView, callback, type); - } - return super.startActionModeForChild(originalView, callback, type); - } - - private ActionMode createFloatingActionMode( - View originatingView, ActionMode.Callback2 callback) { - if (mFloatingActionMode != null) { - mFloatingActionMode.finish(); - } - cleanupFloatingActionModeViews(); - mFloatingToolbar = new FloatingToolbar(mFakeWindow); - final FloatingActionMode mode = - new FloatingActionMode(mContext, callback, originatingView, mFloatingToolbar); - mFloatingActionModeOriginatingView = originatingView; - mFloatingToolbarPreDrawListener = - new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - mode.updateViewLocationInWindow(); - return true; - } - }; - return mode; - } - - private void setHandledFloatingActionMode(ActionMode mode) { - mFloatingActionMode = mode; - mFloatingActionMode.invalidate(); // Will show the floating toolbar if necessary. - mFloatingActionModeOriginatingView.getViewTreeObserver() - .addOnPreDrawListener(mFloatingToolbarPreDrawListener); - } - - private void cleanupFloatingActionModeViews() { - if (mFloatingToolbar != null) { - mFloatingToolbar.dismiss(); - mFloatingToolbar = null; - } - if (mFloatingActionModeOriginatingView != null) { - if (mFloatingToolbarPreDrawListener != null) { - mFloatingActionModeOriginatingView.getViewTreeObserver() - .removeOnPreDrawListener(mFloatingToolbarPreDrawListener); - mFloatingToolbarPreDrawListener = null; - } - mFloatingActionModeOriginatingView = null; - } - } - - private ActionMode startActionMode( - View originatingView, ActionMode.Callback callback, int type) { - ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback); - ActionMode mode = createFloatingActionMode(originatingView, wrappedCallback); - if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) { - setHandledFloatingActionMode(mode); - } else { - mode = null; - } - return mode; - } - - private class ActionModeCallback2Wrapper extends ActionMode.Callback2 { - private final ActionMode.Callback mWrapped; - - public ActionModeCallback2Wrapper(ActionMode.Callback wrapped) { - mWrapped = wrapped; - } - - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - return mWrapped.onCreateActionMode(mode, menu); - } - - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - requestFitSystemWindows(); - return mWrapped.onPrepareActionMode(mode, menu); - } - - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return mWrapped.onActionItemClicked(mode, item); - } - - public void onDestroyActionMode(ActionMode mode) { - mWrapped.onDestroyActionMode(mode); - if (mode == mFloatingActionMode) { - cleanupFloatingActionModeViews(); - mFloatingActionMode = null; - } - requestFitSystemWindows(); - } - - @Override - public void onGetContentRect(ActionMode mode, View view, Rect outRect) { - if (mWrapped instanceof ActionMode.Callback2) { - ((ActionMode.Callback2) mWrapped).onGetContentRect(mode, view, outRect); - } else { - super.onGetContentRect(mode, view, outRect); - } - } - } - - interface InteractionEventHandler { - /** - * Returns a result for {@link ViewGroup#dispatchTouchEvent(MotionEvent)} or null to defer - * to the super method. - */ - Boolean handleDispatchTouchEvent(MotionEvent ev); - - /** - * Returns if the view should intercept the touch event. - * - * The touch event may still be interecepted if - * {@link ViewGroup#onInterceptTouchEvent(MotionEvent)} decides to do so. - */ - boolean shouldInterceptTouchEvent(MotionEvent ev); - - /** - * Called when the view decides to intercept the touch event. - */ - void didIntercept(MotionEvent ev); - - boolean handleTouchEvent(MotionEvent ev); - - void didNotHandleTouchEvent(MotionEvent ev); - - boolean interceptMediaKey(KeyEvent event); - - boolean dispatchKeyEvent(KeyEvent event); - } - - /** - * Minimal window to satisfy FloatingToolbar. - */ - private Window mFakeWindow = new Window(mContext) { - @Override - public void takeSurface(SurfaceHolder.Callback2 callback) { - } - - @Override - public void takeInputQueue(InputQueue.Callback callback) { - } - - @Override - public boolean isFloating() { - return false; - } - - @Override - public void alwaysReadCloseOnTouchAttr() { - } - - @Override - public void setContentView(@LayoutRes int layoutResID) { - } - - @Override - public void setContentView(View view) { - } - - @Override - public void setContentView(View view, ViewGroup.LayoutParams params) { - } - - @Override - public void addContentView(View view, ViewGroup.LayoutParams params) { - } - - @Override - public void clearContentView() { - } - - @Override - public View getCurrentFocus() { - return null; - } - - @Override - public LayoutInflater getLayoutInflater() { - return null; - } - - @Override - public void setTitle(CharSequence title) { - } - - @Override - public void setTitleColor(@ColorInt int textColor) { - } - - @Override - public void openPanel(int featureId, KeyEvent event) { - } - - @Override - public void closePanel(int featureId) { - } - - @Override - public void togglePanel(int featureId, KeyEvent event) { - } - - @Override - public void invalidatePanelMenu(int featureId) { - } - - @Override - public boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags) { - return false; - } - - @Override - public boolean performPanelIdentifierAction(int featureId, int id, int flags) { - return false; - } - - @Override - public void closeAllPanels() { - } - - @Override - public boolean performContextMenuIdentifierAction(int id, int flags) { - return false; - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - } - - @Override - public void setBackgroundDrawable(Drawable drawable) { - } - - @Override - public void setFeatureDrawableResource(int featureId, @DrawableRes int resId) { - } - - @Override - public void setFeatureDrawableUri(int featureId, Uri uri) { - } - - @Override - public void setFeatureDrawable(int featureId, Drawable drawable) { - } - - @Override - public void setFeatureDrawableAlpha(int featureId, int alpha) { - } - - @Override - public void setFeatureInt(int featureId, int value) { - } - - @Override - public void takeKeyEvents(boolean get) { - } - - @Override - public boolean superDispatchKeyEvent(KeyEvent event) { - return false; - } - - @Override - public boolean superDispatchKeyShortcutEvent(KeyEvent event) { - return false; - } - - @Override - public boolean superDispatchTouchEvent(MotionEvent event) { - return false; - } - - @Override - public boolean superDispatchTrackballEvent(MotionEvent event) { - return false; - } - - @Override - public boolean superDispatchGenericMotionEvent(MotionEvent event) { - return false; - } - - @Override - public View getDecorView() { - return StatusBarWindowView.this; - } - - @Override - public View peekDecorView() { - return null; - } - - @Override - public Bundle saveHierarchyState() { - return null; - } - - @Override - public void restoreHierarchyState(Bundle savedInstanceState) { - } - - @Override - protected void onActive() { - } - - @Override - public void setChildDrawable(int featureId, Drawable drawable) { - } - - @Override - public void setChildInt(int featureId, int value) { - } - - @Override - public boolean isShortcutKey(int keyCode, KeyEvent event) { - return false; - } - - @Override - public void setVolumeControlStream(int streamType) { - } - - @Override - public int getVolumeControlStream() { - return 0; - } - - @Override - public int getStatusBarColor() { - return 0; - } - - @Override - public void setStatusBarColor(@ColorInt int color) { - } - - @Override - public int getNavigationBarColor() { - return 0; - } - - @Override - public void setNavigationBarColor(@ColorInt int color) { - } - - @Override - public void setDecorCaptionShade(int decorCaptionShade) { - } - - @Override - public void setResizingCaptionDrawable(Drawable drawable) { - } - - @Override - public void onMultiWindowModeChanged() { - } - - @Override - public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { - } - - @Override - public void reportActivityRelaunched() { - } - - @Override - public WindowInsetsController getInsetsController() { - return null; - } - }; - } - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index 21d0bb8c2daf..802da3e8c21c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -19,8 +19,9 @@ package com.android.systemui.statusbar.phone.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBarWindowView; -import com.android.systemui.statusbar.phone.StatusBarWindowViewController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; +import com.android.systemui.statusbar.phone.StatusBarWindowController; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -41,7 +42,8 @@ public interface StatusBarComponent { */ @Subcomponent.Builder interface Builder { - @BindsInstance Builder statusBarWindowView(StatusBarWindowView statusBarWindowView); + @BindsInstance Builder statusBarWindowView( + NotificationShadeWindowView notificationShadeWindowView); StatusBarComponent build(); } @@ -54,10 +56,16 @@ public interface StatusBarComponent { @interface StatusBarScope {} /** + * Creates a NotificationShadeWindowViewController. + */ + @StatusBarScope + NotificationShadeWindowViewController getNotificationShadeWindowViewController(); + + /** * Creates a StatusBarWindowViewController. */ @StatusBarScope - StatusBarWindowViewController getStatusBarWindowViewController(); + StatusBarWindowController getStatusBarWindowController(); /** * Creates a NotificationPanelViewController. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 20bd51d27050..37d8c9ae2958 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -17,7 +17,7 @@ package com.android.systemui.statusbar.phone.dagger; import com.android.systemui.statusbar.phone.NotificationPanelView; -import com.android.systemui.statusbar.phone.StatusBarWindowView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import dagger.Module; import dagger.Provides; @@ -28,8 +28,8 @@ public abstract class StatusBarViewModule { @Provides @StatusBarComponent.StatusBarScope public static NotificationPanelView getNotificationPanelView( - StatusBarWindowView statusBarWindowView) { - return statusBarWindowView.getNotificationPanelView(); + NotificationShadeWindowView notificationShadeWindowView) { + return notificationShadeWindowView.getNotificationPanelView(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java index 625d88481c5a..d62da10de3d5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java @@ -25,7 +25,7 @@ import android.widget.FrameLayout; import com.android.systemui.R; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBarWindowView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import java.util.Objects; import java.util.function.Consumer; @@ -36,14 +36,14 @@ import java.util.function.Consumer; public class BrightnessMirrorController implements CallbackController<BrightnessMirrorController.BrightnessMirrorListener> { - private final StatusBarWindowView mStatusBarWindow; + private final NotificationShadeWindowView mStatusBarWindow; private final Consumer<Boolean> mVisibilityCallback; private final NotificationPanelViewController mNotificationPanel; private final ArraySet<BrightnessMirrorListener> mBrightnessMirrorListeners = new ArraySet<>(); private final int[] mInt2Cache = new int[2]; private View mBrightnessMirror; - public BrightnessMirrorController(StatusBarWindowView statusBarWindow, + public BrightnessMirrorController(NotificationShadeWindowView statusBarWindow, NotificationPanelViewController notificationPanelViewController, @NonNull Consumer<Boolean> visibilityCallback) { mStatusBarWindow = statusBarWindow; diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java index ba264c0ae6db..5706bee3f60d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java @@ -53,6 +53,7 @@ import com.android.systemui.ScreenDecorations.TunablePaddingTagListener; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentService; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.tuner.TunablePadding; @@ -80,7 +81,8 @@ public class ScreenDecorationsTest extends SysuiTestCase { private WindowManager mWindowManager; private FragmentService mFragmentService; private FragmentHostManager mFragmentHostManager; - private StatusBarWindowView mView; + private NotificationShadeWindowView mView; + private StatusBarWindowView mStatusBarWindowView; private TunablePaddingService mTunablePaddingService; private Handler mMainHandler; @Mock @@ -99,9 +101,11 @@ public class ScreenDecorationsTest extends SysuiTestCase { mFragmentService = mDependency.injectMockDependency(FragmentService.class); mWindowManager = mock(WindowManager.class); - mView = spy(new StatusBarWindowView(mContext, null)); + mView = spy(new NotificationShadeWindowView(mContext, null)); + mStatusBarWindowView = spy(new StatusBarWindowView(mContext, null)); when(mStatusBarLazy.get()).thenReturn(mStatusBar); - when(mStatusBar.getStatusBarWindow()).thenReturn(mView); + when(mStatusBar.getNotificationShadeWindowView()).thenReturn(mView); + when(mStatusBar.getStatusBarWindow()).thenReturn(mStatusBarWindowView); Display display = mContext.getSystemService(WindowManager.class).getDefaultDisplay(); when(mWindowManager.getDefaultDisplay()).thenReturn(display); diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java index c3df3f633f3b..04116ec68600 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -74,8 +74,8 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.HeadsUpManager; @@ -126,7 +126,7 @@ public class BubbleControllerTest extends SysuiTestCase { private ArgumentCaptor<NotificationRemoveInterceptor> mRemoveInterceptorCaptor; private TestableBubbleController mBubbleController; - private StatusBarWindowController mStatusBarWindowController; + private NotificationShadeWindowController mNotificationShadeWindowController; private NotificationEntryListener mEntryListener; private NotificationRemoveInterceptor mRemoveInterceptor; @@ -170,11 +170,11 @@ public class BubbleControllerTest extends SysuiTestCase { new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent())); // Bubbles get added to status bar window view - mStatusBarWindowController = new StatusBarWindowController(mContext, mWindowManager, - mActivityManager, mDozeParameters, mStatusBarStateController, + mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, + mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mConfigurationController, mKeyguardBypassController, mColorExtractor, - mSuperStatusBarViewFactory, mResources); - mStatusBarWindowController.attach(); + mSuperStatusBarViewFactory); + mNotificationShadeWindowController.attach(); // Need notifications for bubbles mNotificationTestHelper = new NotificationTestHelper(mContext, mDependency); @@ -201,7 +201,7 @@ public class BubbleControllerTest extends SysuiTestCase { mock(NotificationInterruptionStateProvider.HeadsUpSuppressor.class)); mBubbleData = new BubbleData(mContext); mBubbleController = new TestableBubbleController(mContext, - mStatusBarWindowController, + mNotificationShadeWindowController, mStatusBarStateController, mShadeController, mBubbleData, @@ -250,7 +250,7 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.removeBubble( mRow.getEntry().getKey(), BubbleController.DISMISS_USER_GESTURE); - assertFalse(mStatusBarWindowController.getBubblesShowing()); + assertFalse(mNotificationShadeWindowController.getBubblesShowing()); assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); verify(mNotificationEntryManager, times(2)).updateNotifications(anyString()); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); @@ -290,7 +290,7 @@ public class BubbleControllerTest extends SysuiTestCase { assertTrue(mBubbleController.hasBubbles()); mBubbleController.dismissStack(BubbleController.DISMISS_USER_GESTURE); - assertFalse(mStatusBarWindowController.getBubblesShowing()); + assertFalse(mNotificationShadeWindowController.getBubblesShowing()); verify(mNotificationEntryManager, times(3)).updateNotifications(any()); assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); assertNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().getKey())); @@ -308,14 +308,14 @@ public class BubbleControllerTest extends SysuiTestCase { assertTrue(mBubbleController.hasBubbles()); assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); - assertFalse(mStatusBarWindowController.getBubbleExpanded()); + assertFalse(mNotificationShadeWindowController.getBubbleExpanded()); // Expand the stack BubbleStackView stackView = mBubbleController.getStackView(); mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); - assertTrue(mStatusBarWindowController.getBubbleExpanded()); + assertTrue(mNotificationShadeWindowController.getBubbleExpanded()); // Make sure the notif is suppressed assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( @@ -325,7 +325,7 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.collapseStack(); verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().getKey()); assertFalse(mBubbleController.isStackExpanded()); - assertFalse(mStatusBarWindowController.getBubbleExpanded()); + assertFalse(mNotificationShadeWindowController.getBubbleExpanded()); } @Test @@ -711,7 +711,7 @@ public class BubbleControllerTest extends SysuiTestCase { static class TestableBubbleController extends BubbleController { // Let's assume surfaces can be synchronized immediately. TestableBubbleController(Context context, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, StatusBarStateController statusBarStateController, ShadeController shadeController, BubbleData data, @@ -723,7 +723,7 @@ public class BubbleControllerTest extends SysuiTestCase { NotificationEntryManager entryManager, RemoteInputUriController remoteInputUriController) { super(context, - statusBarWindowController, statusBarStateController, shadeController, + notificationShadeWindowController, statusBarStateController, shadeController, data, Runnable::run, configurationController, interruptionStateProvider, zenModeController, lockscreenUserManager, groupManager, entryManager, remoteInputUriController); diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java index 64fbc1bac658..acc30d9f8374 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -36,8 +36,8 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; @@ -57,7 +57,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock LockPatternUtils mLockPatternUtils; private @Mock KeyguardUpdateMonitor mUpdateMonitor; private @Mock StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private @Mock StatusBarWindowController mStatusBarWindowController; + private @Mock NotificationShadeWindowController mNotificationShadeWindowController; private @Mock BroadcastDispatcher mBroadcastDispatcher; private @Mock DismissCallbackRegistry mDismissCallbackRegistry; private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); @@ -77,7 +77,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { TestableLooper.get(this).runWithLooper(() -> { mViewMediator = new KeyguardViewMediator( mContext, mFalsingManager, mLockPatternUtils, mBroadcastDispatcher, - mStatusBarWindowController, () -> mStatusBarKeyguardViewManager, + mNotificationShadeWindowController, () -> mStatusBarKeyguardViewManager, mDismissCallbackRegistry, mUiBgExecutor); }); } @@ -87,6 +87,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mViewMediator.start(); mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); verify(mUpdateMonitor).setKeyguardGoingAway(false); - verify(mStatusBarWindowController, never()).setKeyguardGoingAway(anyBoolean()); + verify(mNotificationShadeWindowController, never()).setKeyguardGoingAway(anyBoolean()); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java index bb9c14bbb2a3..6d83ac32cef5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java @@ -34,8 +34,8 @@ import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener; import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBarWindowController; import com.android.systemui.statusbar.policy.HeadsUpManager; import org.junit.Before; @@ -97,6 +97,6 @@ public class NonPhoneDependencyTest extends SysuiTestCase { viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer); TestableLooper.get(this).processAllMessages(); - assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class)); + assertFalse(mDependency.hasInstantiatedDependency(NotificationShadeWindowController.class)); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java index 3fdbd3edfcaa..61e43b010dda 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java @@ -55,7 +55,7 @@ import com.android.systemui.statusbar.notification.row.NotificationRowContentBin import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; -import com.android.systemui.statusbar.phone.StatusBarWindowController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.tests.R; import java.util.concurrent.CountDownLatch; @@ -87,7 +87,7 @@ public class NotificationTestHelper { mContext = context; dependency.injectMockDependency(NotificationMediaManager.class); dependency.injectMockDependency(BubbleController.class); - dependency.injectMockDependency(StatusBarWindowController.class); + dependency.injectMockDependency(NotificationShadeWindowController.class); dependency.injectMockDependency(SmartReplyController.class); StatusBarStateController stateController = mock(StatusBarStateController.class); mGroupManager = new NotificationGroupManager(stateController); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimatorTest.java index a54f7335ba67..a07cfc3c3226 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimatorTest.java @@ -34,8 +34,8 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBarWindowView; -import com.android.systemui.statusbar.phone.StatusBarWindowViewController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; import org.junit.Assert; import org.junit.Before; @@ -49,20 +49,22 @@ public class ActivityLaunchAnimatorTest extends SysuiTestCase { private ActivityLaunchAnimator mLaunchAnimator; private ActivityLaunchAnimator.Callback mCallback = mock(ActivityLaunchAnimator.Callback.class); - private StatusBarWindowViewController mStatusBarWindowViewController = mock( - StatusBarWindowViewController.class); - private StatusBarWindowView mStatusBarWindowView = mock(StatusBarWindowView.class); + private NotificationShadeWindowViewController mNotificationShadeWindowViewController = mock( + NotificationShadeWindowViewController.class); + private NotificationShadeWindowView mNotificationShadeWindowView = mock( + NotificationShadeWindowView.class); private NotificationListContainer mNotificationContainer = mock(NotificationListContainer.class); private ExpandableNotificationRow mRow = mock(ExpandableNotificationRow.class); @Before public void setUp() throws Exception { - when(mStatusBarWindowViewController.getView()).thenReturn(mStatusBarWindowView); - when(mStatusBarWindowView.getResources()).thenReturn(mContext.getResources()); + when(mNotificationShadeWindowViewController.getView()) + .thenReturn(mNotificationShadeWindowView); + when(mNotificationShadeWindowView.getResources()).thenReturn(mContext.getResources()); when(mCallback.areLaunchAnimationsEnabled()).thenReturn(true); mLaunchAnimator = new ActivityLaunchAnimator( - mStatusBarWindowViewController, + mNotificationShadeWindowViewController, mCallback, mock(NotificationPanelViewController.class), mNotificationContainer); @@ -92,7 +94,7 @@ public class ActivityLaunchAnimatorTest extends SysuiTestCase { RemoteAnimationAdapter launchAnimation = mLaunchAnimator.getLaunchAnimation(mRow, false /* occluded */); Assert.assertTrue("No animation generated", launchAnimation != null); - executePostsImmediately(mStatusBarWindowView); + executePostsImmediately(mNotificationShadeWindowView); mLaunchAnimator.setLaunchResult(ActivityManager.START_SUCCESS, true /* wasIntentActivity */); verify(mCallback).onExpandAnimationTimedOut(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index 5907a0a683a8..769b774aeec2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -67,7 +67,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock - private StatusBarWindowController mStatusBarWindowController; + private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private DozeScrimController mDozeScrimController; @Mock @@ -104,9 +104,9 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { res.addOverride(com.android.internal.R.integer.config_wakeUpDelayDoze, 0); mBiometricUnlockController = new BiometricUnlockController(mContext, mDozeScrimController, mKeyguardViewMediator, mScrimController, mStatusBar, mShadeController, - mStatusBarWindowController, mKeyguardStateController, mHandler, mUpdateMonitor, - res.getResources(), mKeyguardBypassController, mDozeParameters, mMetricsLogger, - mDumpController); + mNotificationShadeWindowController, mKeyguardStateController, mHandler, + mUpdateMonitor, res.getResources(), mKeyguardBypassController, mDozeParameters, + mMetricsLogger, mDumpController); mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java index d31f17531889..3c6a69882d44 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java @@ -79,12 +79,12 @@ public class DozeServiceHostTest extends SysuiTestCase { @Mock private DozeLog mDozeLog; @Mock private PulseExpansionHandler mPulseExpansionHandler; @Mock private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; - @Mock private StatusBarWindowController mStatusBarWindowController; + @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private PowerManager mPowerManager; @Mock private WakefulnessLifecycle mWakefullnessLifecycle; @Mock private StatusBar mStatusBar; @Mock private NotificationIconAreaController mNotificationIconAreaController; - @Mock private StatusBarWindowViewController mStatusBarWindowViewController; + @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock private NotificationPanelViewController mNotificationPanel; @Mock private View mAmbientIndicationContainer; @@ -99,12 +99,12 @@ public class DozeServiceHostTest extends SysuiTestCase { mBatteryController, mScrimController, () -> mBiometricUnlockController, mKeyguardViewMediator, () -> mAssistManager, mDozeScrimController, mKeyguardUpdateMonitor, mVisualStabilityManager, mPulseExpansionHandler, - mStatusBarWindowController, mNotificationWakeUpCoordinator, + mNotificationShadeWindowController, mNotificationWakeUpCoordinator, mLockscreenLockIconController); mDozeServiceHost.initialize(mStatusBar, mNotificationIconAreaController, - mStatusBarKeyguardViewManager, mStatusBarWindowViewController, mNotificationPanel, - mAmbientIndicationContainer); + mStatusBarKeyguardViewManager, mNotificationShadeWindowViewController, + mNotificationPanel, mAmbientIndicationContainer); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java index 7fa69018b496..50d8bf0b02c2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java @@ -57,7 +57,7 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { private HeadsUpManagerPhone mHeadsUpManager; @Mock private NotificationGroupManager mGroupManager; - @Mock private View mStatusBarWindowView; + @Mock private View mNotificationShadeWindowView; @Mock private VisualStabilityManager mVSManager; @Mock private StatusBar mBar; @Mock private StatusBarStateController mStatusBarStateController; @@ -65,13 +65,13 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { private boolean mLivesPastNormalTime; private final class TestableHeadsUpManagerPhone extends HeadsUpManagerPhone { - TestableHeadsUpManagerPhone(Context context, View statusBarWindowView, + TestableHeadsUpManagerPhone(Context context, View notificationShadeWindowView, NotificationGroupManager groupManager, StatusBar bar, VisualStabilityManager vsManager, StatusBarStateController statusBarStateController, KeyguardBypassController keyguardBypassController) { super(context, statusBarStateController, keyguardBypassController); - setUp(statusBarWindowView, groupManager, bar, vsManager); + setUp(notificationShadeWindowView, groupManager, bar, vsManager); mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME; mAutoDismissNotificationDecay = TEST_AUTO_DISMISS_TIME; } @@ -89,9 +89,9 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { .thenReturn(TEST_AUTO_DISMISS_TIME); when(mVSManager.isReorderingAllowed()).thenReturn(true); mDependency.injectMockDependency(BubbleController.class); - mDependency.injectMockDependency(StatusBarWindowController.class); + mDependency.injectMockDependency(NotificationShadeWindowController.class); mDependency.injectMockDependency(ConfigurationController.class); - mHeadsUpManager = new TestableHeadsUpManagerPhone(mContext, mStatusBarWindowView, + mHeadsUpManager = new TestableHeadsUpManagerPhone(mContext, mNotificationShadeWindowView, mGroupManager, mBar, mVSManager, mStatusBarStateController, mBypassController); super.setUp(); mHeadsUpManager.mHandler = mTestHandler; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java index 147edf6589e9..40d3395f2ca1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.systemui.statusbar.phone; @@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.IActivityManager; -import android.content.res.Resources; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; import android.view.WindowManager; @@ -49,11 +48,11 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidTestingRunner.class) @RunWithLooper @SmallTest -public class StatusBarWindowControllerTest extends SysuiTestCase { +public class NotificationShadeWindowControllerTest extends SysuiTestCase { @Mock private WindowManager mWindowManager; @Mock private DozeParameters mDozeParameters; - @Mock private StatusBarWindowView mStatusBarView; + @Mock private NotificationShadeWindowView mStatusBarView; @Mock private IActivityManager mActivityManager; @Mock private SysuiStatusBarStateController mStatusBarStateController; @Mock private ConfigurationController mConfigurationController; @@ -61,28 +60,28 @@ public class StatusBarWindowControllerTest extends SysuiTestCase { @Mock private SysuiColorExtractor mColorExtractor; @Mock ColorExtractor.GradientColors mGradientColors; @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; - @Mock private Resources mResources; - private StatusBarWindowController mStatusBarWindowController; + private NotificationShadeWindowController mNotificationShadeWindowController; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mDozeParameters.getAlwaysOn()).thenReturn(true); when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); - when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(mStatusBarView); + when(mSuperStatusBarViewFactory.getNotificationShadeWindowView()) + .thenReturn(mStatusBarView); - mStatusBarWindowController = new StatusBarWindowController(mContext, mWindowManager, - mActivityManager, mDozeParameters, mStatusBarStateController, + mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, + mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mConfigurationController, mKeyguardBypassController, mColorExtractor, - mSuperStatusBarViewFactory, mResources); + mSuperStatusBarViewFactory); - mStatusBarWindowController.attach(); + mNotificationShadeWindowController.attach(); } @Test public void testSetDozing_hidesSystemOverlays() { - mStatusBarWindowController.setDozing(true); + mNotificationShadeWindowController.setDozing(true); ArgumentCaptor<WindowManager.LayoutParams> captor = ArgumentCaptor.forClass(WindowManager.LayoutParams.class); verify(mWindowManager).updateViewLayout(any(), captor.capture()); @@ -91,7 +90,7 @@ public class StatusBarWindowControllerTest extends SysuiTestCase { assertThat(flag).isNotEqualTo(0); reset(mWindowManager); - mStatusBarWindowController.setDozing(false); + mNotificationShadeWindowController.setDozing(false); verify(mWindowManager).updateViewLayout(any(), captor.capture()); flag = captor.getValue().privateFlags & WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; @@ -100,7 +99,7 @@ public class StatusBarWindowControllerTest extends SysuiTestCase { @Test public void testOnThemeChanged_doesntCrash() { - mStatusBarWindowController.onThemeChanged(); + mNotificationShadeWindowController.onThemeChanged(); } @Test @@ -110,6 +109,6 @@ public class StatusBarWindowControllerTest extends SysuiTestCase { @Test public void testSetForcePluginOpen_beforeStatusBarInitialization() { - mStatusBarWindowController.setForcePluginOpen(true); + mNotificationShadeWindowController.setForcePluginOpen(true); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java index f9848f3c0719..985354007e25 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarWindowViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java @@ -56,10 +56,10 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest -public class StatusBarWindowViewTest extends SysuiTestCase { +public class NotificationShadeWindowViewTest extends SysuiTestCase { - private StatusBarWindowView mView; - private StatusBarWindowViewController mController; + private NotificationShadeWindowView mView; + private NotificationShadeWindowViewController mController; @Mock private NotificationWakeUpCoordinator mCoordinator; @Mock private PulseExpansionHandler mPulseExpansionHandler; @@ -84,15 +84,16 @@ public class StatusBarWindowViewTest extends SysuiTestCase { public void setUp() { MockitoAnnotations.initMocks(this); - mView = spy(new StatusBarWindowView(getContext(), null)); + mView = spy(new NotificationShadeWindowView(getContext(), null)); when(mView.findViewById(R.id.notification_stack_scroller)) .thenReturn(mNotificationStackScrollLayout); + when(mStatusBarStateController.isDozing()).thenReturn(false); mDependency.injectTestDependency(ShadeController.class, mShadeController); when(mDockManager.isDocked()).thenReturn(false); - mController = new StatusBarWindowViewController( + mController = new NotificationShadeWindowViewController( new InjectionInflationController( SystemUIFactory.getInstance().getRootComponent()), mCoordinator, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 5b5eaadee552..675a2df768d8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -104,7 +104,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { mock(KeyguardUpdateMonitor.class), mock(NavigationModeController.class), mock(DockManager.class), - mock(StatusBarWindowController.class), + mock(NotificationShadeWindowController.class), mKeyguardStateController, mock(NotificationMediaManager.class)); mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer, @@ -270,12 +270,12 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { KeyguardUpdateMonitor keyguardUpdateMonitor, NavigationModeController navigationModeController, DockManager dockManager, - StatusBarWindowController statusBarWindowController, + NotificationShadeWindowController notificationShadeWindowController, KeyguardStateController keyguardStateController, NotificationMediaManager notificationMediaManager) { super(context, callback, lockPatternUtils, sysuiStatusBarStateController, configurationController, keyguardUpdateMonitor, navigationModeController, - dockManager, statusBarWindowController, keyguardStateController, + dockManager, notificationShadeWindowController, keyguardStateController, notificationMediaManager); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java index 782e14c83951..dd896be0e120 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java @@ -100,16 +100,17 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase { mDependency.injectMockDependency(NotificationMediaManager.class); mDependency.injectMockDependency(VisualStabilityManager.class); mDependency.injectMockDependency(NotificationGutsManager.class); - mDependency.injectMockDependency(StatusBarWindowController.class); + mDependency.injectMockDependency(NotificationShadeWindowController.class); NotificationEntryManager entryManager = mDependency.injectMockDependency(NotificationEntryManager.class); when(entryManager.getActiveNotificationsForCurrentUser()).thenReturn(new ArrayList<>()); - StatusBarWindowView statusBarWindowView = mock(StatusBarWindowView.class); - when(statusBarWindowView.getResources()).thenReturn(mContext.getResources()); + NotificationShadeWindowView notificationShadeWindowView = + mock(NotificationShadeWindowView.class); + when(notificationShadeWindowView.getResources()).thenReturn(mContext.getResources()); mStatusBarNotificationPresenter = new StatusBarNotificationPresenter(mContext, mock(NotificationPanelViewController.class), mock(HeadsUpManagerPhone.class), - statusBarWindowView, mock(NotificationListContainerViewGroup.class), + notificationShadeWindowView, mock(NotificationListContainerViewGroup.class), mock(DozeScrimController.class), mock(ScrimController.class), mock(ActivityLaunchAnimator.class), mock(DynamicPrivacyController.class), mock(NotificationAlertingManager.class), diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index fee48522683d..e90e398ba061 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -201,7 +201,7 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; - @Mock private StatusBarWindowView mStatusBarWindowView; + @Mock private NotificationShadeWindowView mNotificationShadeWindowView; @Mock private BroadcastDispatcher mBroadcastDispatcher; @Mock private AssistManager mAssistManager; @Mock private NotificationGutsManager mNotificationGutsManager; @@ -224,9 +224,9 @@ public class StatusBarTest extends SysuiTestCase { @Mock private BubbleController mBubbleController; @Mock private NotificationGroupManager mGroupManager; @Mock private NotificationGroupAlertTransferHelper mGroupAlertTransferHelper; - @Mock private StatusBarWindowController mStatusBarWindowController; + @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private NotificationIconAreaController mNotificationIconAreaController; - @Mock private StatusBarWindowViewController mStatusBarWindowViewController; + @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; @Mock private DozeParameters mDozeParameters; @Mock private Lazy<LockscreenWallpaper> mLockscreenWallpaperLazy; @Mock private LockscreenWallpaper mLockscreenWallpaper; @@ -324,11 +324,11 @@ public class StatusBarTest extends SysuiTestCase { when(mStatusBarComponentBuilderProvider.get()).thenReturn(mStatusBarComponentBuilder); when(mStatusBarComponentBuilder.build()).thenReturn(mStatusBarComponent); - when(mStatusBarComponent.getStatusBarWindowViewController()).thenReturn( - mStatusBarWindowViewController); + when(mStatusBarComponent.getNotificationShadeWindowViewController()).thenReturn( + mNotificationShadeWindowViewController); mShadeController = new ShadeControllerImpl(mCommandQueue, - mStatusBarStateController, mStatusBarWindowController, + mStatusBarStateController, mNotificationShadeWindowController, mStatusBarKeyguardViewManager, mContext.getSystemService(WindowManager.class), () -> mStatusBar, () -> mAssistManager, () -> mBubbleController); @@ -384,7 +384,7 @@ public class StatusBarTest extends SysuiTestCase { () -> mAssistManager, mNotificationListener, configurationController, - mStatusBarWindowController, + mNotificationShadeWindowController, mLockscreenLockIconController, mDozeParameters, mScrimController, @@ -417,7 +417,7 @@ public class StatusBarTest extends SysuiTestCase { mNotificationRowBinder, mDismissCallbackRegistry); - when(mStatusBarWindowView.findViewById(R.id.lock_icon_container)).thenReturn( + when(mNotificationShadeWindowView.findViewById(R.id.lock_icon_container)).thenReturn( mLockIconContainer); when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class), @@ -430,7 +430,7 @@ public class StatusBarTest extends SysuiTestCase { // TODO: we should be able to call mStatusBar.start() and have all the below values // initialized automatically. - mStatusBar.mStatusBarWindow = mStatusBarWindowView; + mStatusBar.mNotificationShadeWindowView = mNotificationShadeWindowView; mStatusBar.mNotificationPanelViewController = mNotificationPanelViewController; mStatusBar.mDozeScrimController = mDozeScrimController; mStatusBar.mNotificationIconAreaController = mNotificationIconAreaController; diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java index 8ce92a3154f3..a6041e0ee91c 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java @@ -701,6 +701,7 @@ public class AccessibilityWindowManager { case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL: case WindowManager.LayoutParams.TYPE_SEARCH_BAR: case WindowManager.LayoutParams.TYPE_STATUS_BAR: + case WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE: case WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL: case WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL: case WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY: diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index ea83adba4d8a..ec9049ee05ee 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -46,7 +46,6 @@ import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SYSTEM_WINDOW; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR; import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; @@ -55,6 +54,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG; @@ -1632,7 +1632,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // If a system window has focus, then it doesn't make sense // right now to interact with applications. if (info.layoutParamsType == TYPE_KEYGUARD_DIALOG - || (info.layoutParamsPrivateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { + || (info.layoutParamsType == TYPE_NOTIFICATION_SHADE + && isKeyguardShowing())) { // the "app" is keyguard, so give it the key return 0; } @@ -2205,12 +2206,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public int getMaxWallpaperLayer() { - return getWindowLayerFromTypeLw(TYPE_STATUS_BAR); + return getWindowLayerFromTypeLw(TYPE_NOTIFICATION_SHADE); } @Override public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { - return attrs.type == TYPE_STATUS_BAR; + return attrs.type == TYPE_NOTIFICATION_SHADE; } @Override @@ -2221,6 +2222,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } switch (win.getAttrs().type) { + case TYPE_NOTIFICATION_SHADE: case TYPE_STATUS_BAR: case TYPE_NAVIGATION_BAR: case TYPE_WALLPAPER: @@ -2228,7 +2230,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; default: // Hide only windows below the keyguard host window. - return getWindowLayerLw(win) < getWindowLayerFromTypeLw(TYPE_STATUS_BAR); + return getWindowLayerLw(win) < getWindowLayerFromTypeLw(TYPE_NOTIFICATION_SHADE); } } @@ -3445,7 +3447,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardOccluded = false; mKeyguardDelegate.setOccluded(false, true /* animate */); if (mKeyguardCandidate != null) { - mKeyguardCandidate.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; if (!mKeyguardDelegate.hasLockscreenWallpaper()) { mKeyguardCandidate.getAttrs().flags |= FLAG_SHOW_WALLPAPER; } @@ -3455,7 +3456,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardOccluded = true; mKeyguardDelegate.setOccluded(true, false /* animate */); if (mKeyguardCandidate != null) { - mKeyguardCandidate.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; mKeyguardCandidate.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; } return true; @@ -4658,6 +4658,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } @Override + public boolean isKeyguardShowing() { + if (mKeyguardDelegate == null) return false; + return mKeyguardDelegate.isShowing(); + } + + @Override public boolean isKeyguardShowingAndNotOccluded() { if (mKeyguardDelegate == null) return false; return mKeyguardDelegate.isShowing() && !mKeyguardOccluded; diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index b014372fa7cb..c39da5fb0e99 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -39,6 +39,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_PHONE; import static android.view.WindowManager.LayoutParams.TYPE_POINTER; import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; @@ -812,55 +813,57 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { return 16; case TYPE_STATUS_BAR: return 17; - case TYPE_STATUS_BAR_PANEL: + case TYPE_NOTIFICATION_SHADE: return 18; - case TYPE_STATUS_BAR_SUB_PANEL: + case TYPE_STATUS_BAR_PANEL: return 19; - case TYPE_KEYGUARD_DIALOG: + case TYPE_STATUS_BAR_SUB_PANEL: return 20; + case TYPE_KEYGUARD_DIALOG: + return 21; case TYPE_VOLUME_OVERLAY: // the on-screen volume indicator and controller shown when the user // changes the device volume - return 21; + return 22; case TYPE_SYSTEM_OVERLAY: // the on-screen volume indicator and controller shown when the user // changes the device volume - return canAddInternalSystemWindow ? 22 : 11; + return canAddInternalSystemWindow ? 23 : 11; case TYPE_NAVIGATION_BAR: // the navigation bar, if available, shows atop most things - return 23; + return 24; case TYPE_NAVIGATION_BAR_PANEL: // some panels (e.g. search) need to show on top of the navigation bar - return 24; + return 25; case TYPE_SCREENSHOT: // screenshot selection layer shouldn't go above system error, but it should cover // navigation bars at the very least. - return 25; + return 26; case TYPE_SYSTEM_ERROR: // system-level error dialogs - return canAddInternalSystemWindow ? 26 : 10; + return canAddInternalSystemWindow ? 27 : 10; case TYPE_MAGNIFICATION_OVERLAY: // used to highlight the magnified portion of a display - return 27; + return 28; case TYPE_DISPLAY_OVERLAY: // used to simulate secondary display devices - return 28; + return 29; case TYPE_DRAG: // the drag layer: input for drag-and-drop is associated with this window, // which sits above all other focusable windows - return 29; + return 30; case TYPE_ACCESSIBILITY_OVERLAY: // overlay put by accessibility services to intercept user interaction - return 30; + return 31; case TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY: - return 31; + return 32; case TYPE_SECURE_SYSTEM_OVERLAY: - return 32; - case TYPE_BOOT_PROGRESS: return 33; + case TYPE_BOOT_PROGRESS: + return 34; case TYPE_POINTER: // the (mouse) pointer layer - return 34; + return 35; default: Slog.e("WindowManager", "Unknown window type: " + type); return APPLICATION_LAYER; @@ -1195,6 +1198,11 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { public boolean isKeyguardOccluded(); /** + * @return true if in keyguard is on. + */ + boolean isKeyguardShowing(); + + /** * @return true if in keyguard is on and not occluded. */ public boolean isKeyguardShowingAndNotOccluded(); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 908c4f1ddd66..f93309a84466 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -65,7 +65,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; @@ -75,7 +74,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; -import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; @@ -875,7 +874,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (w.mHasSurface && isDisplayed) { final int type = w.mAttrs.type; if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR - || (w.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { + || mWmService.mPolicy.isKeyguardShowing()) { mTmpApplySurfaceChangesTransactionState.syswin = true; } if (mTmpApplySurfaceChangesTransactionState.preferredRefreshRate == 0 @@ -3557,7 +3556,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final SparseBooleanArray drawnWindowTypes = new SparseBooleanArray(); // Presuppose keyguard is drawn because if its window isn't attached, we don't know if it // wants to be shown or hidden, then it should not delay enabling the screen. - drawnWindowTypes.put(TYPE_STATUS_BAR, true); + drawnWindowTypes.put(TYPE_NOTIFICATION_SHADE, true); final WindowState visibleNotDrawnWindow = getWindow(w -> { if (w.mViewVisibility == View.VISIBLE && !w.mObscured && !w.isDrawnLw()) { @@ -3568,8 +3567,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (type == TYPE_BOOT_PROGRESS || type == TYPE_BASE_APPLICATION || type == TYPE_WALLPAPER) { drawnWindowTypes.put(type, true); - } else if (type == TYPE_STATUS_BAR) { - drawnWindowTypes.put(TYPE_STATUS_BAR, mWmService.mPolicy.isKeyguardDrawnLw()); + } else if (type == TYPE_NOTIFICATION_SHADE) { + drawnWindowTypes.put(TYPE_NOTIFICATION_SHADE, + mWmService.mPolicy.isKeyguardDrawnLw()); } } return false; @@ -3591,7 +3591,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final boolean haveBootMsg = drawnWindowTypes.get(TYPE_BOOT_PROGRESS); final boolean haveApp = drawnWindowTypes.get(TYPE_BASE_APPLICATION); final boolean haveWallpaper = drawnWindowTypes.get(TYPE_WALLPAPER); - final boolean haveKeyguard = drawnWindowTypes.get(TYPE_STATUS_BAR); + final boolean haveKeyguard = drawnWindowTypes.get(TYPE_NOTIFICATION_SHADE); ProtoLog.i(WM_DEBUG_SCREEN_ON, "******** booted=%b msg=%b haveBoot=%b haveApp=%b haveWall=%b " @@ -5445,7 +5445,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_IMMERSIVE_STICKY; final boolean stickyHideNav = (sysUiVisibility & stickyHideNavFlags) == stickyHideNavFlags; - return !stickyHideNav && type != TYPE_INPUT_METHOD && type != TYPE_STATUS_BAR + return !stickyHideNav && type != TYPE_INPUT_METHOD && type != TYPE_NOTIFICATION_SHADE && win.getActivityType() != ACTIVITY_TYPE_HOME; } diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index d6e3c8a8b179..2c325e56cebe 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -61,9 +61,8 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; @@ -78,6 +77,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; @@ -290,6 +290,7 @@ public class DisplayPolicy { private final ArraySet<WindowState> mScreenDecorWindows = new ArraySet<>(); private WindowState mStatusBar = null; + private WindowState mNotificationShade = null; private final int[] mStatusBarHeightForRotation = new int[4]; private WindowState mNavigationBar = null; @NavigationBarPosition @@ -369,8 +370,6 @@ public class DisplayPolicy { private WindowState mTopDockedOpaqueOrDimmingWindowState; private boolean mTopIsFullscreen; private boolean mForceStatusBar; - private boolean mForceStatusBarFromKeyguard; - private boolean mForceStatusBarTransparent; private int mNavBarOpacityMode = NAV_BAR_OPAQUE_WHEN_FREEFORM_OR_DOCKED; private boolean mForcingShowNavBar; private int mForcingShowNavBarLayer; @@ -852,15 +851,13 @@ public class DisplayPolicy { // letterboxed. Hence always let them extend under the cutout. attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; break; - case TYPE_STATUS_BAR: - + case TYPE_NOTIFICATION_SHADE: // If the Keyguard is in a hidden state (occluded by another window), we force to // remove the wallpaper and keyguard flag so that any change in-flight after setting // the keyguard as occluded wouldn't set these flags again. // See {@link #processKeyguardSetHiddenResultLw}. if (mService.mPolicy.isKeyguardOccluded()) { attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; - attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; } break; @@ -892,11 +889,6 @@ public class DisplayPolicy { attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; break; } - - if (attrs.type != TYPE_STATUS_BAR) { - // The status bar is the only window allowed to exhibit keyguard behavior. - attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; - } } /** @@ -915,6 +907,7 @@ public class DisplayPolicy { * Currently enforces that two window types are singletons per display: * <ul> * <li>{@link WindowManager.LayoutParams#TYPE_STATUS_BAR}</li> + * <li>{@link WindowManager.LayoutParams#TYPE_NOTIFICATION_SHADE}</li> * <li>{@link WindowManager.LayoutParams#TYPE_NAVIGATION_BAR}</li> * </ul> * @@ -941,6 +934,16 @@ public class DisplayPolicy { } } break; + case TYPE_NOTIFICATION_SHADE: + mContext.enforceCallingOrSelfPermission( + android.Manifest.permission.STATUS_BAR_SERVICE, + "DisplayPolicy"); + if (mNotificationShade != null) { + if (mNotificationShade.isAlive()) { + return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; + } + } + break; case TYPE_NAVIGATION_BAR: mContext.enforceCallingOrSelfPermission( android.Manifest.permission.STATUS_BAR_SERVICE, @@ -975,12 +978,15 @@ public class DisplayPolicy { } switch (attrs.type) { - case TYPE_STATUS_BAR: - mStatusBar = win; - mStatusBarController.setWindow(win); + case TYPE_NOTIFICATION_SHADE: + mNotificationShade = win; if (mDisplayContent.isDefaultDisplay) { mService.mPolicy.setKeyguardCandidateLw(win); } + break; + case TYPE_STATUS_BAR: + mStatusBar = win; + mStatusBarController.setWindow(win); final TriConsumer<DisplayFrames, WindowState, Rect> frameProvider = (displayFrames, windowState, rect) -> { rect.top = 0; @@ -1037,14 +1043,16 @@ public class DisplayPolicy { if (mStatusBar == win) { mStatusBar = null; mStatusBarController.setWindow(null); - if (mDisplayContent.isDefaultDisplay) { - mService.mPolicy.setKeyguardCandidateLw(null); - } mDisplayContent.setInsetProvider(ITYPE_STATUS_BAR, null, null); } else if (mNavigationBar == win) { mNavigationBar = null; mNavigationBarController.setWindow(null); mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, null, null); + } else if (mNotificationShade == win) { + mNotificationShade = null; + if (mDisplayContent.isDefaultDisplay) { + mService.mPolicy.setKeyguardCandidateLw(null); + } } if (mLastFocusedWindow == win) { mLastFocusedWindow = null; @@ -1061,6 +1069,10 @@ public class DisplayPolicy { return mStatusBar; } + WindowState getNotificationShade() { + return mNotificationShade; + } + WindowState getNavigationBar() { return mNavigationBar; } @@ -1083,12 +1095,6 @@ public class DisplayPolicy { if (DEBUG_ANIM) Slog.i(TAG, "selectAnimation in " + win + ": transit=" + transit); if (win == mStatusBar) { - final boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; - final boolean expanded = win.getAttrs().height == MATCH_PARENT - && win.getAttrs().width == MATCH_PARENT; - if (isKeyguard || expanded) { - return ANIMATION_NONE; - } if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) { return R.anim.dock_top_exit; @@ -1426,10 +1432,10 @@ public class DisplayPolicy { || (behavior & BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE) != 0; boolean navAllowedHidden = immersive || immersiveSticky; navTranslucent &= !immersiveSticky; // transient trumps translucent - boolean isKeyguardShowing = isStatusBarKeyguard() - && !mService.mPolicy.isKeyguardOccluded(); - boolean statusBarForcesShowingNavigation = !isKeyguardShowing && mStatusBar != null - && (mStatusBar.getAttrs().privateFlags + boolean isKeyguardShowing = isKeyguardShowing() && !isKeyguardOccluded(); + boolean notificationShadeForcesShowingNavigation = + !isKeyguardShowing && mNotificationShade != null + && (mNotificationShade.getAttrs().privateFlags & PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION) != 0; // When the navigation bar isn't visible, we put up a fake input window to catch all @@ -1456,7 +1462,7 @@ public class DisplayPolicy { navVisible |= !canHideNavigationBar(); boolean updateSysUiVisibility = layoutNavigationBar(displayFrames, uiMode, navVisible, - navTranslucent, navAllowedHidden, statusBarForcesShowingNavigation); + navTranslucent, navAllowedHidden, notificationShadeForcesShowingNavigation); if (DEBUG_LAYOUT) Slog.i(TAG, "mDock rect:" + displayFrames.mDock); updateSysUiVisibility |= layoutStatusBar(displayFrames, sysui, isKeyguardShowing); if (updateSysUiVisibility) { @@ -2105,7 +2111,7 @@ public class DisplayPolicy { df.set(displayFrames.mUnrestricted); pf.set(displayFrames.mUnrestricted); } else if ((sysUiFl & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 - && (type == TYPE_STATUS_BAR + && (type == TYPE_NOTIFICATION_SHADE || type == TYPE_TOAST || type == TYPE_DOCK_DIVIDER || type == TYPE_VOICE_INTERACTION_STARTING @@ -2357,8 +2363,6 @@ public class DisplayPolicy { mTopDockedOpaqueWindowState = null; mTopDockedOpaqueOrDimmingWindowState = null; mForceStatusBar = false; - mForceStatusBarFromKeyguard = false; - mForceStatusBarTransparent = false; mForcingShowNavBar = false; mForcingShowNavBarLayer = -1; @@ -2386,14 +2390,6 @@ public class DisplayPolicy { mForcingShowNavBar = true; mForcingShowNavBarLayer = win.getSurfaceLayer(); } - if (attrs.type == TYPE_STATUS_BAR) { - if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { - mForceStatusBarFromKeyguard = true; - } - if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) { - mForceStatusBarTransparent = true; - } - } boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW && attrs.type < FIRST_SYSTEM_WINDOW; @@ -2515,32 +2511,25 @@ public class DisplayPolicy { if (mStatusBar != null) { if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar - + " forcefkg=" + mForceStatusBarFromKeyguard + " top=" + mTopFullscreenOpaqueWindowState); - boolean shouldBeTransparent = mForceStatusBarTransparent - && !mForceStatusBar - && !mForceStatusBarFromKeyguard; - if (!shouldBeTransparent) { - mStatusBarController.setShowTransparent(false /* transparent */); - } else if (!mStatusBar.isVisibleLw()) { - mStatusBarController.setShowTransparent(true /* transparent */); - } - - boolean statusBarForcesShowingNavigation = - (mStatusBar.getAttrs().privateFlags + final boolean forceShowStatusBar = (mStatusBar.getAttrs().privateFlags + & PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR) != 0; + final boolean notificationShadeForcesShowingNavigation = + mNotificationShade != null + && (mNotificationShade.getAttrs().privateFlags & PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION) != 0; + boolean topAppHidesStatusBar = topAppHidesStatusBar(); - if (mForceStatusBar || mForceStatusBarFromKeyguard || mForceStatusBarTransparent - || statusBarForcesShowingNavigation) { + if (mForceStatusBar || forceShowStatusBar) { if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); if (mStatusBarController.setBarShowingLw(true)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; } // Maintain fullscreen layout until incoming animation is complete. topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); - // Transient status bar is not allowed if status bar is on lockscreen or status bar - // is expecting the navigation keys from the user. - if ((mForceStatusBarFromKeyguard || statusBarForcesShowingNavigation) + // Transient status bar is not allowed if notification shade is expecting the + // navigation keys from the user. + if (notificationShadeForcesShowingNavigation && mStatusBarController.isTransientShowing()) { mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, mLastSystemUiFlags, mLastSystemUiFlags); @@ -3104,11 +3093,9 @@ public class DisplayPolicy { } } - private boolean isStatusBarKeyguard() { - return mStatusBar != null - && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; + boolean isKeyguardShowing() { + return mService.mPolicy.isKeyguardShowing(); } - private boolean isKeyguardOccluded() { // TODO (b/113840485): Handle per display keyguard. return mService.mPolicy.isKeyguardOccluded(); @@ -3141,7 +3128,7 @@ public class DisplayPolicy { // keys, we let it keep controlling the visibility. final boolean lastFocusCanReceiveKeys = (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys()); - winCandidate = isStatusBarKeyguard() ? mStatusBar + winCandidate = isKeyguardShowing() ? mNotificationShade : lastFocusCanReceiveKeys ? mLastFocusedWindow : mTopFullscreenOpaqueWindowState; if (winCandidate == null) { @@ -3149,7 +3136,8 @@ public class DisplayPolicy { } } final WindowState win = winCandidate; - if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && isKeyguardOccluded()) { + if (win.getAttrs().type == TYPE_NOTIFICATION_SHADE && isKeyguardShowing() + && isKeyguardOccluded()) { // We are updating at a point where the keyguard has gotten // focus, but we were last in a state where the top window is // hiding it. This is probably because the keyguard as been @@ -3283,8 +3271,8 @@ public class DisplayPolicy { private int updateLightStatusBarAppearanceLw(@Appearance int appearance, WindowState opaque, WindowState opaqueOrDimming) { - final boolean onKeyguard = isStatusBarKeyguard() && !isKeyguardOccluded(); - final WindowState statusColorWin = onKeyguard ? mStatusBar : opaqueOrDimming; + final boolean onKeyguard = isKeyguardShowing() && !isKeyguardOccluded(); + final WindowState statusColorWin = onKeyguard ? mNotificationShade : opaqueOrDimming; if (statusColorWin != null && (statusColorWin == opaque || onKeyguard)) { // If the top fullscreen-or-dimming window is also the top fullscreen, respect // its light flag. @@ -3372,11 +3360,11 @@ public class DisplayPolicy { // visibility changes. mForceShowSystemBars = dockedStackVisible || win.inFreeformWindowingMode() || resizing || mForceShowSystemBarsFromExternal; - final boolean forceOpaqueStatusBar = mForceShowSystemBars && !mForceStatusBarFromKeyguard; + final boolean forceOpaqueStatusBar = mForceShowSystemBars && !isKeyguardShowing(); // apply translucent bar vis flags - WindowState fullscreenTransWin = isStatusBarKeyguard() && !isKeyguardOccluded() - ? mStatusBar + WindowState fullscreenTransWin = isKeyguardShowing() && !isKeyguardOccluded() + ? mNotificationShade : mTopFullscreenOpaqueWindowState; vis = mStatusBarController.applyTranslucentFlagLw(fullscreenTransWin, vis, oldVis); vis = mNavigationBarController.applyTranslucentFlagLw(fullscreenTransWin, vis, oldVis); @@ -3396,8 +3384,8 @@ public class DisplayPolicy { // prevent status bar interaction from clearing certain flags int type = win.getAttrs().type; - boolean statusBarHasFocus = type == TYPE_STATUS_BAR; - if (statusBarHasFocus && !isStatusBarKeyguard()) { + boolean notificationShadeHasFocus = type == TYPE_NOTIFICATION_SHADE; + if (notificationShadeHasFocus && !isKeyguardShowing()) { int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE @@ -3432,7 +3420,7 @@ public class DisplayPolicy { (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; final boolean transientStatusBarAllowed = mStatusBar != null - && (statusBarHasFocus || (!mForceShowSystemBars + && (notificationShadeHasFocus || (!mForceShowSystemBars && (hideStatusBarWM || (hideStatusBarSysui && immersiveSticky)))); final boolean transientNavBarAllowed = mNavigationBar != null @@ -3443,7 +3431,7 @@ public class DisplayPolicy { && now - mPendingPanicGestureUptime <= PANIC_GESTURE_EXPIRATION; final DisplayPolicy defaultDisplayPolicy = mService.getDefaultDisplayContentLocked().getDisplayPolicy(); - if (pendingPanic && hideNavBarSysui && !isStatusBarKeyguard() + if (pendingPanic && hideNavBarSysui && !isKeyguardShowing() // TODO (b/111955725): Show keyguard presentation on all external displays && defaultDisplayPolicy.isKeyguardDrawComplete()) { // The user performed the panic gesture recently, we're about to hide the bars, @@ -3705,8 +3693,11 @@ public class DisplayPolicy { pw.print(" mDreamingSleepToken="); pw.println(mDreamingSleepToken); if (mStatusBar != null) { pw.print(prefix); pw.print("mStatusBar="); pw.print(mStatusBar); - pw.print(" isStatusBarKeyguard="); pw.println(isStatusBarKeyguard()); } + if (mNotificationShade != null) { + pw.print(prefix); pw.print("mExpandedPanel="); pw.print(mNotificationShade); + } + pw.print(" isKeyguardShowing="); pw.println(isKeyguardShowing()); if (mNavigationBar != null) { pw.print(prefix); pw.print("mNavigationBar="); pw.println(mNavigationBar); pw.print(prefix); pw.print("mNavBarOpacityMode="); pw.println(mNavBarOpacityMode); @@ -3735,7 +3726,6 @@ public class DisplayPolicy { } pw.print(prefix); pw.print("mTopIsFullscreen="); pw.println(mTopIsFullscreen); pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); - pw.print(" mForceStatusBarFromKeyguard="); pw.println(mForceStatusBarFromKeyguard); pw.print(prefix); pw.print("mForceShowSystemBarsFromExternal="); pw.print(mForceShowSystemBarsFromExternal); pw.print(" mAllowLockscreenWhenOn="); pw.println(mAllowLockscreenWhenOn); diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 091f66c0b19a..4c5914bfd8c2 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -23,7 +23,6 @@ import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT; @@ -527,7 +526,7 @@ final class InputMonitor { mDisableWallpaperTouchEvents = true; } final boolean hasWallpaper = wallpaperController.isWallpaperTarget(w) - && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0 + && !mService.mPolicy.isKeyguardShowing() && !mDisableWallpaperTouchEvents; // If there's a drag in progress and 'child' is a potential drop target, diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index a0089639bce6..fa764e3dfc18 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -22,8 +22,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; import android.annotation.Nullable; @@ -188,7 +187,7 @@ class InsetsPolicy { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) { return mTransientControlTarget; } - if (areSystemBarsForciblyVisible() || isStatusBarForciblyVisible()) { + if (areSystemBarsForciblyVisible() || isKeyguardOrStatusBarForciblyVisible()) { return null; } return focusedWin; @@ -204,29 +203,27 @@ class InsetsPolicy { return focusedWin; } - private boolean isStatusBarForciblyVisible() { - final WindowState statusBar = mPolicy.getStatusBar(); - if (statusBar == null) { - return false; - } - final int privateFlags = statusBar.mAttrs.privateFlags; - - // TODO(b/118118435): Pretend to the app that it's still able to control it? - if ((privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) { + private boolean isKeyguardOrStatusBarForciblyVisible() { + if (mPolicy.isKeyguardShowing()) { return true; } - if ((privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { - return true; + final WindowState statusBar = mPolicy.getStatusBar(); + if (statusBar != null) { + // TODO(b/118118435): Pretend to the app that it's still able to control it? + if ((statusBar.mAttrs.privateFlags & PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR) != 0) { + return true; + } } return false; } private boolean isNavBarForciblyVisible() { - final WindowState statusBar = mPolicy.getStatusBar(); - if (statusBar == null) { + final WindowState notificationShade = mPolicy.getNotificationShade(); + if (notificationShade == null) { return false; } - if ((statusBar.mAttrs.privateFlags & PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION) != 0) { + if ((notificationShade.mAttrs.privateFlags + & PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION) != 0) { return true; } return false; diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 2f726e9999eb..8b1005e2e847 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -35,7 +35,6 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE; import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; @@ -1147,7 +1146,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // While a dream or keyguard is showing, obscure ordinary application content on // secondary displays (by forcibly enabling mirroring unless there is other content // we want to show) but still allow opaque keyguard dialogs to be shown. - if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { + if (type == TYPE_DREAM || mWmService.mPolicy.isKeyguardShowing()) { mObscureApplicationContentOnSecondaryDisplays = true; } displayHasContent = true; diff --git a/services/core/java/com/android/server/wm/StatusBarController.java b/services/core/java/com/android/server/wm/StatusBarController.java index f4260d32a77d..cac992a67541 100644 --- a/services/core/java/com/android/server/wm/StatusBarController.java +++ b/services/core/java/com/android/server/wm/StatusBarController.java @@ -17,7 +17,6 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; -import static android.view.WindowManager.LayoutParams.MATCH_PARENT; import static com.android.server.wm.WindowManagerInternal.AppTransitionListener; @@ -102,11 +101,6 @@ public class StatusBarController extends BarController { } } - @Override - protected boolean skipAnimation() { - return mWin.getAttrs().height == MATCH_PARENT; - } - AppTransitionListener getAppTransitionListener() { return mAppTransitionListener; } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index e3b593e90fa5..77d755d6f36d 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -63,6 +63,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; @@ -1283,6 +1284,7 @@ public class WindowManagerService extends IWindowManager.Stub static boolean excludeWindowTypeFromTapOutTask(int windowType) { switch (windowType) { case TYPE_STATUS_BAR: + case TYPE_NOTIFICATION_SHADE: case TYPE_NAVIGATION_BAR: case TYPE_INPUT_METHOD_DIALOG: return true; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 8969bb5d4374..2965764e8961 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -73,6 +73,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_PHONE; import static android.view.WindowManager.LayoutParams.TYPE_POINTER; import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; @@ -3210,6 +3211,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP case TYPE_PRIORITY_PHONE: case TYPE_SEARCH_BAR: case TYPE_STATUS_BAR: + case TYPE_NOTIFICATION_SHADE: case TYPE_STATUS_BAR_PANEL: case TYPE_STATUS_BAR_SUB_PANEL: case TYPE_SYSTEM_DIALOG: diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 486616df6f11..6189fbdbfb78 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -272,7 +272,8 @@ class WindowStateAnimator { mWin.checkPolicyVisibilityChange(); final DisplayContent displayContent = mWin.getDisplayContent(); - if (mAttrType == LayoutParams.TYPE_STATUS_BAR && mWin.isVisibleByPolicy()) { + if ((mAttrType == LayoutParams.TYPE_STATUS_BAR + || mAttrType == LayoutParams.TYPE_NOTIFICATION_SHADE) && mWin.isVisibleByPolicy()) { // Upon completion of a not-visible to visible status bar animation a relayout is // required. displayContent.setLayoutNeeded(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index f2ba97c269d5..1637370df0f7 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -39,6 +39,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; @@ -139,6 +140,7 @@ public class DisplayContentTests extends WindowTestsBase { mChildAppWindowAbove, mDockedDividerWindow, mStatusBarWindow, + mNotificationShadeWindow, mNavBarWindow, mImeWindow, mImeDialogWindow)); @@ -161,6 +163,7 @@ public class DisplayContentTests extends WindowTestsBase { mImeDialogWindow, mDockedDividerWindow, mStatusBarWindow, + mNotificationShadeWindow, mNavBarWindow)); } @@ -177,6 +180,7 @@ public class DisplayContentTests extends WindowTestsBase { mImeDialogWindow, mDockedDividerWindow, mStatusBarWindow, + mNotificationShadeWindow, mNavBarWindow)); } @@ -193,6 +197,24 @@ public class DisplayContentTests extends WindowTestsBase { mStatusBarWindow, mImeWindow, mImeDialogWindow, + mNotificationShadeWindow, + mNavBarWindow)); + } + + @Test + public void testForAllWindows_WithNotificationShadeImeTarget() throws Exception { + mDisplayContent.mInputMethodTarget = mNotificationShadeWindow; + + assertForAllWindowsOrder(Arrays.asList( + mWallpaperWindow, + mChildAppWindowBelow, + mAppWindow, + mChildAppWindowAbove, + mDockedDividerWindow, + mStatusBarWindow, + mNotificationShadeWindow, + mImeWindow, + mImeDialogWindow, mNavBarWindow)); } @@ -211,6 +233,7 @@ public class DisplayContentTests extends WindowTestsBase { mDockedDividerWindow, voiceInteractionWindow, mStatusBarWindow, + mNotificationShadeWindow, mNavBarWindow, mImeWindow, mImeDialogWindow)); @@ -585,7 +608,7 @@ public class DisplayContentTests extends WindowTestsBase { final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); window.mActivityRecord.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); - final WindowState keyguard = createWindow(null, TYPE_STATUS_BAR, dc, "keyguard"); + final WindowState keyguard = createWindow(null, TYPE_NOTIFICATION_SHADE , dc, "keyguard"); keyguard.mHasSurface = true; keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java index df34c7c00b51..c3bead7162e6 100644 --- a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java @@ -22,13 +22,16 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMAR import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; +import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; +import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -118,11 +121,11 @@ public class InsetsPolicyTest extends WindowTestsBase { @Test public void testControlsForDispatch_keyguard() { - addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |= PRIVATE_FLAG_KEYGUARD; + addWindow(TYPE_NOTIFICATION_SHADE, "notificationShade"); addWindow(TYPE_NAVIGATION_BAR, "navBar"); + mockKeyguardShowing(); final InsetsSourceControl[] controls = addAppWindowAndGetControlsForDispatch(); - // The app must not control the top bar. assertNotNull(controls); assertEquals(1, controls.length); @@ -130,9 +133,9 @@ public class InsetsPolicyTest extends WindowTestsBase { // TODO: adjust this test if we pretend to the app that it's still able to control it. @Test - public void testControlsForDispatch_forceStatusBarVisibleTransparent() { - addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |= - PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; + public void testControlsForDispatch_forceStatusBarVisible() { + addWindow(TYPE_STATUS_BAR, "topBar").mAttrs.privateFlags |= + PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; addWindow(TYPE_NAVIGATION_BAR, "navBar"); final InsetsSourceControl[] controls = addAppWindowAndGetControlsForDispatch(); @@ -144,7 +147,7 @@ public class InsetsPolicyTest extends WindowTestsBase { @Test public void testControlsForDispatch_statusBarForceShowNavigation() { - addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |= + addWindow(TYPE_NOTIFICATION_SHADE, "notificationShade").mAttrs.privateFlags |= PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; addWindow(TYPE_NAVIGATION_BAR, "navBar"); @@ -257,4 +260,10 @@ public class InsetsPolicyTest extends WindowTestsBase { mDisplayContent.getInsetsPolicy().updateBarControlTarget(win); return mDisplayContent.getInsetsStateController().getControlsForDispatch(win); } + + private void mockKeyguardShowing() { + final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy(); + spyOn(displayPolicy); + doReturn(true).when(displayPolicy).isKeyguardShowing(); + } } diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java index 894890a2d0f1..277bc41cf34e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java @@ -18,6 +18,7 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; @@ -85,9 +86,12 @@ public class RootWindowContainerTests extends WindowTestsBase { public void testIsAnyNonToastWindowVisibleForUid_aFewNonToastButNoneVisible() { final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar", FAKE_CALLING_UID); + final WindowState notificationShade = createWindow(null, TYPE_NOTIFICATION_SHADE, + "notificationShade", FAKE_CALLING_UID); final WindowState app = createWindow(null, TYPE_APPLICATION, "app", FAKE_CALLING_UID); assertFalse(statusBar.isVisibleNow()); + assertFalse(notificationShade.isVisibleNow()); assertFalse(app.isVisibleNow()); assertFalse(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID)); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java index 08ee0eb30d6b..9f45044c6a60 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java @@ -17,7 +17,7 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; -import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; @@ -91,7 +91,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { @Override public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { - return attrs.type == TYPE_STATUS_BAR; + return attrs.type == TYPE_NOTIFICATION_SHADE; } @Override @@ -263,6 +263,11 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { } @Override + public boolean isKeyguardShowing() { + return mKeyguardShowingAndNotOccluded; + } + + @Override public boolean isKeyguardShowingAndNotOccluded() { return mKeyguardShowingAndNotOccluded; } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index 7e248f854dcf..6d0b54fd2ccd 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -545,7 +545,7 @@ public class WindowStateTests extends WindowTestsBase { final WindowState startingWindow = createWindow(null /* parent */, TYPE_APPLICATION_STARTING, startingApp.mToken, "starting"); startingApp.mActivityRecord.startingWindow = startingWindow; - final WindowState keyguardHostWindow = mStatusBarWindow; + final WindowState keyguardHostWindow = mNotificationShadeWindow; final WindowState allDrawnApp = mAppWindow; allDrawnApp.mActivityRecord.allDrawn = true; diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index 31a7f2437536..20eab5a45ff1 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -31,6 +31,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; +import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; @@ -76,6 +77,7 @@ class WindowTestsBase extends SystemServiceTestsBase { WindowState mImeWindow; WindowState mImeDialogWindow; WindowState mStatusBarWindow; + WindowState mNotificationShadeWindow; WindowState mDockedDividerWindow; WindowState mNavBarWindow; WindowState mAppWindow; @@ -119,6 +121,8 @@ class WindowTestsBase extends SystemServiceTestsBase { mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG, "mImeDialogWindow"); mStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "mStatusBarWindow"); + mNotificationShadeWindow = createCommonWindow(null, TYPE_NOTIFICATION_SHADE, + "mNotificationShadeWindow"); mNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "mNavBarWindow"); mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER, "mDockedDividerWindow"); |