2

According to my research on the net, I found that to count the number of permission of the recent version of Android (Android 7), we can refer to the official documentation proposed in this link (https://developer.android.com/reference/android/Manifest.permission.html).

The proposed table contains 138 permissions, which is what I thought my count is correct until the AndroidManifest.xml (https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r29/core/res/AndroidManifest.xml) file analysis of the Android OS that I scan with this little parsing program found on github (https://github.com/benjholla/AndroidPermissionAttributeMapper).

The resulting output files are:

android.permission-group.CONTACTS:
3 Permissions
android.permission.READ_CONTACTS
android.permission.GET_ACCOUNTS
android.permission.WRITE_CONTACTS
NO PERMISSION GROUP FOUND:
320 Permissions
android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK
android.permission.DIAGNOSTIC
android.permission.INTERACT_ACROSS_USERS
android.permission.SIGNAL_PERSISTENT_PROCESSES
android.permission.START_TASKS_FROM_RECENTS
android.permission.BIND_SCREENING_SERVICE
android.permission.SET_TIME_ZONE
com.android.browser.permission.WRITE_HISTORY_BOOKMARKS
android.permission.REGISTER_SIM_SUBSCRIPTION
android.permission.USER_ACTIVITY
android.permission.RECEIVE_MEDIA_RESOURCE_USAGE
android.permission.TABLET_MODE
android.permission.SUBSCRIBED_FEEDS_READ
android.permission.BIND_TV_REMOTE_SERVICE
android.permission.CONTROL_INCALL_EXPERIENCE
android.permission.MASTER_CLEAR
android.permission.WAKE_LOCK
android.permission.HDMI_CEC
android.permission.MODIFY_CELL_BROADCASTS
android.permission.MANAGE_USERS
android.permission.BIND_VOICE_INTERACTION
android.permission.GRANT_RUNTIME_PERMISSIONS
android.permission.BIND_RUNTIME_PERMISSION_PRESENTER_SERVICE
android.permission.PACKAGE_USAGE_STATS
android.permission.BLUETOOTH_MAP
android.permission.GET_PACKAGE_SIZE
android.permission.BIND_TELECOM_CONNECTION_SERVICE
android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST
com.android.alarm.permission.SET_ALARM
android.permission.SET_WALLPAPER_HINTS
android.permission.DEVICE_POWER
android.permission.UPDATE_CONFIG
android.permission.INTERNET
android.permission.INJECT_EVENTS
android.permission.UPDATE_LOCK_TASK_PACKAGES
android.permission.RECEIVE_EMERGENCY_BROADCAST
android.permission.RETRIEVE_WINDOW_TOKEN
android.permission.CAMERA_DISABLE_TRANSMIT_LED
android.permission.SET_WALLPAPER
android.permission.BIND_PRINT_SERVICE
android.permission.READ_LOGS
android.permission.REMOVE_TASKS
android.permission.READ_SYNC_SETTINGS
android.permission.ACCESS_MTP
android.permission.AUTHENTICATE_ACCOUNTS
android.permission.CONTROL_LOCATION_UPDATES
android.permission.READ_PROFILE
android.permission.CRYPT_KEEPER
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.READ_FRAME_BUFFER
com.android.launcher.permission.UNINSTALL_SHORTCUT
android.permission.CONTROL_VPN
android.permission.BIND_DIRECTORY_SEARCH
android.permission.SCORE_NETWORKS
android.permission.BIND_MIDI_DEVICE_SERVICE
android.permission.GET_APP_OPS_STATS
android.permission.ACCESS_CHECKIN_PROPERTIES
android.permission.GET_APP_GRANTED_URI_PERMISSIONS
android.permission.SEND_RESPOND_VIA_MESSAGE
android.permission.MANAGE_ACTIVITY_STACKS
android.permission.CHANGE_CONFIGURATION
android.permission.VIBRATE
android.permission.GET_TOP_ACTIVITY_INFO
android.permission.GET_PROCESS_STATE_AND_OOM_SCORE
android.permission.WRITE_SYNC_SETTINGS
android.permission.RESTART_PACKAGES
android.permission.KILL_BACKGROUND_PROCESSES
android.permission.HARDWARE_TEST
android.permission.BIND_TRUST_AGENT
android.permission.FORCE_STOP_PACKAGES
android.permission.READ_NETWORK_USAGE_HISTORY
android.permission.READ_PRECISE_PHONE_STATE
android.permission.READ_BLOCKED_NUMBERS
android.permission.READ_WIFI_CREDENTIAL
android.permission.RESET_SHORTCUT_MANAGER_THROTTLING
android.permission.MOVE_PACKAGE
android.permission.BLUETOOTH
android.permission.SERIAL_PORT
com.android.voicemail.permission.WRITE_VOICEMAIL
android.permission.WRITE_USER_DICTIONARY
android.permission.ACCESS_WIMAX_STATE
android.permission.SET_SCREEN_COMPATIBILITY
android.permission.ACCESS_VR_MANAGER
android.permission.BLUETOOTH_STACK
android.permission.BIND_INCALL_SERVICE
android.permission.BIND_PRINT_RECOMMENDATION_SERVICE
android.permission.INSTALL_PACKAGES
android.permission.BIND_VR_LISTENER_SERVICE
android.permission.SET_PREFERRED_APPLICATIONS
android.permission.BIND_TV_INPUT
android.permission.GET_DETAILED_TASKS
android.permission.SET_PROCESS_LIMIT
android.permission.WRITE_PROFILE
android.permission.RECEIVE_BLUETOOTH_MAP
android.permission.ACCESS_WIFI_STATE
android.permission.LAUNCH_TRUST_AGENT_SETTINGS
android.permission.BIND_ROUTE_PROVIDER
android.permission.REGISTER_WINDOW_MANAGER_LISTENERS
com.android.voicemail.permission.READ_VOICEMAIL
android.permission.INTERNAL_SYSTEM_WINDOW
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
android.permission.SET_POINTER_SPEED
android.permission.READ_OEM_UNLOCK_STATE
android.permission.OEM_UNLOCK_STATE
android.permission.NOTIFY_PENDING_SYSTEM_UPDATE
android.permission.WRITE_DREAM_STATE
android.permission.CONTROL_KEYGUARD
android.permission.RETRIEVE_WINDOW_CONTENT
android.permission.BIND_DREAM_SERVICE
android.permission.LOCAL_MAC_ADDRESS
android.permission.PACKET_KEEPALIVE_OFFLOAD
android.permission.ACCESS_INPUT_FLINGER
android.permission.FLASHLIGHT
android.permission.CAPTURE_TV_INPUT
android.permission.EXPAND_STATUS_BAR
android.permission.ACCESS_SURFACE_FLINGER
android.permission.ASEC_CREATE
android.permission.READ_DREAM_STATE
android.permission.BIND_INPUT_METHOD
android.permission.RECEIVE_DATA_ACTIVITY_CHANGE
android.permission.BIND_NFC_SERVICE
android.permission.GLOBAL_SEARCH_CONTROL
android.permission.ACCESS_PDB_STATE
android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS
android.permission.UPDATE_LOCK
android.permission.DUMP
android.permission.MANAGE_NETWORK_POLICY
android.permission.ACCESS_NOTIFICATIONS
android.permission.ACCESS_FM_RADIO
android.permission.CARRIER_FILTER_SMS
android.permission.BIND_TEXT_SERVICE
android.permission.CONFIRM_FULL_BACKUP
android.permission.ASEC_MOUNT_UNMOUNT
android.permission.BACKUP
android.permission.TRUST_LISTENER
android.permission.SET_ACTIVITY_WATCHER
android.permission.BIND_REMOTE_DISPLAY
android.permission.PERFORM_SIM_ACTIVATION
android.permission.CAPTURE_AUDIO_HOTWORD
android.permission.READ_SEARCH_INDEXABLES
android.permission.ASEC_ACCESS
android.permission.SET_ORIENTATION
android.permission.BIND_CONDITION_PROVIDER_SERVICE
android.permission.USE_CREDENTIALS
android.permission.STATUS_BAR_SERVICE
android.permission.FACTORY_TEST
android.permission.ACCESS_EPHEMERAL_APPS
android.permission.CHANGE_NETWORK_STATE
android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.DVB_DEVICE
android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.BIND_DEVICE_ADMIN
android.permission.SEND_SMS_NO_CONFIRMATION
android.permission.BLUETOOTH_PRIVILEGED
android.permission.MODIFY_PHONE_STATE
android.permission.CAPTURE_AUDIO_OUTPUT
android.permission.CONFIGURE_DISPLAY_COLOR_TRANSFORM
android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS
android.permission.SHUTDOWN
android.permission.NET_ADMIN
android.permission.DELETE_CACHE_FILES
android.permission.READ_USER_DICTIONARY
android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS
android.permission.BROADCAST_NETWORK_PRIVILEGED
android.permission.CAMERA_SEND_SYSTEM_EVENTS
android.permission.INTERACT_ACROSS_USERS_FULL
android.permission.MANAGE_NOTIFICATIONS
android.permission.MODIFY_PARENTAL_CONTROLS
android.permission.OVERRIDE_WIFI_CONFIG
android.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS
android.permission.DISABLE_KEYGUARD
android.permission.CHANGE_APP_IDLE_STATE
android.permission.BIND_NOTIFICATION_LISTENER_SERVICE
android.permission.ACCESS_NETWORK_CONDITIONS
android.permission.BIND_NOTIFICATION_RANKER_SERVICE
android.permission.CALL_PRIVILEGED
android.permission.BIND_INTENT_FILTER_VERIFIER
android.permission.RECEIVE_STK_COMMANDS
android.permission.MANAGE_USB
android.permission.CAPTURE_VIDEO_OUTPUT
android.permission.MODIFY_AUDIO_ROUTING
android.permission.MANAGE_SOUND_TRIGGER
android.permission.CHANGE_WIFI_STATE
android.permission.GET_TASKS
android.permission.TV_INPUT_HARDWARE
android.permission.SET_WALLPAPER_COMPONENT
android.permission.SET_TIME
android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.MANAGE_MEDIA_PROJECTION
android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME
android.permission.TV_VIRTUAL_REMOTE_CONTROLLER
android.permission.DISPATCH_PROVISIONING_MESSAGE
android.permission.CAPTURE_SECURE_VIDEO_OUTPUT
android.permission.UPDATE_APP_OPS_STATS
android.permission.BROADCAST_SMS
android.permission.CHANGE_BACKGROUND_DATA_SETTING
android.permission.REMOVE_DRM_CERTIFICATES
android.permission.BLUETOOTH_ADMIN
android.permission.WRITE_GSERVICES
android.permission.MANAGE_CA_CERTIFICATES
android.permission.NFC
android.permission.START_ANY_ACTIVITY
android.permission.CHANGE_COMPONENT_ENABLED_STATE
android.permission.TETHER_PRIVILEGED
android.permission.CHANGE_WIMAX_STATE
android.permission.PEERS_MAC_ADDRESS
android.permission.DISPATCH_NFC_MESSAGE
android.permission.ACCESS_NOTIFICATION_POLICY
android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
android.permission.LOCATION_HARDWARE
android.permission.REMOTE_AUDIO_PLAYBACK
com.android.launcher.permission.INSTALL_SHORTCUT
android.permission.MOUNT_FORMAT_FILESYSTEMS
android.permission.RESET_FINGERPRINT_LOCKOUT
android.permission.WRITE_SMS
android.permission.NET_TUNNELING
android.permission.STATUS_BAR
android.permission.COPY_PROTECTED_DATA
android.permission.QUERY_DO_NOT_ASK_CREDENTIALS_ON_BOOT
android.permission.REORDER_TASKS
android.permission.BIND_PACKAGE_VERIFIER
android.permission.BIND_KEYGUARD_APPWIDGET
android.permission.TEMPORARY_ENABLE_ACCESSIBILITY
android.permission.MANAGE_FINGERPRINT
android.permission.READ_PRIVILEGED_PHONE_STATE
android.permission.ASEC_DESTROY
android.permission.REVOKE_RUNTIME_PERMISSIONS
android.permission.REAL_GET_TASKS
android.permission.BIND_ACCESSIBILITY_SERVICE
android.permission.FRAME_STATS
android.permission.MANAGE_VOICE_KEYPHRASES
android.permission.ACCOUNT_MANAGER
android.permission.STORAGE_INTERNAL
android.permission.READ_INSTALL_SESSIONS
android.permission.GET_ACCOUNTS_PRIVILEGED
android.permission.MANAGE_APP_OPS_RESTRICTIONS
android.permission.ACCESS_MOCK_LOCATION
android.permission.GET_PASSWORD
android.permission.GLOBAL_SEARCH
android.permission.TRANSMIT_IR
android.permission.MANAGE_DEVICE_ADMINS
android.permission.BROADCAST_WAP_PUSH
android.permission.INTENT_FILTER_VERIFICATION_AGENT
android.permission.MEDIA_CONTENT_CONTROL
android.permission.MANAGE_DOCUMENTS
android.permission.PROVIDE_TRUST_AGENT
android.permission.BIND_CARRIER_MESSAGING_SERVICE
android.permission.WRITE_MEDIA_STORAGE
com.android.browser.permission.READ_HISTORY_BOOKMARKS
android.permission.SET_ALWAYS_FINISH
android.permission.REBOOT
android.permission.CONNECTIVITY_INTERNAL
android.permission.BIND_CARRIER_SERVICES
android.permission.CONTROL_WIFI_DISPLAY
android.permission.GET_INTENT_SENDER_INTENT
android.permission.LOOP_RADIO
android.permission.BIND_CONNECTION_SERVICE
android.permission.CACHE_CONTENT
android.permission.WRITE_SECURE_SETTINGS
android.permission.MANAGE_APP_TOKENS
android.permission.SUBSCRIBED_FEEDS_WRITE
android.permission.MANAGE_ACCOUNTS
android.permission.ACCESS_DRM_CERTIFICATES
android.permission.WRITE_APN_SETTINGS
android.permission.CLEAR_APP_CACHE
android.permission.BRICK
android.permission.WRITE_SOCIAL_STREAM
android.permission.BIND_PRINT_SPOOLER_SERVICE
android.permission.WRITE_BLOCKED_NUMBERS
android.permission.PACKAGE_VERIFICATION_AGENT
android.permission.MODIFY_DAY_NIGHT_MODE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.BIND_VPN_SERVICE
android.permission.CONFIGURE_WIFI_DISPLAY
android.permission.MODIFY_NETWORK_ACCOUNTING
android.permission.REQUEST_INSTALL_PACKAGES
android.permission.BROADCAST_PACKAGE_REMOVED
android.permission.REGISTER_CONNECTION_MANAGER
android.permission.READ_SYNC_STATS
android.permission.BROADCAST_STICKY
android.permission.INSTALL_LOCATION_PROVIDER
android.permission.REGISTER_CALL_PROVIDER
android.permission.KILL_UID
android.permission.INVOKE_CARRIER_SETUP
android.permission.BIND_JOB_SERVICE
android.permission.SET_INPUT_CALIBRATION
android.permission.READ_SOCIAL_STREAM
android.permission.UPDATE_DEVICE_STATS
android.permission.READ_INPUT_STATE
android.permission.SET_DEBUG_APP
android.permission.BIND_WALLPAPER
android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY
android.permission.RECOVERY
android.permission.SYSTEM_ALERT_WINDOW
android.permission.CREATE_USERS
android.permission.SET_KEYBOARD_LAYOUT
android.permission.CLEAR_APP_USER_DATA
android.permission.FILTER_EVENTS
android.permission.BIND_REMOTEVIEWS
android.permission.BIND_QUICK_SETTINGS_TILE
android.permission.STOP_APP_SWITCHES
android.permission.BIND_CHOOSER_TARGET_SERVICE
android.permission.ACCESS_VOICE_INTERACTION_SERVICE
android.permission.RECEIVE_WIFI_CREDENTIAL_CHANGE
android.permission.SET_ANIMATION_SCALE
android.permission.PERSISTENT_ACTIVITY
android.permission.ACCESS_NETWORK_STATE
android.permission.BATTERY_STATS
android.permission.FREEZE_SCREEN
android.permission.DELETE_PACKAGES
android.permission.CLEAR_APP_GRANTED_URI_PERMISSIONS
android.permission.PERFORM_CDMA_PROVISIONING
android.permission.ASEC_RENAME
android.permission.GET_PACKAGE_IMPORTANCE
android.permission.FORCE_BACK
android.permission.BIND_APPWIDGET
android.permission.NFC_HANDOVER_STATUS
android.permission.WRITE_SETTINGS
android.permission.ACCESS_KEYGUARD_SECURE_STORAGE
android.permission-group.STORAGE:
2 Permissions
android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_EXTERNAL_STORAGE
android.permission-group.PHONE:
10 Permissions
android.permission.USE_SIP
android.permission.ACCESS_UCE_PRESENCE_SERVICE
android.permission.CALL_PHONE
com.android.voicemail.permission.ADD_VOICEMAIL
android.permission.ACCESS_UCE_OPTIONS_SERVICE
android.permission.READ_CALL_LOG
android.permission.WRITE_CALL_LOG
android.permission.PROCESS_OUTGOING_CALLS
android.permission.ACCESS_IMS_CALL_SERVICE
android.permission.READ_PHONE_STATE
android.permission-group.LOCATION:
2 Permissions
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission-group.MICROPHONE:
1 Permissions
android.permission.RECORD_AUDIO
android.permission-group.SENSORS:
2 Permissions
android.permission.BODY_SENSORS
android.permission.USE_FINGERPRINT
android.permission-group.SMS:
6 Permissions
android.permission.SEND_SMS
android.permission.RECEIVE_SMS
android.permission.READ_SMS
android.permission.RECEIVE_WAP_PUSH
android.permission.READ_CELL_BROADCASTS
android.permission.RECEIVE_MMS
android.permission-group.CAMERA:
1 Permissions
android.permission.CAMERA
android.permission-group.CALENDAR:
2 Permissions
android.permission.WRITE_CALENDAR
android.permission.READ_CALENDAR

As you can see, the number of permissions detected far exceeds the number quoted in the documentation, there are permissions listed in AndroidManifest.xml and does not exist in the documentation, for example: android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK, android.permission .ACCESS_FM_RADIO!

What is the error in my analysis? What I want in the end is the number of permissions proposed to developers in Android 7, is that 138 permissions or more? If it's more how can I count them if I based on the AndroidManifest.xml file?

Thank you for your help.

Nimpo
  • 430
  • 6
  • 13
J.Adam
  • 33
  • 5
  • these are private permissions that aren't exposed in the sdk. all the public ones are @ https://developer.android.com/reference/android/Manifest.permission.html – TWL Feb 09 '17 at 23:59
  • So according to what I understood, when we say that an X version of Android offers Y permissions, we only talk about public permissions, right? Which means my first count is correct: Android 7 offers only 138 permissions – J.Adam Feb 10 '17 at 00:07
  • "when we say that an X version of Android offers Y permissions" -- that would depend entirely on who "we" is. Whoever "we" is should be much more precise. – CommonsWare Feb 10 '17 at 00:09
  • @CommonsWare "we" represent ordinary app developers, Your answer below is very clear, thank you ;) – J.Adam Feb 10 '17 at 07:32

2 Answers2

5

What I want in the end is the number of permissions proposed to developers in Android 7, is that 138 permissions or more?

It is unclear what you mean by "the number of permissions proposed to developers".

If you mean "the number of permissions defined on an Android 7.0 device", the answer is ¯\_(ツ)_/¯, as apps can define their own permissions.

If you mean "the number of permissions defined on an Android 7.0 device, as shipped from the factory", the answer is ¯\_(ツ)_/¯, as a manufacturer's pre-installed apps can define their own permissions.

If you mean "the number of permissions defined on an Android 7.0 device, as shipped from the factory, not including those from pre-installed apps", the answer is ¯\_(ツ)_/¯, as a manufacturer (or custom ROM developer) can modify the platform AndroidManifest.xml file.

If you mean "the number of permissions defined in the Android 7.0 edition of the Android Open Source Project, and not counting any AOSP apps like Settings", that will be the number of <permission> elements in the platform AndroidManifest.xml file at minimum. Right now, that's 300+ (my count is 353 based on the master branch).

If you mean "the number of permissions that ordinary app developers working on Android 7.0 will deal with", that would be the permissions documented in the Manifest.permission JavaDocs, which will be a small subset of those defined in the platform AndroidManifest.xml file. For example, ACCESS_FM_RADIO is one that you cited as being in the manifest but not in the documentation — that is because it has the @hide annotation:

<!-- @SystemApi Allows access to FM
     @hide This is not a third-party API (intended for system apps).-->
<permission android:name="android.permission.ACCESS_FM_RADIO"
    android:protectionLevel="signature|privileged" />

In the platform Java classes, @hide-annotated elements get removed from the SDK as part of building android.jar. Similarly, @hide-annotated manifest elements get removed as well from the SDK, even though they should exist on the device.

FWIW, my PermissionReporter sample app uses PackageManager to find all of the defined permissions on an Android device and list them in tabs based on protection level. So, for example, ACCESS_FM_RADIO shows up there on an Android 7.1.1 device.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • BRAVO! Thank you for this – Chisko Feb 10 '17 at 00:20
  • ok,it's clear, so if we analyse all AndroidManifest files included in all Android application published in Google Play, I can only find documented permissions existing in the Manifest.permission JavaDocs, right? – J.Adam Feb 10 '17 at 08:01
  • @J.Adam: "I can only find documented permissions existing in the Manifest.permission JavaDocs" -- that is a bit of a tautology ("I can only find documented things in the documentation"). But, yes, for ordinary app developers, the ones documented in the JavaDocs are the ones that matter. – CommonsWare Feb 10 '17 at 13:26
  • @CommonsWare I've think I got to write some code to enumerate over the (Android-framework-documented) permissions that developers can use . Written about those on another answer here. You think it's correct? Result seems promising... – android developer Jul 03 '18 at 13:46
  • @androiddeveloper: The code is fine as far as it goes, though I would not assume that it will necessarily reflect what you might think it does. AFAIK, a device manufacturer can put their own permissions in `android.permission-group.`-prefixed groups, for example. Hopefully, few do. If your objective is "run this on a few devices for the same API level and consider all the ones in common", that's reasonable. But I would not assume for an individual device that this algorithm is guaranteed to limit you to permissions that should be in the API docs. – CommonsWare Jul 03 '18 at 22:11
  • @CommonsWare Thanks. For some reason though, I can see "READ_CELL_BROADCASTS" , which isn't documented. And that's on Android P, on Pixel 2... – android developer Jul 04 '18 at 08:42
  • @androiddeveloper: That permission is marked with `@hide`, at least in [the current `master` branch edition of the platform manifest](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/AndroidManifest.xml). – CommonsWare Jul 04 '18 at 10:47
  • @CommonsWare That's odd. Any idea how to filter those out? And what this permission is ? And is it really available for (third party) Android developers ? – android developer Jul 04 '18 at 14:47
  • @androiddeveloper: "Any idea how to filter those out?" -- pretty much by definition, they are indistinguishable from others at runtime. So, have your code parse the JavaDoc HTML :-) "And what this permission is ?" -- all I know is what's in its code comment, which would have been in the JavaDoc had this not been hidden. "And is it really available for (third party) Android developers ?" -- perhaps not on Android 9.0+, if they're somehow blocking access to hidden permissions the way that they are for hidden Java stuff. My guess is that it is available. – CommonsWare Jul 04 '18 at 15:13
  • @CommonsWare I think it's about emergency messages. Maybe they aren't sure what to do about it ("Pending API council approval"). So you say it's impossible for me in code to differentiate between those marked as hidden, and the rest? – android developer Jul 04 '18 at 18:11
  • @androiddeveloper: "So you say it's impossible for me in code to differentiate between those marked as hidden, and the rest?" -- using only stuff on the device, yes. The only difference between a hidden permission and a regular permission is that the hidden permission is not included in the SDK, just as hidden classes and methods are not included in the SDK. – CommonsWare Jul 04 '18 at 18:17
  • I've noticed that starting from some Android version (I think Android 10), it's impossible to get which permission belongs to which permission group. Is this true? At least in Android code, should it be possible to check it out somehow? It's important to know how many dialogs and which - would be shown to the user upon requesting. – android developer Jun 06 '20 at 20:45
  • @androiddeveloper: You are probably referring to [this](https://developer.android.com/about/versions/10/privacy/changes#permission-groups-removed). I have not tried this recently myself. – CommonsWare Jun 06 '20 at 20:47
  • @CommonsWare It's not just in the UI. It's via adb too. I can't find any way to do it. Can you please check it out? It could be useful for planning the UX of the app, if we can know how many dialogs (and which) are going to be shown to the user. I don't get why they even removed it. Doesn't make sense. – android developer Jun 06 '20 at 20:54
  • @androiddeveloper: Personally, I would try not to make any assumptions about that, even if you had the information. Device manufacturers have lots of power here, and I would not assume that all manufacturers have left the permission dialog alone. – CommonsWare Jun 06 '20 at 20:58
  • @CommonsWare Isn't it against the CTS ? – android developer Jun 06 '20 at 21:00
  • @androiddeveloper: I am uncertain -- I don't have all of those memorized. :-) – CommonsWare Jun 06 '20 at 21:02
  • @CommonsWare Can you still check it out , or at least give me direction where to look for this information (not the CTS, but the permissions stuff) ? – android developer Jun 06 '20 at 21:10
  • @androiddeveloper: Um, I'm just a guy. I do not have special visibility into things like this. Are you saying that you have tried reading the value of [`group` on `PermissionInfo`](https://developer.android.com/reference/android/content/pm/PermissionInfo#group) and it is `null` or empty or something on Android 10? That is what I would expect from the documentation that I linked to, but I have not tried it. – CommonsWare Jun 06 '20 at 21:20
  • @CommonsWare The groups do exist, but when you try to find out which permissions belong to which group, it returns you incorrect results, and most/all of the permissions enter one called `android.permission-group.UNDEFINED` . That's what I get from both code (using the sample I wrote, which uses `queryPermissionsByGroup`) and adb, and according to the source code of Android that I've looked one day, it was there too. But it has to be different somewhere else, because eventually the user sees something else. – android developer Jun 06 '20 at 22:24
  • @androiddeveloper: That's very strange. I thought that it would be correct in the platform manifest and would be filtered out in the SDK, but that's not the case -- `android.permission-group.UNDEFINED` is in the manifest. It looks like the actual mapping is [here](https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java) -- see the various `private static final Set` fields of permissions for a group. – CommonsWare Jun 06 '20 at 22:37
  • @CommonsWare Seems you've found it! But where does it say which Android API it is? I don't see "MANAGE_EXTERNAL_STORAGE" so it's not Android R, at least. And, is it possible to use reflection to get there? – android developer Jun 06 '20 at 23:34
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/215453/discussion-between-android-developer-and-commonsware). – android developer Jun 07 '20 at 05:22
  • @androiddeveloper: "But where does it say which Android API it is?" -- that link was to the `master` branch, so it will vary. You can find the file in the repo and switch branches/tags to certain versions. However, the source to Android R is not available yet AFAIK. "is it possible to use reflection to get there?" -- I forget how the reflection ban works, but there is nothing obvious on those static fields that would seem to prevent them from being accessed. – CommonsWare Jun 07 '20 at 10:55
  • @CommonsWare Seems it started existing only from Android 9, probably when getting permission groups information started becoming impossible. Anyway, tried reflection, and it didn't let me. I really hate that Google blocks reflection. Especially for simple stuff. I've noticed though that on the link you've provided, I can't see "ACCEPT_HANDOVER" for example which is supposed to be of Phone permission group. Maybe some are missing? I also think that "PROCESS_OUTGOING_CALLS" is part of CALL_LOG permission group, and not Phone permission group – android developer Jun 08 '20 at 21:39
