3

I have a rooted TV Box with Android 7.1.2 which didn't come with the Files app (com.android.documentsui), so I can't give write access to external drives.

I tried the following steps to install DocumentsUI.apk:

  • move DocumentsUI.apk to /system/priv-app/DocumentsUI/DocumentsUI.apk
  • chmod 744 /system/priv-app/DocumentsUI
  • chmod 644 /system/priv-app/DocumentsUI/DocumentsUI.apk
  • chown 0.0 /system/priv-app/DocumentsUI
  • chown 0.0 /system/priv-app/DocumentsUI/DocumentsUI.apk
  • chcon u:object_r:system_file:s0 /system/priv-app/DocumentsUI
  • chcon u:object_r:system_file:s0 /system/priv-app/DocumentsUI/DocumentsUI.apk
  • reboot

Even so, when I try to launch the app, it always force closes with the following error message on logcat: Neither user 10072 nor current process has android.permission.CACHE_CONTENT

Any idea if I'm missing something?

Please note I'm not on Android 8+ so as far as I know I don't have to add an XML on /system/etc/permissions.

Denis Isidoro
  • 31
  • 1
  • 1
  • 2

2 Answers2

3

Just found this thread on the Kodi site that might help. https://forum.kodi.tv/showthread.php?tid=308040&page=2

Short version: Since you are rooted find /data/system/packages.xml and /data/system/packages.list

Now you should find your package name in packages.list and then edit packages.xml

Find the apps section you want (e.g. com.ghisler.android.TotalCommander),

locate its <perms> section and add the following line:
<item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" />

Have a look at the Kodi thread if something I've type is unclear. Hope this helps,

Chris.

Chris
  • 31
  • 2
2

CACHE_CONTENT permission has protection level signature:

<!-- @hide Allows an application to cache content.
     <p>Not for use by third-party applications.
     <p>Protection level: signature
-->
<permission android:name="android.permission.CACHE_CONTENT"
            android:protectionLevel="signature" />

Putting your app in /system/priv-app isn't enough. It also needs to be signed with the same key used to sign the platform (as it's Android's platform that defines that permission).

AFAIK there's not an easy answer here. You need to integrate the unsigned APK into the Android build system as a prebuilt (or if you have the source, as regular app), and build your own Android dist and flash that.

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • Any idea if I can circumvent the problem otherwise? Giving write access to external devices directly, I mean, without the need for launching DocumentsUI – Denis Isidoro Apr 27 '18 at 20:23
  • I not not familiar with the functionality of that app. Can you describe what you are trying to accomplish? – Jeffrey Blattman Apr 27 '18 at 20:49
  • I want to download some content to a USB HDD. Normally, applications demand the permission for write access as in [this flow](https://plus.google.com/+KrzysztofG%C5%82odowski/posts/7C18qDBoYP4). However, I can't get past the "Grant" button – Denis Isidoro Apr 27 '18 at 20:57
  • This is getting out of my understanding, sorry. This thread https://forum.kodi.tv/showthread.php?tid=304517 seems to indicate you can write to the drive but it needs to be at a well-defined path. Starting an app to request permission to do something is an odd workflow. – Jeffrey Blattman Apr 28 '18 at 00:12