I am trying to define a signature level permission in framework/base/core/res/AndroidManifest.xml as there is already so much permission that is already defined. I thought of if I will define it here so that any other app can't redefine that same permission in their apps. Even I am able to redefine "android.permission.SEND_SMS" or even I can change the protectionLevel also.
But I noticed that I can redefine any system permission in my 3rd party android app. Why it's happing so?
I got to know though I can redefine the permission it's not granted for that 3rd party app if its protection level is signature.
Also, I got to know that if I define permission in any App, not on the framework side, I can't redefine the same permission in any 3rd party app.
Because it will not be treated as a framework level permission. So that if a user tries to install an app that defines the same <permission> element as does some other already-installed app, and the two apps are not signed by the same signing key, the second app's installation fails with an INSTALL_FAILED_DUPLICATE_PERMISSION error.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_DUPLICATE_PERMISSION
List of apks:
[0] 'E:\AndroidProjects\testing\app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'Failed to commit install session 128835007 with command cmd package install-commit 128835007. Error: INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.example.permcheck attempting to redeclare permission com.my.prm.external.lib.permission.SDK_API_ACCESS already owned by com.example.app.testapp'
I think behind the scene this code is running for permission check.
Why android can't just throw an error if it's already defined in the framework? What is the intention of Android system devps to not throw an error in such a case as it throws an error in case of permission is already defined in any installed package?