Permission in Android

Learn via video courses
Topics Covered

Overview

Permissions are very important in the Android operating system for maintaining user security and privacy. Permissions are limitations imposed on an app's use of particular resources or device features. Android notifies users of the permissions needed while installing an app. Access to the device's camera, microphone, location, contacts, and other features can be granted as permissions. Android has a permissions architecture that aims to balance app functionality with user privacy. "Runtime permissions" were introduced to the platform with Android 6.0 (Marshmallow). This implies that if an app wants to access private information or carry out certain tasks, it must ask the user for permission during the app running.

:::

Understanding App Permissions and their Workflow

App permissions as a mechanism to control access to restricted data and actions

An essential component of Android's security and privacy framework are app permissions. They serve as a tool to regulate access to restricted data and activities within an application, ensuring that users have control over their personal information and that apps have a limited amount of access to sensitive resources.

Workflow for using app permissions in Android apps:

Requesting permissions from users

When an app requires access to restricted resources or functionality, it needs to request the necessary permissions from the user. This is typically done using the requestPermissions() method, which displays a system-generated dialog to the user. The dialog should clearly state the reasons why the app needs the requested permissions and how granting them will enhance the app's functionality or user experience.

Checking if permissions are granted or denied

After the user responds to a permission request, developers can check the results in the onRequestPermissionsResult() method. They examine the grantResults parameter, which is an array corresponding to requested permissions. Each element indicates whether the permission was granted or denied and can be compared to constants like PackageManager.PERMISSION_GRANTED or PackageManager.PERMISSION_DENIED to determine the status of each permission.

Handling permission results

The app can take the required action based on the findings of the authorization. The programme can access the limited data or carry out the necessary tasks if the permissions are given. The programme must, however, graciously manage the situation if the permissions are refused.

Types of permissions

Install-time permissions

"Required permissions," commonly referred to as "install-time permissions," are permissions that are given to an app when it is installed. These rights don't need the user's express consent at runtime. Access to the internet, use of the device's vibration function, or the ability to read from external storage are a few examples of install-time rights. These permissions are regarded as less crucial and do not provide a serious privacy or security concern.

Normal permissions

Normal permissions are those that an app receives at installation time without user intervention. These permissions enable an app to carry out particular tasks or access particular, less sensitive resources. The majority of the time, normal permissions are connected to basic functions and don't significantly compromise user privacy or device security. Accessing the network status, the device's battery statistics, or the Bluetooth connection are a few examples of standard permissions.

Signature permissions

Apps that are signed with the same digital certificate as the system are the only ones that may receive signature permissions, commonly referred to as "system permissions," a particular kind of permission. These rights allow access to critical resources and give users elevated privileges, which are generally only available to system-level programmes. To guarantee the integrity and security of crucial system processes, signature permissions are utilised. Access to protected system APIs or the ability to change system settings are two examples of signature permissions.

Runtime permissions

Android 6.0 introduced runtime permissions, which allow apps to request specific permissions when they need them. Users are presented with permission requests that explain why access is necessary, providing more control over privacy and security. Examples include camera access, location, and contact reading.

Special permissions

Runtime permissions are a subset of special permissions, which are more sensitive and need extra inspection and user approval. These permissions provide users access to extremely private information or activities that directly affect their privacy or the security of their devices. Features like allowing an app to draw over other programmes, access call records, change system settings, or install apps from untrusted sources are examples of special rights. Before being given to apps, certain rights may be subject to more stringent review procedures and need explicit user consent.

Permission groups

Depending on the sort of data or functionality they govern, Android permissions are divided into several types. These permission groups offer a practical method for managing and organising the permissions needed by an app. In order to manage access to critical resources and protect user privacy, developers must have a thorough understanding of the typical permission groups and the permissions that go along with them. The following list of typical Android permission groups includes:

Camera:

The camera permission group controls access to the device's camera. Permissions in this group include:

CAMERA: Allows the app to access the device's camera to capture photos or videos.

Microphone:

The microphone permission group grants access to the device's microphone. Permissions in this group include:

RECORD_AUDIO: Allows the app to record audio using the device's microphone.

Location:

The location permission group is associated with accessing the device's location information. Permissions in this group include:

ACCESS_FINE_LOCATION: Allows the app to access precise location information using GPS or network-based methods. ACCESS_COARSE_LOCATION: Allows the app to access approximate location information using network-based methods.

Contacts:

Contact permission is categorized as a dangerous permission in Android, which means that it requires explicit user approval. These dangerous permissions have the potential to access sensitive user data or perform actions that could affect the device or user privacy.

Storage:

Scoped Storage is a storage mechanism introduced in Android 10 (API level 29) and further refined in Android 11 (API level 30) as a way to enhance app security and privacy. It is designed to provide better control and restrictions on how apps can access and manage files on a user's device. Before Scoped Storage, Android used a more permissive storage model known as Legacy Storage, where apps had broad access to the entire file system. This model presented certain security and privacy risks, as apps could access and modify files outside of their designated storage areas, potentially leading to data leaks or unauthorized access.

Phone:

The phone permission group is associated with managing telephony-related functionalities. Permissions in this group include:

