Yeah, so I managed to do it myself.
TL;DR: grant permissions for the package installed in the user profile.
I am using Tasker only on the first user profile (not Owner).
You probably have to install Tasker in your primary profile as well (I had to)
Enable Developer mode and USB Debugging in the Owner profile. Connect the cable to the unlocked phone, approve the connection (works only in the Owner profile anyway)
see your secondary user ID: adb shell pm list users
Users:
UserInfo{0:SirOwner:xxxx} running
UserInfo{10:FellowUser:xxxx} running
Grant WRITE_SECURE_SETTINGS
to Tasker (you may have to do it both for the Owner and User. Maybe I was lucky)
adb shell pm grant --user 10 net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
if you have to do it for the owner, run again without --user 10
If you made a mistake, run pm revoke
in the similar way
you want to verify:
adb shell pm dump-package net.dinglisch.android.taskerm | less +/WRITE_SECURE_SETTINGS +n
It should show this ("revoked for the Owner, granted for the User 10") :
android.permission.WRITE_SECURE_SETTINGS: granted=false
android.permission.WRITE_SECURE_SETTINGS: granted=true, userId=10
Maybe reboot? (I had to reboot :/ )
Verify it works, then disable USB debugging and the developer mode.
MORE INFO (adding so this reply can be indexed better):
Since I was using Tasker only on the additional, second user profile, and not the owner, when I run this:
adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
I was greeted with the error message:
Failure [package not found]
Error: package not found
To combat it I though I need Tasker for the primary Owner profile as well (I actually had the very similar thing with another app with the DEVICE_ADMIN
permission, need to have the app in the Owner as well), and tried the advised call:
This KIND OF worked but for the owner profile only:
adb shell pm dump-package net.dinglisch.android.taskerm | grep SECURE_SET
shows:
android.permission.WRITE_SECURE_SETTINGS: granted=true
android.permission.WRITE_SECURE_SETTINGS: granted=false, userId=10
-- and the Tasker in the User profile kept complaining about being unable to toggle the location.
Turns out my earlier adb
call only adds the permission to the default user (Owner, UID 0).
So I poked around (adb shell pm help | less
) and came up with adding --user 10
.
It works.
HINT HINT:
In the below example ONLY the package in the profile 10 has the permission granted:
android.permission.WRITE_SECURE_SETTINGS: granted=false
android.permission.WRITE_SECURE_SETTINGS: granted=true, userId=10
android.permission.WRITE_SECURE_SETTINGS: granted=false, userId=11
In the following example Owner and User 10 have it granted:
android.permission.WRITE_SECURE_SETTINGS: granted=true
android.permission.WRITE_SECURE_SETTINGS: granted=false, userId=11
See the pattern? User's permission is not shown if it matches the Owner.