1

I think you can create a list of the permission groups and their permissions, that are allowed for developers (and therefore should be documented here) , by using this code:

fun checkPermissions() {
    val allPermissionGroups = packageManager.getAllPermissionGroups(0)
    var permissionsCount = 0
    for (permissionGroup in allPermissionGroups) {
        val permissionGroupName = permissionGroup.name
        if (!permissionGroupName.startsWith("android.permission-group."))
            continue
        Log.d("AppLog", "permissionGroup:$permissionGroupName:")
        val permissions = packageManager.queryPermissionsByGroup(permissionGroupName, 0)
        for (permission in permissions) {
            if (!permission.packageName.startsWith("android") ||
                    (permission.protectionLevel and PermissionInfo.PROTECTION_SIGNATURE) != 0)
                continue
            Log.d("AppLog", " $permission")
            ++permissionsCount
        }
    }
    Log.d("AppLog", "total permissions count:$permissionsCount")
}

Running it on Android P (API 28), for example, I get that it found 30 permissions :

permissionGroup:android.permission-group.CONTACTS:
 android.permission.WRITE_CONTACTS
 android.permission.GET_ACCOUNTS
 android.permission.READ_CONTACTS
permissionGroup:android.permission-group.PHONE:
 android.permission.ANSWER_PHONE_CALLS
 android.permission.READ_PHONE_NUMBERS
 android.permission.READ_PHONE_STATE
 android.permission.CALL_PHONE
 android.permission.ACCEPT_HANDOVER
 android.permission.USE_SIP
 com.android.voicemail.permission.ADD_VOICEMAIL
