Package org.robolectric.shadows
Class ShadowKeyguardManager
java.lang.Object
org.robolectric.shadows.ShadowKeyguardManager
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An implementation ofKeyguardManager.KeyguardLock
, for use in tests. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Intent
createConfirmFactoryResetCredentialIntent
(CharSequence title, CharSequence description, CharSequence alternateButtonLabel) Returns the intent set viasetConfirmFactoryResetCredentialIntent(Intent)
, otherwise null.protected boolean
For tests, returns the value set viasetinRestrictedInputMode(boolean)
, or false by default.protected boolean
protected boolean
isDeviceLocked
(int userId) protected boolean
For tests on Android >=M, returns the value set bysetIsDeviceSecure(boolean)
, or false by default.protected boolean
isDeviceSecure
(int userId) For tests on Android >=M, returns the value set bysetIsDeviceSecure(int, boolean)
, or false by default.protected boolean
For tests, returns the value set viasetKeyguardLocked(boolean)
, or false by default.protected boolean
For tests, returns the value set bysetIsKeyguardSecure(boolean)
, or false by default.protected void
requestDismissKeyguard
(Activity activity, KeyguardManager.KeyguardDismissCallback callback) static void
reset()
void
For tests on Android >= O MR1, sets the value to be returned bycreateConfirmFactoryResetCredentialIntent(CharSequence,CharSequence,CharSequence)
.void
setinRestrictedInputMode
(boolean restricted) Deprecated.void
setInRestrictedInputMode
(boolean restricted) Sets the value to be returned byKeyguardManager.inKeyguardRestrictedInputMode()
.void
setIsDeviceLocked
(boolean isDeviceLocked) For tests on Android >=L MR1, sets the value to be returned byisDeviceLocked()
.void
setIsDeviceLocked
(int userId, boolean isLocked) For tests on Android >= L MR1, sets the value to be returned byisDeviceLocked(int)
.void
setIsDeviceSecure
(boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure()
.void
setIsDeviceSecure
(int userId, boolean isDeviceSecure) For tests on Android >=M, sets the value to be returned byisDeviceSecure(int)
.void
setIsKeyguardSecure
(boolean secure) Sets the value to be returned byisKeyguardSecure()
.void
setKeyguardLocked
(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