## 3 Chidroid Architecture
### AppOpsManager and Privilege Extraction  
The following stanza (Listing 16) includes sample logs retrieved from an Android smartphone using the Package Manager to enumerate the installed software packages. These logs display the package names, version numbers, and permissions of the packages installed on the device. Package names are unique identifiers assigned to each application by the developer, while version numbers indicate the current version of the application installed on the device. The permissions indicate the actions and data the application can access on the device. ```
1 com.linkedin.android
2 Vidmode:COARSE_LOCATION:ignore
3 FILE_LOCATION:ignore
4 READ_CONTACTS:ignore
5 WRITE_CONTACTS:ignore
6 READ_CALENDAR:ignore* [7] CAMERA:ignore
* RECORD_AUDIO: ignore
* READ_PHONE_STATE: ignore
* SYSTEM_ALERT_WINDOW: default; rejectTime=+2d18h29m18s525 msago
* READ_CLIPBOARD: allow; time=+7l44h26m24s53 msago
* WAKE_LOCK: allow; time=+10h57m51s192 msago; duration=+265 ms
* USE_BIOMETRIC: allow; time=+1h41m59s218 msago

The logs show the permissions of LinkedIn ([[https://www.linkedin.com/](https://www.linkedin.com/)]([https://www.linkedin.com/](https://www.linkedin.com/)), accessed 20 February 2023), namely \"com.linkedin.android\". By tracking the permissions of these packages, it is possible to detect any abnormal usage of permissions, such as a game requesting permission to write to external storage when it should not. This can help ensure that the software packages are not violating any regulations or policies and do not present any security risks to the device or its users. Another example (Listing 17) follows for the Termux application. ```
1 com.termux
2 Uid mode:LEGACY_STORAGE:allow
3 ACCES_MEDIA_LOCATION:ignore
4 SYSTEM_ALERT_WINDOW: ignore
5 READ_CLIPBOARD: allow; time=+38d16h15m20s598 msago
6 WRITE_CLIPBOARD: allow; time=+38d16h21m13s703 msago
7 START_FOREGROUND: allow; time=+20d16h15m12s687 msago; duration=+40\(\leftrightarrow\) s7 ms
8 MANAAGE_EXTERNAL_STORAGE: default; rejectTime=+64d2h40m4s128 msago
```
Listing 17: Permissions on the Termux package. The above logs (Listing 17) present the permissions requested by the Termux application for Android. The application has been granted the \"LEGACY_STORAGE\", \"READ_CLIPBOARD\", \"WRITE_CLIPBOARD\", and \"START_FOREGROUND\" permissions by the user, but has not been granted the \"ACCESS_MEDIA_LOCATION\" or \"MANAGE_EXTERNAL_STORAGE\" permission. The application requests the following permissions:

* LEGACY_STORAGE: This permission allows the application to access the device's legacy storage directories, which may be used to store data compatible with older versions of Android. * ACCESS_MEDIA_LOCATION: This permission allows the application to access the location metadata associated with media files on the device, such as photos and videos. * SYSTEM_ALERT_WINDOW: This permission allows the application to display windows on top of other applications, which may be used to display important information or to provide additional functionality. * READ_CLIPBOARD: This permission allows the application to read from the device's clipboard, which may be used to paste text or other data into the app. * WRITE_CLIPBOARD: This permission allows the application to write to the device's clipboard, which may be used to copy text or other data from the app. * START_FOREGROUND: This permission allows the application to start a foreground service, which will continue to run even if the application is not in the foreground. * MANAGE_EXTERNAL_STORAGE: This permission allows the application to manage the device's external storage, such as an SD card, which may be used to store application data or other files. The temporal metrics \"time\" and \"duration\" for the permissions \"READ_CLIPBOARD\", \"WRITE_CLIPBOARD\", and \"START_FOREGROUND\" serve to record the point in time when the user granted the permission, as well as the duration for which the application has utilised the permission.