androidandroid-5.1.1-lollipop

difficulties installing in /system/priv-app on Android TV 5.1.1


I have copied my app into /system/priv-app/ and rebooted the system. The app no longer appears under Downloaded Apps, but now under System Apps. However, this only happens when I do not remove the original copy of the app under /data/app/. If I do remove the original copy under /data/app/ and reboot, the app does not show up anywhere at all, even though there is a copy of it under /system/priv-app/. Additionally, I verified with getPackageManager().getApplicationInfo(getPackageName(), 0).sourceDir that when the app does run (if I still have a copy in /data/app/), it is running from the non-privileged directory, even though I start it from under System Apps.

My permissions and ownership are all in line with all of the other apps in the /system/priv-app/ directory: drwxr-xr-x root root

I found some related stackoverflow questions in which it is said to be sometimes necessary to run chcon on the APK after copying to /system/priv-app/. My system emits and error message "Could not label [my path] with u:object_r:app_data_file:s0: Operation not supported on transport endpoint". I discovered some documentation which said, "You are limited to changing the context of files whose partition is formatted with the ext4 file system. Any attempt to change the context of a file on another system results in the [error message I got]." So obviously chcon is not the solution in my case.

I'd be grateful for any tips on getting my app to show up under System Apps and run from the /system/priv-app/ directory.

Thanks!

EDITED TO ADD: I also signed my APK with the system key that has been used for key system apps. This also had no effect.


Solution

  • It turns out that I needed to first uninstall the package using from its original location using the Android package manager before the app could be picked up by the system to install. Previously, I had simply removed it on the command line from its original location. This time, I copied the files from /data/app/ to /system/priv-app/, ran pm uninstall [my package name], and rebooted. The program was successfully installed when the system came back up.