[Fix settings] Multi user for settings wrapper

Audit and fix SettingsProxy usages to account for multiple users.

Note that this does not fix any Settings usages that does not use
SettingsProxy. There maybe be outstanding files to change, but from a
glance, most of the usages seem to be user aware.

Bug: 226391543
Test: Manual and fixed unit tests

Change-Id: Ia8ff59fe55049cc79ac73237087d3aaca2cbb3b3
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index fcac681..422772d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -25,6 +25,7 @@
 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 @@
             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 @@
     }
 
     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 b8e6d9f..2fd3731 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 @@
 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 @@
 
     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 @@
     }
 
     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 73faa34..44879aa 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.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 @@
     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 @@
                 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 @@
                                     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 @@
                                     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 3335c8d..be6f732 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.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 @@
             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 @@
     /** 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 1f58112..1f61647 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 @@
             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 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 5ed9ab9..772e9fa 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.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 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 e436ccf..5646545 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 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 8194957..7dd1ebd 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.database.ContentObserver;
 import android.os.Bundle;
 import android.os.Parcelable;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
@@ -223,7 +224,10 @@
                 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++) {
@@ -260,10 +264,11 @@
         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 3e50acb..f26176c 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 @@
         };
 
         // 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 @@
     }
 
     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 c06b8e6..2424dc5 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 @@
                     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 de25ca9..acff871 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.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 @@
                 }
             };
 
-            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 @@
                 }
             };
 
-            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 3e1b4d6..fe9e75c 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.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 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 @@
 
     @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 bbae5dc..4ed5649c 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.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.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 @@
         `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 @@
         `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 c415c1f..77f451f 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 @@
         `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 50b779c..95fed6ca0 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 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 @@
         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 1171bd2..eb998cc 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.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 @@
     @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 @@
         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 @@
         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 1e5acde..c88ceac 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.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 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 5095094..542e0d3 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.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;
@@ -329,7 +330,8 @@
         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 b8f66fc..3dfc94b 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 @@
                 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 @@
                 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 @@
                 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 @@
                 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 @@
                 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 @@
                 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());