I'm trying to pin screen programmatically on Android L. My app includes xml file with
<?xml version="1.0" encoding="utf-8"?>
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<force-lock/>
<watch-login/>
<disable-camera/>
<disable-keyguard-features/>
<encrypted-storage/>
<expire-password/>
<limit-password/>
<reset-password/>
<set-global-proxy/>
<wipe-data/>
</uses-policies>
</device-admin>
I installed app with proper lines in AndroidManifest file where I defined AdminReceiver. Everything worked fine a few weeks ago, but right now when I came back to this project - App ask me to confirm "Pin screen" popup everytime when app starts.
When I'm debugging I noticed weird behavior
devicePolicyManager.isAdminActive(componentName)
is true
devicePolicyManager.isDeviceOwnerApp(getPackageName())
is true
but
devicePolicyManager.isLockTaskPermitted(getPackageName())
is false
It doesn't matter if I set app as device owner using adb commend dpm set-device-owner ...
or by pushing device_owner.xml file to /data/system/
My question is why app doesn't have permission to lock screen?