[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
This commit is contained in:
Aaron Liu
2022-04-05 16:36:50 +00:00
parent f86c86cd8f
commit e28baefa31
19 changed files with 123 additions and 72 deletions

View File

@@ -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));

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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.util.SparseArray;
import android.view.LayoutInflater;
@@ -223,7 +224,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++) {
@@ -260,10 +264,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

View File

@@ -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() {

View File

@@ -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);

View File

@@ -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++;
}

View File

@@ -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();

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);
}
}

View File

@@ -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());
}

View File

@@ -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;
@@ -329,7 +330,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

View File

@@ -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());