Class Lockscreen


  • public class Lockscreen
    extends Object
    Lock and unlock a Clover device's lock screen. On Clover devices lock and unlocking the screen is tied to logging out and logging in Clover employees.

    Please consider use of these methods carefully. Clover devices' passcode login system provides security and auditing to merchants. Misuse of this class can circumvent these systems. If you plan to use this class for a production Clover application please post in community.clover.com to ensure your use case will pass Clover's approval process.

    Developers should prefer to unlock to the default employee if enabled by the merchant. This can be handled transparently with the unlock() method that will prefer the default employee if enabled, and otherwise will unlock to the owner employee.

    To explicitly unlock to the default employee use unlockDefault(). Note that this will fail if the default employee is not enabled by the merchant.

    To check if the merchant has a default employee use the following code:

       EmployeeConnector ec; // Obtain an instance in the usual way
       Employee defaultEmployee = ec.getEmployee(Lockscreen.DEFAULT_EMPLOYEE_ID);
       boolean isDefaultEmployeeEnabled = defaultEmployee != null;
     
    To unlock to a specific employee use unlock(String). To get a list of employees and their UUIDs use EmployeeConnector.getEmployees().

    All lock / unlock methods return a boolean indicating if the operation was successful. Attempting to unlock a device that is already unlocked will fail. Attempting to lock a device that is already locked will fail.

    To understand if a Clover device is currently locked use {@link @link com.clover.sdk.v3.employees.EmployeeConnector#getEmployee()}. This will return either the currently logged in employee, or null otherwise.

    To understand if the merchant has enabled the default employee, use EmployeeConnector.getEmployee(String) with and argument of DEFAULT_EMPLOYEE_ID.

    The behavior of these methods on non-Clover devices and Android emulators differs. On non-Clover devices, Clover software does not control the lock screen. While the methods in this class will logout or login Clover employees, they will not cause the device's lock screen to show or hide.

    • Field Detail

      • DEFAULT_EMPLOYEE_ID

        public static final String DEFAULT_EMPLOYEE_ID
        An ID for the default employee which is a employee that has no passcode. Not all merchants enable the default employee.
        See Also:
        unlockDefault(), Constant Field Values
    • Constructor Detail

      • Lockscreen

        public Lockscreen​(Context context)
    • Method Detail

      • lock

        public boolean lock()
        Lock the device.
      • unlock

        public boolean unlock()
        Unlock the device as the default employee. If the merchant does not have a default employee, login as the owner employee.

        This is equivalent to calling unlock(String) with a null employee ID.

      • unlockDefault

        public boolean unlockDefault()
        Unlock the device as the default employee. This will return false if the merchant has not enabled the default employee.
      • unlock

        public boolean unlock​(String employeeId)
        Unlock the device as the given employee UUID. This method returns false if the provided employee ID does not match an employee for this merchant.