Following this discussion, I've signed a system app I'm working on using a specific device's proprietary platform certificates which I received from the manufacturer. I signed it as follows:
java -jar out/host/linux-x86/framework/signapk.jar \
build/target/product/security/platform.x509.pem \
build/target/product/security/platform.pk8 \
Launcher-unsigned.apk \
Launcher-unsigned.apk
zipalign -f 4 Launcher-signed.apk Launcher.apk
My launcher has various permissions:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
[snip]
<uses-permission
android:name="android.permission.SET_PREFERRED_APPLICATIONS"
tools:ignore="ProtectedPermissons" />
And I included in the manifest:
<manifest [...]
android:sharedUserId="android.uid.system" >
Where previously my app would succeed in writing the SD-card, but fail setting a preferred application (my code similar to this), it now no longer throws a SecurityException, but instead writing to the SD-card throws a FileNotFoundException with a message that permission was denied.
What could be happening that my app gets some protected permissions, but loses some others?