What are the different protection levels in Android Permission?
Whenever we are developing an Android application, we need various components of Android devices like camera, GPS, etc. So, to use these features of our Android device, we need to take permission from the user to use something present on their phone. You can’t directly use any of those features. Also, there are various protection levels in permission i.e. if the protection level of permission is very low then you need not ask the user to use that permission. You can directly use that. But for dangerous permissions, you need to explicitly take permission from the user.
In this blog, we will learn various protections levels in permission. So, let’s get started.
Protection levels
Normally, if we want to add take some permission from the user, we write the below code in our AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
The above line grants permission to use the internet.
Using permission is not a simple task, you have to decide if you need to explicitly ask the user for permission or you can directly take permission. This decision is made based on the protection level of permission. Following are the three protection levels of permissions in Android:
- Normal Permissions
- Signature Permissions
- Dangerous Permissions
These are the three main protection levels of permissions, apart from this there is one more protection level called the Special Permission. Let’s have a look at them, one by one.
Normal Permissions
If there is a very little or no risk of the user privacy then the permission comes under the Normal Permission category. For example, if you want to get the data and time, then these things involve no user privacy and in this case, you need not ask the user to use date or time. You can directly use this facility by adding permission in the AndroidManifest.xml file. At the installation time, the system will automatically grant permission to your app. Following are the permission that comes under Normal Permissions:
- ACCESS_LOCATION_EXTRA_COMMANDS
- ACCESS_NETWORK_STATE
- CHANGE_NETWORK_STATE
- ACCESS_WIFI_STATE
- CHANGE_WIFI_STATE
- CHANGE_WIFI_MULTICAST_STATE
- BLUETOOTH
- BLUETOOTH_ADMIN
- INTERNET
- SET_ALARM
- SET_WALLPAPER
- VIBRATE
- WAKE_LOCK
Signature Permissions
The android system grants these permissions at the installation time but there is one condition. The app that is asking for some permission must be signed with the same signature as that of the app that defines the required permission. Following are some of the Signature permissions:
- BIND_ACCESSIBILITY_SERVICE
- BIND_AUTOFILL_SERVICE
- BIND_CARRIER_SERVICE
- BIND_DEVICE_ADMIN
- BIND_INPUT_METHOD
- BIND_NFC_SERVICE
- BIND_TV_INPUT
- BIND_WALLPAPER
- READ_VOICEMAIL
- WRITE_SETTINGS
- WRITE_VOICEMAIL
Dangerous Permissions
Dangerous permissions include that permission that involve user data in some or the other way. For example, if you want to read contacts from the phone or you want to access the file storage of the phone then these permissions come under the Dangerous permission as they include user’s privacy. To use Dangerous permissions, you have to explicitly ask for permission before using that by showing some alert dialog or any other dialog. If the user denies the permission then your application can’t use that particular permission. Following are some of the Dangerous permissions:
- READ_CALENDAR
- WRITE_CALENDAR
- CAMERA
- READ_CALL_LOG
- WRITE_CALL_LOG
- READ_CONTACTS
- WRITE_CONTACTS
- GET_ACCOUNTS
- ACCESS_FINE_LOCATION
- ACCESS_COARSE_LOCATION
- SEND_SMS
- RECEIVE_SMS
Special Permissions
These are those permissions that are neither Normal permissions nor Dangerous permissions. Most of the applications should not use these permissions because they are very sensitive and you need user authorization before using these permissions. To use this permission, you must declare it in the AndroidManifest.xml file and then send an intent to request for user authorization. Some of the Special permissions are:
- WRITE_SETTINGS
- SYSTEM_ALERT_WINDOW
Conclusion
In this blog, we learned various protection levels that are present in permissions. They are Normal permissions, Signature permissions, and Dangerous permissions. If you want to look more examples of these permissions then you can refer to the Android website .
Keep Learning :)
Team MindOrks!