CALL_PHONE: Allows the app to initiate phone calls. READ_PHONE_STATE: Allows the app to access information about the device's telephony status, such as the phone number and network information.

SMS:

SMS permission in Android grants apps the ability to read, send, and receive SMS messages. It allows apps to access and interact with the user's text messages, including reading the content, sending new messages, and managing SMS conversations. This permission is categorized as a dangerous permission, requiring explicit user approval and adherence to privacy guidelines.

The SMS permission group controls access to sending and receiving SMS messages. Permissions in this group include:

SEND_SMS: Allows the app to send SMS messages. RECEIVE_SMS: Allows the app to receive SMS messages.

Internet:

The internet permission group is related to accessing the internet. Permissions in this group include:

INTERNET: Allows the app to access the internet. Sensors: The sensors permission group grants access to various sensors on the device. Permissions in this group include:

BODY_SENSORS:

Allows the app to access data from the user's body sensors, such as heart rate or step count.

Best practices (Control, Transparency, Data minimization)

Control: Requesting only the necessary permissions for app functionality

The permissions that an app needs to work properly should only be requested, therefore developers should carefully analyse the permissions that are needed. This entails carefully evaluating the app's features and functions to decide which permissions are actually required to provide those functionalities. Developers reduce possible privacy concerns and show a dedication to honouring user choices and data protection by simply seeking the necessary permissions.

Transparency: Providing clear explanations for why permissions are required

When an app asks for permissions, it's crucial to give consumers explicit justifications for why those rights are required. Users must be aware of the precise objectives and advantages of providing each permission. For instance, if an app asks for access to the device's location, it should disclose that the permission is required in order to deliver personalised content or location-based services. Developers establish confidence and aid user decision-making by being upfront about the justifications for permission requests.

Data minimization: Requesting access to only the data required for app functionality

A crucial aspect of privacy and security procedures is the reduction of data. When asking for permissions, developers should abide by this rule and only ask for the precise information or resources required for the app's intended functionality. For instance, if an app needs access to the user's contacts in order to provide social sharing functionality, it should just ask for the essential contacts and not for broader access to the full contact list. By doing this, user data exposure risks are reduced and it is clear that user privacy is being respected.

Associate runtime permissions with specific actions to enhance user understanding

It is advantageous to explicitly link the runtime permissions that an app seeks to certain functions or features within the app. By doing this, developers provide consumers a clear explanation of why and how the requested permission pertains to the operation of the programme. For instance, if an app asks for access to the camera, it might state that this is required for the app's social networking feature, which allows users to take and share photographs. Users are more likely to approve permissions when this relationship makes it easier for them to understand why.

Considering app dependencies and the permissions they require

To use certain capabilities, many programmes rely on dependencies or libraries from other parties. It is essential for developers to analyse, comprehend, and confirm that the permissions requested by these dependencies are consistent with the privacy and security objectives of the programme. Developers should think about whether the dependencies' requests for permission are essential to the app's key features or whether they may be minimised. Developers may keep control over the permissions that their app requests and prevent excessive or unnecessary access to user data by being aware of app dependencies.

Permissions in System Components

Broadcast Receivers:

Broadcast receivers are parts that keep an eye out for system-wide or app-specific events. Regarding permits, broadcast receivers may be designated with restrictions on who may deliver them broadcasts. Developers may verify that only applications with the necessary permission can send broadcasts to the receiver by defining the permissions in the receiver declaration.

Services

Services are parts of an app that function separately from its graphical user interface and carry out lengthy processes or handle tasks. Services may also ask for permission to manage how the system and other apps are interacted with. Foreground Service: A foreground service in Android is a type of service that runs in the foreground, providing ongoing functionality to the user. It requires a persistent notification, indicating that the service is active and running. Foreground services are used for tasks that are noticeable to the user, such as playing music, tracking location, or performing important background operations. They have higher priority than regular background services and are less likely to be killed by the system, ensuring a consistent user experience and preventing disruption of critical tasks.

Content providers:

By allowing access to structured data held in an app's private storage or other shared places, content providers facilitate data exchange between several apps. Permissions can be set by content providers to limit who can access or write the data they expose.

Overall Best Practices:

Make that the permissions system components ask for are appropriate and consistent with the operation of the app by periodically reviewing and auditing them.

  • Reduce the number of permissions system components ask for to minimise potential privacy hazards and security holes.
  • By simply seeking the permissions necessary for the particular tasks carried out by each system component, adhere to the concept of least privilege.
  • Update and patch the programme often to fix any security flaws or modifications to the Android platform's permission mechanism.
  • Developers may ensure the right use of permissions in system components, improve the security of their apps, and safeguard user privacy by adhering to certain specific concerns and recommended practises.

Conclusion

  • Android app permissions are crucial for limiting access to private data and activities.
  • Requesting permission from users, determining whether that permission is granted or refused, and managing permission outcomes are all steps in the workflow for utilising app permissions.
  • Limiting permission requests to those required for app functioning shows control and allays privacy worries.
  • Giving users concise justifications for why permissions are needed encourages transparency and aids in decision-making.
  • Only requesting access to the data necessary for app operation is consistent with the data reduction principle and safeguards user privacy.