Android development RecoverySystem.installPackage() cannot write to /cache/recovery/command permission denied

前端 未结 5 1653
陌清茗
陌清茗 2020-12-10 03:42

I have been asked to write a small simple app for an Android-based product. The device comes with two Android system images with different features. The app I\'m writing is

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 04:08

    System apps (apps with shared user ID set to android.uid.system) cannot install system updates on Android 5 and newer - it's forbidden by a SELinux policy. To be specific writing to /cache is forbidden for system apps. In other words:

    • /cache is owned by system user so your app running under system UID can write to it. But only if SELinux is disabled/permissive.
    • If you have android.permission.ACCESS_CACHE_FILESYSTEM platform signature permission, you can write to /cache.

    You'll need to remove the shared user ID. You still have to sign the app with platform signature and ensure you have the following permissions:

    • android.permission.REBOOT
    • android.permission.ACCESS_CACHE_FILESYSTEM - to write to /cache
    • android.permission.RECOVERY - required on API 21 to reboot to recovery

    This will work on Kitkat and Lollipop+ alike.

提交回复
热议问题