DeviceLockManager
public
final
class
DeviceLockManager
extends Object
java.lang.Object | |
↳ | android.devicelock.DeviceLockManager |
Manager used to interact with the system device lock service. The device lock feature is used by special applications ('kiosk apps', downloaded and installed by the device lock solution) to lock and unlock a device. A typical use case is a financed device, where the financing entity has the capability to lock the device in case of a missed payment. When a device is locked, only a limited set of interactions with the device is allowed (for example, placing emergency calls).
Use Context.getSystemService(java.lang.String)
with Context.DEVICE_LOCK_SERVICE
to create a DeviceLockManager
.
Requires the
PackageManager#FEATURE_DEVICE_LOCK
feature which can be detected using PackageManager.hasSystemFeature(String)
.
Summary
Constants | |
---|---|
int |
DEVICE_LOCK_ROLE_FINANCING
Constant representing a financed device role, returned by |
Public methods | |
---|---|
void
|
getDeviceId(Executor executor, OutcomeReceiver<DeviceId, Exception> callback)
Get the device id. |
void
|
getKioskApps(Executor executor, OutcomeReceiver<Map<Integer, String>, Exception> callback)
Get the kiosk app roles and packages. |
void
|
isDeviceLocked(Executor executor, OutcomeReceiver<Boolean, Exception> callback)
Check if the device is locked or not. |
void
|
lockDevice(Executor executor, OutcomeReceiver<Void, Exception> callback)
Lock the device. |
void
|
unlockDevice(Executor executor, OutcomeReceiver<Void, Exception> callback)
Unlock the device. |
Inherited methods | |
---|---|
Constants
DEVICE_LOCK_ROLE_FINANCING
public static final int DEVICE_LOCK_ROLE_FINANCING
Constant representing a financed device role, returned by getKioskApps(Executor, OutcomeReceiver)
.
Constant Value: 0 (0x00000000)
Public methods
getDeviceId
public void getDeviceId (Executor executor, OutcomeReceiver<DeviceId, Exception> callback)
Get the device id.
Requires Manifest.permission.MANAGE_DEVICE_LOCK_STATE
Parameters | |
---|---|
executor |
Executor : the Executor on which to invoke the callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : this returns either the DeviceId or an exception.
This value cannot be null . |
getKioskApps
public void getKioskApps (Executor executor, OutcomeReceiver<Map<Integer, String>, Exception> callback)
Get the kiosk app roles and packages.
Parameters | |
---|---|
executor |
Executor : the Executor on which to invoke the callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : this returns either a Map of device roles/package names,
or an exception. The Integer in the map represent the device lock role
(at this moment, the only supported role is
.DEVICE_LOCK_ROLE_FINANCING . The String represents tha package
name of the kiosk app for that role.
This value cannot be null . |
isDeviceLocked
public void isDeviceLocked (Executor executor, OutcomeReceiver<Boolean, Exception> callback)
Check if the device is locked or not.
Requires Manifest.permission.MANAGE_DEVICE_LOCK_STATE
Parameters | |
---|---|
executor |
Executor : the Executor on which to invoke the callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : this returns either the lock status or an exception.
This value cannot be null . |
lockDevice
public void lockDevice (Executor executor, OutcomeReceiver<Void, Exception> callback)
Lock the device.
Requires Manifest.permission.MANAGE_DEVICE_LOCK_STATE
Parameters | |
---|---|
executor |
Executor : the Executor on which to invoke the callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : this returns either success or an exception.
This value cannot be null . |
unlockDevice
public void unlockDevice (Executor executor, OutcomeReceiver<Void, Exception> callback)
Unlock the device.
Requires Manifest.permission.MANAGE_DEVICE_LOCK_STATE
Parameters | |
---|---|
executor |
Executor : the Executor on which to invoke the callback.
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver : this returns either success or an exception.
This value cannot be null . |