Merge changes I66a1c6b5,I11be9d8e into udc-qpr-dev

* changes:
  Hide Quick Settings shade when the FontScalingDialog is opened
  Fix Font Size Dialog user settings in second/guest user
This commit is contained in:
Candice Lo
2023-06-14 00:12:27 +00:00
committed by Android (Google) Code Review
4 changed files with 123 additions and 20 deletions

View File

@@ -34,6 +34,7 @@ import com.android.systemui.R
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView
import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SecureSettings
@@ -48,6 +49,7 @@ class FontScalingDialog(
private val systemSettings: SystemSettings, private val systemSettings: SystemSettings,
private val secureSettings: SecureSettings, private val secureSettings: SecureSettings,
private val systemClock: SystemClock, private val systemClock: SystemClock,
private val userTracker: UserTracker,
@Main mainHandler: Handler, @Main mainHandler: Handler,
@Background private val backgroundDelayableExecutor: DelayableExecutor @Background private val backgroundDelayableExecutor: DelayableExecutor
) : SystemUIDialog(context) { ) : SystemUIDialog(context) {
@@ -98,7 +100,8 @@ class FontScalingDialog(
seekBarWithIconButtonsView.setMax((strEntryValues).size - 1) seekBarWithIconButtonsView.setMax((strEntryValues).size - 1)
val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, 1.0f) val currentScale =
systemSettings.getFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId)
lastProgress.set(fontSizeValueToIndex(currentScale)) lastProgress.set(fontSizeValueToIndex(currentScale))
seekBarWithIconButtonsView.setProgress(lastProgress.get()) seekBarWithIconButtonsView.setProgress(lastProgress.get())
@@ -195,18 +198,25 @@ class FontScalingDialog(
@WorkerThread @WorkerThread
fun updateFontScale() { fun updateFontScale() {
systemSettings.putString(Settings.System.FONT_SCALE, strEntryValues[lastProgress.get()]) systemSettings.putStringForUser(
Settings.System.FONT_SCALE,
strEntryValues[lastProgress.get()],
userTracker.userId
)
} }
@WorkerThread @WorkerThread
fun updateSecureSettingsIfNeeded() { fun updateSecureSettingsIfNeeded() {
if ( if (
secureSettings.getString(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED) != secureSettings.getStringForUser(
ON
) {
secureSettings.putString(
Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
ON userTracker.userId
) != ON
) {
secureSettings.putStringForUser(
Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
ON,
userTracker.userId
) )
} }
} }

View File

@@ -38,7 +38,9 @@ import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SystemSettings import com.android.systemui.util.settings.SystemSettings
@@ -57,11 +59,13 @@ constructor(
statusBarStateController: StatusBarStateController, statusBarStateController: StatusBarStateController,
activityStarter: ActivityStarter, activityStarter: ActivityStarter,
qsLogger: QSLogger, qsLogger: QSLogger,
private val keyguardStateController: KeyguardStateController,
private val dialogLaunchAnimator: DialogLaunchAnimator, private val dialogLaunchAnimator: DialogLaunchAnimator,
private val systemSettings: SystemSettings, private val systemSettings: SystemSettings,
private val secureSettings: SecureSettings, private val secureSettings: SecureSettings,
private val systemClock: SystemClock, private val systemClock: SystemClock,
private val featureFlags: FeatureFlags, private val featureFlags: FeatureFlags,
private val userTracker: UserTracker,
@Background private val backgroundDelayableExecutor: DelayableExecutor @Background private val backgroundDelayableExecutor: DelayableExecutor
) : ) :
QSTileImpl<QSTile.State?>( QSTileImpl<QSTile.State?>(
@@ -86,26 +90,40 @@ constructor(
} }
override fun handleClick(view: View?) { override fun handleClick(view: View?) {
mUiHandler.post { // We animate from the touched view only if we are not on the keyguard
val animateFromView: Boolean = view != null && !keyguardStateController.isShowing
val runnable = Runnable {
val dialog: SystemUIDialog = val dialog: SystemUIDialog =
FontScalingDialog( FontScalingDialog(
mContext, mContext,
systemSettings, systemSettings,
secureSettings, secureSettings,
systemClock, systemClock,
userTracker,
mainHandler, mainHandler,
backgroundDelayableExecutor backgroundDelayableExecutor
) )
if (view != null) { if (animateFromView) {
dialogLaunchAnimator.showFromView( dialogLaunchAnimator.showFromView(
dialog, dialog,
view, view!!,
DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG)
) )
} else { } else {
dialog.show() dialog.show()
} }
} }
mainHandler.post {
mActivityStarter.executeRunnableDismissingKeyguard(
runnable,
/* cancelAction= */ null,
/* dismissShade= */ true,
/* afterKeyguardGone= */ true,
/* deferred= */ false
)
}
} }
override fun handleUpdateState(state: QSTile.State?, arg: Any?) { override fun handleUpdateState(state: QSTile.State?, arg: Any?) {

View File

@@ -25,6 +25,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.R import com.android.systemui.R
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView
import com.android.systemui.settings.UserTracker
import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.capture
import com.android.systemui.util.mockito.whenever import com.android.systemui.util.mockito.whenever
@@ -38,6 +39,7 @@ import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor import org.mockito.ArgumentCaptor
import org.mockito.Captor import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.spy import org.mockito.Mockito.spy
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
@@ -63,6 +65,7 @@ class FontScalingDialogTest : SysuiTestCase() {
.getResources() .getResources()
.getStringArray(com.android.settingslib.R.array.entryvalues_font_size) .getStringArray(com.android.settingslib.R.array.entryvalues_font_size)
@Mock private lateinit var userTracker: UserTracker
@Captor @Captor
private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener> private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener>
@@ -72,7 +75,7 @@ class FontScalingDialogTest : SysuiTestCase() {
val mainHandler = Handler(TestableLooper.get(this).getLooper()) val mainHandler = Handler(TestableLooper.get(this).getLooper())
systemSettings = FakeSettings() systemSettings = FakeSettings()
// Guarantee that the systemSettings always starts with the default font scale. // Guarantee that the systemSettings always starts with the default font scale.
systemSettings.putFloat(Settings.System.FONT_SCALE, 1.0f) systemSettings.putFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId)
secureSettings = FakeSettings() secureSettings = FakeSettings()
systemClock = FakeSystemClock() systemClock = FakeSystemClock()
backgroundDelayableExecutor = FakeExecutor(systemClock) backgroundDelayableExecutor = FakeExecutor(systemClock)
@@ -82,6 +85,7 @@ class FontScalingDialogTest : SysuiTestCase() {
systemSettings, systemSettings,
secureSettings, secureSettings,
systemClock, systemClock,
userTracker,
mainHandler, mainHandler,
backgroundDelayableExecutor backgroundDelayableExecutor
) )
@@ -93,7 +97,12 @@ class FontScalingDialogTest : SysuiTestCase() {
val seekBar: SeekBar = fontScalingDialog.findViewById<SeekBar>(R.id.seekbar)!! val seekBar: SeekBar = fontScalingDialog.findViewById<SeekBar>(R.id.seekbar)!!
val progress: Int = seekBar.getProgress() val progress: Int = seekBar.getProgress()
val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale =
systemSettings.getFloatForUser(
Settings.System.FONT_SCALE,
/* def= */ 1.0f,
userTracker.userId
)
assertThat(currentScale).isEqualTo(fontSizeValueArray[progress].toFloat()) assertThat(currentScale).isEqualTo(fontSizeValueArray[progress].toFloat())
@@ -119,7 +128,12 @@ class FontScalingDialogTest : SysuiTestCase() {
backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.advanceClockToNext()
backgroundDelayableExecutor.runAllReady() backgroundDelayableExecutor.runAllReady()
val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale =
systemSettings.getFloatForUser(
Settings.System.FONT_SCALE,
/* def= */ 1.0f,
userTracker.userId
)
assertThat(seekBar.getProgress()).isEqualTo(1) assertThat(seekBar.getProgress()).isEqualTo(1)
assertThat(currentScale).isEqualTo(fontSizeValueArray[1].toFloat()) assertThat(currentScale).isEqualTo(fontSizeValueArray[1].toFloat())
@@ -145,7 +159,12 @@ class FontScalingDialogTest : SysuiTestCase() {
backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.advanceClockToNext()
backgroundDelayableExecutor.runAllReady() backgroundDelayableExecutor.runAllReady()
val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale =
systemSettings.getFloatForUser(
Settings.System.FONT_SCALE,
/* def= */ 1.0f,
userTracker.userId
)
assertThat(seekBar.getProgress()).isEqualTo(fontSizeValueArray.size - 2) assertThat(seekBar.getProgress()).isEqualTo(fontSizeValueArray.size - 2)
assertThat(currentScale) assertThat(currentScale)
.isEqualTo(fontSizeValueArray[fontSizeValueArray.size - 2].toFloat()) .isEqualTo(fontSizeValueArray[fontSizeValueArray.size - 2].toFloat())
@@ -159,16 +178,21 @@ class FontScalingDialogTest : SysuiTestCase() {
val seekBarWithIconButtonsView: SeekBarWithIconButtonsView = val seekBarWithIconButtonsView: SeekBarWithIconButtonsView =
fontScalingDialog.findViewById(R.id.font_scaling_slider)!! fontScalingDialog.findViewById(R.id.font_scaling_slider)!!
secureSettings.putInt(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF) secureSettings.putIntForUser(
Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
OFF,
userTracker.userId
)
// Default seekbar progress for font size is 1, set it to another progress 0 // Default seekbar progress for font size is 1, set it to another progress 0
seekBarWithIconButtonsView.setProgress(0) seekBarWithIconButtonsView.setProgress(0)
backgroundDelayableExecutor.runAllReady() backgroundDelayableExecutor.runAllReady()
val currentSettings = val currentSettings =
secureSettings.getInt( secureSettings.getIntForUser(
Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
/* def = */ OFF /* def = */ OFF,
userTracker.userId
) )
assertThat(currentSettings).isEqualTo(ON) assertThat(currentSettings).isEqualTo(ON)
@@ -199,7 +223,12 @@ class FontScalingDialogTest : SysuiTestCase() {
backgroundDelayableExecutor.runAllReady() backgroundDelayableExecutor.runAllReady()
// Verify that the scale of font size remains the default value 1.0f. // Verify that the scale of font size remains the default value 1.0f.
var systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) var systemScale =
systemSettings.getFloatForUser(
Settings.System.FONT_SCALE,
/* def= */ 1.0f,
userTracker.userId
)
assertThat(systemScale).isEqualTo(1.0f) assertThat(systemScale).isEqualTo(1.0f)
// Simulate releasing the finger from the seekbar. // Simulate releasing the finger from the seekbar.
@@ -209,7 +238,12 @@ class FontScalingDialogTest : SysuiTestCase() {
backgroundDelayableExecutor.runAllReady() backgroundDelayableExecutor.runAllReady()
// Verify that the scale of font size has been updated. // Verify that the scale of font size has been updated.
systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) systemScale =
systemSettings.getFloatForUser(
Settings.System.FONT_SCALE,
/* def= */ 1.0f,
userTracker.userId
)
assertThat(systemScale).isEqualTo(fontSizeValueArray[0].toFloat()) assertThat(systemScale).isEqualTo(fontSizeValueArray[0].toFloat())
fontScalingDialog.dismiss() fontScalingDialog.dismiss()

View File

@@ -33,6 +33,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.qs.QSHost import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.eq
@@ -44,8 +46,11 @@ import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.anyBoolean import org.mockito.Mockito.anyBoolean
import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
@@ -61,6 +66,8 @@ class FontScalingTileTest : SysuiTestCase() {
@Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var qsLogger: QSLogger
@Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator
@Mock private lateinit var uiEventLogger: QsEventLogger @Mock private lateinit var uiEventLogger: QsEventLogger
@Mock private lateinit var userTracker: UserTracker
@Mock private lateinit var keyguardStateController: KeyguardStateController
private lateinit var testableLooper: TestableLooper private lateinit var testableLooper: TestableLooper
private lateinit var systemClock: FakeSystemClock private lateinit var systemClock: FakeSystemClock
@@ -69,6 +76,8 @@ class FontScalingTileTest : SysuiTestCase() {
val featureFlags = FakeFeatureFlags() val featureFlags = FakeFeatureFlags()
@Captor private lateinit var argumentCaptor: ArgumentCaptor<Runnable>
@Before @Before
fun setUp() { fun setUp() {
MockitoAnnotations.initMocks(this) MockitoAnnotations.initMocks(this)
@@ -88,11 +97,13 @@ class FontScalingTileTest : SysuiTestCase() {
statusBarStateController, statusBarStateController,
activityStarter, activityStarter,
qsLogger, qsLogger,
keyguardStateController,
dialogLaunchAnimator, dialogLaunchAnimator,
FakeSettings(), FakeSettings(),
FakeSettings(), FakeSettings(),
FakeSystemClock(), FakeSystemClock(),
featureFlags, featureFlags,
userTracker,
backgroundDelayableExecutor, backgroundDelayableExecutor,
) )
fontScalingTile.initialize() fontScalingTile.initialize()
@@ -124,14 +135,44 @@ class FontScalingTileTest : SysuiTestCase() {
} }
@Test @Test
fun clickTile_showDialog() { fun clickTile_screenUnlocked_showDialogAnimationFromView() {
`when`(keyguardStateController.isShowing).thenReturn(false)
val view = View(context) val view = View(context)
fontScalingTile.click(view) fontScalingTile.click(view)
testableLooper.processAllMessages() testableLooper.processAllMessages()
verify(activityStarter)
.executeRunnableDismissingKeyguard(
argumentCaptor.capture(),
eq(null),
eq(true),
eq(true),
eq(false)
)
argumentCaptor.value.run()
verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean()) verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean())
} }
@Test
fun clickTile_onLockScreen_neverShowDialogAnimationFromView() {
`when`(keyguardStateController.isShowing).thenReturn(true)
val view = View(context)
fontScalingTile.click(view)
testableLooper.processAllMessages()
verify(activityStarter)
.executeRunnableDismissingKeyguard(
argumentCaptor.capture(),
eq(null),
eq(true),
eq(true),
eq(false)
)
argumentCaptor.value.run()
verify(dialogLaunchAnimator, never())
.showFromView(any(), eq(view), nullable(), anyBoolean())
}
@Test @Test
fun getLongClickIntent_getExpectedIntent() { fun getLongClickIntent_getExpectedIntent() {
val intent: Intent? = fontScalingTile.getLongClickIntent() val intent: Intent? = fontScalingTile.getLongClickIntent()