I am trying to get the MANAGE_USERS permission for my app. I have signed and installed my app with the platform keys, but unfortunately I get the following error when running the app:
java.lang.SecurityException: You either need MANAGE_USERS or CREATE_USERS permission to: query users
at android.os.Parcel.createExceptionOrNull(Parcel.java:2285)
at android.os.Parcel.createException(Parcel.java:2269)
at android.os.Parcel.readException(Parcel.java:2252)
at android.os.Parcel.readException(Parcel.java:2194)
at android.os.IUserManager$Stub$Proxy.getUsers(IUserManager.java:1955)
at android.os.UserManager.getUsers(UserManager.java:3123)
at android.os.UserManager.getUsers(UserManager.java:3110)
at android.os.UserManager.getUsers(UserManager.java:3096)
at android.os.UserManager.getUserCount(UserManager.java:3082)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.pm.UserManagerService.checkManageOrCreateUsersPermission(UserManagerService.java:2340)
at com.android.server.pm.UserManagerService.getUsers(UserManagerService.java:756)
at android.os.IUserManager$Stub.onTransact(IUserManager.java:869)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
I downloaded the platform keys from: https://android.googlesource.com/platform/build/+/refs/tags/android-r-preview-4/target/product/security
Then I created the keystore with the following command using the keytool-importkeypair tool:
keytool-importkeypair -k google_certificate.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform
The build number of my os is: RPP4.200409.015 and the os version is Android R
After that I signed my app using the Build > Generate Signed Bundle/APK option in Android Studio
In my AndroidManifest.xml I added the following line:
<uses-permission android:name="android.permission.MANAGE_USERS"/>
Shouldn´t the app gain the permissions because it is signed with the platform keys? How can I get the user MANAGE_USERS permission?