2

The Lock Screen uses two timers. The first timer is the "Sleep" timer which turns off the device display to extend battery life.

The second timer called the "Automatic lock" timer turns on security features like pin, pattern, password or face unlock and protects the device from unknown users.


screenshot (click image for larger variant)

So I want that,

  1. My phone do not get locked when the screen go off until I lock it manually( i.e. by power key). By default 30min is the max. time when the screen get off but the phone do not get locked on lock screen.
  2. How to manually turn off screen without locking the phone (because if i use power key i will need to enter pin or password).(second one is not so important I just to know is there is a way instead of just relying on screen timeout)

Note: Device is Samsung j7 nxt, Android 9.0 rooted and Magisk and Edxposed Manager installed.

My device do not support face unlock and fingerprint unlock. I use shared wifi, so that cannot be used for smart lock. I do not have Wi-Fi at home I use phone data and there is some issue with my Bluetooth Unable to connect my bluetooth to pc or otherphone.

The only way to achieve this thing is through increasing time in lock automatically.

3
  • 1
    android.stackexchange.com/q/215891 – alecxs Aug 27 '20 at 21:08
  • 1
    The timer is not only there to save battery it is also there to protect your screen. According a different question you own a Samsung J7 which has an AMOLED screen. Therefore if you really want to keep the screen on for a long time make sure to reduce the brightness to a minimum otherwise you will earlier or later see ghost mages because of the AMOLED has worn out. I also recommend to you not to keep the display on for an unlimited amount of time. – Robert Aug 28 '20 at 8:02
  • 1
    you want the screen go off, but don't enter pin when use again - that is afaik what smart lock functionality provides. so any emulated event which can trigger smart lock should do the trick, don't you think so? – alecxs Aug 28 '20 at 9:51
2

Difficult part of this situation is that OP doesn't have access to conventional smart unlock methods like Faceunlock, Wifi, Bluetooth, Location fence. So the solution has to depend on using system (OS) properties. That brings a caveat, it may not run on all devices. It runs fine on my OnePlus 7,with Oxygen OS, Android 10.

  • I prefer using MacroDroid for automation , since it is free (upto 5 macros) and easy to learn. To understand how MacroDroid works, see answer here (Not affiliated to any app). Credits to this solution go to user pr3jker who uploaded his template in two macros (accessible from the templates section of app). This is a no-frill, bare bone macro improvised from those and can be improved upon to meet specific needs. The good part is this meets both requirements asked by OP. You need two macros.

  • First Macro (unlock w/o PIN)

  • Triggers:

  1. Screen Off
  2. Empty Trigger
  • Action

System Setting → Secure → Setting Key, enter lock_screen_lock_after_timeout (copy paste sometimes adds invisible characters, so key it in) → Value enter 86400 (or 86400000 on Android 10 as it uses mlliseconds iso. seconds) make sure it is integer selected → OK and name, save the macro

Logic: When the screen goes off (depending on the sleep time you set in your device) or when called by another macro (empty trigger) the actual lock screen period is extended to 24 hours (86400 seconds). Effectively, you are setting sleep time to 24 hours, irrespective of the system sleep time setting (Your screen will go off as per the system sleep time but actually it is 24 hours) . So, when you press the power key to unlock, it does so without needing to enter PIN.

To test, set system sleep time to 15 seconds, let the screen fade and go off, unlock device by power key press (Don't lock device by power key, let the screen go off)

  • Second Macro (to toggle the first macro)

  • Trigger: Empty Trigger

  • Action Enable /Disable Macro → from the drop down menu choose the first macro → Toggle Macro → OK, name and save the macro

Go to the widgets section of your launcher, locate MacroDroid shortcut widget and drop it on home screen and assign the second macro to it.

When you click the widget, the first macro is disabled and on next click it is enabled. You can add corresponding text warnings or audio feed back on toggling, since disabling Key guard (PIN) is a security risk and you agree that you are consciously doing it. For example, another action can be added in the second macro, lF Macro enabled (first one) pop up message and audio warning so that you are aware of zero Key guard security.

Note: Disabling the macro only ensures that it is not triggered again but the previous values will hold - for example, if you set it for 24 hours and disable it after 2 hours, the behavior will persist for another 22 hours. So, either set the time period short or see the template macro for remedy. Like I said, it's a bare bone macro in the answer.


Since you have EdXposed installed, you may want to install Xposed edge module and map gestures to the second macro (choose shortcut and then MacroDroid shortcut as action). This is what I did since I am mostly at home and don't really need to lock my device and with a gesture enable key guard when stepping out.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.