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