1 page.title=Android 6.0 Testing Guide 2 page.image=images/cards/card-n-guide_2x.png 3 meta.tags="preview", "testing" 4 page.tags="preview", "developer preview" 5 6 @jd:body 7 8 <div id="qv-wrapper"> 9 <div id="qv"> 10 <h2>In this document</h2> 11 <ol> 12 <li><a href="#runtime-permissions">Testing Permissions</a></li> 13 <li><a href="#doze-standby">Testing Doze and App Standby</a></li> 14 <li><a href="#ids">Auto Backup and Device Identifiers</a></li> 15 </ol> 16 </div> 17 </div> 18 19 <p> 20 Android 6.0 gives you an opportunity to ensure your apps work with the next 21 version of the platform. This preview includes a number of APIs and behavior changes that can 22 impact your app, as described in the <a href="{@docRoot}preview/api-overview.html">API 23 Overview</a> and <a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>. In testing 24 your app with the preview, there are some specific system changes that you should focus on to 25 ensure that users have a good experience. 26 </p> 27 28 <p> 29 This guide describes the what and how to test preview features with your app. You should 30 prioritize testing of these specific preview features, due to their high potential impact on your 31 app's behavior: 32 </p> 33 34 <ul> 35 <li><a href="#runtime-permissions">Permissions</a> 36 </li> 37 <li><a href="#doze-standby">Doze and App Standby</a> 38 </li> 39 <li><a href="#ids">Auto Backup and Device Identifiers</a></li> 40 </ul> 41 42 <h2 id="runtime-permissions">Testing Permissions</h2> 43 44 <p> 45 The new <a href="{@docRoot}preview/features/runtime-permissions.html">Permissions</a> model 46 changes the way that permissions are allocated to your app by the user. Instead of granting all 47 permissions during the install procedure, your app must ask the user for individual permissions 48 at runtime. For users this behavior provides more granular control over each apps activities, as 49 well as better context for understanding why the app is requesting a specific permission. Users 50 can grant or revoke the permissions granted to an app individually at any time. This feature of 51 the preview is most likely to have an impact on your app's behavior and may prevent some of your 52 app features from working, or they may work in a degraded state. 53 </p> 54 55 <p class="caution"> 56 This change affects all apps running on the new platform, even those not targeting the new 57 platform version. The platform provides a limited compatibility behavior for legacy apps, but you 58 should begin planning your apps migration to the new permissions model now, with a goal of 59 publishing an updated version of your app at the official platform launch. 60 </p> 61 62 63 <h3 id="permission-test-tips">Test tips</h3> 64 65 <p> 66 Use the following test tips to help you plan and execute testing of your app with the new 67 permissions behavior. 68 </p> 69 70 <ul> 71 <li>Identify your apps current permissions and the related code paths.</li> 72 <li>Test user flows across permission-protected services and data.</li> 73 <li>Test with various combinations of granted/revoked permission.</li> 74 <li>Use the {@code adb} tool to manage permssions from the command line: 75 <ul> 76 <li>List permissions and status by group: 77 <pre>adb shell pm list permissions -d -g</pre> 78 </li> 79 <li>Grant or revoke one or more permissions using the following syntax:<br> 80 <pre>adb shell pm [grant|revoke] <permission.name> ...</pre> 81 </li> 82 </ul> 83 </li> 84 <li>Analyze your app for services that use permissions.</li> 85 </ul> 86 87 <h3 id="permission-test-strategy">Test strategy</h3> 88 89 <p> 90 The permissions change affects the structure and design of your app, as well as 91 the user experience and flows you provide to users. You should assess your apps current 92 permissions use and start planning for the new flows you want to offer. The official release of 93 the platform provides compatibility behavior, but you should plan on updating your app and not 94 rely on these behaviors. 95 </p> 96 97 <p> 98 Identify the permissions that your app actually needs and uses, and then find the various code 99 paths that use the permission-protected services. You can do this through a combination of 100 testing on the new platform and code analysis. In testing, you should focus on opting in to 101 runtime permissions by changing the apps {@code targetSdkVersion} to the preview version. For 102 more information, see <a href="{@docRoot}preview/setup-sdk.html#">Set up 103 the Android N SDK</a>. 104 </p> 105 106 <p> 107 Test with various combinations of permissions revoked and added, to highlight the user flows that 108 depend on permissions. Where a dependency is not obvious or logical you should consider 109 refactoring or compartmentalizing that flow to eliminate the dependency or make it clear why the 110 permission is needed. 111 </p> 112 113 <p> 114 For more information on the behavior of runtime permissions, testing, and best practices, see the 115 <a href="{@docRoot}preview/features/runtime-permissions.html">Permissions</a> developer 116 preview page. 117 </p> 118 119 120 <h2 id="doze-standby">Testing Doze and App Standby</h2> 121 122 <p> 123 The power saving features of Doze and App Standby limit the amount of background processing that 124 your app can perform when a device is in an idle state or while your app is not in focus. The 125 restrictions the system may impose on apps include limited or no network access, 126 suspended background tasks, suspended Notifications, ignored wake requests, and alarms. To ensure 127 that your app behaves properly with these power saving optimizations, you should test your app by 128 simulating these low power states. 129 </p> 130 131 <h4 id="doze">Testing your app with Doze</h4> 132 133 <p>To test Doze with your app:</p> 134 135 <ol> 136 <li>Configure a hardware device or virtual device with an Android N system image.</li> 137 <li>Connect the device to your development machine and install your app.</li> 138 <li>Run your app and leave it active.</li> 139 <li>Simulate the device going into Doze mode by running the following commands: 140 141 <pre> 142 $ adb shell dumpsys battery unplug 143 $ adb shell dumpsys deviceidle step 144 $ adb shell dumpsys deviceidle -h 145 </pre> 146 147 </li> 148 <li>Observe the behavior of your app when the device is re-activated. Make sure it 149 recovers gracefully when the device exits Doze.</li> 150 </ol> 151 152 153 <h4 id="standby">Testing apps with App Standby</h4> 154 155 <p>To test the App Standby mode with your app:</p> 156 157 <ol> 158 <li>Configure a hardware device or virtual device with an Android N system image.</li> 159 <li>Connect the device to your development machine and install your app.</li> 160 <li>Run your app and leave it active.</li> 161 <li>Simulate the app going into standby mode by running the following commands: 162 163 <pre> 164 $ adb shell am broadcast -a android.os.action.DISCHARGING 165 $ adb shell am set-idle <packageName> true 166 </pre> 167 168 </li> 169 <li>Simulate waking your app using the following command: 170 <pre>$ adb shell am set-idle <packageName> false</pre> 171 </li> 172 <li>Observe the behavior of your app when it is woken. Make sure it recovers gracefully 173 from standby mode. In particular, you should check if your app's Notifications and background 174 jobs continue to function as expected.</li> 175 </ol> 176 177 <h2 id="ids">Auto Backup for Apps and Device-Specific Identifiers</h2> 178 179 <p>If your app is persisting any device-specific identifiers, such as Google 180 Cloud Messaging registration ID, in internal storage, 181 make sure to follow best practices to exclude the storage 182 location from auto-backup, as described in <a href="{@docRoot}preview/backup/index.html">Auto 183 Backup for Apps</a>. </p> 184