question

yasu avatar image
yasu asked yasu answered

Unlock Clover Flex with passcode programmatically

Hi, I'm working in Sandbox environment.


Is it possible to unlock a device of Clover Flex with passcode through code? When working from home, I sometimes find the device felt asleep. I can wake up the terminal through the following code, but afterwards I cannot proceed a payment.

private void wakeUpDeviceForciblyForDebug() {
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

        PowerManager.WakeLock wl;
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "My Tag");
        wl.acquire();

        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
        keyguardLock.disableKeyguard();
    }

I'm guessing this happens due to lack of passcode while waking up the terminal by code. So, I'm wondering if it's possible to unlock the device programmatically either by "Quick Access" or with passcode. Of course I can count on my collegues to unlock the terminal with passcode, but I prefer to not disturb them too much.


Any advice would be appreciated,


Thank you

Clover Android SDKClover Flex
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered yasu commented
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

yasu avatar image yasu commented ·

I was able to unlock the screen with the information from the link, thank you very much!

0 Likes 0 ·
yasu avatar image
yasu answered

I have used this code below :

@Override    
protected void onCreate(Bundle savedInstanceState) {        
   super.onCreate(savedInstanceState);            
   unlockScreenWithoutPasscode();            
}     

private void unlockScreenWithoutPasscode(){        
   Lockscreen lockscreen = new Lockscreen(this);        
   lockscreen.unlock();    
}
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community