Ofir A.
Ofir A.

Reputation: 3162

Running Android Automotive application on system user (user 0) only

I'm building an Android Automotive system application that doesn't include any UI.

This service acts as a local backend/proxy on the device waiting for requests from other applications, making the desired action and return the needed data as a response.

Must of the interaction between the service and the other applications are handled using AIDL.

Two questions:

  1. Because our system is multiple users aware there are two process created, one for each user - system user (user#0) and a regular user (user#12). Is there any way to notify the system to create only the process for the system user? I tried to mark the receiver as singleUser=true, but it didn't help, two process are still created for each user.
  2. Another approach that I used was to identify on the boot completed receiver which user is currently running and in case this a regular user disabled the app using PackageManager.setApplicationEnabledSetting(), like Google suggested here. The problem is that when other application is trying to communicate using an AIDL service I'm getting the error below. Worth to mention that each service is marked with android:exported="true" and android:singleUser="true". From what I know marking the service as singleUser=true should make all the calls to be routed to the service running on the system user. Am I missing something with the current implementation?

ActivityManager: Unable to start service Intent { act=com.companyName.appName.services.serviceName pkg=com.companyName.appName } U=12: not found

Upvotes: 2

Views: 518

Answers (1)

Martin Zeitler
Martin Zeitler

Reputation: 76799

One can bind with Context.bindServiceAsUser().

This depends on permission android.permission.INTERACT_ACROSS_USERS and both packages must have the same signature. See the documentation: Building Multiuser-Aware Apps.

<permission
    android:name="android.permission.INTERACT_ACROSS_USERS"  
    android:protectionLevel="signature"/>

Upvotes: 0

Related Questions