Acquire “signature” permissionlevel on Android

2019-05-23 21:24发布

问题:

I'm building an Android app, and one of the permission I need is defined as:

android:protectionLevel="signature|system|development"

How do I get the signature protection level? Do I need to sign my application somehow?

Do I need to sign it with OEM ? (Samsung\HTC\LG)?

回答1:

signature means that to be able to get access to the resource, your app have to be signed with the same certificate that the holder of the permission. If this is not your app you are trying to connect to, then you basically are out of luck. If that's system one then you are out of luck even more, This is documented here:

"signature"

A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.

EDIT

Im trying to read logcat file through my application. this requires the permission android.permission.READ_LOGS

You cannot access logs on stock ROM that are not created by your application. That's introduced for security reasons, so would not make sense to let you get it just because you need it. If you build own ROM, then you can have it, but then you should know this already.