Loading packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +15 −15 Original line number Diff line number Diff line Loading @@ -23,8 +23,8 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.res.Configuration; import android.content.res.Configuration.Orientation; import android.metrics.LogMaker; import android.util.Log; import android.view.View; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -75,6 +75,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr @Nullable private Consumer<Boolean> mMediaVisibilityChangedListener; @Orientation private int mLastOrientation; private String mCachedSpecs = ""; @Nullable Loading @@ -88,21 +89,16 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr new QSPanel.OnConfigurationChangedListener() { @Override public void onConfigurationChange(Configuration newConfig) { mQSLogger.logOnConfigurationChanged( /* lastOrientation= */ mLastOrientation, /* newOrientation= */ newConfig.orientation, /* containerName= */ mView.getDumpableTag()); mShouldUseSplitNotificationShade = LargeScreenUtils.shouldUseSplitNotificationShade(getResources()); // Logging to aid the investigation of b/216244185. Log.d(TAG, "onConfigurationChange: " + "mShouldUseSplitNotificationShade=" + mShouldUseSplitNotificationShade + ", " + "newConfig.windowConfiguration=" + newConfig.windowConfiguration); mQSLogger.logOnConfigurationChanged(mLastOrientation, newConfig.orientation, mView.getDumpableTag()); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; switchTileLayout(false); } switchTileLayoutIfNeeded(); onConfigurationChanged(); } }; Loading Loading @@ -334,6 +330,10 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr } } private void switchTileLayoutIfNeeded() { switchTileLayout(/* force= */ false); } boolean switchTileLayout(boolean force) { /* Whether or not the panel currently contains a media player. */ boolean horizontal = shouldUseHorizontalLayout(); Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +21 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { // Then the layout changes assertThat(mController.shouldUseHorizontalLayout()).isTrue(); verify(mHorizontalLayoutListener).run(); // not invoked verify(mHorizontalLayoutListener).run(); // When it is rotated back to portrait mConfiguration.orientation = Configuration.ORIENTATION_PORTRAIT; Loading @@ -300,4 +300,24 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { verify(mQSTile).refreshState(); verify(mOtherTile, never()).refreshState(); } @Test public void configurationChange_onlySplitShadeConfigChanges_horizontalLayoutStatusUpdated() { // Preconditions for horizontal layout when(mMediaHost.getVisible()).thenReturn(true); when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(false); mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE; mController.setUsingHorizontalLayoutChangeListener(mHorizontalLayoutListener); mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration); assertThat(mController.shouldUseHorizontalLayout()).isTrue(); reset(mHorizontalLayoutListener); // Only split shade status changes when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true); mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration); // Horizontal layout is updated accordingly. assertThat(mController.shouldUseHorizontalLayout()).isFalse(); verify(mHorizontalLayoutListener).run(); } } Loading
packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +15 −15 Original line number Diff line number Diff line Loading @@ -23,8 +23,8 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.res.Configuration; import android.content.res.Configuration.Orientation; import android.metrics.LogMaker; import android.util.Log; import android.view.View; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -75,6 +75,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr @Nullable private Consumer<Boolean> mMediaVisibilityChangedListener; @Orientation private int mLastOrientation; private String mCachedSpecs = ""; @Nullable Loading @@ -88,21 +89,16 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr new QSPanel.OnConfigurationChangedListener() { @Override public void onConfigurationChange(Configuration newConfig) { mQSLogger.logOnConfigurationChanged( /* lastOrientation= */ mLastOrientation, /* newOrientation= */ newConfig.orientation, /* containerName= */ mView.getDumpableTag()); mShouldUseSplitNotificationShade = LargeScreenUtils.shouldUseSplitNotificationShade(getResources()); // Logging to aid the investigation of b/216244185. Log.d(TAG, "onConfigurationChange: " + "mShouldUseSplitNotificationShade=" + mShouldUseSplitNotificationShade + ", " + "newConfig.windowConfiguration=" + newConfig.windowConfiguration); mQSLogger.logOnConfigurationChanged(mLastOrientation, newConfig.orientation, mView.getDumpableTag()); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; switchTileLayout(false); } switchTileLayoutIfNeeded(); onConfigurationChanged(); } }; Loading Loading @@ -334,6 +330,10 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr } } private void switchTileLayoutIfNeeded() { switchTileLayout(/* force= */ false); } boolean switchTileLayout(boolean force) { /* Whether or not the panel currently contains a media player. */ boolean horizontal = shouldUseHorizontalLayout(); Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +21 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { // Then the layout changes assertThat(mController.shouldUseHorizontalLayout()).isTrue(); verify(mHorizontalLayoutListener).run(); // not invoked verify(mHorizontalLayoutListener).run(); // When it is rotated back to portrait mConfiguration.orientation = Configuration.ORIENTATION_PORTRAIT; Loading @@ -300,4 +300,24 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { verify(mQSTile).refreshState(); verify(mOtherTile, never()).refreshState(); } @Test public void configurationChange_onlySplitShadeConfigChanges_horizontalLayoutStatusUpdated() { // Preconditions for horizontal layout when(mMediaHost.getVisible()).thenReturn(true); when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(false); mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE; mController.setUsingHorizontalLayoutChangeListener(mHorizontalLayoutListener); mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration); assertThat(mController.shouldUseHorizontalLayout()).isTrue(); reset(mHorizontalLayoutListener); // Only split shade status changes when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true); mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration); // Horizontal layout is updated accordingly. assertThat(mController.shouldUseHorizontalLayout()).isFalse(); verify(mHorizontalLayoutListener).run(); } }