title: How Do We List All Defined Permissions?
body: <p>The classic answer for listing all defined permissions is to use the <code>pm list permissions</code> command. However, on Android 5.1 and the current preview edition of Android 6.0, that command does not list everything.</p>
  
  <p>For example, on a Nexus 4 running Android 5.1, I get output like this:</p>
  
  <pre><code>$ adb shell pm list permissions| fgrep WRITE_
  permission:com.intsig.camscanner.WRITE_CAMSCANNER
  permission:android.permission.WRITE_GSERVICES
  permission:com.google.android.providers.gsf.permission.WRITE_GSERVICES
  permission:com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL
  permission:com.android.launcher3.permission.WRITE_SETTINGS
  permission:com.google.android.providers.settings.permission.WRITE_GSETTINGS
  permission:com.android.chrome.permission.READ_WRITE_BOOKMARK_FOLDERS
  </code></pre>
  
  <p><code>WRITE_EXTERNAL_STORAGE</code> does not appear there. Yet that permission has been around since Android 1.6 or so. Similar commands show that <code>pm list permissions</code> is missing <code>READ_EXTERNAL_STORAGE</code>, <code>READ_CONTACTS</code>, <code>WRITE_CONTACTS</code>, <code>INTERNET</code>, and probably many others.</p>
  
  <p>So, if <code>pm list permissions</code> does not give us a full roster of defined permissions on a device, is there another way of getting that data?</p>
  
  <p>In theory, there may be a way to get it from <code>PackageManager</code>, but I don't see a <code>getAllPermissions()</code> method, and <code>getAllPermissionGroups()</code> will leave out any permissions that are not in groups.</p>
  
  <p>My current reason for inquiry is that I want to see what permissions are defined on Android 6.0 and their protection levels, and we don't have the Android 6.0 source code yet AFAIK. There are permissions, like <code>CHANGE_WIFI_STATE</code>, <code>BLUETOOTH</code>, <code>BLUETOOTH_ADMIN</code>, <code>NFC</code>, and others, that historically had been <code>dangerous</code>. They are all still in the Android SDK, yet they are not listed among the permissions associated with the new Android 6.0 runtime permission system. So, I am trying to determine if they have been downgraded to <code>normal</code> or something. While I can do that through <code>PackageManager</code> on a permission-by-permission basis, I was hoping to try to collect <code>protectionLevel</code> values for all permissions.</p>