What are The Different Protection Levels in Android Permission? - GeeksforGeeks

19 Sep, 2021
When building an Android application, we require different Android device components such as the camera, GPS, and so on. So, in order to use these capabilities of our Android smartphone, we must first obtain permission from the user to use something on their phone. You cannot utilize any of those functionalities directly. Furthermore, permission has different protection levels; for example, if the permission’s protection level is very low, you do not need to ask the user to use that permission. You may use it right away. However, for hazardous permissions, you must expressly obtain the user’s permission. In this geeks for geeks article, we will learn about the various layers of authorization protection.
Normally, if we want to add certain user permissions, we enter the following code in our AndroidManifest.xml file:
<uses-permission android:name="android.permission.VIBRATE" />
The preceding line enables access to the vibration or the haptic motor of the device.
Using permission is not an easy process; you must decide if you need to explicitly ask the user for permission or whether you may take permission immediately. This choice is dependent on the permission’s degree of protection. The three permission protection levels in Android are as follows:
Normal PermissionsSignature PermissionsDangerous Permissions
Normal Permissions
Signature Permissions
Dangerous Permissions
These are the three primary permissions protection levels; however, there is an additional security level known as the Special Permission. Let’s take a look at them one at a time.
The permission falls within the Normal Permission category if there is little or no danger to the user’s privacy. For example, if you want to acquire the data and time, these things do not entail any user privacy, and you do not need to ask the user to use date or time in this situation. You may utilize this feature directly by adding permission to the AndroidManifest.xml file. The system will automatically provide authorization to your app during the installation process. Normal Permissions include the following permissions:
ACCESS_LOCATION_EXTRA_COMMANDSACCESS_NETWORK_STATECHANGE_NETWORK_STATEACCESS_WIFI_STATECHANGE_WIFI_STATECHANGE_WIFI_MULTICAST_STATEBLUETOOTHBLUETOOTH_ADMININTERNETSET_ALARMSET_WALLPAPERVIBRATEWAKE_LOCK
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
The Android system gives these rights during installation, but there is a catch. The app requesting permission must be signed with the same signature as the app defining the needed permission.  Some of the Signature permissions are as follows:
BIND_ACCESSIBILITY_SERVICEBIND_AUTOFILL_SERVICEBIND_CARRIER_SERVICEBIND_DEVICE_ADMINBIND_INPUT_METHODBIND_NFC_SERVICEBIND_TV_INPUTBIND_WALLPAPERREAD_VOICEMAILWRITE_SETTINGSWRITE_VOICEMAIL
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
Permissions that are dangerous include those that affect user data in some way. For example, if you wish to read contacts from the phone or access the phone’s file storage, these rights fall under the Dangerous category since they involve the user’s privacy. To utilize Dangerous permissions, you must first expressly seek permission by displaying an alert dialogue or any other dialogue. If the user refuses the permission, your application will be unable to utilize that permission. Some of the Dangerous permissions are as follows:
READ_CALENDARWRITE_CALENDARCAMERAREAD_CALL_LOGWRITE_CALL_LOGREAD_CONTACTSWRITE_CONTACTSGET_ACCOUNTSACCESS_FINE_LOCATIONACCESS_COARSE_LOCATIONSEND_SMSRECEIVE_SMS
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
These are the permits that are neither Normal nor Dangerous in nature. Most apps should not utilize these rights since they are extremely sensitive and require user consent before being used. To utilize this permission, declare it in the AndroidManifest.xml file and then submit an intent requesting user authorization. Some of the special permissions are as follows:
WRITE_SETTINGSSYSTEM_ALERT_WINDOW
WRITE_SETTINGS
SYSTEM_ALERT_WINDOW
In this article, we learned about the various degrees of protection available in permissions. Normal permissions, Signature permissions, and Dangerous permissions are the three types.
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - Custom Bottom Navigation Bar
Retrofit with Kotlin Coroutine in Android
GridView in Android with Example
Android Listview in Java with Example
How to Change the Background Color After Clicking the Button in Android?
How to Read Data from SQLite Database in Android?
How to Post Data to API using Retrofit in Android?
Fragment Lifecycle in Android
How to Add Image to Drawable Folder in Android Studio?
Animation in Android with Example