permissionGroup:android.permission-group.CALENDAR:
 android.permission.READ_CALENDAR
 android.permission.WRITE_CALENDAR
permissionGroup:android.permission-group.CALL_LOG:
 android.permission.READ_CALL_LOG
 android.permission.WRITE_CALL_LOG
 android.permission.PROCESS_OUTGOING_CALLS
permissionGroup:android.permission-group.CAMERA:
 android.permission.CAMERA
permissionGroup:android.permission-group.SENSORS:
 android.permission.BODY_SENSORS
 android.permission.USE_FINGERPRINT
 android.permission.USE_BIOMETRIC
permissionGroup:android.permission-group.LOCATION:
 android.permission.ACCESS_FINE_LOCATION
 android.permission.ACCESS_COARSE_LOCATION
permissionGroup:android.permission-group.STORAGE:
 android.permission.READ_EXTERNAL_STORAGE
 android.permission.WRITE_EXTERNAL_STORAGE
permissionGroup:android.permission-group.MICROPHONE:
 android.permission.RECORD_AUDIO
permissionGroup:android.permission-group.SMS:
 android.permission.READ_SMS
 android.permission.RECEIVE_WAP_PUSH
 android.permission.RECEIVE_MMS
 android.permission.RECEIVE_SMS
 android.permission.SEND_SMS
 android.permission.READ_CELL_BROADCASTS
total permissions count:30

EDIT:

For some reason I can see here "READ_CELL_BROADCASTS", which isn't documented. No idea what it is.

EDIT: starting from some Android version (I think Android 10 - API 29), you can't get which permission belongs to which permission group.

EDIT: Seems the code for the permission groups and their permissions, at least for English locale, is here:

https://cs.android.com/android/platform/superproject/+/master:packages/apps/PermissionController/src/com/android/packageinstaller/permission/utils/Utils.java;bpv=1;bpt=1;l=137


EDIT: starting from Android 12, it's finally official again and working:

packageManager.getAllPermissionGroups(0).forEach { permissionGroup: PermissionGroupInfo ->
    val permissionGroupName = permissionGroup.name
    if (!permissionGroupName.startsWith("android.permission-group."))
        return@forEach
    packageManager.getPlatformPermissionsForGroup(permissionGroupName, mainExecutor) { groupPermissions ->
        Log.d("AppLog", "permissionGroup:$permissionGroupName")
        groupPermissions.forEach { permissionName ->
            Log.d("AppLog", "\t$permissionName")
        }
    }
}

I've prepared a more updated code here:

https://stackoverflow.com/a/69053542/878126

android developer
  • 114,585
  • 152
  • 739
  • 1,270