Package org.robolectric.shadows
Class ShadowLocaleManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowLocaleManager
-
@Implements(value=android.app.LocaleManager.class, minSdk=33, isInAndroidSdk=false) public class ShadowLocaleManager extends Object
Shadow ofLocaleManager
-
-
Constructor Summary
Constructors Constructor Description ShadowLocaleManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenforceInstallerCheck(boolean value)Sets the value ofenforceInstallerCheck.protected LocaleListgetApplicationLocales(String packageName)Returns the stored locales from in-memory map for the given package whenLocaleManager.getApplicationLocales()is invoked in source code via tests.protected voidsetApplicationLocales(String packageName, LocaleList locales)Stores the passed locales for the given package in-memory.voidsetCallerAsInstallerForPackage(String packageName)Sets the caller as the installer of the given package.
-
-
-
Method Detail
-
getApplicationLocales
@Implementation protected LocaleList getApplicationLocales(String packageName)
Returns the stored locales from in-memory map for the given package whenLocaleManager.getApplicationLocales()is invoked in source code via tests.If
enforceInstallerCheckis set as true, this method will return locales only if the package is installed by caller. Else it will throw aSecurityException.Adds the package name in a set to record that this method was invoked for given package.
-
setApplicationLocales
@Implementation protected void setApplicationLocales(String packageName, LocaleList locales)
Stores the passed locales for the given package in-memory.Use this method in tests to substitute call for
LocaleManager.setApplicationLocales(android.os.LocaleList).
-
enforceInstallerCheck
public void enforceInstallerCheck(boolean value)
Sets the value ofenforceInstallerCheck.Set this to true if the intention to invoke
getApplicationLocales(java.lang.String)is as an installer of the app.In order to mark apps as installed by the caller(installer), use
setCallerAsInstallerForPackage(java.lang.String).
-
setCallerAsInstallerForPackage
public void setCallerAsInstallerForPackage(String packageName)
Sets the caller as the installer of the given package.We are explicitly not storing the package name of the installer. It's implied that the test app is the installer if using this method.
-
-