From f587b631470be71be879457891f91d5798917477 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Wed, 12 Feb 2020 13:16:12 +0800 Subject: [PATCH] Move the view inflation outside of constructor. Move the view inflation operation from the constructor of NotificationShadeWindowController to StatusBar#start. Fix: 149326478 Test: atest SystemUITests Change-Id: I34386e30ac0777d7b2ba93142ad69e6ff43dbc82 --- .../phone/NotificationShadeWindowController.java | 13 ++++++------- .../android/systemui/statusbar/phone/StatusBar.java | 1 + .../systemui/bubbles/BubbleControllerTest.java | 5 +++-- .../NewNotifPipelineBubbleControllerTest.java | 5 +++-- .../NotificationShadeWindowControllerTest.java | 12 ++++-------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java index 10b68b9a518d9..d0162172eeefb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java @@ -18,8 +18,8 @@ package com.android.systemui.statusbar.phone; import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; - import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_BEHAVIOR_CONTROLLED; + import static com.android.systemui.DejankUtils.whitelistIpcs; import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT; @@ -48,7 +48,6 @@ 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; @@ -96,15 +95,13 @@ public class NotificationShadeWindowController implements Callback, Dumpable, 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) { + KeyguardBypassController keyguardBypassController, SysuiColorExtractor colorExtractor) { mContext = context; mWindowManager = windowManager; mActivityManager = activityManager; @@ -114,8 +111,6 @@ public class NotificationShadeWindowController implements Callback, Dumpable, mLpChanged = new LayoutParams(); mKeyguardBypassController = keyguardBypassController; mColorExtractor = colorExtractor; - mSuperStatusBarViewFactory = superStatusBarViewFactory; - mNotificationShadeView = mSuperStatusBarViewFactory.getNotificationShadeWindowView(); mLockScreenDisplayTimeout = context.getResources() .getInteger(R.integer.config_lockScreenDisplayTimeout); @@ -194,6 +189,10 @@ public class NotificationShadeWindowController implements Callback, Dumpable, onThemeChanged(); } + public void setNotificationShadeView(ViewGroup view) { + mNotificationShadeView = view; + } + public ViewGroup getNotificationShadeView() { return mNotificationShadeView; } 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 c68d9942419be..cc1932b6aeeae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1353,6 +1353,7 @@ public class StatusBar extends SystemUI implements DemoMode, .statusBarWindowView(mNotificationShadeWindowView).build(); mNotificationShadeWindowViewController = statusBarComponent .getNotificationShadeWindowViewController(); + mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowViewController.setupExpandedStatusBar(); mStatusBarWindowController = statusBarComponent.getStatusBarWindowController(); mPhoneStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView(); 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 c3b55e2ec1682..7d47f6bd4aca0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -201,8 +201,9 @@ public class BubbleControllerTest extends SysuiTestCase { // Bubbles get added to status bar window view mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, - mConfigurationController, mKeyguardBypassController, mColorExtractor, - mSuperStatusBarViewFactory); + mConfigurationController, mKeyguardBypassController, mColorExtractor); + mNotificationShadeWindowController.setNotificationShadeView( + mSuperStatusBarViewFactory.getNotificationShadeWindowView()); mNotificationShadeWindowController.attach(); // Need notifications for bubbles diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java index 72405fc519faf..5a1bef9e16e66 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java @@ -195,8 +195,9 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase { // Bubbles get added to status bar window view mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, - mConfigurationController, mKeyguardBypassController, mColorExtractor, - mSuperStatusBarViewFactory); + mConfigurationController, mKeyguardBypassController, mColorExtractor); + mNotificationShadeWindowController.setNotificationShadeView( + mSuperStatusBarViewFactory.getNotificationShadeWindowView()); mNotificationShadeWindowController.attach(); // Need notifications for bubbles diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java index 40d3395f2ca1d..7d52df731efec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java @@ -34,7 +34,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.colorextraction.ColorExtractor; import com.android.systemui.SysuiTestCase; import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -52,14 +51,13 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase { @Mock private WindowManager mWindowManager; @Mock private DozeParameters mDozeParameters; - @Mock private NotificationShadeWindowView mStatusBarView; + @Mock private NotificationShadeWindowView mNotificationShadeWindowView; @Mock private IActivityManager mActivityManager; @Mock private SysuiStatusBarStateController mStatusBarStateController; @Mock private ConfigurationController mConfigurationController; @Mock private KeyguardBypassController mKeyguardBypassController; @Mock private SysuiColorExtractor mColorExtractor; @Mock ColorExtractor.GradientColors mGradientColors; - @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; private NotificationShadeWindowController mNotificationShadeWindowController; @@ -68,13 +66,11 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); when(mDozeParameters.getAlwaysOn()).thenReturn(true); when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); - when(mSuperStatusBarViewFactory.getNotificationShadeWindowView()) - .thenReturn(mStatusBarView); mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, - mConfigurationController, mKeyguardBypassController, mColorExtractor, - mSuperStatusBarViewFactory); + mConfigurationController, mKeyguardBypassController, mColorExtractor); + mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.attach(); } @@ -104,7 +100,7 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase { @Test public void testAdd_updatesVisibilityFlags() { - verify(mStatusBarView).setSystemUiVisibility(anyInt()); + verify(mNotificationShadeWindowView).setSystemUiVisibility(anyInt()); } @Test