What I want to achieve is to change lock screen, regularly. As an example, the lock screen is a PIN, and the PIN number should be increased by one everyday (e.g., using cron jobs).

It seems there is no such an app on Google Play Store, as it is a special task (if it is, please send the link here). The next method would be using Terminal. My phone is rooted with Termux installed.

Now, the questions are:

  • How to change the lock screen from Terminal?

  • How to set the screen lock type? For example, you would say the screen lock should be changed from a PIN to pattern. Consider the special cases such as pattern, please (if they are possible or not).

Note: The reasons of doing such a thing is just personally-preferred, so, asking the benefits of doing so seems useless. Someone else might want to change it just for the fun.

Edit: locksettings is added in Android Oreo, as mentioned by @IrfanLatif and this answer. As a result, it seems I am out of luck, becuase my Android version is before Oreo (i.e. Android 7.1.2).

  • 2
    This is a duplicate to that question since there's no known solution for Android 7 or before. Otherwise, if there are, then they are free to answer the duplicate one to prevent fragmented answers on different questions. – Andrew T. Sep 16 '19 at 12:18
  • 1
    locksettings command was added in Oreo: android.googlesource.com/platform/frameworks/base/+/… – Irfan Latif Sep 16 '19 at 12:33