Im installed apk into /system/priv-app folder in my Android 7.1.1 emulator so it works as privilege system app but when when I try to install apk using this code of my app
val runtime = Runtime.getRuntime()
val process = runtime.exec("pm install -r -f $apkFilePath")
process.waitFor()
val output = process.inputStream.bufferedReader().use { it.readText() }
val error = process.errorStream.bufferedReader().use { it.readText() }
In the error
output I'm getting
Error: java.lang.SecurityException: Permission Denial: runInstallCreate from pm command asks to run as user -1 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
I tried to add permission in the Manifest file
<uses-permission
android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
android:protectionLevel="signatureOrSystem"
tools:ignore="ProtectedPermissions"
/>
But still getting the same error. I even tried
runtime.exec("pm install -r -f --user -1 $apkFilePath")
still giving the same error
What is interesting if try this code
runtime.exec("pm install -r -f --user 0 $apkFilePath")
then the error
output will become NullPointerException
So why INTERACT_ACROSS_USERS_FULL
permission doesn't work and --user -1
doesn't work as well? I thought system privilege app has access to install apk silently, so where is the problem then?