Android aidl cannot bind to a service when a host is installed after a client

I have a helpl service that works correctly until the client is installed, when the host is installed earlier, but, as I mentioned in the header, when the host is not installed, and I install the client, and after that I install the host, I get SecurityException in bindService ()

Intent serviceIntent = new Intent(AidlService.class.getName());
if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
    mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}

Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { act=com.mypackage.AidlService}

I also tested several applications that use helpl and they had the same problem!

UPDATE

I realized that the problem is the resolution, because my service uses user permissions, when the client is installed in front of the host, it cannot understand the permissions, so when I install the host and try to bind it, android cannot use this permission, so it throws an exception safety

android:permission="com.mypackage.AidlService.BIND"

<permission android:name="com.mypackage.AidlService.BIND"
            android:label="@string/perName"
            android:description="@string/perDesc"
            android:protectionLevel="normal" />

any idea to fix the problem?

+4
source share
1 answer

In accordance with Android User Permissions based on an application installation order

you should use android: protectionLevel = "signature" instead of the usual in the permission tag

+4
source

Source: https://habr.com/ru/post/1535528/


All Articles