diff options
19 files changed, 123 insertions, 72 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index fcac6813ae7a..422772de11f2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -25,6 +25,7 @@ import static com.android.keyguard.KeyguardClockSwitch.SMALL; import android.app.WallpaperManager; import android.content.res.Resources; import android.database.ContentObserver; +import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import android.view.View; @@ -264,10 +265,11 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mKeyguardUnlockAnimationController.setLockscreenSmartspace(mSmartspaceView); } - mSecureSettings.registerContentObserver( + mSecureSettings.registerContentObserverForUser( Settings.Secure.getUriFor(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK), false, /* notifyForDescendants */ - mDoubleLineClockObserver + mDoubleLineClockObserver, + UserHandle.USER_ALL ); updateDoubleLineClock(); @@ -476,8 +478,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } private void updateDoubleLineClock() { - mCanShowDoubleLineClock = mSecureSettings.getInt( - Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1) != 0; + mCanShowDoubleLineClock = mSecureSettings.getIntForUser( + Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1, + UserHandle.USER_CURRENT) != 0; if (!mCanShowDoubleLineClock) { mUiExecutor.execute(() -> displayClock(KeyguardClockSwitch.SMALL, /* animate */ true)); diff --git a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt index b8e6d9f0f60a..2fd373105745 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt @@ -19,6 +19,7 @@ package com.android.systemui.controls.dagger import android.content.ContentResolver import android.content.Context import android.database.ContentObserver +import android.os.UserHandle import android.provider.Settings import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.management.ControlsListingController @@ -73,10 +74,11 @@ class ControlsComponent @Inject constructor( init { if (featureEnabled) { - secureSettings.registerContentObserver( + secureSettings.registerContentObserverForUser( Settings.Secure.getUriFor(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), false, /* notifyForDescendants */ - showWhileLockedObserver + showWhileLockedObserver, + UserHandle.USER_ALL ) updateShowWhileLocked() } @@ -123,8 +125,8 @@ class ControlsComponent @Inject constructor( } private fun updateShowWhileLocked() { - canShowWhileLockedSetting = secureSettings.getInt( - Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0) != 0 + canShowWhileLockedSetting = secureSettings.getIntForUser( + Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0, UserHandle.USER_CURRENT) != 0 } enum class Visibility { diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt index 73faa3459c7b..44879aa9e85b 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt @@ -27,6 +27,7 @@ import android.content.pm.ResolveInfo import android.database.ContentObserver import android.net.Uri import android.os.Handler +import android.os.UserHandle import android.os.VibrationEffect import android.provider.Settings.Secure import android.service.controls.Control @@ -74,10 +75,10 @@ class ControlActionCoordinatorImpl @Inject constructor( private var actionsInProgress = mutableSetOf<String>() private val isLocked: Boolean get() = !keyguardStateController.isUnlocked() - private var mAllowTrivialControls: Boolean = secureSettings.getInt( - Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 0) != 0 - private var mShowDeviceControlsInLockscreen: Boolean = secureSettings.getInt( - Secure.LOCKSCREEN_SHOW_CONTROLS, 0) != 0 + private var mAllowTrivialControls: Boolean = secureSettings.getIntForUser( + Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 0, UserHandle.USER_CURRENT) != 0 + private var mShowDeviceControlsInLockscreen: Boolean = secureSettings.getIntForUser( + Secure.LOCKSCREEN_SHOW_CONTROLS, 0, UserHandle.USER_CURRENT) != 0 override lateinit var activityContext: Context companion object { @@ -95,23 +96,25 @@ class ControlActionCoordinatorImpl @Inject constructor( super.onChange(selfChange, uri) when (uri) { lockScreenShowControlsUri -> { - mAllowTrivialControls = secureSettings.getInt( - Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 0) != 0 + mAllowTrivialControls = secureSettings.getIntForUser( + Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, + 0, UserHandle.USER_CURRENT) != 0 } showControlsUri -> { mShowDeviceControlsInLockscreen = secureSettings - .getInt(Secure.LOCKSCREEN_SHOW_CONTROLS, 0) != 0 + .getIntForUser(Secure.LOCKSCREEN_SHOW_CONTROLS, + 0, UserHandle.USER_CURRENT) != 0 } } } } - secureSettings.registerContentObserver( + secureSettings.registerContentObserverForUser( lockScreenShowControlsUri, - false /* notifyForDescendants */, controlsContentObserver + false /* notifyForDescendants */, controlsContentObserver, UserHandle.USER_ALL ) - secureSettings.registerContentObserver( + secureSettings.registerContentObserverForUser( showControlsUri, - false /* notifyForDescendants */, controlsContentObserver + false /* notifyForDescendants */, controlsContentObserver, UserHandle.USER_ALL ) } @@ -311,7 +314,8 @@ class ControlActionCoordinatorImpl @Inject constructor( MAX_NUMBER_ATTEMPTS_CONTROLS_DIALOG) .commit() } - secureSettings.putInt(Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 1) + secureSettings.putIntForUser(Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 1, + UserHandle.USER_CURRENT) true } .create() @@ -325,8 +329,10 @@ class ControlActionCoordinatorImpl @Inject constructor( MAX_NUMBER_ATTEMPTS_CONTROLS_DIALOG) .commit() } - secureSettings.putInt(Secure.LOCKSCREEN_SHOW_CONTROLS, 1) - secureSettings.putInt(Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 1) + secureSettings.putIntForUser(Secure.LOCKSCREEN_SHOW_CONTROLS, + 1, UserHandle.USER_CURRENT) + secureSettings.putIntForUser(Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, + 1, UserHandle.USER_CURRENT) true } .create() diff --git a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebug.java b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebug.java index 3335c8d62f46..be6f732ee5f7 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebug.java +++ b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlagsDebug.java @@ -31,6 +31,7 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; +import android.os.UserHandle; import android.util.Log; import androidx.annotation.NonNull; @@ -210,7 +211,8 @@ public class FeatureFlagsDebug implements FeatureFlags, Dumpable { Log.w(TAG, "Failed to set id " + id + " to " + value); return; } - mSecureSettings.putString(mFlagManager.idToSettingsKey(id), data); + mSecureSettings.putStringForUser(mFlagManager.idToSettingsKey(id), data, + UserHandle.USER_CURRENT); Log.i(TAG, "Set id " + id + " to " + value); removeFromCache(id); mFlagManager.dispatchListenersAndMaybeRestart(id, this::restartSystemUI); @@ -238,7 +240,8 @@ public class FeatureFlagsDebug implements FeatureFlags, Dumpable { /** Works just like {@link #eraseFlag(int)} except that it doesn't restart SystemUI. */ private void eraseInternal(int id) { // We can't actually "erase" things from sysprops, but we can set them to empty! - mSecureSettings.putString(mFlagManager.idToSettingsKey(id), ""); + mSecureSettings.putStringForUser(mFlagManager.idToSettingsKey(id), "", + UserHandle.USER_CURRENT); Log.i(TAG, "Erase id " + id); } diff --git a/packages/SystemUI/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelper.java b/packages/SystemUI/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelper.java index 1f58112c5dc6..1f61647b713f 100644 --- a/packages/SystemUI/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelper.java +++ b/packages/SystemUI/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelper.java @@ -16,6 +16,7 @@ package com.android.systemui.hdmi; +import android.os.UserHandle; import android.provider.Settings; import com.android.internal.app.LocalePicker; @@ -50,8 +51,8 @@ public class HdmiCecSetMenuLanguageHelper { SecureSettings secureSettings) { mBackgroundExecutor = executor; mSecureSettings = secureSettings; - String denylist = mSecureSettings.getString( - Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST); + String denylist = mSecureSettings.getStringForUser( + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, UserHandle.USER_CURRENT); mDenylist = new HashSet<>(denylist == null ? Collections.EMPTY_SET : Arrays.asList(denylist.split(SEPARATOR))); @@ -91,7 +92,7 @@ public class HdmiCecSetMenuLanguageHelper { */ public void declineLocale() { mDenylist.add(mLocale.toLanguageTag()); - mSecureSettings.putString(Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, - String.join(SEPARATOR, mDenylist)); + mSecureSettings.putStringForUser(Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, + String.join(SEPARATOR, mDenylist), UserHandle.USER_CURRENT); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java index 5ed9ab9c4f65..772e9faf6feb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java @@ -25,6 +25,7 @@ import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; +import android.os.UserHandle; import android.service.quickaccesswallet.GetWalletCardsError; import android.service.quickaccesswallet.GetWalletCardsResponse; import android.service.quickaccesswallet.QuickAccessWalletClient; @@ -182,7 +183,8 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { public boolean isAvailable() { return mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION) && !mPackageManager.hasSystemFeature(FEATURE_CHROME_OS) - && mSecureSettings.getString(NFC_PAYMENT_DEFAULT_COMPONENT) != null; + && mSecureSettings.getStringForUser(NFC_PAYMENT_DEFAULT_COMPONENT, + UserHandle.USER_CURRENT) != null; } @Nullable diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt index e436ccfd66c6..5646545dcd23 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt @@ -200,7 +200,8 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor( private fun readShowSilentNotificationSetting() { val showSilentNotifs = - secureSettings.getBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, true) + secureSettings.getBoolForUser(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, + true, UserHandle.USER_CURRENT) hideSilentNotificationsOnLockscreen = !showSilentNotifs } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java index 9e48b763f4f6..597c949168d4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java @@ -31,6 +31,7 @@ import android.app.Fragment; import android.database.ContentObserver; import android.os.Bundle; import android.os.Parcelable; +import android.os.UserHandle; import android.provider.Settings; import android.telephony.SubscriptionManager; import android.util.SparseArray; @@ -254,7 +255,10 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue R.array.config_collapsed_statusbar_icon_blocklist)); String vibrateIconSlot = getString(com.android.internal.R.string.status_bar_volume); boolean showVibrateIcon = - mSecureSettings.getInt(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0) == 0; + mSecureSettings.getIntForUser( + Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, + 0, + UserHandle.USER_CURRENT) == 0; // Filter out vibrate icon from the blocklist if the setting is on for (int i = 0; i < blockList.size(); i++) { @@ -291,10 +295,11 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue initOngoingCallChip(); mAnimationScheduler.addCallback(this); - mSecureSettings.registerContentObserver( + mSecureSettings.registerContentObserverForUser( Settings.Secure.getUriFor(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON), false, - mVolumeSettingObserver); + mVolumeSettingObserver, + UserHandle.USER_ALL); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java index 3e50acb75401..f26176c15451 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java @@ -119,8 +119,8 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio }; // Register to listen for changes in Settings.Secure settings. - mSecureSettings.registerContentObserver( - Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, mContentObserver); + mSecureSettings.registerContentObserverForUser( + Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, mContentObserver, UserHandle.USER_ALL); // Register to listen for changes in DeviceConfig settings. mDeviceConfigProxy.addOnPropertiesChangedListener( @@ -230,7 +230,8 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio } private boolean getShowSystemSetting() { - return mSecureSettings.getInt(Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1; + return mSecureSettings.getIntForUser(Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0, + UserHandle.USER_CURRENT) == 1; } private boolean getExperimentStarted() { diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java index c06b8e67c2f8..2424dc5cf0fb 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java @@ -306,8 +306,9 @@ public class ThemeOverlayController extends CoreStartable implements Dumpable { Log.d(TAG, "Updating theme setting from " + overlayPackageJson + " to " + jsonObject.toString()); } - mSecureSettings.putString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, - jsonObject.toString()); + mSecureSettings.putStringForUser( + Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, + jsonObject.toString(), UserHandle.USER_CURRENT); } } catch (JSONException e) { Log.i(TAG, "Failed to parse THEME_CUSTOMIZATION_OVERLAY_PACKAGES.", e); diff --git a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java index de25ca981a65..acff8712e92e 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java @@ -24,6 +24,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.database.ContentObserver; +import android.os.UserHandle; import android.provider.Settings; import android.service.quickaccesswallet.GetWalletCardsRequest; import android.service.quickaccesswallet.QuickAccessWalletClient; @@ -275,10 +276,11 @@ public class QuickAccessWalletController { } }; - mSecureSettings.registerContentObserver( + mSecureSettings.registerContentObserverForUser( Settings.Secure.getUriFor(Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT), false /* notifyForDescendants */, - mDefaultPaymentAppObserver); + mDefaultPaymentAppObserver, + UserHandle.USER_ALL); } mDefaultPaymentAppChangeEvents++; } @@ -294,10 +296,11 @@ public class QuickAccessWalletController { } }; - mSecureSettings.registerContentObserver( + mSecureSettings.registerContentObserverForUser( Settings.Secure.getUriFor(QuickAccessWalletClientImpl.SETTING_KEY), false /* notifyForDescendants */, - mWalletPreferenceObserver); + mWalletPreferenceObserver, + UserHandle.USER_ALL); } mWalletPreferenceChangeEvents++; } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index 3e1b4d63f36a..fe9e75c4ce00 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -30,6 +31,7 @@ import static org.mockito.Mockito.when; import android.content.res.Resources; import android.database.ContentObserver; import android.net.Uri; +import android.os.UserHandle; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.view.View; @@ -250,13 +252,14 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { @Test public void testChangeToDoubleLineClockSetsSmallClock() { - when(mSecureSettings.getInt(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1)) + when(mSecureSettings.getIntForUser(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1, + UserHandle.USER_CURRENT)) .thenReturn(0); ArgumentCaptor<ContentObserver> observerCaptor = ArgumentCaptor.forClass(ContentObserver.class); mController.init(); - verify(mSecureSettings).registerContentObserver(any(Uri.class), - anyBoolean(), observerCaptor.capture()); + verify(mSecureSettings).registerContentObserverForUser(any(Uri.class), + anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL)); ContentObserver observer = observerCaptor.getValue(); mExecutor.runAllReady(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt index bbae5dca10c1..4ed5649c9c50 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlActionCoordinatorImplTest.kt @@ -21,6 +21,7 @@ import android.content.SharedPreferences import android.database.ContentObserver import android.net.Uri import android.os.Handler +import android.os.UserHandle import android.provider.Settings import android.test.suitebuilder.annotation.SmallTest import android.testing.AndroidTestingRunner @@ -40,6 +41,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Answers +import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock import org.mockito.Mockito import org.mockito.Mockito.`when` @@ -97,7 +99,8 @@ class ControlActionCoordinatorImplTest : SysuiTestCase() { `when`(secureSettings.getUriFor(Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS)) .thenReturn(Settings.Secure .getUriFor(Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS)) - `when`(secureSettings.getInt(Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, 0)) + `when`(secureSettings.getIntForUser(Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS, + 0, UserHandle.USER_CURRENT)) .thenReturn(1) coordinator = spy(ControlActionCoordinatorImpl( @@ -125,8 +128,8 @@ class ControlActionCoordinatorImplTest : SysuiTestCase() { `when`(pref.getInt(DeviceControlsControllerImpl.PREFS_SETTINGS_DIALOG_ATTEMPTS, 0)) .thenReturn(2) - verify(secureSettings).registerContentObserver(any(Uri::class.java), - anyBoolean(), any(ContentObserver::class.java)) + verify(secureSettings).registerContentObserverForUser(any(Uri::class.java), + anyBoolean(), any(ContentObserver::class.java), anyInt()) `when`(cvh.cws.ci.controlId).thenReturn(ID) `when`(cvh.cws.control?.isAuthRequired()).thenReturn(true) diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/dagger/ControlsComponentTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/dagger/ControlsComponentTest.kt index c415c1fabdf3..77f451f61c3c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/dagger/ControlsComponentTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/dagger/ControlsComponentTest.kt @@ -137,7 +137,8 @@ class ControlsComponentTest : SysuiTestCase() { `when`(lockPatternUtils.getStrongAuthForUser(anyInt())) .thenReturn(STRONG_AUTH_NOT_REQUIRED) `when`(keyguardStateController.isUnlocked()).thenReturn(false) - `when`(secureSettings.getInt(eq(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), anyInt())) + `when`(secureSettings.getIntForUser(eq(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS), + anyInt(), anyInt())) .thenReturn(1) val component = setupComponent(true) diff --git a/packages/SystemUI/tests/src/com/android/systemui/flags/FeatureFlagsDebugTest.kt b/packages/SystemUI/tests/src/com/android/systemui/flags/FeatureFlagsDebugTest.kt index 50b779cb6bf5..95fed6ca063f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/flags/FeatureFlagsDebugTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/flags/FeatureFlagsDebugTest.kt @@ -34,6 +34,7 @@ import com.google.common.truth.Truth.assertThat import org.junit.Assert import org.junit.Before import org.junit.Test +import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock import org.mockito.Mockito.anyBoolean import org.mockito.Mockito.anyString @@ -321,7 +322,7 @@ class FeatureFlagsDebugTest : SysuiTestCase() { inOrder(mFlagManager, mSecureSettings).apply { verify(mFlagManager, times(numReads)).readFlagValue(eq(id), any<FlagSerializer<*>>()) verify(mFlagManager).idToSettingsKey(eq(id)) - verify(mSecureSettings).putString(eq("key-$id"), eq(data)) + verify(mSecureSettings).putStringForUser(eq("key-$id"), eq(data), anyInt()) verify(mFlagManager).dispatchListenersAndMaybeRestart(eq(id), any()) }.verifyNoMoreInteractions() verifyNoMoreInteractions(mFlagManager, mSecureSettings) diff --git a/packages/SystemUI/tests/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelperTest.java index 1171bd299c1f..eb998cc588fd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/hdmi/HdmiCecSetMenuLanguageHelperTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.os.UserHandle; import android.provider.Settings; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; @@ -53,8 +54,9 @@ public class HdmiCecSetMenuLanguageHelperTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); - when(mSecureSettings.getString( - Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST)).thenReturn(null); + when(mSecureSettings.getStringForUser( + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, + UserHandle.USER_CURRENT)).thenReturn(null); mHdmiCecSetMenuLanguageHelper = new HdmiCecSetMenuLanguageHelper(mExecutor, mSecureSettings); } @@ -84,8 +86,9 @@ public class HdmiCecSetMenuLanguageHelperTest extends SysuiTestCase { mHdmiCecSetMenuLanguageHelper.setLocale("de"); mHdmiCecSetMenuLanguageHelper.declineLocale(); assertThat(mHdmiCecSetMenuLanguageHelper.isLocaleDenylisted()).isEqualTo(true); - verify(mSecureSettings).putString( - Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de"); + verify(mSecureSettings).putStringForUser( + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de", + UserHandle.USER_CURRENT); } @Test @@ -93,12 +96,14 @@ public class HdmiCecSetMenuLanguageHelperTest extends SysuiTestCase { mHdmiCecSetMenuLanguageHelper.setLocale("de"); mHdmiCecSetMenuLanguageHelper.declineLocale(); assertThat(mHdmiCecSetMenuLanguageHelper.isLocaleDenylisted()).isEqualTo(true); - verify(mSecureSettings).putString( - Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de"); + verify(mSecureSettings).putStringForUser( + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de", + UserHandle.USER_CURRENT); mHdmiCecSetMenuLanguageHelper.setLocale("pl"); mHdmiCecSetMenuLanguageHelper.declineLocale(); assertThat(mHdmiCecSetMenuLanguageHelper.isLocaleDenylisted()).isEqualTo(true); - verify(mSecureSettings).putString( - Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de,pl"); + verify(mSecureSettings).putStringForUser( + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, "de,pl", + UserHandle.USER_CURRENT); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java index 1e5acde8bef5..c88ceac458ee 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java @@ -45,6 +45,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Handler; +import android.os.UserHandle; import android.service.quickaccesswallet.GetWalletCardsError; import android.service.quickaccesswallet.GetWalletCardsResponse; import android.service.quickaccesswallet.QuickAccessWalletClient; @@ -186,7 +187,8 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { public void testIsAvailable_qawFeatureAvailable() { when(mPackageManager.hasSystemFeature(FEATURE_NFC_HOST_CARD_EMULATION)).thenReturn(true); when(mPackageManager.hasSystemFeature("org.chromium.arc")).thenReturn(false); - when(mSecureSettings.getString(NFC_PAYMENT_DEFAULT_COMPONENT)).thenReturn("Component"); + when(mSecureSettings.getStringForUser(NFC_PAYMENT_DEFAULT_COMPONENT, + UserHandle.USER_CURRENT)).thenReturn("Component"); assertTrue(mTile.isAvailable()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java index 497f7fba2dbf..98397fb01b6b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java @@ -29,6 +29,7 @@ import android.app.Fragment; import android.app.StatusBarManager; import android.content.Context; import android.os.Bundle; +import android.os.UserHandle; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; @@ -331,7 +332,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { String str = mContext.getString(com.android.internal.R.string.status_bar_volume); // GIVEN the setting is ON - when(mSecureSettings.getInt(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0)) + when(mSecureSettings.getIntForUser(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0, + UserHandle.USER_CURRENT)) .thenReturn(1); // WHEN CollapsedStatusBarFragment builds the blocklist diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java index b8f66fc41f04..3dfc94bcd5b6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java @@ -292,8 +292,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); assertThat(updatedSetting.getValue().contains("android.theme.customization.accent_color")) .isFalse(); @@ -330,8 +331,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); assertThat(updatedSetting.getValue().contains( "android.theme.customization.color_both\":\"0")).isTrue(); @@ -396,8 +398,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK, USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); assertThat(updatedSetting.getValue().contains( "android.theme.customization.color_both\":\"1")).isTrue(); @@ -426,8 +429,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); assertThat(updatedSetting.getValue().contains( "android.theme.customization.color_source\":\"lock_wallpaper")).isTrue(); assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index")) @@ -456,8 +460,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); assertThat(updatedSetting.getValue().contains( "android.theme.customization.color_source\":\"home_wallpaper")).isTrue(); assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index")) @@ -491,8 +496,9 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { USER_SYSTEM); ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class); - verify(mSecureSettings).putString( - eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture()); + verify(mSecureSettings).putStringForUser( + eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture(), + anyInt()); verify(mThemeOverlayApplier) .applyCurrentUserOverlays(any(), any(), anyInt(), any()); |