Package org.robolectric.shadows
Class ShadowKeyguardManager
java.lang.Object
org.robolectric.shadows.ShadowKeyguardManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn implementation ofKeyguardManager.KeyguardLock, for use in tests. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IntentcreateConfirmFactoryResetCredentialIntent(CharSequence title, CharSequence description, CharSequence alternateButtonLabel) Returns the intent set viasetConfirmFactoryResetCredentialIntent(Intent), otherwise null.protected booleanFor tests, returns the value set viasetinRestrictedInputMode(boolean), or false by default.protected booleanprotected booleanisDeviceLocked(int userId) protected booleanFor tests on Android >=M, returns the value set bysetIsDeviceSecure(boolean), or false by default.protected booleanisDeviceSecure(int userId) For tests on Android >=M, returns the value set bysetIsDeviceSecure(int, boolean), or false by default.protected booleanFor tests, returns the value set viasetKeyguardLocked(boolean), or false by default.protected booleanFor tests, returns the value set bysetIsKeyguardSecure(boolean), or false by default.protected voidrequestDismissKeyguard(Activity activity, KeyguardManager.KeyguardDismissCallback callback) static voidreset()voidFor tests on Android >= O MR1, sets the value to be returned bycreateConfirmFactoryResetCredentialIntent(CharSequence,CharSequence,CharSequence).voidsetinRestrictedInputMode(boolean restricted) Deprecated.voidsetInRestrictedInputMode(boolean restricted) Sets the value to be returned byKeyguardManager.inKeyguardRestrictedInputMode().voidsetIsDeviceLocked(boolean isDeviceLocked) For tests on Android >=L MR1, sets the value to be returned byisDeviceLocked().voidsetIsDeviceLocked(int userId, boolean isLocked) For tests on Android >= L MR1, sets the value to be returned byisDeviceLocked(int).voidsetIsDeviceSecure(boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure().voidsetIsDeviceSecure(int userId, boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure(int).voidsetIsKeyguardSecure(boolean secure) Sets the value to be returned byisKeyguardSecure().voidsetKeyguardLocked(boolean isKeyguardLocked) Sets whether the device keyguard is locked or not.
-
Constructor Details
-
ShadowKeyguardManager
public ShadowKeyguardManager()
-
-
Method Details
-
inKeyguardRestrictedInputMode
For tests, returns the value set viasetinRestrictedInputMode(boolean), or false by default.- See Also:
-
requestDismissKeyguard
@Implementation(minSdk=26) protected void requestDismissKeyguard(Activity activity, KeyguardManager.KeyguardDismissCallback callback) -
isKeyguardLocked
For tests, returns the value set viasetKeyguardLocked(boolean), or false by default.- See Also:
-
setKeyguardLocked
public void setKeyguardLocked(boolean isKeyguardLocked) Sets whether the device keyguard is locked or not. This affects the value to be returned byisKeyguardLocked()and also invokes callbacks set inKeyguardManager.requestDismissKeyguard(Activity, KeyguardDismissCallback)()}.- Parameters:
isKeyguardLocked- true to lock the keyguard. If a KeyguardDismissCallback is set will fireKeyguardManager.KeyguardDismissCallback.onDismissCancelled()or false to unlock and dismiss the keyguard firingKeyguardManager.KeyguardDismissCallback.onDismissSucceeded()if a KeyguardDismissCallback is set.
-
setinRestrictedInputMode
Deprecated.usesetInRestrictedInputMode(boolean)insteadSets the value to be returned byKeyguardManager.inKeyguardRestrictedInputMode(). -
setInRestrictedInputMode
public void setInRestrictedInputMode(boolean restricted) Sets the value to be returned byKeyguardManager.inKeyguardRestrictedInputMode(). -
isKeyguardSecure
For tests, returns the value set bysetIsKeyguardSecure(boolean), or false by default.- See Also:
-
setIsKeyguardSecure
public void setIsKeyguardSecure(boolean secure) Sets the value to be returned byisKeyguardSecure().- See Also:
-
isDeviceSecure
For tests on Android >=M, returns the value set bysetIsDeviceSecure(boolean), or false by default.- See Also:
-
setIsDeviceSecure
public void setIsDeviceSecure(boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure().- See Also:
-
isDeviceSecure
For tests on Android >=M, returns the value set bysetIsDeviceSecure(int, boolean), or false by default.- See Also:
-
setIsDeviceSecure
public void setIsDeviceSecure(int userId, boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure(int).- See Also:
-
setIsDeviceLocked
public void setIsDeviceLocked(boolean isDeviceLocked) For tests on Android >=L MR1, sets the value to be returned byisDeviceLocked().- See Also:
-
isDeviceLocked
- Returns:
- false by default, or the value passed to
setIsDeviceLocked(boolean). - See Also:
-
setIsDeviceLocked
public void setIsDeviceLocked(int userId, boolean isLocked) For tests on Android >= L MR1, sets the value to be returned byisDeviceLocked(int).- See Also:
-
isDeviceLocked
-
setConfirmFactoryResetCredentialIntent
For tests on Android >= O MR1, sets the value to be returned bycreateConfirmFactoryResetCredentialIntent(CharSequence,CharSequence,CharSequence). -
createConfirmFactoryResetCredentialIntent
@Implementation(minSdk=27) protected Intent createConfirmFactoryResetCredentialIntent(CharSequence title, CharSequence description, CharSequence alternateButtonLabel) Returns the intent set viasetConfirmFactoryResetCredentialIntent(Intent), otherwise null. -
reset
-
setInRestrictedInputMode(boolean)instead