Search code examples
androidselinux

Android BIND_JOB_SERVICE & sepolicy


I have a valid manifest file with the right permission & "exported" set as well. But, I still get the below error:

Error: Requires permission android.permission.BIND_JOB_SERVICE

The command (initiated over adb) is a running a service (via "am startservice") & the manifest file has these details:

<service
            android:name=".MyService"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.BIND_JOB_SERVICE" />

Logcat doesn't have anything useful, just throws the permission required error (which the APK already has). This seems like a sepolicy restriction since if I remove the policy (by running "setenforce 0"), then the command works fine (no errors seen as well)

I've tried running in "permissive" mode but it doesn't show any useful messages. Is there any way to figure out what policy needs to be turned on?

Here's the actual error from logcat:

05-16 14:03:32.892   566   897 W ActivityManager: Permission Denial: Accessing service com.abc.def/.MyService from pid=6757, uid=2000 requires android.permission.BIND_JOB_SERVICE

Solution

  • What I found was, putting the same command in a bash script and sourcing it works fine!!