Loading packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ private fun SceneScope.stateForQuickSettingsContent( QSSceneAdapter.State.QS } else -> error( "Bad transition for QuickSettings: fromContent=$fromContent," + " toScene=$toContent" ) // We are not in a transition between states that have QS, so just make // sure it's closed. This could be an issue if going from SplitShade to // a folded device. QSSceneAdapter.State.CLOSED } } is TransitionState.Transition.OverlayTransition -> Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; Loading Loading @@ -604,6 +606,46 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { assertThat(mPagedTileLayoutListening).isFalse(); } @Test public void reAttach_configurationChangePending_triggersConfigurationListener() { mController.onViewDetached(); when(mQSPanel.hadConfigurationChangeWhileDetached()).thenReturn(true); clearInvocations(mQSLogger); mController.onViewAttached(); verify(mQSLogger).logOnConfigurationChanged( anyInt(), anyInt(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyString() ); } @Test public void reAttach_noConfigurationChangePending_doesntTriggerConfigurationListener() { mController.onViewDetached(); when(mQSPanel.hadConfigurationChangeWhileDetached()).thenReturn(false); clearInvocations(mQSLogger); mController.onViewAttached(); verify(mQSLogger, never()).logOnConfigurationChanged( anyInt(), anyInt(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyString() ); } private boolean usingMediaPlayer() { return !SceneContainerFlag.isEnabled(); Loading packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +15 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,8 @@ public class QSPanel extends LinearLayout implements Tunable { @Nullable private View mMediaViewPlaceHolderForScene; private boolean mHadConfigurationChangeWhileDetached; public QSPanel(Context context, AttributeSet attrs) { super(context, attrs); mUsingMediaPlayer = useQsMediaPlayer(context); Loading Loading @@ -425,10 +427,23 @@ public class QSPanel extends LinearLayout implements Tunable { @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (!isAttachedToWindow()) { mHadConfigurationChangeWhileDetached = true; } mOnConfigurationChangedListeners.forEach( listener -> listener.onConfigurationChange(newConfig)); } final boolean hadConfigurationChangeWhileDetached() { return mHadConfigurationChangeWhileDetached; } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mHadConfigurationChangeWhileDetached = false; } @Override protected void onFinishInflate() { super.onFinishInflate(); Loading packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,12 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr mMediaHost.addVisibilityChangeListener(mMediaHostVisibilityListener); } mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener); // We were not attached and the configuration may have changed, trigger the listener. if (mView.hadConfigurationChangeWhileDetached()) { mOnConfigurationChangedListener.onConfigurationChange( getContext().getResources().getConfiguration() ); } setTiles(); mLastOrientation = getResources().getConfiguration().orientation; mLastScreenLayout = getResources().getConfiguration().screenLayout; Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt +64 −5 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ */ package com.android.systemui.qs import android.content.res.Configuration import android.graphics.Rect import android.platform.test.flag.junit.FlagsParameterization import android.testing.TestableContext Loading Loading @@ -91,8 +92,10 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { @After fun tearDown() { if (qsPanel.isAttachedToWindow) { ViewUtils.detachView(qsPanel) } } @Test fun testHasCollapseAccessibilityAction() { Loading @@ -119,7 +122,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), QSTileViewImpl(themedContext) QSTileViewImpl(themedContext), ) ) Loading @@ -129,7 +132,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { qsPanel.setUsingHorizontalLayout(/* horizontal */ true, mediaView, /* force */ true) qsPanel.measure( /* width */ View.MeasureSpec.makeMeasureSpec(3000, View.MeasureSpec.EXACTLY), /* height */ View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY) /* height */ View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY), ) qsPanel.layout(0, 0, qsPanel.measuredWidth, qsPanel.measuredHeight) Loading @@ -147,7 +150,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { val padding = 10 themedContext.orCreateTestableResources.addOverride( R.dimen.qs_panel_padding_bottom, padding padding, ) qsPanel.updatePadding() assertThat(qsPanel.paddingBottom).isEqualTo(padding) Loading @@ -160,7 +163,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { themedContext.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_top, padding) themedContext.orCreateTestableResources.addOverride( R.dimen.qs_panel_padding_top, paddingCombined paddingCombined, ) qsPanel.updatePadding() Loading Loading @@ -267,6 +270,62 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(qsPanel.tileLayout!!.maxColumns).isEqualTo(2) } @Test fun noPendingConfigChangesAtBeginning() { assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangesWhileDetached_pendingConfigChanges() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } @Test fun configChangesWhileDetached_reattach_pendingConfigChanges() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } @Test fun configChangesWhileDetached_reattach_detach_pendingConfigChanges_reset() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } ViewUtils.detachView(qsPanel) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangeWhileAttached_noPendingConfigChanges() { qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangeWhileAttachedWithPending_doesntResetPending() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } companion object { @Parameters(name = "{0}") @JvmStatic fun getParams() = parameterizeSceneContainerFlag() } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettings.kt +4 −4 Original line number Diff line number Diff line Loading @@ -128,10 +128,10 @@ private fun SceneScope.stateForQuickSettingsContent( QSSceneAdapter.State.QS } else -> error( "Bad transition for QuickSettings: fromContent=$fromContent," + " toScene=$toContent" ) // We are not in a transition between states that have QS, so just make // sure it's closed. This could be an issue if going from SplitShade to // a folded device. QSSceneAdapter.State.CLOSED } } is TransitionState.Transition.OverlayTransition -> Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; Loading Loading @@ -604,6 +606,46 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { assertThat(mPagedTileLayoutListening).isFalse(); } @Test public void reAttach_configurationChangePending_triggersConfigurationListener() { mController.onViewDetached(); when(mQSPanel.hadConfigurationChangeWhileDetached()).thenReturn(true); clearInvocations(mQSLogger); mController.onViewAttached(); verify(mQSLogger).logOnConfigurationChanged( anyInt(), anyInt(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyString() ); } @Test public void reAttach_noConfigurationChangePending_doesntTriggerConfigurationListener() { mController.onViewDetached(); when(mQSPanel.hadConfigurationChangeWhileDetached()).thenReturn(false); clearInvocations(mQSLogger); mController.onViewAttached(); verify(mQSLogger, never()).logOnConfigurationChanged( anyInt(), anyInt(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyString() ); } private boolean usingMediaPlayer() { return !SceneContainerFlag.isEnabled(); Loading
packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +15 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,8 @@ public class QSPanel extends LinearLayout implements Tunable { @Nullable private View mMediaViewPlaceHolderForScene; private boolean mHadConfigurationChangeWhileDetached; public QSPanel(Context context, AttributeSet attrs) { super(context, attrs); mUsingMediaPlayer = useQsMediaPlayer(context); Loading Loading @@ -425,10 +427,23 @@ public class QSPanel extends LinearLayout implements Tunable { @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (!isAttachedToWindow()) { mHadConfigurationChangeWhileDetached = true; } mOnConfigurationChangedListeners.forEach( listener -> listener.onConfigurationChange(newConfig)); } final boolean hadConfigurationChangeWhileDetached() { return mHadConfigurationChangeWhileDetached; } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mHadConfigurationChangeWhileDetached = false; } @Override protected void onFinishInflate() { super.onFinishInflate(); Loading
packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,12 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr mMediaHost.addVisibilityChangeListener(mMediaHostVisibilityListener); } mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener); // We were not attached and the configuration may have changed, trigger the listener. if (mView.hadConfigurationChangeWhileDetached()) { mOnConfigurationChangedListener.onConfigurationChange( getContext().getResources().getConfiguration() ); } setTiles(); mLastOrientation = getResources().getConfiguration().orientation; mLastScreenLayout = getResources().getConfiguration().screenLayout; Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt +64 −5 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ */ package com.android.systemui.qs import android.content.res.Configuration import android.graphics.Rect import android.platform.test.flag.junit.FlagsParameterization import android.testing.TestableContext Loading Loading @@ -91,8 +92,10 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { @After fun tearDown() { if (qsPanel.isAttachedToWindow) { ViewUtils.detachView(qsPanel) } } @Test fun testHasCollapseAccessibilityAction() { Loading @@ -119,7 +122,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), QSTileViewImpl(themedContext) QSTileViewImpl(themedContext), ) ) Loading @@ -129,7 +132,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { qsPanel.setUsingHorizontalLayout(/* horizontal */ true, mediaView, /* force */ true) qsPanel.measure( /* width */ View.MeasureSpec.makeMeasureSpec(3000, View.MeasureSpec.EXACTLY), /* height */ View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY) /* height */ View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY), ) qsPanel.layout(0, 0, qsPanel.measuredWidth, qsPanel.measuredHeight) Loading @@ -147,7 +150,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { val padding = 10 themedContext.orCreateTestableResources.addOverride( R.dimen.qs_panel_padding_bottom, padding padding, ) qsPanel.updatePadding() assertThat(qsPanel.paddingBottom).isEqualTo(padding) Loading @@ -160,7 +163,7 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { themedContext.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_top, padding) themedContext.orCreateTestableResources.addOverride( R.dimen.qs_panel_padding_top, paddingCombined paddingCombined, ) qsPanel.updatePadding() Loading Loading @@ -267,6 +270,62 @@ class QSPanelTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(qsPanel.tileLayout!!.maxColumns).isEqualTo(2) } @Test fun noPendingConfigChangesAtBeginning() { assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangesWhileDetached_pendingConfigChanges() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } @Test fun configChangesWhileDetached_reattach_pendingConfigChanges() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } @Test fun configChangesWhileDetached_reattach_detach_pendingConfigChanges_reset() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } ViewUtils.detachView(qsPanel) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangeWhileAttached_noPendingConfigChanges() { qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isFalse() } @Test fun configChangeWhileAttachedWithPending_doesntResetPending() { ViewUtils.detachView(qsPanel) qsPanel.onConfigurationChanged(Configuration()) testableLooper.runWithLooper { ViewUtils.attachView(qsPanel) } qsPanel.onConfigurationChanged(Configuration()) assertThat(qsPanel.hadConfigurationChangeWhileDetached()).isTrue() } companion object { @Parameters(name = "{0}") @JvmStatic fun getParams() = parameterizeSceneContainerFlag() } Loading