You will select applications that you want protect with pattern lock code.
When user will open that protected application then apps lock show automatically and ask correct pattern.
For this process application need some sensitive permissions from user.
android.permission.GET_TASKS
Allows an application to get information about the currently or recently running tasks.
android.permission.PACKAGE_USAGE_STATS
Allows an application to collect component usage statistics
Declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application.
3) QUERY ALL PACKAGES
Constant Value: "android.permission.QUERY_ALL_PACKAGES"
Google Play restricts the use of high-risk or sensitive permissions, including the QUERY_ALL_PACKAGES permission, which gives visibility into the inventory of installed apps on a given device. Play regards the inventory of installed apps queried from a user’s device as personal and sensitive information, and the use of the permission is only permitted when your app's core user-facing functionality or purpose requires broad visibility into installed apps on the user’s device.
android.permission.RECEIVE_BOOT_COMPLETED
Allows an application to receive the Intent.ACTION_BOOT_COMPLETED that is broadcast after the system finishes booting. If you don't request this permission, you will not receive the broadcast at that time. Though holding this permission does not have any security implications, it can have a negative impact on the user experience by increasing the amount of time it takes the system to start and allowing applications to have themselves running without the user being aware of them. As such, you must explicitly declare your use of this facility to make that visible to the user.
android.permission.FOREGROUND_SERVICE
Allows a regular application to use Service.startForeground.
android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
Permission an application must hold in order to use Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.
7) SYSTEM_ALERT_WINDOW
Constant Value: "android.permission.SYSTEM_ALERT_WINDOW"
Allows an app to create windows using the type WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, shown on top of all other apps. Very few apps should use this permission; these windows are intended for system-level interaction with the user.
8) WRITE_EXTERNAL_STORAGE
Constant Value: "android.permission.WRITE_EXTERNAL_STORAGE"
Allows an application to write to external storage.