How to prevent other applications from define same permission name

Viewed 2575

My application define a permission with android:protectionLevel="signature".

<permission android:name="my.app.permission.EXAMPLE" android:protectionLevel="signature" />

My intention is make application modules that can be launched only by my signed app. These application modules have android:permission in its activities. This works fine. but... A third-party app can use the same permission name and changed the protection level to normal, like this

<permission android:name="my.app.permission.EXAMPLE" android:protectionLevel="normal" />

If my app is installed first, i can prevent others apps to override the permission. However, if one uninstalls my app and then installs his app it redefines the permission.

Is it possible prevent other application use the same permission name, for example, giving the permission a unique id like application package?

Although the Manifest is encrypted, anyone can read the permission name in log cat when it tries to start the activity that requires this permission (An exception is thrown having the required permission name).

3 Answers

copyed from Google Andorid Doc: Note: The system does not allow multiple packages to declare a permission with the same name, unless all the packages are signed with the same certificate. If a package declares a permission, the system does not permit the user to install other packages with the same permission name, unless those packages are signed with the same certificate as the first package. To avoid naming collisions, we recommend using reverse-domain-style naming for custom permissions, for example com.example.myapp.ENGAGE_HYPERSPACE.

https://developer.android.com/guide/topics/permissions/defining

Related