JustWonder
JustWonder

Reputation: 2443

Android service with u10_system user id

This is under Android Kitkat/Lollipop with multiple account feature enabled. I created a service with the user id "system", and had an activity binding to the service. Then in different user account, I tried to have another activity binding to the same service (with the flag Context.BIND_AUTO_CREATE). I was hoping that the activity would be bound to the existing service with the user id "system". However, Android created a new service with the user id "u10_system". Why would this happen? Is it possible to bind to the existing service whose user id is "system"?

Edit: For the service, I had this attribute: android:singleUser="true". The service also has INTERACT_ACCROSS_USERS permission.

Upvotes: 4

Views: 2166

Answers (1)

bk138
bk138

Reputation: 3088

What you see is the effect of a combination of sharedUserId and singleUser flags in AndroidManifest.xml. This is what I found to happen in Android 12 (so ~8y later, things might have been different in Lollipop...):

  • sharedUserId:system && singleUser:true
    • runs as linux user "system" uid 1000 aka Android user 0
    • singleton and priviledged
  • sharedUserId:system
    • runs as "u10_system"
    • not singleton but priviledged
  • singleUser:true
    • runs as linux user "u0_a222" (or another _a number)
    • singleton but not priviledged
  • none
    • runs for each normal user
    • not singleton, not priviledged

Upvotes: 0

Related Questions