Merge "Fix package names of View Ids in cts test." into nyc-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index b6a992f..ded4ccc 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -119,6 +119,8 @@
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
             <meta-data android:name="test_category" android:value="@string/test_category_device_admin" />
+            <meta-data android:name="test_required_features"
+                    android:value="android.software.device_admin" />
         </activity>
 
         <activity android:name=".admin.RedactedNotificationKeyguardDisabledFeaturesActivity"
@@ -129,6 +131,8 @@
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
             <meta-data android:name="test_category" android:value="@string/test_category_device_admin" />
+            <meta-data android:name="test_required_features"
+                    android:value="android.software.device_admin" />
         </activity>
 
         <activity android:name=".admin.ScreenLockTestActivity"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index bfab6cd..78d21ee 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1621,7 +1621,7 @@
     <string name="provisioning_byod_disable_unredacted_notifications_instruction">
         Please press the Go button to lock the screen. Wait a couple of seconds and look out for a
         notification from CtsVerifier.\n
-        Expected result is the notification is shown as \"Contents hidden\", you can not see the contents
+        Expected result is the notification is shown as \"Contents hidden by policy\", you can not see the contents
         (Which would read \"This is a notification\"). You should be seeing a work badge.\n
         After you log back in, please navigate back to CtsVerifier and mark the test as \"Pass\" or \"Fail\".
     </string>
@@ -1645,20 +1645,17 @@
     <string name="provisioning_byod_disallow_apps_control_prepare_button">Prepare test</string>
     <string name="provisioning_byod_disabled_uninstall_button">Disabled uninstall button</string>
     <string name="provisioning_byod_disabled_uninstall_button_instruction">
-        Please press the Go button to go to Settings > Apps. Choose a managed app. Check if the button that says
-        either \"Uninstall\" or \"Disable\" is greyed out and disabled, i.e. nothing happens when you tap on it.
+        Please press the Go button to go to Settings > Apps. Choose a managed app. Check that performing either \"Uninstall\" or \"Disable\" is not possible and triggers a support message when trying to do so.
         Then please press Back and mark the test as \"Pass\" or \"Fail\".
     </string>
     <string name="provisioning_byod_disabled_force_stop_button">Disabled force stop button</string>
     <string name="provisioning_byod_disabled_force_stop_button_instruction">
-        Please press the Go button to go to Settings > Apps. Choose a managed app. Check if the button that says
-        \"Force stop\" is greyed out and disabled, i.e. nothing happens when you tap on it.
+        Please press the Go button to go to Settings > Apps. Choose a managed app. Check that performing \"Force stop\" is not possible and triggers a support message when trying to do so.
         Then please press Back and mark the test as \"Pass\" or \"Fail\".
     </string>
     <string name="provisioning_byod_disabled_app_storage_buttons">Disabled app storage buttons</string>
     <string name="provisioning_byod_disabled_app_storage_buttons_instruction">
-        Please press the Go button to go to Settings > Apps. Choose a managed (badged) app. Select \"Storage\". Check that the buttons
-        \"Clear Data\" and \"Clear Cache\" are disabled, i.e. nothing happens when you tap on them.
+        Please press the Go button to go to Settings > Apps. Choose a managed (badged) app. Select \"Storage\". Check that performing \"Clear Data\" and \"Clear Cache\" is not possible and triggers a support message when trying to do so.
         Note: if an app has no data then tapping the clear data button has no effect anyway. Make sure you have selected
         the badged version of app with non-zero app data. Badged \"Settings\" may be a good candidate.
         Then please press Back and mark the test as \"Pass\" or \"Fail\".
@@ -1994,9 +1991,9 @@
     <string name="device_profile_owner_permission_lockdown_test_instructions">
             Select each of the three grant states for the permission shown below in turn.\n
             Now open application settings, select Permissions, and verify if the following behaviour is observed.\n
-            <b>Allow:</b> Permission is granted to the app and cannot be changed through the settings UI.\n
+            <b>Allow:</b> Permission is granted to the app and cannot be changed through the settings UI. Trying to change it triggers a support message.\n
             <b>Let user decide:</b> Permission state can be changed through the settings UI.\n
-            <b>Deny:</b> Permission is denied to the app and cannot be changed through the settings UI.\n
+            <b>Deny:</b> Permission is denied to the app and cannot be changed through the settings UI. Trying to change it triggers a support message.\n
             Please mark the test accordingly.
     </string>
     <string name="device_owner_permission_lockdown_test_info">
@@ -2004,11 +2001,10 @@
     </string>
     <string name="device_owner_disallow_usb_file_transfer_test">Disallow USB file transfer</string>
     <string name="device_owner_disallow_usb_file_transfer_test_info">
-            Please press below button to set the \"disallow USB file transfer\" restriction.
+            Please press below button to set the \"disallow USB file transfer\" restriction.\n
             Next, connect your device to your desktop computer through USB, open the USB notification from the status bar
-            and check that the \"Transfer files (MTP)\" and \"Transfer photos (PTP)\" options are not present. Also, check
-            that you can download files from your phone to the desktop computer. The test is successful if the files from
-            your phone are not and cannot be downloaded through USB.\n
+            and check that the \"Transfer files (MTP)\" and \"Transfer photos (PTP)\" cannot be selected and triggers a support message when trying to select them.\n
+            Also, check that if you can download files from your phone to the desktop computer. The test is successful if the files from your phone are not and cannot be downloaded through USB.\n
             Please mark the test accordingly.
     </string>
     <string name="profile_owner_permission_lockdown_test_info">
@@ -2043,7 +2039,7 @@
         Confirm that:\n
         \n
         - You cannot view Bluetooth devices in range.\n
-        - You cannot edit, add or remove any already paired devices.\n
+        - Trying to edit, add or remove any already paired devices triggers a support message.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -2054,7 +2050,7 @@
         Confirm that:\n
         \n
         - You cannot view WiFi networks in range.\n
-        - You cannot edit, add or remove any existing WiFi configs.\n
+        - Trying to edit, add or remove any existing WiFi configs triggers a support message.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -2065,7 +2061,7 @@
         Confirm that:\n
         \n
         - Data roaming is disabled.\n
-        - You cannot enable data roaming.\n
+        - Enabling data roaming is not possible and triggers a support message.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -2101,7 +2097,8 @@
         1. Press Go to open the Vpn settings page.\n
         Confirm that:\n
         - You cannot add a new VPN network.\n
-        - You cannot edit, add or remove any existing VPNs.\n\n
+        - You cannot edit, add or remove any existing VPNs.\n
+        - Trying to perform any of the above actions will trigger a support message.\n\n
         2. Press Check VPN to check programmatic Vpn test.\n
         - Check Vpn setup\n\n
         Use the Back button to return to this page.
@@ -2151,18 +2148,48 @@
     <string name="disallow_adjust_volume_action">Adjusting the volume</string>
     <string name="disallow_apps_control">Disallow controlling apps</string>
     <string name="disallow_apps_control_action">DISABLE/UNINSTALL/FORCE STOP-ing any app in the managed device/profile other than CtsVerifier</string>
+    <string name="disallow_config_cell_broadcasts">Disallow config cell broadcasts</string>
+    <string name="disallow_config_cell_broadcasts_action">Configuring cell broadcasts</string>
+    <string name="disallow_config_credentials">Disallow config credentials</string>
+    <string name="disallow_config_credentials_action">Configuring user credentials</string>
+    <string name="disallow_config_mobile_networks">Disallow config mobile networks</string>
+    <string name="disallow_config_mobile_networks_action">Configuring mobile networks</string>
+    <string name="disallow_config_tethering">Disallow config tethering</string>
+    <string name="disallow_config_tethering_action">Configuring tethering and portable hotspots</string>
     <string name="disallow_config_wifi">Disallow config Wi-Fi</string>
     <string name="disallow_config_wifi_action">Modifying Wi-Fi configuration</string>
+    <string name="disallow_debugging_features">Disallow debugging features</string>
+    <string name="disallow_debugging_features_action">Enabling developer options</string>
+    <string name="disallow_factory_reset">Disallow factory reset</string>
+    <string name="disallow_factory_reset_action">Factory resetting the device</string>
     <string name="disallow_fun">Disallow fun</string>
     <string name="disallow_fun_action">Opening android easter egg game by tapping repeatedly on the \'Android version\' option</string>
+    <string name="disallow_install_unknown_sources">Disallow install unknown sources</string>
+    <string name="disallow_install_unknown_sources_action">Enabling \'Unknown sources\' setting</string>
     <string name="disallow_modify_accounts">Disallow modify accounts</string>
     <string name="disallow_modify_accounts_action">Adding an account or removing an account (if you have already added one)</string>
+    <string name="disallow_network_reset">Disallow network reset</string>
+    <string name="disallow_network_reset_action">Resetting network settings</string>
+    <string name="disallow_outgoing_beam">Disallow outgoing beam</string>
+    <string name="disallow_outgoing_beam_action">Switching on android beam</string>
+    <string name="disallow_remove_user">Disallow remove user</string>
+    <string name="disallow_remove_user_action">Removing other users</string>
     <string name="disallow_share_location">Disallow share location</string>
     <string name="disallow_share_location_action">Turning on location sharing</string>
+    <string name="disallow_uninstall_apps">Disallow uninstall apps</string>
+    <string name="disallow_uninstall_apps_action">Uninstalling applications other CtsVerifier</string>
     <string name="disallow_keyguard_unredacted_notifications">Disallow lockscreen unredacted notification</string>
     <string name="disallow_keyguard_unredacted_notifications_set_step">Disallow unredacted notifications when device is locked by turning on the switch below</string>
     <string name="disallow_keyguard_unredacted_notifications_action">Selecting show all notification content when device is locked</string>
     <string name="disallow_keyguard_unredacted_notifications_widget_label">@string/disallow_keyguard_unredacted_notifications</string>
+    <string name="set_auto_time_required">Set auto (network) time required</string>
+    <string name="auto_time_required_set_step">Set auto time required policy by turning on the switch below</string>
+    <string name="set_auto_time_required_action">Modifying date and time</string>
+    <string name="set_auto_time_required_widget_label">@string/set_auto_time_required</string>
+    <string name="set_lock_screen_info">Set lock screen info</string>
+    <string name="lock_screen_info_set_step">Select a lock screen info by setting a non-empty message in the edittext below.</string>
+    <string name="set_lock_screen_info_action">Modifying lock screen message</string>
+    <string name="set_lock_screen_info_widget_label">@string/set_lock_screen_info</string>
     <string name="set_maximum_time_to_lock">Set maximum time to lock</string>
     <string name="maximum_time_to_lock_set_step">
         Select a non-zero maximum time to lock value by setting a value in the edittext box below.
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/CommandReceiverActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/CommandReceiverActivity.java
index c506d77..8636646 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/CommandReceiverActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/CommandReceiverActivity.java
@@ -39,11 +39,13 @@
     public static final String COMMAND_SET_USER_RESTRICTION = "set-user_restriction";
     public static final String COMMAND_DISALLOW_KEYGUARD_UNREDACTED_NOTIFICATIONS =
             "disallow-keyguard-unredacted-notifications";
+    public static final String COMMAND_SET_AUTO_TIME_REQUIRED = "set-auto-time-required";
     public static final String COMMAND_SET_GLOBAL_SETTING =
             "set-global-setting";
     public static final String COMMAND_SET_MAXIMUM_TO_LOCK = "set-maximum-time-to-lock";
     public static final String COMMAND_SET_PASSWORD_QUALITY = "set-password-quality";
     public static final String COMMAND_SET_KEYGUARD_DISABLED = "set-keyguard-disabled";
+    public static final String COMMAND_SET_LOCK_SCREEN_INFO = "set-lock-screen-info";
     public static final String COMMAND_SET_STATUSBAR_DISABLED = "set-statusbar-disabled";
     public static final String COMMAND_ALLOW_ONLY_SYSTEM_INPUT_METHODS =
             "allow-only-system-input-methods";
@@ -92,6 +94,13 @@
                     mDpm.setKeyguardDisabledFeatures(mAdmin,
                             DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
                 } break;
+                case COMMAND_SET_AUTO_TIME_REQUIRED: {
+                    mDpm.setAutoTimeRequired(mAdmin,
+                            intent.getBooleanExtra(EXTRA_ENFORCED, false));
+                }
+                case COMMAND_SET_LOCK_SCREEN_INFO: {
+                    mDpm.setDeviceOwnerLockScreenInfo(mAdmin, intent.getStringExtra(EXTRA_VALUE));
+                }
                 case COMMAND_SET_MAXIMUM_TO_LOCK: {
                     final long timeInSeconds = Long.parseLong(intent.getStringExtra(EXTRA_VALUE));
                     mDpm.setMaximumTimeToLock(mAdmin,
@@ -159,19 +168,32 @@
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_ADD_USER);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_ADJUST_VOLUME);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_BLUETOOTH);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_CELL_BROADCASTS);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_TETHERING);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_VPN);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_WIFI);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_DATA_ROAMING);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_DEBUGGING_FEATURES);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_FACTORY_RESET);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_FUN);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_NETWORK_RESET);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_OUTGOING_BEAM);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_REMOVE_USER);
 
+        mDpm.setDeviceOwnerLockScreenInfo(mAdmin, null);
         mDpm.setKeyguardDisabled(mAdmin, false);
+        mDpm.setAutoTimeRequired(mAdmin, false);
         mDpm.setStatusBarDisabled(mAdmin, false);
     }
 
     private void clearProfileOwnerRelatedPolicies() {
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_APPS_CONTROL);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_CONFIG_CREDENTIALS);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_MODIFY_ACCOUNTS);
         mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_SHARE_LOCATION);
+        mDpm.clearUserRestriction(mAdmin, UserManager.DISALLOW_UNINSTALL_APPS);
 
         mDpm.setKeyguardDisabledFeatures(mAdmin, 0);
         mDpm.setPasswordQuality(mAdmin, 0);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
index 58a1fef..0cf58f7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
@@ -283,15 +283,9 @@
         }
 
         // Check for intents which can be forwarded to the managed profile.
-        Intent intent = checkForIntentsNotHandled(forwardedIntentsFromPrimary,
-                forwarderActivityInfo, true);
-        if (intent != null) {
-            Log.d(TAG, intent + " from primary profile should be forwarded to the " +
-                    "managed profile but is not.");
-            return false;
-        }
-
-        return true;
+        return checkForIntentsNotHandled(forwardedIntentsFromPrimary,
+                forwarderActivityInfo, "from primary profile should be forwarded to the " +
+                "managed profile but is not.", true);
     }
 
     /**
@@ -307,25 +301,17 @@
             return false;
         }
 
+        boolean success = true;
         // Check for intents which can be forwarded to the primary profile.
-        Intent intent = checkForIntentsNotHandled(forwardedIntentsFromManaged,
-                forwarderActivityInfo, true);
-        if (intent != null) {
-            Log.d(TAG, intent + " from managed profile should be forwarded to the " +
-                    "primary profile but is not.");
-            return false;
-        }
+        success &= checkForIntentsNotHandled(forwardedIntentsFromManaged,
+                forwarderActivityInfo, " from managed profile should be forwarded to the " +
+                "primary profile but is not.", true);
 
         // Check for intents which cannot be forwarded to the primary profile.
-        intent = checkForIntentsNotHandled(notForwardedIntentsFromManaged,
-                forwarderActivityInfo, false);
-        if (intent != null) {
-            Log.d(TAG, intent + " from managed profile should not be forwarded to the " +
-                    "primary profile but it is.");
-            return false;
-        }
-
-        return true;
+        success &= checkForIntentsNotHandled(notForwardedIntentsFromManaged,
+                forwarderActivityInfo, "from managed profile should not be forwarded to the " +
+                "primary profile but it is.", false);
+        return success;
     }
 
     /**
@@ -365,17 +351,18 @@
 
     /**
      * Checks if the intents passed are correctly handled.
-     * @return {@code null} if all the intents are correctly handled
-     *         otherwise, the first intent in the list which is not handled correctly.
+     * @return {@code false} if at least one intent is not handled correctly.
      */
-    private Intent checkForIntentsNotHandled(ArrayList<Intent> intentList,
-            ActivityInfo expectedForwarderActivityInfo, boolean canResolve) {
+    private boolean checkForIntentsNotHandled(ArrayList<Intent> intentList,
+            ActivityInfo expectedForwarderActivityInfo, String errorMessage, boolean canResolve) {
+        boolean success = true;
         for (Intent intent : intentList) {
             if (canForwarderActivityHandleIntent(intent,
                     expectedForwarderActivityInfo) != canResolve) {
-                return intent;
+                Log.e(TAG, intent + " " + errorMessage);
+                success = false;
             }
         }
-        return null;
+        return success;
     }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestActivity.java
index f190a2d..9261284 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestActivity.java
@@ -49,8 +49,10 @@
             "com.android.cts.verifier.managedprovisioning.extra.TEST";
 
     public static final String TEST_CHECK_USER_RESTRICTION = "check-user-restriction";
+    public static final String TEST_CHECK_AUTO_TIME_REQUIRED = "check-auto-time-required";
     public static final String TEST_CHECK_KEYGURAD_UNREDACTED_NOTIFICATION =
             "check-keyguard-unredacted-notification";
+    public static final String TEST_CHECK_LOCK_SCREEN_INFO = "check-lock-screen-info";
     public static final String TEST_CHECK_MAXIMUM_TIME_TO_LOCK = "check-maximum-time-to-lock";
     public static final String TEST_CHECK_PASSWORD_QUALITY = "check-password-quality";
     public static final String TEST_CHECK_PERMITTED_ACCESSIBILITY_SERVICE =
@@ -66,12 +68,24 @@
 
     private static final Map<String, PolicyTestItem> POLICY_TEST_ITEMS = new ArrayMap<>();
     static {
+        POLICY_TEST_ITEMS.put(TEST_CHECK_AUTO_TIME_REQUIRED, new PolicyTestItem(
+                R.string.auto_time_required_set_step,
+                R.string.set_auto_time_required_action,
+                R.string.set_auto_time_required_widget_label,
+                R.id.switch_widget,
+                CommandReceiverActivity.COMMAND_SET_AUTO_TIME_REQUIRED));
         POLICY_TEST_ITEMS.put(TEST_CHECK_KEYGURAD_UNREDACTED_NOTIFICATION, new PolicyTestItem(
                 R.string.disallow_keyguard_unredacted_notifications_set_step,
                 R.string.disallow_keyguard_unredacted_notifications_action,
                 R.string.disallow_keyguard_unredacted_notifications_widget_label,
                 R.id.switch_widget,
                 CommandReceiverActivity.COMMAND_DISALLOW_KEYGUARD_UNREDACTED_NOTIFICATIONS));
+        POLICY_TEST_ITEMS.put(TEST_CHECK_LOCK_SCREEN_INFO, new PolicyTestItem(
+                R.string.lock_screen_info_set_step,
+                R.string.set_lock_screen_info_action,
+                R.string.set_lock_screen_info_widget_label,
+                R.id.edit_text_widget,
+                CommandReceiverActivity.COMMAND_SET_LOCK_SCREEN_INFO));
         POLICY_TEST_ITEMS.put(TEST_CHECK_MAXIMUM_TIME_TO_LOCK, new PolicyTestItem(
                 R.string.maximum_time_to_lock_set_step,
                 R.string.set_maximum_time_to_lock_action,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
index e613bf3..88f4f18 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
@@ -44,21 +44,27 @@
     private static final Pair<Intent, Integer>[] POLICIES;
     static {
         final String[] policyTests = new String[] {
+            PolicyTransparencyTestActivity.TEST_CHECK_AUTO_TIME_REQUIRED,
             PolicyTransparencyTestActivity.TEST_CHECK_KEYGURAD_UNREDACTED_NOTIFICATION,
+            PolicyTransparencyTestActivity.TEST_CHECK_LOCK_SCREEN_INFO,
             PolicyTransparencyTestActivity.TEST_CHECK_MAXIMUM_TIME_TO_LOCK,
             PolicyTransparencyTestActivity.TEST_CHECK_PASSWORD_QUALITY,
             PolicyTransparencyTestActivity.TEST_CHECK_PERMITTED_ACCESSIBILITY_SERVICE,
             PolicyTransparencyTestActivity.TEST_CHECK_PERMITTED_INPUT_METHOD
         };
         final String[] settingsIntentActions = new String[] {
+            Settings.ACTION_DATE_SETTINGS,
             Settings.ACTION_SETTINGS,
+            Settings.ACTION_SECURITY_SETTINGS,
             Settings.ACTION_DISPLAY_SETTINGS,
             DevicePolicyManager.ACTION_SET_NEW_PASSWORD,
             Settings.ACTION_ACCESSIBILITY_SETTINGS,
             Settings.ACTION_INPUT_METHOD_SETTINGS
         };
         final int[] policyLabels = new int[] {
+            R.string.set_auto_time_required,
             R.string.disallow_keyguard_unredacted_notifications,
+            R.string.set_lock_screen_info,
             R.string.set_maximum_time_to_lock,
             R.string.set_password_quality,
             R.string.set_permitted_accessibility_services,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
index 7db1cd9..06d0381 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
@@ -31,10 +31,21 @@
         UserManager.DISALLOW_ADD_USER,
         UserManager.DISALLOW_ADJUST_VOLUME,
         UserManager.DISALLOW_APPS_CONTROL,
+        UserManager.DISALLOW_CONFIG_CELL_BROADCASTS,
+        UserManager.DISALLOW_CONFIG_CREDENTIALS,
+        UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
+        UserManager.DISALLOW_CONFIG_TETHERING,
         UserManager.DISALLOW_CONFIG_WIFI,
+        UserManager.DISALLOW_DEBUGGING_FEATURES,
+        UserManager.DISALLOW_FACTORY_RESET,
         UserManager.DISALLOW_FUN,
+        UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
         UserManager.DISALLOW_MODIFY_ACCOUNTS,
-        UserManager.DISALLOW_SHARE_LOCATION
+        UserManager.DISALLOW_NETWORK_RESET,
+        UserManager.DISALLOW_OUTGOING_BEAM,
+        UserManager.DISALLOW_REMOVE_USER,
+        UserManager.DISALLOW_SHARE_LOCATION,
+        UserManager.DISALLOW_UNINSTALL_APPS
     };
 
     private static final ArrayMap<String, UserRestrictionItem> USER_RESTRICTION_ITEMS;
@@ -43,30 +54,63 @@
             R.string.disallow_add_user,
             R.string.disallow_adjust_volume,
             R.string.disallow_apps_control,
+            R.string.disallow_config_cell_broadcasts,
+            R.string.disallow_config_credentials,
+            R.string.disallow_config_mobile_networks,
+            R.string.disallow_config_tethering,
             R.string.disallow_config_wifi,
+            R.string.disallow_debugging_features,
+            R.string.disallow_factory_reset,
             R.string.disallow_fun,
+            R.string.disallow_install_unknown_sources,
             R.string.disallow_modify_accounts,
+            R.string.disallow_network_reset,
+            R.string.disallow_outgoing_beam,
+            R.string.disallow_remove_user,
             R.string.disallow_share_location,
+            R.string.disallow_uninstall_apps
         };
 
         final int[] restrictionActions = new int[] {
             R.string.disallow_add_user_action,
             R.string.disallow_adjust_volume_action,
             R.string.disallow_apps_control_action,
+            R.string.disallow_config_cell_broadcasts_action,
+            R.string.disallow_config_credentials_action,
+            R.string.disallow_config_mobile_networks_action,
+            R.string.disallow_config_tethering_action,
             R.string.disallow_config_wifi_action,
+            R.string.disallow_debugging_features_action,
+            R.string.disallow_factory_reset_action,
             R.string.disallow_fun_action,
+            R.string.disallow_install_unknown_sources_action,
             R.string.disallow_modify_accounts_action,
-            R.string.disallow_share_location_action
+            R.string.disallow_network_reset_action,
+            R.string.disallow_outgoing_beam_action,
+            R.string.disallow_remove_user_action,
+            R.string.disallow_share_location_action,
+            R.string.disallow_uninstall_apps_action
         };
 
         final String[] settingsIntentActions = new String[] {
             Settings.ACTION_SETTINGS,
             Settings.ACTION_SOUND_SETTINGS,
             Settings.ACTION_APPLICATION_SETTINGS,
+            Settings.ACTION_SOUND_SETTINGS,
+            Settings.ACTION_SECURITY_SETTINGS,
+            Settings.ACTION_WIRELESS_SETTINGS,
+            Settings.ACTION_WIRELESS_SETTINGS,
             Settings.ACTION_WIFI_SETTINGS,
             Settings.ACTION_DEVICE_INFO_SETTINGS,
+            Settings.ACTION_PRIVACY_SETTINGS,
+            Settings.ACTION_DEVICE_INFO_SETTINGS,
+            Settings.ACTION_SECURITY_SETTINGS,
             Settings.ACTION_SYNC_SETTINGS,
-            Settings.ACTION_LOCATION_SOURCE_SETTINGS
+            Settings.ACTION_PRIVACY_SETTINGS,
+            Settings.ACTION_WIRELESS_SETTINGS,
+            Settings.ACTION_SETTINGS,
+            Settings.ACTION_LOCATION_SOURCE_SETTINGS,
+            Settings.ACTION_APPLICATION_SETTINGS,
         };
 
         if (RESTRICTION_IDS.length != restrictionLabels.length
@@ -88,6 +132,7 @@
             new ArrayList<String>();
     static {
         ALSO_VALID_FOR_PO.add(UserManager.DISALLOW_APPS_CONTROL);
+        ALSO_VALID_FOR_PO.add(UserManager.DISALLOW_UNINSTALL_APPS);
         ALSO_VALID_FOR_PO.add(UserManager.DISALLOW_MODIFY_ACCOUNTS);
         ALSO_VALID_FOR_PO.add(UserManager.DISALLOW_SHARE_LOCATION);
     }
diff --git a/common/host-side/tradefed/res/config/common-compatibility-config.xml b/common/host-side/tradefed/res/config/common-compatibility-config.xml
index 5bac748..6a654ea 100644
--- a/common/host-side/tradefed/res/config/common-compatibility-config.xml
+++ b/common/host-side/tradefed/res/config/common-compatibility-config.xml
@@ -19,6 +19,5 @@
     <build_provider class="com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider" />
     <test class="com.android.compatibility.common.tradefed.testtype.CompatibilityTest" />
     <logger class="com.android.tradefed.log.FileLogger" />
-    <result_reporter class="com.android.compatibility.common.tradefed.result.ResultReporter" />
-
+    <template-include name="reporters" default="basic-reporters" />
 </configuration>
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
index 65f60bd..7f84a3a 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
@@ -18,21 +18,29 @@
 import com.android.tradefed.build.BuildInfo;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.build.IBuildProvider;
+import com.android.tradefed.config.Option;
 import com.android.tradefed.config.OptionClass;
-
 /**
  * A simple {@link IBuildProvider} that uses a pre-existing Compatibility install.
  */
 @OptionClass(alias="compatibility-build-provider")
 public class CompatibilityBuildProvider implements IBuildProvider {
 
+    @Option(name="branch", description="build branch name to supply.")
+    private String mBranch = null;
+
     /**
      * {@inheritDoc}
      */
     @Override
     public IBuildInfo getBuild() {
         // Create a blank BuildInfo which will get populated later.
-        return new BuildInfo();
+        IBuildInfo ctsBuild = new BuildInfo();
+        if (mBranch  != null) {
+            ctsBuild.setBuildBranch(mBranch);
+        }
+
+        return ctsBuild;
     }
 
     /**
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
index 8e48cdb..5186b29 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
@@ -342,7 +342,12 @@
                     }
                 }
                 if (mResultServer != null && !mResultServer.trim().isEmpty()) {
-                    mUploader.uploadResult(resultFile, mReferenceUrl);
+                    try {
+                        logResult("Result Server Response: %d",
+                                mUploader.uploadResult(resultFile, mReferenceUrl));
+                    } catch (IOException ioe) {
+                        Log.e(mDeviceSerial, ioe);
+                    }
                 }
             } catch (IOException | XmlPullParserException e) {
                 CLog.e(e);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
index fabc4e1..1a4be53 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
@@ -51,16 +51,19 @@
 
     private static final String LOG_TAG = DynamicConfigPusher.class.getSimpleName();
 
-    @Option(name = "cleanup", description = "Whether to clean up config files after test is done.")
+    @Option(name = "cleanup", description = "Whether to remove config files from the test " +
+            "target after test completion.")
     private boolean mCleanup = true;
 
-    @Option(name="module-name", description = "Specify the module name")
+    @Option(name="config-filename", description = "The module name for module-level " +
+            "configurations, or the suite name for suite-level configurations")
     private String mModuleName;
 
-    @Option(name = "target", description = "Specify the target, 'device' or 'host'")
+    @Option(name = "target", description = "The test target, \"device\" or \"host\"")
     private TestTarget mTarget;
 
-    @Option(name = "version-name", description = "Specify the version for override config")
+    @Option(name = "version", description = "The version of the configuration to retrieve " +
+            "from the server, e.g. \"1\"")
     private static String mVersion;
 
 
@@ -93,16 +96,16 @@
         if (originUrl != null) {
             try {
                 String requestUrl = originUrl
-                        .replace("{module-name}", mModuleName).replace("{version-name}", mVersion);
+                        .replace("{module}", mModuleName).replace("{version}", mVersion);
                 java.net.URL request = new URL(requestUrl);
                 apfeConfigInJson = StreamUtil.getStringFromStream(request.openStream());
             } catch (IOException e) {
                 LogUtil.printLog(Log.LogLevel.WARN, LOG_TAG,
-                        "Cannot download and parse json config from Url");
+                        "Cannot download and parse json config from URL");
             }
         } else {
             LogUtil.printLog(Log.LogLevel.INFO, LOG_TAG,
-                    "Dynamic config override Url is not set");
+                    "Dynamic config override URL is not set, using local configuration values");
         }
 
         File src = null;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index 17ce7e8..6d0aa69 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -166,6 +166,10 @@
             description = "Take a screenshot on every test failure.")
     private boolean mScreenshotOnFailure = false;
 
+    @Option(name = "reboot-on-failure",
+            description = "Reboot the device after every test failure.")
+    private boolean mRebootOnFailure = false;
+
     private int mTotalShards;
     private ITestDevice mDevice;
     private IBuildInfo mBuild;
@@ -242,7 +246,7 @@
             List<IModuleDef> modules = moduleRepo.getModules(getDevice().getSerialNumber());
 
             listener = new FailureListener(listener, getDevice(), mBugReportOnFailure,
-                    mLogcatOnFailure, mScreenshotOnFailure);
+                    mLogcatOnFailure, mScreenshotOnFailure, mRebootOnFailure);
             int moduleCount = modules.size();
             CLog.logAndDisplay(LogLevel.INFO, "Starting %d module%s on %s", moduleCount,
                     (moduleCount > 1) ? "s" : "", mDevice.getSerialNumber());
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
index c3509d1..5d2cd38 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
@@ -33,14 +33,17 @@
     private boolean mBugReportOnFailure;
     private boolean mLogcatOnFailure;
     private boolean mScreenshotOnFailure;
+    private boolean mRebootOnFailure;
 
     public FailureListener(ITestInvocationListener listener, ITestDevice device,
-            boolean bugReportOnFailure, boolean logcatOnFailure, boolean screenshotOnFailure) {
+            boolean bugReportOnFailure, boolean logcatOnFailure, boolean screenshotOnFailure,
+            boolean rebootOnFailure) {
         super(listener);
         mDevice = device;
         mBugReportOnFailure = bugReportOnFailure;
         mLogcatOnFailure = logcatOnFailure;
         mScreenshotOnFailure = screenshotOnFailure;
+        mRebootOnFailure = rebootOnFailure;
     }
 
     /**
@@ -76,6 +79,22 @@
                         mDevice.getSerialNumber());
             }
         }
+        if (mRebootOnFailure) {
+            try {
+                // Rebooting on all failures can hide legitimate issues and platform instabilities,
+                // therefore only allowed on "user-debug" and "eng" builds.
+                if ("user".equals(mDevice.getProperty("ro.build.type"))) {
+                    CLog.e("Reboot-on-failure should only be used during development," +
+                            " this is a\" user\" build device");
+                } else {
+                    mDevice.reboot();
+                }
+            } catch (DeviceNotAvailableException e) {
+                CLog.e(e);
+                CLog.e("Device %s became unavailable while rebooting",
+                        mDevice.getSerialNumber());
+            }
+        }
     }
 
 }
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
index b438dff..89d8754 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
@@ -222,6 +222,10 @@
         addFilters(excludeFilters, mExcludeFilters, abis);
 
         File[] configFiles = testsDir.listFiles(new ConfigFilter());
+        if (configFiles.length == 0) {
+            throw new IllegalArgumentException(
+                    String.format("No config files found in %s", testsDir.getAbsolutePath()));
+        }
         for (File configFile : configFiles) {
             final String name = configFile.getName().replace(CONFIG_EXT, "");
             final String[] pathArg = new String[] { configFile.getAbsolutePath() };
@@ -382,6 +386,7 @@
          */
         @Override
         public boolean accept(File dir, String name) {
+            CLog.d(String.format("%s/%s", dir.getAbsolutePath(), name));
             return name.endsWith(CONFIG_EXT);
         }
     }
@@ -519,7 +524,7 @@
             if (value1 == 0 && value2 == 0) {
                 return (int) Math.signum(def2.getRuntimeHint() - def1.getRuntimeHint());
             }
-            return (int) Math.signum(value2 - value1);
+            return (int) Math.signum(value1 - value2);
         }
     }
 }
diff --git a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java b/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
index 18c5d26..8317203 100644
--- a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
+++ b/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
@@ -35,8 +35,6 @@
  */
 public class DynamicConfig {
 
-    public final static String MODULE_NAME = "module-name";
-
     //XML constant
     public static final String NS = null;
     public static final String CONFIG_TAG = "dynamicConfig";
@@ -57,7 +55,12 @@
     }
 
     public String getValue(String key) {
-        return mDynamicConfigMap.get(key).get(0);
+        List<String> singleValue = mDynamicConfigMap.get(key);
+        if (singleValue == null || singleValue.size() == 0 || singleValue.size() > 1) {
+            // key must exist in the map, and map to a list containing exactly one string
+            return null;
+        }
+        return singleValue.get(0);
     }
 
     public List<String> getValues(String key) {
diff --git a/common/util/src/com/android/compatibility/common/util/MultipartForm.java b/common/util/src/com/android/compatibility/common/util/MultipartForm.java
index 4ae7860..c311492 100644
--- a/common/util/src/com/android/compatibility/common/util/MultipartForm.java
+++ b/common/util/src/com/android/compatibility/common/util/MultipartForm.java
@@ -77,21 +77,19 @@
      *
      * This will handle a redirection from the server.
      *
+     * @return response code
      * @throws IOException
      */
-    public void submit() throws IOException {
-        String redirectUrl = submitForm(mServerUrl);
-        if (redirectUrl != null) {
-            submitForm(redirectUrl);
-        }
+    public int submit() throws IOException {
+        return submitForm(mServerUrl);
     }
 
     /**
      * @param serverUrl to post the data to
-     * @return a url if the server redirected to another url
+     * @return response code
      * @throws IOException
      */
-    private String submitForm(String serverUrl) throws IOException {
+    private int submitForm(String serverUrl) throws IOException {
         HttpURLConnection connection = null;
         try {
             URL url = new URL(serverUrl);
@@ -116,16 +114,16 @@
             InputStream input = connection.getInputStream();
             input.close();
 
-            if (connection.getResponseCode() == 302) {
-                return connection.getHeaderField("Location");
+            int response = connection.getResponseCode();
+            if (response == 302) {
+                return submitForm(connection.getHeaderField("Location"));
             }
+            return response;
         } finally {
             if (connection != null) {
                 connection.disconnect();
             }
         }
-
-        return null;
     }
 
     /* package */ byte[] getContentBody() throws IOException {
diff --git a/common/util/src/com/android/compatibility/common/util/ResultUploader.java b/common/util/src/com/android/compatibility/common/util/ResultUploader.java
index ff8d156..e279333 100644
--- a/common/util/src/com/android/compatibility/common/util/ResultUploader.java
+++ b/common/util/src/com/android/compatibility/common/util/ResultUploader.java
@@ -44,15 +44,15 @@
      * @param referenceUrl A reference url to use.
      * @throws IOException
      */
-    public void uploadResult(File reportFile, String referenceUrl) throws IOException {
+    public int uploadResult(File reportFile, String referenceUrl) throws IOException {
         InputStream input = new FileInputStream(reportFile);
         try {
             byte[] data = getBytes(input);
-            mMultipartForm.addFormFile("result-xml", "test-result.xml.gz", data);
+            mMultipartForm.addFormFile("resultXml", "test-result.xml.gz", data);
             if (referenceUrl == null || referenceUrl.trim().isEmpty()) {
                 mMultipartForm.addFormValue("reference-url", referenceUrl);
             }
-            mMultipartForm.submit();
+            return mMultipartForm.submit();
         } finally {
             input.close();
         }
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
index 30b32e1..e93d5c7 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
@@ -37,6 +37,7 @@
 import java.io.OutputStream;
 
 import android.app.Activity;
+import android.app.Instrumentation;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
@@ -47,6 +48,8 @@
 import android.net.Uri;
 import android.os.Environment;
 import android.os.SystemClock;
+import android.os.storage.StorageManager;
+import android.os.storage.StorageVolume;
 import android.provider.DocumentsContract;
 import android.provider.DocumentsContract.Document;
 import android.provider.DocumentsProvider;
@@ -375,11 +378,12 @@
     public void testOpenExternalDirectory_invalidPath() throws Exception {
         if (!supportedHardware()) return;
 
-        final String externalRoot = getExternalStorageDirectory().getPath();
-        openExternalDirectoryInvalidPath("");
-        openExternalDirectoryInvalidPath("/dev/null");
-        openExternalDirectoryInvalidPath(externalRoot + "/../");
-        openExternalDirectoryInvalidPath(externalRoot + "/HiddenStuff");
+        for (StorageVolume volume : getVolumes()) {
+            openExternalDirectoryInvalidPath(volume, "");
+            openExternalDirectoryInvalidPath(volume, "/dev/null");
+            openExternalDirectoryInvalidPath(volume, "/../");
+            openExternalDirectoryInvalidPath(volume, "/HiddenStuff");
+        }
     }
 
     public void testOpenExternalDirectory_userRejects() throws Exception {
@@ -387,17 +391,19 @@
 
         final String externalRoot = getExternalStorageDirectory().getPath();
 
+        final StorageVolume primaryVolume = getPrimaryVolume();
+
         // Tests user clicking DENY button, for all valid directories.
         for (String directory : STANDARD_DIRECTORIES) {
             final Uri uri = Uri.fromFile(new File(externalRoot, directory));
 
-            final UiAlertDialog dialog = openExternalDirectoryValidPath(uri);
+            final UiAlertDialog dialog = openExternalDirectoryValidPath(primaryVolume, directory);
             dialog.noButton.click();
             assertActivityFailed();
         }
 
         // Also test user clicking back button - one directory is enough.
-        openExternalDirectoryValidPath(Uri.fromFile(new File(externalRoot, DIRECTORY_PICTURES)));
+        openExternalDirectoryValidPath(primaryVolume, DIRECTORY_PICTURES);
         mDevice.pressBack();
         assertActivityFailed();
     }
@@ -406,18 +412,14 @@
         if (!supportedHardware())
             return;
 
-        // TODO: once there is an API to get all volumes, use a for loop to call method below
-        // to all of them (rather than hard-coding).
-        userAcceptsOpenExternalDirectoryTest(getExternalStorageDirectory().getPath(),
-                "Internal storage");
+        for (StorageVolume volume : getVolumes()) {
+            userAcceptsOpenExternalDirectoryTest(volume);
+        }
     }
 
-    private void userAcceptsOpenExternalDirectoryTest(String rootPath, String rootDescription)
-            throws Exception {
-        final Uri requestedUri = Uri.fromFile(new File(rootPath, DIRECTORY_PICTURES));
-
+    private void userAcceptsOpenExternalDirectoryTest(StorageVolume volume) throws Exception {
         // Asserts dialog contain the proper message.
-        final UiAlertDialog dialog = openExternalDirectoryValidPath(requestedUri);
+        final UiAlertDialog dialog = openExternalDirectoryValidPath(volume, DIRECTORY_PICTURES);
         final String message = dialog.messageText.getText();
         Log.v(TAG, "request permission message: " + message);
         final Context context = getInstrumentation().getTargetContext();
@@ -425,7 +427,7 @@
                 context.getApplicationInfo()).toString();
         assertContainsRegex("missing app label", appLabel, message);
         assertContainsRegex("missing folder", DIRECTORY_PICTURES, message);
-        assertContainsRegex("missing root", rootDescription, message);
+        assertContainsRegex("missing root", volume.getDescription(context), message);
 
         // Call API...
         dialog.yesButton.click();
@@ -671,23 +673,37 @@
         return result.data;
     }
 
-    private void openExternalDirectoryInvalidPath(String path) {
-        sendOpenExternalDirectoryIntent(Uri.fromFile(new File(path)));
+    private void openExternalDirectoryInvalidPath(StorageVolume volume, String path) {
+        sendOpenExternalDirectoryIntent(volume, path);
         assertActivityFailed();
     }
 
-    private UiAlertDialog openExternalDirectoryValidPath(Uri uri) throws UiObjectNotFoundException {
-        sendOpenExternalDirectoryIntent(uri);
+    private UiAlertDialog openExternalDirectoryValidPath(StorageVolume volume, String path)
+            throws UiObjectNotFoundException {
+        sendOpenExternalDirectoryIntent(volume, path);
         return new UiAlertDialog();
     }
 
-    private void sendOpenExternalDirectoryIntent(Uri uri) {
-        final Intent intent = new Intent(Intent.ACTION_OPEN_EXTERNAL_DIRECTORY);
-        intent.setData(uri);
+    private void sendOpenExternalDirectoryIntent(StorageVolume volume, String directoryName) {
+        final Intent intent = volume.createAccessIntent(directoryName);
         mActivity.startActivityForResult(intent, REQUEST_CODE);
         mDevice.waitForIdle();
     }
 
+    private StorageVolume[] getVolumes() {
+        final StorageManager sm = (StorageManager)
+                getInstrumentation().getTargetContext().getSystemService(Context.STORAGE_SERVICE);
+        final StorageVolume[] volumes = sm.getVolumeList();
+        assertTrue("empty volumes", volumes.length > 0);
+        return volumes;
+    }
+
+    private StorageVolume getPrimaryVolume() {
+        final StorageManager sm = (StorageManager)
+                getInstrumentation().getTargetContext().getSystemService(Context.STORAGE_SERVICE);
+        return sm.getPrimaryVolume();
+    }
+
     private final class UiAlertDialog {
         final UiObject messageText;
         final UiObject yesButton;
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ContactsTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ContactsTest.java
index 3d64d47..0c4e74c 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ContactsTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ContactsTest.java
@@ -259,9 +259,7 @@
         assertManagedLocalContact(contactInfo);
         contactInfo.assertPhotoUrisReadable();
         assertFalse(contactInfo.hasPhotoId());
-
-        // Quirk: the _id column from the SIP lookup is actually of the data id, not the contact id.
-        // assertTrue(isEnterpriseContactId(contactInfo.contactId));
+        assertTrue(isEnterpriseContactId(contactInfo.contactId));
     }
 
     public void testPrimaryProfileEnterpriseEmailLookup_canAccessEnterpriseContact()
@@ -1093,12 +1091,32 @@
         contactInfo.assertPhotoUri(R.raw.managed_photo);
     }
 
+    private void assertContactInfoEquals(ContactInfo lhs, ContactInfo rhs) {
+        if (lhs == null) {
+            assertNull(rhs);
+        } else {
+            assertNotNull(rhs);
+            assertEquals(lhs.contactId, rhs.contactId);
+            assertEquals(lhs.displayName, rhs.displayName);
+            assertEquals(lhs.photoId, rhs.photoId);
+            assertEquals(lhs.photoThumbnailUri, rhs.photoThumbnailUri);
+            assertEquals(lhs.photoUri, rhs.photoUri);
+        }
+    }
+
     private ContactInfo getContactInfoFromPhoneLookupUri(boolean isEnterprise, String phoneNumber) {
         Uri baseUri = (isEnterprise) ? PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI
                 : PhoneLookup.CONTENT_FILTER_URI;
         Uri uri = baseUri.buildUpon().appendPath(phoneNumber).build();
-        return getContactInfoFromUri(uri, PhoneLookup._ID, PhoneLookup.DISPLAY_NAME,
+        ContactInfo contactInfo = getContactInfoFromUri(uri, PhoneLookup._ID,
+                PhoneLookup.DISPLAY_NAME,
                 PhoneLookup.PHOTO_URI, PhoneLookup.PHOTO_THUMBNAIL_URI, PhoneLookup.PHOTO_ID);
+
+        ContactInfo contactInfo2 = getContactInfoFromUri(uri, PhoneLookup.CONTACT_ID,
+                PhoneLookup.DISPLAY_NAME,
+                PhoneLookup.PHOTO_URI, PhoneLookup.PHOTO_THUMBNAIL_URI, PhoneLookup.PHOTO_ID);
+        assertContactInfoEquals(contactInfo, contactInfo2);
+        return contactInfo;
     }
 
     private ContactInfo getContactInfoFromEnterprisePhoneLookupUriWithSipAddress(
@@ -1107,7 +1125,7 @@
                 : PhoneLookup.CONTENT_FILTER_URI;
         Uri uri = baseUri.buildUpon().appendPath(sipAddress)
                 .appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1").build();
-        return getContactInfoFromUri(uri, PhoneLookup._ID, PhoneLookup.DISPLAY_NAME,
+        return getContactInfoFromUri(uri, PhoneLookup.CONTACT_ID, PhoneLookup.DISPLAY_NAME,
                 PhoneLookup.PHOTO_URI, PhoneLookup.PHOTO_THUMBNAIL_URI, PhoneLookup.PHOTO_ID);
     }
 
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
index 667afcb..63f2309 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
@@ -20,6 +20,7 @@
 import android.app.Instrumentation;
 import android.content.ComponentName;
 import android.content.Context;
+import android.content.Intent;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.net.Uri;
@@ -81,11 +82,19 @@
         super.tearDown();
     }
 
+    public void testOutgoingCallUsingTelecomManager() throws Exception {
+        internalTestOutgoingCall(true /* usingTelecomManager */);
+    }
+
+    public void testOutgoingCallUsingActionCall() throws Exception {
+        internalTestOutgoingCall(false /* usingTelecomManager */);
+    }
+
     /**
      *  Placing an outgoing call through our phone account and verify the call is inserted
      *  properly.
      */
-    public void testOutgoingCall() throws Exception {
+    private void internalTestOutgoingCall(boolean usingTelecomManager) throws Exception {
         // Make sure no lingering values from previous runs.
         cleanupCall(false);
         final Context context = getInstrumentation().getContext();
@@ -102,10 +111,11 @@
                             countDownLatch));
 
             // Place the call.
-            Uri phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, PHONE_NUMBER, null);
-            Bundle extras = new Bundle();
-            extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
-            mTelecomManager.placeCall(phoneUri, extras);
+            if (usingTelecomManager) {
+                placeCallUsingTelecomManager(phoneAccountHandle);
+            } else {
+                placeCallUsingActionCall(phoneAccountHandle);
+            }
 
             // Make sure the call inserted is correct.
             boolean calllogProviderChanged = countDownLatch.await(1, TimeUnit.MINUTES);
@@ -118,6 +128,21 @@
         }
     }
 
+    private void placeCallUsingTelecomManager(PhoneAccountHandle phoneAccountHandle) {
+        Uri phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, PHONE_NUMBER, null);
+        Bundle extras = new Bundle();
+        extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
+        mTelecomManager.placeCall(phoneUri, extras);
+    }
+
+    private void placeCallUsingActionCall(PhoneAccountHandle phoneAccountHandle) {
+        Intent intent = new Intent(Intent.ACTION_CALL);
+        intent.setData(Uri.parse("tel:" + PHONE_NUMBER));
+        intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(intent);
+    }
+
     /**
      *  Add an incoming call with our phone account and verify the call is inserted properly.
      */
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index 5d1198c..7a0e86a 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -629,10 +629,20 @@
         if (!mHasFeature) {
             return;
         }
-        // Place a outgoing call through work phone account and verify the call is inserted
-        // properly.
+        // Place a outgoing call through work phone account using TelecomManager and verify the
+        // call is inserted properly.
         assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
-                "testOutgoingCall",
+                "testOutgoingCallUsingTelecomManager",
+                mProfileUserId));
+        // Make sure the call is not inserted into parent user.
+        assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
+                "testEnsureCallNotInserted",
+                mParentUserId));
+
+        // Place a outgoing call through work phone account using ACTION_CALL and verify the call
+        // is inserted properly.
+        assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
+                "testOutgoingCallUsingActionCall",
                 mProfileUserId));
         // Make sure the call is not inserted into parent user.
         assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
diff --git a/hostsidetests/vm/Android.mk b/hostsidetests/vm/Android.mk
new file mode 100644
index 0000000..dee1364
--- /dev/null
+++ b/hostsidetests/vm/Android.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed_v2 compatibility-host-util tradefed-prebuilt
+
+LOCAL_STATIC_JAVA_LIBRARIES := cts-migration-lib
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_MODULE := CtsVmHostTestCases
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/vm/AndroidTest.xml b/hostsidetests/vm/AndroidTest.xml
new file mode 100644
index 0000000..35db3ad
--- /dev/null
+++ b/hostsidetests/vm/AndroidTest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS VM test cases">
+    <target_preparer class="android.core.vm.targetprep.VmTestPreparer" />
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="android.core.vm-tests-tf.jar" />
+    </test>
+</configuration>
diff --git a/hostsidetests/vm/targetprep/Android.mk b/hostsidetests/vm/targetprep/Android.mk
new file mode 100644
index 0000000..18c2dea
--- /dev/null
+++ b/hostsidetests/vm/targetprep/Android.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_JAVA_LIBRARIES := compatibility-host-util cts-tradefed_v2 tradefed-prebuilt
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := compatibility-host-vm-targetprep
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/vm/targetprep/src/android/core/vm/targetprep/VmTestPreparer.java b/hostsidetests/vm/targetprep/src/android/core/vm/targetprep/VmTestPreparer.java
new file mode 100644
index 0000000..d46e330
--- /dev/null
+++ b/hostsidetests/vm/targetprep/src/android/core/vm/targetprep/VmTestPreparer.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.core.vm.targetprep;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.targetprep.BuildError;
+import com.android.tradefed.targetprep.ITargetCleaner;
+import com.android.tradefed.targetprep.TargetSetupError;
+import com.android.tradefed.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.zip.ZipFile;
+
+/**
+ * Configures the device to run VM tests.
+ */
+@OptionClass(alias="vm-test-preparer")
+public class VmTestPreparer implements ITargetCleaner {
+
+    private static final String JAR_FILE = "android.core.vm-tests-tf.jar";
+    private static final String TEMP_DIR = "/data/local/tmp";
+    private static final String VM_TEMP_DIR = TEMP_DIR +"/vm-tests";
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setUp(ITestDevice device, IBuildInfo buildInfo)
+            throws TargetSetupError, BuildError, DeviceNotAvailableException {
+        CompatibilityBuildHelper helper = new CompatibilityBuildHelper(buildInfo);
+        if (!installVmPrereqs(device, helper)) {
+            throw new RuntimeException(String.format(
+                    "Failed to install vm-tests prereqs on device %s",
+                    device.getSerialNumber()));
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
+            throws DeviceNotAvailableException {
+        cleanupDeviceFiles(device);
+    }
+
+    /**
+     * Install pre-requisite jars for running vm-tests, creates temp directories for test.
+     *
+     * @param device the {@link ITestDevice}
+     * @param ctsBuild the {@link CompatibilityBuildHelper}
+     * @throws DeviceNotAvailableException
+     * @return true if test jar files are extracted and pushed to device successfully
+     */
+    private boolean installVmPrereqs(ITestDevice device, CompatibilityBuildHelper ctsBuild)
+            throws DeviceNotAvailableException {
+        cleanupDeviceFiles(device);
+        // Creates temp directory recursively. We also need to create the dalvik-cache directory
+        // which is used by the dalvikvm to optimize things. Without the dalvik-cache, there will be
+        // a sigsev thrown by the vm.
+        createRemoteDir(device, VM_TEMP_DIR + "/dalvik-cache" );
+        try {
+            File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+            File localTmpDir = FileUtil.createTempDir("cts-vm", tmpDir);
+            File jarFile = new File(ctsBuild.getTestsDir(), JAR_FILE);
+            if (!jarFile.exists()) {
+                CLog.e("Missing jar file %s", jarFile.getPath());
+                return false;
+            }
+            ZipFile zipFile = new ZipFile(jarFile);
+            FileUtil.extractZip(zipFile, localTmpDir);
+            File localTestTmpDir = new File(localTmpDir, "tests");
+            if (!device.pushDir(localTestTmpDir, VM_TEMP_DIR)) {
+                CLog.e("Failed to push vm test files");
+                return false;
+            }
+            FileUtil.recursiveDelete(localTmpDir);
+        } catch (IOException e) {
+            CLog.e("Failed to extract jar file %s and sync it to device %s.",
+                    JAR_FILE, device.getSerialNumber());
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Removes temporary file directory from device
+     *
+     * @param device
+     * @throws DeviceNotAvailableException
+     */
+    private void cleanupDeviceFiles(ITestDevice device) throws DeviceNotAvailableException {
+        if (device.doesFileExist(VM_TEMP_DIR)) {
+            device.executeShellCommand(String.format("rm -r %s", VM_TEMP_DIR));
+        }
+    }
+
+    /**
+     * Creates the file directory recursively in the device.
+     *
+     * @param device the {@link ITestDevice}
+     * @param remoteFilePath the absolute path.
+     * @throws DeviceNotAvailableException
+     */
+    private void createRemoteDir(ITestDevice device, String remoteFilePath)
+            throws DeviceNotAvailableException {
+        if (device.doesFileExist(remoteFilePath)) {
+            return;
+        }
+        if (!(device.doesFileExist(TEMP_DIR))) {
+            CLog.e("Error: %s does not exist", TEMP_DIR);
+        }
+        device.executeShellCommand(String.format("mkdir %s", VM_TEMP_DIR));
+        device.executeShellCommand(String.format("mkdir %s", remoteFilePath));
+    }
+}
\ No newline at end of file
diff --git a/tests/accessibilityservice/AndroidManifest.xml b/tests/accessibilityservice/AndroidManifest.xml
index 41e13ee..43a7baf 100644
--- a/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/accessibilityservice/AndroidManifest.xml
@@ -44,23 +44,38 @@
       <activity android:label="Full screen activity for gesture dispatch testing"
               android:name=".AccessibilityGestureDispatchTest$GestureDispatchActivity"/>
 
-        <service
-                android:name="android.accessibilityservice.cts.StubGestureAccessibilityService"
-                android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
-            <intent-filter>
-                <action android:name="android.accessibilityservice.AccessibilityService" />
+      <service
+              android:name="android.accessibilityservice.cts.StubGestureAccessibilityService"
+              android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
+          <intent-filter>
+              <action android:name="android.accessibilityservice.AccessibilityService" />
 
-                <category android:name="android.accessibilityservice.category.FEEDBACK_GENERIC" />
-            </intent-filter>
+              <category android:name="android.accessibilityservice.category.FEEDBACK_GENERIC" />
+          </intent-filter>
 
-            <meta-data
-                    android:name="android.accessibilityservice"
-                    android:resource="@xml/stub_gesture_a11y_service" />
-        </service>
+          <meta-data
+                  android:name="android.accessibilityservice"
+                  android:resource="@xml/stub_gesture_a11y_service" />
+      </service>
+
+      <activity android:label="@string/accessibility_soft_keyboard_modes_activity"
+              android:name=".AccessibilitySoftKeyboardModesTest$SoftKeyboardModesActivity"
+              android:windowSoftInputMode="stateAlwaysVisible" />
+
+      <service android:name=".StubSoftKeyboardModesAccessibilityService"
+               android:label="@string/title_soft_keyboard_modes_accessibility_service"
+               android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
+          <intent-filter>
+              <action android:name="android.accessibilityservice.AccessibilityService"/>
+              <category android:name="android.accessibilityservice.category.FEEDBACK_GENERIC" />
+          </intent-filter>
+          <meta-data android:name="android.accessibilityservice"
+                    android:resource="@xml/stub_soft_keyboard_modes_accessibility_service" />
+      </service>
 
     </application>
 
-  <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
                    android:targetPackage="android.accessibilityservice.cts"
                    android:label="Tests for the accessibility APIs.">
         <meta-data android:name="listener"
diff --git a/tests/accessibilityservice/AndroidTest.xml b/tests/accessibilityservice/AndroidTest.xml
index db2707d..1287524 100644
--- a/tests/accessibilityservice/AndroidTest.xml
+++ b/tests/accessibilityservice/AndroidTest.xml
@@ -21,4 +21,4 @@
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="android.accessibilityservice.cts" />
     </test>
-</configuration>
\ No newline at end of file
+</configuration>
diff --git a/tests/accessibilityservice/res/layout/accessibility_soft_keyboard_modes_test.xml b/tests/accessibilityservice/res/layout/accessibility_soft_keyboard_modes_test.xml
new file mode 100644
index 0000000..577a204
--- /dev/null
+++ b/tests/accessibilityservice/res/layout/accessibility_soft_keyboard_modes_test.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<EditText xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/edit_text"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent" />
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/accessibilityservice/res/values/strings.xml
index 89ce1df..1c34c2c 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/accessibilityservice/res/values/strings.xml
@@ -145,5 +145,16 @@
         unveiling\n\n</string>
 
     <string name="full_screen_text_view">Full Screen Text View</string>
+    <!-- Soft Keyboard Modes tests -->
+
+    <!-- String title for the accessibility service -->
+    <string name="accessibility_soft_keyboard_modes_activity">
+        Soft Keyboard Modes Activity</string>
+
+    <string name="title_soft_keyboard_modes_accessibility_service">
+        Stub Soft Keyboard Modes Accessibility Service</string>
+
+    <!-- Description of the accessibility service -->
+    <string name="soft_keyboard_modes_accessibility_service_description">This Accessibility Service was installed for testing purposes. It can be uninstalled by going to Settings > Apps > android.view.accessibilityservice.services and selecting \"Uninstall\".</string>
 
 </resources>
diff --git a/tests/accessibilityservice/res/xml/stub_soft_keyboard_modes_accessibility_service.xml b/tests/accessibilityservice/res/xml/stub_soft_keyboard_modes_accessibility_service.xml
new file mode 100644
index 0000000..b5f9ede
--- /dev/null
+++ b/tests/accessibilityservice/res/xml/stub_soft_keyboard_modes_accessibility_service.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
+    android:accessibilityEventTypes="typeAllMask"
+    android:accessibilityFeedbackType="feedbackGeneric"
+    android:accessibilityFlags="flagDefault|flagRetrieveInteractiveWindows"
+    android:canRetrieveWindowContent="true"
+    android:description="@string/soft_keyboard_modes_accessibility_service_description" />
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java
new file mode 100644
index 0000000..649df16
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java
@@ -0,0 +1,362 @@
+/**
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.cts;
+
+import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.accessibilityservice.AccessibilityService.SoftKeyboardController;
+import android.app.UiAutomation;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.text.Selection;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import android.accessibilityservice.cts.R;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Test cases for testing the accessibility APIs for interacting with the soft keyboard show mode.
+ */
+public class AccessibilitySoftKeyboardModesTest extends ActivityInstrumentationTestCase2
+        <AccessibilitySoftKeyboardModesTest.SoftKeyboardModesActivity> {
+
+    /**
+     * Timeout in which we are waiting for the system to start the mock
+     * accessibility services.
+     */
+    private static final long TIMEOUT_SERVICE_TOGGLE_MS = 10000;
+
+    private static final long TIMEOUT_PROPAGATE_SETTING = 5000;
+
+    private static final int SHOW_MODE_AUTO = 0;
+    private static final int SHOW_MODE_HIDDEN = 1;
+
+    private int mCallbackCount;
+    private int mLastCallbackValue;
+
+    private Context mContext;
+    private StubSoftKeyboardModesAccessibilityService mService;
+    private SoftKeyboardController mKeyboardController;
+
+    private Object mLock = new Object();
+
+    public AccessibilitySoftKeyboardModesTest() {
+        super(SoftKeyboardModesActivity.class);
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        // If we don't call getActivity(), we get an empty list when requesting the number of
+        // windows on screen.
+        getActivity();
+
+        mContext = getInstrumentation().getContext();
+        UiAutomation uiAutomation;
+        try {
+            uiAutomation = getUiAutomation();
+        } catch (RuntimeException e) {
+            // Clean up UI Automation after other tests as we cannot request UI Automation with
+            // different flags if one already exists.
+            uiAutomation = getInstrumentation().getUiAutomation();
+            uiAutomation.destroy();
+
+            // Try to get UI Automation again.
+            uiAutomation = getUiAutomation();
+        }
+        String command = "pm grant " + mContext.getPackageName()
+                + "android.permission.WRITE_SECURE_SETTINGS";
+        executeShellCommand(uiAutomation, command);
+        uiAutomation.destroy();
+
+        disableAllServices();
+        enableTestService();
+
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        disableAllServices();
+    }
+
+    public void testApiReturnValues_shouldChangeValueOnRequestAndSendCallback() throws Exception {
+        mLastCallbackValue = -1;
+
+        final SoftKeyboardController.OnShowModeChangedListener listener =
+                new SoftKeyboardController.OnShowModeChangedListener() {
+                    @Override
+                    public void onShowModeChanged(SoftKeyboardController controller, int showMode) {
+                        synchronized (mLock) {
+                            mLastCallbackValue = showMode;
+                            mLock.notifyAll();
+                        }
+                    }
+                };
+        mKeyboardController.addOnShowModeChangedListener(listener);
+
+        // The soft keyboard should be in its' default mode.
+        assertEquals(SHOW_MODE_AUTO, mKeyboardController.getShowMode());
+
+        // Set the show mode to SHOW_MODE_HIDDEN.
+        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_HIDDEN));
+
+        // Make sure the mode was changed.
+        assertEquals(SHOW_MODE_HIDDEN, mKeyboardController.getShowMode());
+
+        // Make sure we're getting the callback with the proper value.
+        waitForCallbackValueWithLock(SHOW_MODE_HIDDEN);
+
+        // Make sure we can set the value back to the default.
+        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_AUTO));
+        assertEquals(SHOW_MODE_AUTO, mKeyboardController.getShowMode());
+        waitForCallbackValueWithLock(SHOW_MODE_AUTO);
+
+        // Make sure we can remove our listener.
+        assertTrue(mKeyboardController.removeOnShowModeChangedListener(listener));
+    }
+
+    public void testHideSoftKeyboard_shouldHideAndShowKeyboardOnRequest() throws Exception {
+        // The soft keyboard should be in its' default mode.
+        assertEquals(SHOW_MODE_AUTO, mKeyboardController.getShowMode());
+
+        // Note: This Activity always has a visible keyboard (due to windowSoftInputMode being set
+        // to stateAlwaysVisible).
+        int numWindowsWithIme = mService.getTestWindowsListSize();
+
+        // Request the keyboard be hidden.
+        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_HIDDEN));
+        waitForWindowStateChanged();
+
+        // Make sure the keyboard is hidden.
+        assertEquals(numWindowsWithIme - 1, mService.getTestWindowsListSize());
+
+        // Request the default keyboard mode.
+        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_AUTO));
+        waitForWindowStateChanged();
+
+        // Make sure the keyboard is visible.
+        assertEquals(numWindowsWithIme, mService.getTestWindowsListSize());
+    }
+
+
+    public void testHideSoftKeyboard_shouldHideKeyboardUntilAllServicesDisabled() throws Exception {
+        // The soft keyboard should be in its' default mode.
+        assertEquals(SHOW_MODE_AUTO, mKeyboardController.getShowMode());
+
+        // Note: This Activity always has a visible keyboard (due to windowSoftInputMode being set
+        // to stateAlwaysVisible).
+        int numWindowsWithIme = mService.getTestWindowsListSize();
+
+        // Set the show mode to SHOW_MODE_HIDDEN.
+        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_HIDDEN));
+        waitForWindowStateChanged();
+
+        // Make sure the keyboard is hidden.
+        assertEquals(numWindowsWithIme - 1, mService.getTestWindowsListSize());
+
+        // Make sure we can see the soft keyboard once all Accessibility Services are disabled.
+        disableAllServices();
+        waitForWindowStateChanged();
+
+        // Enable our test service,.
+        enableTestService();
+
+        // See how many windows are present.
+        assertEquals(numWindowsWithIme, mService.getTestWindowsListSize());
+    }
+
+    private synchronized UiAutomation getUiAutomation() {
+        return getInstrumentation()
+                .getUiAutomation(UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES);
+    }
+
+    private void executeShellCommand(UiAutomation uiAutomation, String command) throws Exception {
+        ParcelFileDescriptor fd = uiAutomation.executeShellCommand(command);
+        BufferedReader reader = null;
+        try (InputStream inputStream = new FileInputStream(fd.getFileDescriptor())) {
+            reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+            while (reader.readLine() != null) {
+                // Keep reading.
+            }
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+            fd.close();
+        }
+    }
+
+    private void waitForCallbackValueWithLock(int expectedValue) throws Exception {
+        long timeoutTimeMillis = SystemClock.uptimeMillis() + TIMEOUT_PROPAGATE_SETTING;
+
+        while (SystemClock.uptimeMillis() < timeoutTimeMillis) {
+            synchronized(mLock) {
+                if (mLastCallbackValue == expectedValue) {
+                    return;
+                }
+                try {
+                    mLock.wait(timeoutTimeMillis - SystemClock.uptimeMillis());
+                } catch (InterruptedException e) {
+                    // Wait until timeout.
+                }
+            }
+        }
+
+        throw new IllegalStateException("last callback value <" + mLastCallbackValue
+                + "> does not match expected value < " + expectedValue + ">");
+    }
+
+    private void waitForWindowStateChanged() throws Exception {
+        UiAutomation uiAutomation = getUiAutomation();
+        try {
+            uiAutomation.executeAndWaitForEvent(new Runnable() {
+                @Override
+                public void run() {
+                    // Do nothing.
+                }
+            },
+            new UiAutomation.AccessibilityEventFilter() {
+                @Override
+                public boolean accept (AccessibilityEvent event) {
+                    return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
+                }
+            },
+            TIMEOUT_PROPAGATE_SETTING);
+        } catch (TimeoutException ignored) {
+            // Ignore since the event could have occured before this method was called. There should            // be a check after this method returns to catch incorrect values.
+        } finally {
+            uiAutomation.destroy();
+        }
+    }
+
+    private void disableAllServices() throws Exception {
+        final Object waitLockForA11yOff = new Object();
+        AccessibilityManager manager =
+                (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
+        manager.addAccessibilityStateChangeListener(
+                new AccessibilityManager.AccessibilityStateChangeListener() {
+                    @Override
+                    public void onAccessibilityStateChanged(boolean b) {
+                        synchronized (waitLockForA11yOff) {
+                            waitLockForA11yOff.notifyAll();
+                        }
+                    }
+                });
+        ContentResolver cr = mContext.getContentResolver();
+        UiAutomation uiAutomation = getUiAutomation();
+        executeShellCommand(uiAutomation, "settings put secure "
+                + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES + " null");
+        uiAutomation.destroy();
+        StubSoftKeyboardModesAccessibilityService.sInstance = null;
+        long timeoutTimeMillis = SystemClock.uptimeMillis() + TIMEOUT_SERVICE_TOGGLE_MS;
+        while (SystemClock.uptimeMillis() < timeoutTimeMillis) {
+            synchronized (waitLockForA11yOff) {
+                if (!manager.isEnabled()) {
+                    return;
+                }
+                try {
+                    waitLockForA11yOff.wait(timeoutTimeMillis - SystemClock.uptimeMillis());
+                } catch (InterruptedException e) {
+                    // Ignored; loop again
+                }
+            }
+        }
+        throw new RuntimeException("Unable to turn accessibility off");
+    }
+
+    private void enableTestService() throws Exception {
+        Context context = getInstrumentation().getContext();
+        AccessibilityManager manager =
+                (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+        List<AccessibilityServiceInfo> serviceInfos =
+                manager.getInstalledAccessibilityServiceList();
+        for (int i = 0; i < serviceInfos.size(); i++) {
+            AccessibilityServiceInfo serviceInfo = serviceInfos.get(i);
+            if (context.getString(R.string.soft_keyboard_modes_accessibility_service_description)
+                    .equals(serviceInfo.getDescription())) {
+                ContentResolver cr = context.getContentResolver();
+                UiAutomation uiAutomation = getUiAutomation();
+                String command = "settings put secure "
+                        + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES + " "
+                        + serviceInfo.getId();
+                executeShellCommand(uiAutomation, command);
+                executeShellCommand(uiAutomation, "settings put secure "
+                        + Settings.Secure.ACCESSIBILITY_ENABLED + " 1");
+                uiAutomation.destroy();
+
+                // We have enabled the services of interest and need to wait until they
+                // are instantiated and started (if needed) and the system binds to them.
+                long timeoutTimeMillis = SystemClock.uptimeMillis() + TIMEOUT_SERVICE_TOGGLE_MS;
+                while (SystemClock.uptimeMillis() < timeoutTimeMillis) {
+                    synchronized(
+                            StubSoftKeyboardModesAccessibilityService.sWaitObjectForConnecting) {
+                        if (StubSoftKeyboardModesAccessibilityService.sInstance != null) {
+                            mService = StubSoftKeyboardModesAccessibilityService.sInstance;
+                            mKeyboardController = mService.getTestSoftKeyboardController();
+                            return;
+                        }
+                        try {
+                            StubSoftKeyboardModesAccessibilityService.sWaitObjectForConnecting.wait(
+                                    timeoutTimeMillis - SystemClock.uptimeMillis());
+                        } catch (InterruptedException e) {
+                            // Ignored; loop again
+                        }
+                    }
+                }
+                throw new IllegalStateException("Stub accessibility service not started");
+            }
+        }
+        throw new IllegalStateException("Stub accessiblity service not found");
+    }
+
+    /**
+     * Activity for testing the AccessibilityService API for hiding and showring the soft keyboard.
+     */
+    public static class SoftKeyboardModesActivity extends AccessibilityTestActivity {
+        public SoftKeyboardModesActivity() {
+            super();
+        }
+
+        @Override
+        public void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+            setContentView(R.layout.accessibility_soft_keyboard_modes_test);
+        }
+    }
+}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/StubSoftKeyboardModesAccessibilityService.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/StubSoftKeyboardModesAccessibilityService.java
new file mode 100644
index 0000000..27d51d9
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/StubSoftKeyboardModesAccessibilityService.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.cts;
+
+import android.accessibilityservice.AccessibilityService;
+import android.content.Intent;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityWindowInfo;
+
+/**
+ * Stub accessibility service for testing APIs to show/hide Soft Keyboard.
+ */
+public class StubSoftKeyboardModesAccessibilityService extends AccessibilityService {
+
+    public static Object sWaitObjectForConnecting = new Object();
+
+    public static StubSoftKeyboardModesAccessibilityService sInstance = null;
+
+    @Override
+    protected void onServiceConnected() {
+        synchronized (sWaitObjectForConnecting) {
+            sInstance = this;
+            sWaitObjectForConnecting.notifyAll();
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        sInstance = null;
+        super.onDestroy();
+    }
+
+    @Override
+    public void onAccessibilityEvent(AccessibilityEvent event) {
+        /* do nothing */
+    }
+
+    @Override
+    public void onInterrupt() {
+        /* do nothing */
+    }
+
+    public SoftKeyboardController getTestSoftKeyboardController() {
+        return sInstance.getSoftKeyboardController();
+    }
+
+    public int getTestWindowsListSize() {
+        return sInstance.getWindows().size();
+    }
+}
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index 9da1b25..42a158e 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -17,7 +17,6 @@
 package android.app.cts;
 
 import android.app.Notification;
-import android.app.Notification.Topic;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
@@ -26,9 +25,6 @@
 import android.test.AndroidTestCase;
 import android.widget.RemoteViews;
 
-import java.util.Arrays;
-import java.util.List;
-
 public class NotificationTest extends AndroidTestCase {
 
     private Notification mNotification;
@@ -162,33 +158,11 @@
                 .setContentTitle(CONTENT_TITLE)
                 .setContentText(CONTENT_TEXT)
                 .setContentIntent(contentIntent)
-                .setTopic(new Topic("id1", "label1"))
                 .build();
         assertEquals(CONTENT_TEXT, mNotification.extras.getString(Notification.EXTRA_TEXT));
         assertEquals(CONTENT_TITLE, mNotification.extras.getString(Notification.EXTRA_TITLE));
         assertEquals(1, mNotification.icon);
         assertEquals(contentIntent, mNotification.contentIntent);
-        assertEquals(new Topic("id1", "label1"), mNotification.getTopic());
-    }
-
-    public void testWriteTopicToParcel() {
-        mNotification = new Notification.Builder(mContext)
-                .setTopic(new Topic("id2", "label2"))
-                .build();
-        Parcel parcel = Parcel.obtain();
-        mNotification.writeToParcel(parcel, 0);
-        parcel.setDataPosition(0);
-        // Test Notification(Parcel)
-        Notification result = new Notification(parcel);
-        assertEquals(new Topic("id2", "label2"), result.getTopic());
-
-        mNotification = new Notification();
-        parcel = Parcel.obtain();
-        mNotification.writeToParcel(parcel, 0);
-        parcel.setDataPosition(0);
-        // Test Notification(Parcel)
-        result = new Notification(parcel);
-        assertNull(result.getTopic());
     }
 
     public void testToString() {
diff --git a/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java b/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
index 81af410..4272f59 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
@@ -79,6 +79,7 @@
     private static final int NUM_RESULTS_WAIT_TIMEOUT = 100;
     private static final int NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY = 8;
     private static final int NUM_TEST_FOCUS_DISTANCES = 10;
+    private static final int NUM_FOCUS_DISTANCES_REPEAT = 3;
     // 5 percent error margin for calibrated device
     private static final float FOCUS_DISTANCE_ERROR_PERCENT_CALIBRATED = 0.05f;
     // 25 percent error margin for uncalibrated device
@@ -851,36 +852,66 @@
     }
 
     private void focusDistanceTestByCamera() throws Exception {
-        Size maxPrevSize = mOrderedPreviewSizes.get(0);
-        float[] testDistances = getFocusDistanceTestValuesInOrder();
         CaptureRequest.Builder requestBuilder =
                 mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
         requestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+        int calibrationStatus = mStaticInfo.getFocusDistanceCalibrationChecked();
+        float errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_UNCALIBRATED;
+        if (calibrationStatus ==
+                CameraMetadata.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED) {
+            errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_CALIBRATED;
+        } else if (calibrationStatus ==
+                CameraMetadata.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE) {
+            errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_APPROXIMATE;
+        }
+
+        // Test changing focus distance with repeating request
+        focusDistanceTestRepeating(requestBuilder, errorMargin);
+
+        if (calibrationStatus ==
+                CameraMetadata.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED)  {
+            // Test changing focus distance with burst request
+            focusDistanceTestBurst(requestBuilder, errorMargin);
+        }
+    }
+
+    private void focusDistanceTestRepeating(CaptureRequest.Builder requestBuilder,
+            float errorMargin) throws Exception {
+        CaptureRequest request;
+        float[] testDistances = getFocusDistanceTestValuesInOrder(0, 0);
+        Size maxPrevSize = mOrderedPreviewSizes.get(0);
         SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
         startPreview(requestBuilder, maxPrevSize, resultListener);
 
-        CaptureRequest request;
         float[] resultDistances = new float[testDistances.length];
+        int[] resultLensStates = new int[testDistances.length];
+
+        // Collect results
         for (int i = 0; i < testDistances.length; i++) {
             requestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, testDistances[i]);
             request = requestBuilder.build();
             resultListener = new SimpleCaptureCallback();
             mSession.setRepeatingRequest(request, resultListener, mHandler);
             waitForSettingsApplied(resultListener, NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY);
-            resultDistances[i] = verifyFocusDistanceControl(testDistances[i], request,
-                    resultListener);
+            waitForResultValue(resultListener, CaptureResult.LENS_STATE,
+                    CaptureResult.LENS_STATE_STATIONARY, NUM_RESULTS_WAIT_TIMEOUT);
+            CaptureResult result = resultListener.getCaptureResultForRequest(request,
+                    NUM_RESULTS_WAIT_TIMEOUT);
+
+            resultDistances[i] = getValueNotNull(result, CaptureResult.LENS_FOCUS_DISTANCE);
+            resultLensStates[i] = getValueNotNull(result, CaptureResult.LENS_STATE);
+
             if (VERBOSE) {
-                Log.v(TAG, "Capture request focus distance: " + testDistances[i] + " result: "
-                        + resultDistances[i]);
+                Log.v(TAG, "Capture repeating request focus distance: " + testDistances[i]
+                        + " result: " + resultDistances[i] + " lens state " + resultLensStates[i]);
             }
         }
 
-        // Verify the monotonicity
-        mCollector.checkArrayMonotonicityAndNotAllEqual(CameraTestUtils.toObject(resultDistances),
-                /*ascendingOrder*/true);
+        verifyFocusDistance(testDistances, resultDistances, resultLensStates,
+                /*ascendingOrder*/true, /*noOvershoot*/false, /*repeatStart*/0, /*repeatEnd*/0,
+                errorMargin);
 
-        if (mStaticInfo.getCharacteristics().getKeys().
-                contains(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE)) {
+        if (mStaticInfo.areKeysAvailable(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE)) {
 
             // Test hyperfocal distance optionally
             float hyperFocalDistance = mStaticInfo.getHyperfocalDistanceChecked();
@@ -894,57 +925,157 @@
                 // Then wait for the lens.state to be stationary.
                 waitForResultValue(resultListener, CaptureResult.LENS_STATE,
                         CaptureResult.LENS_STATE_STATIONARY, NUM_RESULTS_WAIT_TIMEOUT);
-                // Need get reasonably accurate value.
                 CaptureResult result = resultListener.getCaptureResult(WAIT_FOR_RESULT_TIMEOUT_MS);
                 Float focusDistance = getValueNotNull(result, CaptureResult.LENS_FOCUS_DISTANCE);
-                float errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_UNCALIBRATED;
-                int calibrationStatus = mStaticInfo.getFocusDistanceCalibrationChecked();
-                if (calibrationStatus ==
-                        CameraMetadata.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED) {
-                    errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_CALIBRATED;
-                } else if (calibrationStatus ==
-                        CameraMetadata.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE) {
-                    errorMargin = FOCUS_DISTANCE_ERROR_PERCENT_APPROXIMATE;
-                }
                 mCollector.expectInRange("Focus distance for hyper focal should be close enough to" +
-                                "requested value", focusDistance,
+                        " requested value", focusDistance,
                         hyperFocalDistance * (1.0f - errorMargin),
-                        hyperFocalDistance * (1.0f + errorMargin)
-                );
+                        hyperFocalDistance * (1.0f + errorMargin));
             }
         }
     }
 
+    private void focusDistanceTestBurst(CaptureRequest.Builder requestBuilder,
+            float errorMargin) throws Exception {
+
+        Size maxPrevSize = mOrderedPreviewSizes.get(0);
+        float[] testDistances = getFocusDistanceTestValuesInOrder(NUM_FOCUS_DISTANCES_REPEAT,
+                NUM_FOCUS_DISTANCES_REPEAT);
+        SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
+        startPreview(requestBuilder, maxPrevSize, resultListener);
+
+        float[] resultDistances = new float[testDistances.length];
+        int[] resultLensStates = new int[testDistances.length];
+
+        final int maxPipelineDepth = mStaticInfo.getCharacteristics().get(
+            CameraCharacteristics.REQUEST_PIPELINE_MAX_DEPTH);
+
+        // Move lens to starting position, and wait for the lens.state to be stationary.
+        CaptureRequest request;
+        requestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, testDistances[0]);
+        request = requestBuilder.build();
+        mSession.setRepeatingRequest(request, resultListener, mHandler);
+        waitForResultValue(resultListener, CaptureResult.LENS_STATE,
+                CaptureResult.LENS_STATE_STATIONARY, NUM_RESULTS_WAIT_TIMEOUT);
+
+        // Submit burst of requests with different focus distances
+        List<CaptureRequest> burst = new ArrayList<>();
+        for (int i = 0; i < testDistances.length; i ++) {
+            requestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, testDistances[i]);
+            burst.add(requestBuilder.build());
+        }
+        mSession.captureBurst(burst, resultListener, mHandler);
+
+        for (int i = 0; i < testDistances.length; i++) {
+            CaptureResult result = resultListener.getCaptureResultForRequest(
+                    burst.get(i), maxPipelineDepth+1);
+
+            resultDistances[i] = getValueNotNull(result, CaptureResult.LENS_FOCUS_DISTANCE);
+            resultLensStates[i] = getValueNotNull(result, CaptureResult.LENS_STATE);
+
+            if (VERBOSE) {
+                Log.v(TAG, "Capture burst request focus distance: " + testDistances[i]
+                        + " result: " + resultDistances[i] + " lens state " + resultLensStates[i]);
+            }
+        }
+
+        verifyFocusDistance(testDistances, resultDistances, resultLensStates,
+                /*ascendingOrder*/true, /*noOvershoot*/true,
+                /*repeatStart*/NUM_FOCUS_DISTANCES_REPEAT, /*repeatEnd*/NUM_FOCUS_DISTANCES_REPEAT,
+                errorMargin);
+
+    }
+
     /**
      * Verify focus distance control.
      *
-     * @param distance The focus distance requested
-     * @param request The capture request to control the manual focus distance
-     * @param resultListener The capture listener to recieve capture result callbacks
-     * @return the result focus distance
+     * Assumption:
+     * - First repeatStart+1 elements of requestedDistances share the same value
+     * - Last repeatEnd+1 elements of requestedDistances share the same value
+     * - All elements in between are monotonically increasing/decreasing depending on ascendingOrder.
+     * - Focuser is at requestedDistances[0] at the beginning of the test.
+     *
+     * @param requestedDistances The requested focus distances
+     * @param resultDistances The result focus distances
+     * @param lensStates The result lens states
+     * @param ascendingOrder The order of the expected focus distance request/output
+     * @param noOvershoot Assert that focus control doesn't overshoot the requested value
+     * @param repeatStart The number of times the starting focus distance is repeated
+     * @param repeatEnd The number of times the ending focus distance is repeated
+     * @param errorMargin The error margin between request and result
      */
-    private float verifyFocusDistanceControl(float distance, CaptureRequest request,
-            SimpleCaptureCallback resultListener) {
-        // Need make sure the result corresponding to the request is back, then check.
-        CaptureResult result =
-                resultListener.getCaptureResultForRequest(request, NUM_RESULTS_WAIT_TIMEOUT);
-        // Then wait for the lens.state to be stationary.
-        waitForResultValue(resultListener, CaptureResult.LENS_STATE,
-                CaptureResult.LENS_STATE_STATIONARY, NUM_RESULTS_WAIT_TIMEOUT);
-        // Then check the focus distance.
-        result = resultListener.getCaptureResultForRequest(request, NUM_RESULTS_WAIT_TIMEOUT);
-        Float resultDistance = getValueNotNull(result, CaptureResult.LENS_FOCUS_DISTANCE);
-        if (mStaticInfo.getFocusDistanceCalibrationChecked() ==
-                CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED) {
-            // TODO: what's more to test for CALIBRATED devices?
-        }
+    private void verifyFocusDistance(float[] requestedDistances, float[] resultDistances,
+            int[] lensStates, boolean ascendingOrder, boolean noOvershoot, int repeatStart,
+            int repeatEnd, float errorMargin) {
 
         float minValue = 0;
         float maxValue = mStaticInfo.getMinimumFocusDistanceChecked();
-        mCollector.expectInRange("Result focus distance is out of range",
-                resultDistance, minValue, maxValue);
+        float hyperfocalDistance = 0;
+        if (mStaticInfo.areKeysAvailable(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE)) {
+            hyperfocalDistance = mStaticInfo.getHyperfocalDistanceChecked();
+        }
 
-        return resultDistance;
+        // Verify lens and focus distance do not change for first repeatStart
+        // results.
+        for (int i = 0; i < repeatStart; i ++) {
+            float marginMin = requestedDistances[i] * (1.0f - errorMargin);
+            // HAL may choose to use hyperfocal distance for all distances between [0, hyperfocal].
+            float marginMax =
+                    Math.max(requestedDistances[i], hyperfocalDistance) * (1.0f + errorMargin);
+
+            mCollector.expectEquals("Lens moves even though focus_distance didn't change",
+                    lensStates[i], CaptureResult.LENS_STATE_STATIONARY);
+            if (noOvershoot) {
+                mCollector.expectInRange("Focus distance in result should be close enough to " +
+                        "requested value", resultDistances[i], marginMin, marginMax);
+            }
+            mCollector.expectInRange("Result focus distance is out of range",
+                    resultDistances[i], minValue, maxValue);
+        }
+
+        for (int i = repeatStart; i < resultDistances.length-1; i ++) {
+            float marginMin = requestedDistances[i] * (1.0f - errorMargin);
+            // HAL may choose to use hyperfocal distance for all distances between [0, hyperfocal].
+            float marginMax =
+                    Math.max(requestedDistances[i], hyperfocalDistance) * (1.0f + errorMargin);
+            if (noOvershoot) {
+                // Result focus distance shouldn't overshoot the request
+                boolean condition;
+                if (ascendingOrder) {
+                    condition = resultDistances[i] <= marginMax;
+               } else {
+                    condition = resultDistances[i] >= marginMin;
+                }
+                mCollector.expectTrue(String.format(
+                      "Lens shouldn't move past request focus distance. result " +
+                      resultDistances[i] + " vs target of " +
+                      (ascendingOrder ? marginMax : marginMin)), condition);
+            }
+
+            // Verify monotonically increased focus distance setting
+            boolean condition;
+            float compareDistance = resultDistances[i+1] - resultDistances[i];
+            if (i < resultDistances.length-1-repeatEnd) {
+                condition = (ascendingOrder ? compareDistance > 0 : compareDistance < 0);
+            } else {
+                condition = (ascendingOrder ? compareDistance >= 0 : compareDistance <= 0);
+            }
+            mCollector.expectTrue(String.format("Adjacent [resultDistances, lens_state] results ["
+                  + resultDistances[i] + "," + lensStates[i] + "], [" + resultDistances[i+1] + ","
+                  + lensStates[i+1] + "] monotonicity is broken"), condition);
+        }
+
+        mCollector.expectTrue(String.format("All values of this array are equal: " +
+                resultDistances[0] + " " + resultDistances[resultDistances.length-1]),
+                resultDistances[0] != resultDistances[resultDistances.length-1]);
+
+        // Verify lens moved to destination location.
+        mCollector.expectInRange("Focus distance " + resultDistances[resultDistances.length-1] +
+                " for minFocusDistance should be closed enough to requested value " +
+                requestedDistances[requestedDistances.length-1],
+                resultDistances[resultDistances.length-1],
+                requestedDistances[requestedDistances.length-1] * (1.0f - errorMargin),
+                requestedDistances[requestedDistances.length-1] * (1.0f + errorMargin));
     }
 
     /**
@@ -2232,16 +2363,28 @@
 
     /**
      * Generate test focus distances in range of [0, minFocusDistance] in increasing order.
+     *
+     * @param repeatMin number of times minValue will be repeated.
+     * @param repeatMax number of times maxValue will be repeated.
      */
-    private float[] getFocusDistanceTestValuesInOrder() {
-        float[] testValues = new float[NUM_TEST_FOCUS_DISTANCES + 1];
+    private float[] getFocusDistanceTestValuesInOrder(int repeatMin, int repeatMax) {
+        int totalCount = NUM_TEST_FOCUS_DISTANCES + 1 + repeatMin + repeatMax;
+        float[] testValues = new float[totalCount];
         float minValue = 0;
         float maxValue = mStaticInfo.getMinimumFocusDistanceChecked();
 
         float range = maxValue - minValue;
         float stepSize = range / NUM_TEST_FOCUS_DISTANCES;
-        for (int i = 0; i < testValues.length; i++) {
-            testValues[i] = minValue + stepSize * i;
+
+        for (int i = 0; i < repeatMin; i++) {
+            testValues[i] = minValue;
+        }
+        for (int i = 0; i <= NUM_TEST_FOCUS_DISTANCES; i++) {
+            testValues[repeatMin+i] = minValue + stepSize * i;
+        }
+        for (int i = 0; i < repeatMax; i++) {
+            testValues[repeatMin+NUM_TEST_FOCUS_DISTANCES+1+i] =
+                    maxValue;
         }
 
         return testValues;
diff --git a/tests/libcore/Android.mk b/tests/libcore/Android.mk
index c424cab..6596dd6 100644
--- a/tests/libcore/Android.mk
+++ b/tests/libcore/Android.mk
@@ -43,11 +43,11 @@
 
 # Copy the expectation files to CTS
 LOCAL_COMPATIBILITY_SUPPORT_FILES += \
-    ../../../art/tools/libcore_failures.txt:$(LOCAL_PACKAGE_NAME).failures.expectations \
-    ../../../libcore/expectations/brokentests.txt:$(LOCAL_PACKAGE_NAME).brokentests.expectations \
-    ../../../libcore/expectations/icebox.txt:$(LOCAL_PACKAGE_NAME).icebox.expectations \
-    ../../../libcore/expectations/knownfailures.txt:$(LOCAL_PACKAGE_NAME).knownfailures.expectations \
-    ../../../libcore/expectations/taggedtests.txt:$(LOCAL_PACKAGE_NAME).taggedtests.expectations
+    art/tools/libcore_failures.txt:$(LOCAL_PACKAGE_NAME).failures.expectations \
+    libcore/expectations/brokentests.txt:$(LOCAL_PACKAGE_NAME).brokentests.expectations \
+    libcore/expectations/icebox.txt:$(LOCAL_PACKAGE_NAME).icebox.expectations \
+    libcore/expectations/knownfailures.txt:$(LOCAL_PACKAGE_NAME).knownfailures.expectations \
+    libcore/expectations/taggedtests.txt:$(LOCAL_PACKAGE_NAME).taggedtests.expectations
 
 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
 
diff --git a/tests/openglperf2/jni/Android.mk b/tests/openglperf2/jni/Android.mk
index a312e59..c2bb7a8 100644
--- a/tests/openglperf2/jni/Android.mk
+++ b/tests/openglperf2/jni/Android.mk
@@ -30,4 +30,8 @@
 
 LOCAL_CXX_STL := libc++_static
 
+# TODO (dimitry): replace LOCAL_CXX_STL with LOCAL_SDK_VERSION+LOCAL_NDK_STL_VARIANT
+# LOCAL_SDK_VERSION := 23
+# LOCAL_NDK_STL_VARIANT := c++_static
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/openglperf2/jni/graphics/GLUtils.cpp b/tests/openglperf2/jni/graphics/GLUtils.cpp
index 7786447..e6beecc 100644
--- a/tests/openglperf2/jni/graphics/GLUtils.cpp
+++ b/tests/openglperf2/jni/graphics/GLUtils.cpp
@@ -20,7 +20,7 @@
 
 #define LOG_TAG "CTS_OPENGL"
 #define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
 
 static JNIEnv* sEnv = NULL;
 static jobject sAssetManager = NULL;
@@ -41,7 +41,7 @@
 char* GLUtils::openTextFile(const char* path) {
     AAsset* asset = loadAsset(path);
     if (asset == NULL) {
-        ALOGE("Couldn't load %s", path);
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Couldn't load %s", path);
         return NULL;
     }
     off_t length = AAsset_getLength(asset);
@@ -49,7 +49,7 @@
     int num = AAsset_read(asset, buffer, length);
     AAsset_close(asset);
     if (num != length) {
-        ALOGE("Couldn't read %s", path);
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Couldn't read %s", path);
         delete[] buffer;
         return NULL;
     }
@@ -61,13 +61,13 @@
     GLuint textureId = 0;
     jclass activityClass = sEnv->FindClass("android/opengl2/cts/reference/GLGameActivity");
     if (activityClass == NULL) {
-        ALOGE("Couldn't find activity class");
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Couldn't find activity class");
         return -1;
     }
     jmethodID loadTexture = sEnv->GetStaticMethodID(activityClass, "loadTexture",
             "(Landroid/content/res/AssetManager;Ljava/lang/String;)I");
     if (loadTexture == NULL) {
-        ALOGE("Couldn't find loadTexture method");
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Couldn't find loadTexture method");
         return -1;
     }
     jstring pathStr = sEnv->NewStringUTF(path);
@@ -141,7 +141,8 @@
             if (infoLen > 0) {
                 char* infoLog = (char*) malloc(sizeof(char) * infoLen);
                 glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
-                ALOGE("Error compiling shader:\n%s\n", infoLog);
+                __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
+                                    "Error compiling shader:\n%s\n", infoLog);
                 free(infoLog);
             }
             glDeleteShader(shader);
@@ -177,7 +178,8 @@
             if (infoLen > 0) {
                 char* infoLog = (char*) malloc(sizeof(char) * infoLen);
                 glGetProgramInfoLog(program, infoLen, NULL, infoLog);
-                ALOGE("Error linking program:\n%s\n", infoLog);
+                __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
+                                    "Error linking program:\n%s\n", infoLog);
                 free(infoLog);
             }
             glDeleteProgram(program);
diff --git a/tests/openglperf2/jni/graphics/Matrix.cpp b/tests/openglperf2/jni/graphics/Matrix.cpp
index 0097a5d..463338a 100644
--- a/tests/openglperf2/jni/graphics/Matrix.cpp
+++ b/tests/openglperf2/jni/graphics/Matrix.cpp
@@ -18,7 +18,7 @@
 
 #define LOG_TAG "CTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include "android/log.h"
 
 Matrix::Matrix() {
     identity();
@@ -29,10 +29,10 @@
 }
 
 void Matrix::print(const char* label) {
-    ALOGI("%c", *label);
+    __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%c", *label);
     for (int i = 0; i < 4; i++) {
         const float* d = &(mData[i * 4]);
-        ALOGI("%f %f %f %f\n", d[0], d[1], d[2], d[3]);
+        __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%f %f %f %f\n", d[0], d[1], d[2], d[3]);
     }
 }
 
diff --git a/tests/openglperf2/jni/graphics/Renderer.cpp b/tests/openglperf2/jni/graphics/Renderer.cpp
index 16504fd..effd5ac 100644
--- a/tests/openglperf2/jni/graphics/Renderer.cpp
+++ b/tests/openglperf2/jni/graphics/Renderer.cpp
@@ -16,7 +16,7 @@
 
 #define LOG_TAG "CTS_OPENGL"
 #define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
 
 #include <Trace.h>
 
@@ -26,7 +26,8 @@
 #define EGL_RESULT_CHECK(X) do { \
                                    EGLint error = eglGetError(); \
                                    if (!(X) || error != EGL_SUCCESS) { \
-                                       ALOGE("EGL error '%d' at %s:%d", error, __FILE__, __LINE__);\
+                                       __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
+                                          "EGL error '%d' at %s:%d", error, __FILE__, __LINE__);\
                                        return false; \
                                     } \
                             } while (0)
@@ -160,13 +161,13 @@
 
         GLuint err = glGetError();
         if (err != GL_NO_ERROR) {
-            ALOGE("GLError %d", err);
+            __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GLError %d", err);
             return false;
         }
 
         GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
         if (status != GL_FRAMEBUFFER_COMPLETE) {
-            ALOGE("Framebuffer not complete: %d", status);
+           __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Framebuffer not complete: %d", status);
             return false;
         }
         // Create fbo program.
@@ -190,7 +191,7 @@
 
     GLuint err = glGetError();
     if (err != GL_NO_ERROR) {
-        ALOGE("GLError %d in setUp", err);
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GLError %d in setUp", err);
         return false;
     }
 
@@ -215,7 +216,7 @@
     }
     GLuint err = glGetError();
     if (err != GL_NO_ERROR) {
-        ALOGE("GLError %d in tearDown", err);
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GLError %d in tearDown", err);
         return false;
     }
 
@@ -284,7 +285,7 @@
 
     GLuint err = glGetError();
     if (err != GL_NO_ERROR) {
-        ALOGE("GLError %d in draw", err);
+        __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GLError %d in draw", err);
         return false;
     }
 
diff --git a/tests/openglperf2/jni/primitive/contextswitch/ContextSwitchRenderer.cpp b/tests/openglperf2/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
index 1127d88..5e9b414 100644
--- a/tests/openglperf2/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
+++ b/tests/openglperf2/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
@@ -26,7 +26,7 @@
 
 #define LOG_TAG "CTS_OPENGL"
 #define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
 #include <Trace.h>
 
 static const EGLint contextAttribs[] = {
@@ -127,7 +127,7 @@
                                    GL_TEXTURE_2D, mFboTexId, 0);
             GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
             if (status != GL_FRAMEBUFFER_COMPLETE) {
-                ALOGE("Framebuffer not complete: %d", status);
+                __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Framebuffer not complete: %d", status);
                 return false;
             }
         }
@@ -218,7 +218,7 @@
         }
         GLuint err = glGetError();
         if (err != GL_NO_ERROR) {
-            ALOGE("GLError %d in drawWorkload", err);
+            __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GLError %d in drawWorkload", err);
             break;
         }
     }
diff --git a/tests/openglperf2/jni/reference/scene/flocking/Boid.h b/tests/openglperf2/jni/reference/scene/flocking/Boid.h
index 3e4367a..994126e 100644
--- a/tests/openglperf2/jni/reference/scene/flocking/Boid.h
+++ b/tests/openglperf2/jni/reference/scene/flocking/Boid.h
@@ -16,7 +16,6 @@
 #define BOID_H
 
 #include <graphics/Vector2D.h>
-#include <utils/Compat.h>
 
 class Boid {
 public:
@@ -25,14 +24,14 @@
     void flock(const Boid* boids[], int numBoids, int index, float limitX, float limitY);
     // The following floats are the parameters for the flocking algorithm, changing these
     // modifies the boid's behaviour.
-    static const CONSTEXPR float MAX_SPEED = 2.0f;// Upper limit of boid velocity.
-    static const CONSTEXPR float MAX_FORCE = 0.05f;// Upper limit of the force used to push a boid.
-    static const CONSTEXPR float NEIGHBOUR_RADIUS = 70.0f;// Radius used to find neighbours, was 50.
-    static const CONSTEXPR float DESIRED_BOID_DIST = 35.0f;// Distance boids want to be from others, was 25.
+    static const constexpr float MAX_SPEED = 2.0f;// Upper limit of boid velocity.
+    static const constexpr float MAX_FORCE = 0.05f;// Upper limit of the force used to push a boid.
+    static const constexpr float NEIGHBOUR_RADIUS = 70.0f;// Radius used to find neighbours, was 50.
+    static const constexpr float DESIRED_BOID_DIST = 35.0f;// Distance boids want to be from others, was 25.
     // The weightings of the components.
-    static const CONSTEXPR float SEPARATION_WEIGHT = 2.0f;
-    static const CONSTEXPR float ALIGNMENT_WEIGHT = 1.0f;
-    static const CONSTEXPR float COHESION_WEIGHT = 1.0f;
+    static const constexpr float SEPARATION_WEIGHT = 2.0f;
+    static const constexpr float ALIGNMENT_WEIGHT = 1.0f;
+    static const constexpr float COHESION_WEIGHT = 1.0f;
     Vector2D mPosition;
     Vector2D mVelocity;
     Vector2D mAcceleration;
diff --git a/tests/tests/accounts/src/android/accounts/cts/MockAccountAuthenticator.java b/tests/tests/accounts/src/android/accounts/cts/MockAccountAuthenticator.java
index 194fbfc..470b629 100644
--- a/tests/tests/accounts/src/android/accounts/cts/MockAccountAuthenticator.java
+++ b/tests/tests/accounts/src/android/accounts/cts/MockAccountAuthenticator.java
@@ -147,7 +147,6 @@
     public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
             String authTokenType, String[] requiredFeatures, Bundle options)
             throws NetworkErrorException {
-        super.addAccountFromCredentials(null, null, null);
         this.mResponse = response;
         this.mAccountType = accountType;
         this.mAuthTokenType = authTokenType;
diff --git a/tests/tests/automotive/Android.mk b/tests/tests/automotive/Android.mk
index f4cef01..b21867d 100644
--- a/tests/tests/automotive/Android.mk
+++ b/tests/tests/automotive/Android.mk
@@ -24,7 +24,9 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner car
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
+LOCAL_JAVA_LIBRARIES := android.car
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/automotive/AndroidManifest.xml b/tests/tests/automotive/AndroidManifest.xml
index e0ee3e0..984d896 100644
--- a/tests/tests/automotive/AndroidManifest.xml
+++ b/tests/tests/automotive/AndroidManifest.xml
@@ -15,14 +15,14 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="android.support.car.cts">
+    package="android.car.cts">
     <uses-feature android:name="android.hardware.type.automotive" />
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.support.car.cts"
+                     android:targetPackage="android.car.cts"
                      android:label="CTS tests for Automotive">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarApiTestBase.java b/tests/tests/automotive/src/android/car/cts/CarApiTestBase.java
similarity index 83%
rename from tests/tests/automotive/src/android/support/car/cts/CarApiTestBase.java
rename to tests/tests/automotive/src/android/car/cts/CarApiTestBase.java
index 17482ea3..948604c 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarApiTestBase.java
+++ b/tests/tests/automotive/src/android/car/cts/CarApiTestBase.java
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package android.support.car.cts;
+package android.car.cts;
 
+import android.car.Car;
 import android.content.ComponentName;
+import android.content.ServiceConnection;
 import android.os.IBinder;
 import android.os.Looper;
-import android.support.car.Car;
-import android.support.car.ServiceConnectionListener;
 import android.test.AndroidTestCase;
 
 import java.util.concurrent.Semaphore;
@@ -50,13 +50,11 @@
     protected void tearDown() throws Exception {
         super.tearDown();
         mCar.disconnect();
-    }
-
-    protected synchronized Car getCar() {
+    }    protected synchronized Car getCar() {
         return mCar;
     }
 
-    protected class DefaultServiceConnectionListener implements ServiceConnectionListener {
+    protected class DefaultServiceConnectionListener implements ServiceConnection {
         private final Semaphore mConnectionWait = new Semaphore(0);
 
         public void waitForConnection(long timeoutMs) throws InterruptedException {
@@ -64,21 +62,11 @@
         }
 
         @Override
-        public void onServiceSuspended(int cause) {
-            assertMainThread();
-        }
-
-        @Override
         public void onServiceDisconnected(ComponentName name) {
             assertMainThread();
         }
 
         @Override
-        public void onServiceConnectionFailed(int cause) {
-            assertMainThread();
-        }
-
-        @Override
         public void onServiceConnected(ComponentName name, IBinder service) {
             assertMainThread();
             mConnectionWait.release();
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarAppContextManagerTest.java b/tests/tests/automotive/src/android/car/cts/CarAppContextManagerTest.java
similarity index 98%
rename from tests/tests/automotive/src/android/support/car/cts/CarAppContextManagerTest.java
rename to tests/tests/automotive/src/android/car/cts/CarAppContextManagerTest.java
index 9f031d8..3b0b835 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarAppContextManagerTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarAppContextManagerTest.java
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.Car;
-import android.support.car.CarAppContextManager;
+import android.car.Car;
+import android.car.CarAppContextManager;
 import android.util.Log;
 
 import java.util.concurrent.Semaphore;
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarConnectionListenerTest.java b/tests/tests/automotive/src/android/car/cts/CarConnectionListenerTest.java
similarity index 96%
rename from tests/tests/automotive/src/android/support/car/cts/CarConnectionListenerTest.java
rename to tests/tests/automotive/src/android/car/cts/CarConnectionListenerTest.java
index 25c74f8..f7ab9ad 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarConnectionListenerTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarConnectionListenerTest.java
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.Car;
-import android.support.car.CarConnectionListener;
+import android.car.Car;
+import android.car.CarConnectionListener;
 import android.util.Log;
 
 import java.util.concurrent.Semaphore;
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarInfoManagerTest.java b/tests/tests/automotive/src/android/car/cts/CarInfoManagerTest.java
similarity index 95%
rename from tests/tests/automotive/src/android/support/car/cts/CarInfoManagerTest.java
rename to tests/tests/automotive/src/android/car/cts/CarInfoManagerTest.java
index c13f9bf..1cde840 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarInfoManagerTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarInfoManagerTest.java
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.Car;
-import android.support.car.CarInfoManager;
+import android.car.Car;
+import android.car.CarInfoManager;
 
 public class CarInfoManagerTest extends CarApiTestBase {
 
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarPackageManagerTest.java b/tests/tests/automotive/src/android/car/cts/CarPackageManagerTest.java
similarity index 89%
rename from tests/tests/automotive/src/android/support/car/cts/CarPackageManagerTest.java
rename to tests/tests/automotive/src/android/car/cts/CarPackageManagerTest.java
index 8abcae9..2865710 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarPackageManagerTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarPackageManagerTest.java
@@ -13,13 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.Car;
-import android.support.car.CarNotConnectedException;
-import android.support.car.content.pm.AppBlockingPackageInfo;
-import android.support.car.content.pm.CarAppBlockingPolicy;
-import android.support.car.content.pm.CarPackageManager;
+import android.car.Car;
+import android.car.CarNotConnectedException;
+import android.car.content.pm.CarPackageManager;
 import android.telecom.TelecomManager;
 import android.util.Log;
 
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarSensorManagerTest.java b/tests/tests/automotive/src/android/car/cts/CarSensorManagerTest.java
similarity index 90%
rename from tests/tests/automotive/src/android/support/car/cts/CarSensorManagerTest.java
rename to tests/tests/automotive/src/android/car/cts/CarSensorManagerTest.java
index c10000e..ddcc52e 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarSensorManagerTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarSensorManagerTest.java
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.Car;
-import android.support.car.hardware.CarSensorEvent;
-import android.support.car.hardware.CarSensorManager;
+import android.car.Car;
+import android.car.hardware.CarSensorEvent;
+import android.car.hardware.CarSensorManager;
 
 public class CarSensorManagerTest extends CarApiTestBase {
 
diff --git a/tests/tests/automotive/src/android/support/car/cts/CarUiProviderTest.java b/tests/tests/automotive/src/android/car/cts/CarUiProviderTest.java
similarity index 99%
rename from tests/tests/automotive/src/android/support/car/cts/CarUiProviderTest.java
rename to tests/tests/automotive/src/android/car/cts/CarUiProviderTest.java
index 07e10cb..64f13a6 100644
--- a/tests/tests/automotive/src/android/support/car/cts/CarUiProviderTest.java
+++ b/tests/tests/automotive/src/android/car/cts/CarUiProviderTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.support.car.cts;
+package android.car.cts;
 
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
diff --git a/tests/tests/automotive/src/android/support/car/cts/ExceptionsTest.java b/tests/tests/automotive/src/android/car/cts/ExceptionsTest.java
similarity index 93%
rename from tests/tests/automotive/src/android/support/car/cts/ExceptionsTest.java
rename to tests/tests/automotive/src/android/car/cts/ExceptionsTest.java
index 3391883..496867b 100644
--- a/tests/tests/automotive/src/android/support/car/cts/ExceptionsTest.java
+++ b/tests/tests/automotive/src/android/car/cts/ExceptionsTest.java
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.support.car.cts;
+package android.car.cts;
 
-import android.support.car.CarNotConnectedException;
-import android.support.car.CarNotSupportedException;
+import android.car.CarNotConnectedException;
+import android.car.CarNotSupportedException;
 import android.test.AndroidTestCase;
 
 public class ExceptionsTest extends AndroidTestCase {
diff --git a/tests/tests/graphics/res/drawable/nine_patch_density.xml b/tests/tests/graphics/res/drawable/nine_patch_density.xml
new file mode 100644
index 0000000..9e60cb4
--- /dev/null
+++ b/tests/tests/graphics/res/drawable/nine_patch_density.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
+            android:src="@drawable/nine_patch_density_bitmap" />
diff --git a/tests/tests/graphics/res/drawable/nine_patch_density.9.png b/tests/tests/graphics/res/drawable/nine_patch_density_bitmap.9.png
similarity index 100%
rename from tests/tests/graphics/res/drawable/nine_patch_density.9.png
rename to tests/tests/graphics/res/drawable/nine_patch_density_bitmap.9.png
Binary files differ
diff --git a/tests/tests/graphics/src/android/graphics/cts/RegionTest.java b/tests/tests/graphics/src/android/graphics/cts/RegionTest.java
index 803f3e9..10e277b 100644
--- a/tests/tests/graphics/src/android/graphics/cts/RegionTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/RegionTest.java
@@ -1497,21 +1497,42 @@
         Rect oriRect = new Rect(0, 0, 10, 10);
         mRegion = new Region();
 
+        // test reading/writing an empty parcel
         Parcel p = Parcel.obtain();
         mRegion.writeToParcel(p, flags);
-        assertEquals(8, p.dataSize());
-
-        p = Parcel.obtain();
-        mRegion.set(oriRect);
-        mRegion.writeToParcel(p, flags);
-        assertEquals(24, p.dataSize());
 
         p.setDataPosition(0);
         Region dst = Region.CREATOR.createFromParcel(p);
+        assertTrue(dst.isEmpty());
+
+        // test reading/writing a single rect parcel
+        p = Parcel.obtain();
+        mRegion.set(oriRect);
+        mRegion.writeToParcel(p, flags);
+
+        p.setDataPosition(0);
+        dst = Region.CREATOR.createFromParcel(p);
         assertEquals(oriRect.top, dst.getBounds().top);
         assertEquals(oriRect.left, dst.getBounds().left);
         assertEquals(oriRect.bottom, dst.getBounds().bottom);
         assertEquals(oriRect.right, dst.getBounds().right);
+
+        // test reading/writing a multiple rect parcel
+        p = Parcel.obtain();
+        mRegion.op(5, 5, 15, 15, Region.Op.UNION);
+        mRegion.writeToParcel(p, flags);
+
+        p.setDataPosition(0);
+        dst = Region.CREATOR.createFromParcel(p);
+        assertTrue(dst.contains(2,2));
+        assertTrue(dst.contains(7,7));
+        assertTrue(dst.contains(12,12));
+        assertFalse(dst.contains(2,12));
+        assertFalse(dst.contains(12,2));
+        assertEquals(0, dst.getBounds().top);
+        assertEquals(0, dst.getBounds().left);
+        assertEquals(15, dst.getBounds().bottom);
+        assertEquals(15, dst.getBounds().right);
     }
 
     public void testDescribeContents() {
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedStateListDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedStateListDrawableTest.java
index 2ffd072..12f9828 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedStateListDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedStateListDrawableTest.java
@@ -188,7 +188,7 @@
                 (StateListDrawable) cs.newDrawable(res);
         for (int i = 0; i < count; i++) {
             halfDrawable.selectDrawable(i);
-            assertEquals(origWidth[i] / 2, halfDrawable.getIntrinsicWidth());
+            assertEquals(Math.round(origWidth[i] / 2f), halfDrawable.getIntrinsicWidth());
         }
 
         // Set density to double original.
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
index b8661d2..e118a66 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
@@ -377,12 +377,13 @@
         assertEquals(origPadding, tempPadding);
 
         // Some precision is lost when scaling the half-density
-        // drawable back up to the original density.
+        // drawable back up to the original density. Padding is
+        // always truncated, rather than rounded.
         final Rect sloppyOrigPadding = new Rect();
-        sloppyOrigPadding.left = 2 * Math.round(origPadding.left / 2f);
-        sloppyOrigPadding.top = 2 * Math.round(origPadding.top / 2f);
-        sloppyOrigPadding.right = 2 * Math.round(origPadding.right / 2f);
-        sloppyOrigPadding.bottom = 2 * Math.round(origPadding.bottom / 2f);
+        sloppyOrigPadding.left = 2 * (origPadding.left / 2);
+        sloppyOrigPadding.top = 2 * (origPadding.top / 2);
+        sloppyOrigPadding.right = 2 * (origPadding.right / 2);
+        sloppyOrigPadding.bottom = 2 * (origPadding.bottom / 2);
 
         // Ensure theme density is applied correctly.
         final Theme t = res.newTheme();
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/LayerDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/LayerDrawableTest.java
index d8e63fa..37654dc 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/LayerDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/LayerDrawableTest.java
@@ -1691,20 +1691,20 @@
         final int initialLayerWidth = preloadedDrawable.getLayerWidth(0);
         final int initialLayerHeight = preloadedDrawable.getLayerHeight(0);
 
-        // Set density to half of original. Unlike offsets, which are
+        // Set density to half of original. Padding and insets are
         // truncated, dimensions are rounded to the nearest pixel.
         DrawableTestUtils.setResourcesDensity(res, densityDpi / 2);
         final LayerDrawable halfDrawable =
                 (LayerDrawable) preloadedConstantState.newDrawable(res);
         assertEquals(Math.round(initialWidth / 2f), halfDrawable.getIntrinsicWidth());
-        assertEquals(Math.round(initialLeftPadding / 2f), halfDrawable.getLeftPadding());
-        assertEquals(Math.round(initialRightPadding / 2f), halfDrawable.getRightPadding());
-        assertEquals(Math.round(initialBottomPadding / 2f), halfDrawable.getBottomPadding());
-        assertEquals(Math.round(initialTopPadding / 2f), halfDrawable.getTopPadding());
-        assertEquals(Math.round(initialLayerInsetLeft / 2f),halfDrawable.getLayerInsetLeft(0));
-        assertEquals(Math.round(initialLayerInsetRight / 2f), halfDrawable.getLayerInsetRight(0));
-        assertEquals(Math.round(initialLayerInsetTop / 2f), halfDrawable.getLayerInsetTop(0));
-        assertEquals(Math.round(initialLayerInsetBottom / 2f), halfDrawable.getLayerInsetBottom(0));
+        assertEquals(initialLeftPadding / 2, halfDrawable.getLeftPadding());
+        assertEquals(initialRightPadding / 2, halfDrawable.getRightPadding());
+        assertEquals(initialBottomPadding / 2, halfDrawable.getBottomPadding());
+        assertEquals(initialTopPadding / 2, halfDrawable.getTopPadding());
+        assertEquals(initialLayerInsetLeft / 2,halfDrawable.getLayerInsetLeft(0));
+        assertEquals(initialLayerInsetRight / 2, halfDrawable.getLayerInsetRight(0));
+        assertEquals(initialLayerInsetTop / 2, halfDrawable.getLayerInsetTop(0));
+        assertEquals(initialLayerInsetBottom / 2, halfDrawable.getLayerInsetBottom(0));
         assertEquals(Math.round(initialLayerWidth / 2f), halfDrawable.getLayerWidth(0));
         assertEquals(Math.round(initialLayerHeight / 2f), halfDrawable.getLayerHeight(0));
 
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
index 686c443..b0650c7 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
@@ -396,7 +396,7 @@
         // Restore original density.
         DrawableTestUtils.setResourcesDensity(res, densityDpi);
         final NinePatchDrawable origDrawable =
-                (NinePatchDrawable) preloadedConstantState.newDrawable();
+                (NinePatchDrawable) preloadedConstantState.newDrawable(res);
         assertEquals(origWidth, origDrawable.getIntrinsicWidth());
 
         // Ensure theme density is applied correctly.
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/RotateDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/RotateDrawableTest.java
index b6912a0..31a8141 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/RotateDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/RotateDrawableTest.java
@@ -100,13 +100,15 @@
     public void testSetDegrees() {
         RotateDrawable d = new RotateDrawable();
         assertEquals(0.0f, d.getFromDegrees(), 0.01f);
-        assertEquals(0.0f, d.getFromDegrees(), 0.01f);
+        assertEquals(0.0f, d.getToDegrees(), 0.01f);
 
         d.setFromDegrees(-10.0f);
         assertEquals(-10.0f, d.getFromDegrees(), 0.01f);
+        assertEquals(0.0f, d.getToDegrees(), 0.01f);
 
         d.setToDegrees(10.0f);
-        assertEquals(10.0f, d.getFromDegrees(), 0.01f);
+        assertEquals(10.0f, d.getToDegrees(), 0.01f);
+        assertEquals(-10.0f, d.getFromDegrees(), 0.01f);
     }
 
     public void testGetChangingConfigurations() {
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/StateListDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/StateListDrawableTest.java
index 28d2235..2194a00 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/StateListDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/StateListDrawableTest.java
@@ -206,9 +206,9 @@
         final StateListDrawable halfDrawable =
                 (StateListDrawable) preloadedConstantState.newDrawable(res);
         halfDrawable.selectDrawable(0);
-        assertEquals(origWidth0 / 2, halfDrawable.getIntrinsicWidth());
+        assertEquals(Math.round(origWidth0 / 2f), halfDrawable.getIntrinsicWidth());
         halfDrawable.selectDrawable(1);
-        assertEquals(origWidth1 / 2, halfDrawable.getIntrinsicWidth());
+        assertEquals(Math.round(origWidth1 / 2f), halfDrawable.getIntrinsicWidth());
 
         // Set density to double original.
         DrawableTestUtils.setResourcesDensity(res, densityDpi * 2);
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index 5876532..b43d05a 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -44,6 +44,7 @@
 
 static std::unordered_set<std::string> kPublicLibraries = {
     "libandroid.so",
+    "libcamera2ndk.so",
     "libc.so",
     "libdl.so",
     "libEGL.so",
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordNotificationTest.java b/tests/tests/media/src/android/media/cts/AudioRecordNotificationTest.java
new file mode 100644
index 0000000..d048c53
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/AudioRecordNotificationTest.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.cts;
+
+import android.content.pm.PackageManager;
+import android.cts.util.CtsAndroidTestCase;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioRecord;
+import android.media.AudioRecordConfiguration;
+import android.media.MediaRecorder;
+import android.os.Looper;
+import android.util.Log;
+
+public class AudioRecordNotificationTest extends CtsAndroidTestCase {
+    private final static String TAG = "AudioRecordNotificationTest";
+
+    private final static int TEST_SAMPLE_RATE = 16000;
+    private final static int TEST_AUDIO_SOURCE = MediaRecorder.AudioSource.VOICE_RECOGNITION;
+
+    private final static int TEST_TIMING_TOLERANCE_MS = 70;
+
+    private AudioRecord mAudioRecord;
+    private Looper mLooper;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (!hasMicrophone()) {
+            return;
+        }
+
+        /*
+         * InstrumentationTestRunner.onStart() calls Looper.prepare(), which creates a looper
+         * for the current thread. However, since we don't actually call loop() in the test,
+         * any messages queued with that looper will never be consumed. Therefore, we must
+         * create the instance in another thread, either without a looper, so the main looper is
+         * used, or with an active looper.
+         */
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mLooper = Looper.myLooper();
+                synchronized(this) {
+                    mAudioRecord = new AudioRecord.Builder()
+                                     .setAudioSource(TEST_AUDIO_SOURCE)
+                                     .setAudioFormat(new AudioFormat.Builder()
+                                             .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+                                             .setSampleRate(TEST_SAMPLE_RATE)
+                                             .setChannelMask(AudioFormat.CHANNEL_IN_MONO)
+                                             .build())
+                                     .build();
+                    this.notify();
+                }
+                Looper.loop();
+            }
+        };
+        synchronized(t) {
+            t.start(); // will block until we wait
+            t.wait();
+        }
+        assertNotNull(mAudioRecord);
+        assertNotNull(mLooper);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (hasMicrophone()) {
+            mAudioRecord.stop();
+            mAudioRecord.release();
+            mLooper.quit();
+        }
+        super.tearDown();
+    }
+
+    // start a recording and verify it is seen as an active recording
+    public void testAudioManagerGetActiveRecordConfigurations() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
+        AudioManager am = new AudioManager(getContext());
+        assertNotNull("Could not create AudioManager", am);
+
+        AudioRecordConfiguration[] configs = am.getActiveRecordConfigurations();
+        assertNotNull("Invalid null array of record configurations before recording", configs);
+
+        assertEquals(AudioRecord.STATE_INITIALIZED, mAudioRecord.getState());
+        mAudioRecord.startRecording();
+        assertEquals(AudioRecord.RECORDSTATE_RECORDING, mAudioRecord.getRecordingState());
+        Thread.sleep(TEST_TIMING_TOLERANCE_MS);
+
+        // recording is active, verify there is an active record configuration
+        configs = am.getActiveRecordConfigurations();
+        assertNotNull("Invalid null array of record configurations during recording", configs);
+        assertTrue("no active record configurations (empty array) during recording",
+                configs.length > 0);
+        final int nbConfigsDuringRecording = configs.length;
+
+        // verify our recording shows as one of the recording configs
+        assertTrue("Test source/session not amongst active record configurations",
+                verifyAudioSourceSession(TEST_AUDIO_SOURCE, mAudioRecord.getAudioSessionId(),
+                        configs));
+
+        // stopping recording: verify there are less active record configurations
+        mAudioRecord.stop();
+        Thread.sleep(TEST_TIMING_TOLERANCE_MS);
+        configs = am.getActiveRecordConfigurations();
+        assertTrue("end of recording not reported in record configs",
+                configs.length < nbConfigsDuringRecording);
+    }
+
+    public void testCallback() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
+        AudioManager am = new AudioManager(getContext());
+        assertNotNull("Could not create AudioManager", am);
+
+        MyAudioRecordingCallback callback = new MyAudioRecordingCallback(
+                mAudioRecord.getAudioSessionId(), TEST_AUDIO_SOURCE);
+        am.registerAudioRecordingCallback(callback, null /*handler*/);
+
+        assertEquals(AudioRecord.STATE_INITIALIZED, mAudioRecord.getState());
+        mAudioRecord.startRecording();
+        assertEquals(AudioRecord.RECORDSTATE_RECORDING, mAudioRecord.getRecordingState());
+        Thread.sleep(TEST_TIMING_TOLERANCE_MS);
+
+        assertTrue("AudioRecordingCallback not called", callback.mCalled);
+        assertTrue("Expected record configuration was not found", callback.mParamMatch);
+
+        // stopping recording: callback is called with no match
+        callback.reset();
+        mAudioRecord.stop();
+        Thread.sleep(TEST_TIMING_TOLERANCE_MS);
+        assertTrue("AudioRecordingCallback not called", callback.mCalled);
+        assertFalse("Should not have found test record configuration", callback.mParamMatch);
+
+        // unregister callback and start recording again
+        am.unregisterAudioRecordingCallback(callback);
+        callback.reset();
+        mAudioRecord.startRecording();
+        Thread.sleep(TEST_TIMING_TOLERANCE_MS);
+        assertFalse("Unregistered callback was called", callback.mCalled);
+    }
+
+    class MyAudioRecordingCallback extends AudioManager.AudioRecordingCallback {
+        boolean mCalled = false;
+        boolean mParamMatch = false;
+        final AudioManager mAM;
+        final int mTestSource;
+        final int mTestSession;
+
+        void reset() {
+            mCalled = false;
+            mParamMatch = false;
+        }
+
+        MyAudioRecordingCallback(int session, int source) {
+            mAM = new AudioManager(getContext());
+            mTestSource = source;
+            mTestSession = session;
+        }
+
+        @Override
+        public void onRecordConfigChanged() {
+            mCalled = true;
+            mParamMatch = verifyAudioSourceSession(mTestSource, mTestSession,
+                    mAM.getActiveRecordConfigurations());
+        }
+    }
+
+    private static boolean verifyAudioSourceSession(int source, int session,
+            AudioRecordConfiguration[] configs) {
+        for (int i = 0 ; i < configs.length ; i++) {
+            if ((configs[i].getClientAudioSource() == source) &&
+                    (configs[i].getClientAudioSessionId() == session)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean hasMicrophone() {
+        return getContext().getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_MICROPHONE);
+    }
+}
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index 08bccc1..239f165 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -18,8 +18,8 @@
 */
 -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="android" coreApp="true" android:sharedUserId="android.uid.system"
-    android:sharedUserLabel="@string/android_system_label">
+          package="android" coreApp="true" android:sharedUserId="android.uid.system"
+          android:sharedUserLabel="@string/android_system_label">
 
     <!-- ================================================ -->
     <!-- Special broadcasts that only the system can send -->
@@ -33,6 +33,7 @@
     <protected-broadcast android:name="android.intent.action.TIME_TICK" />
     <protected-broadcast android:name="android.intent.action.TIMEZONE_CHANGED" />
     <protected-broadcast android:name="android.intent.action.DATE_CHANGED" />
+    <protected-broadcast android:name="android.intent.action.PRE_BOOT_COMPLETED" />
     <protected-broadcast android:name="android.intent.action.BOOT_COMPLETED" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_INSTALL" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_ADDED" />
@@ -46,6 +47,8 @@
     <protected-broadcast android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_NEEDS_VERIFICATION" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_VERIFIED" />
+    <protected-broadcast android:name="android.intent.action.PACKAGES_SUSPENDED" />
+    <protected-broadcast android:name="android.intent.action.PACKAGES_UNSUSPENDED" />
     <protected-broadcast android:name="android.intent.action.UID_REMOVED" />
     <protected-broadcast android:name="android.intent.action.QUERY_PACKAGE_RESTART" />
     <protected-broadcast android:name="android.intent.action.CONFIGURATION_CHANGED" />
@@ -65,6 +68,7 @@
     <protected-broadcast android:name="android.intent.action.NEW_OUTGOING_CALL" />
     <protected-broadcast android:name="android.intent.action.REBOOT" />
     <protected-broadcast android:name="android.intent.action.DOCK_EVENT" />
+    <protected-broadcast android:name="android.intent.action.THERMAL_EVENT" />
     <protected-broadcast android:name="android.intent.action.MASTER_CLEAR_NOTIFICATION" />
     <protected-broadcast android:name="android.intent.action.USER_ADDED" />
     <protected-broadcast android:name="android.intent.action.USER_REMOVED" />
@@ -75,6 +79,7 @@
     <protected-broadcast android:name="android.intent.action.USER_BACKGROUND" />
     <protected-broadcast android:name="android.intent.action.USER_FOREGROUND" />
     <protected-broadcast android:name="android.intent.action.USER_SWITCHED" />
+    <protected-broadcast android:name="android.intent.action.USER_INITIALIZE" />
     <protected-broadcast android:name="android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION" />
 
     <protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGED" />
@@ -91,6 +96,10 @@
     <protected-broadcast android:name="android.app.action.EXIT_DESK_MODE" />
     <protected-broadcast android:name="android.app.action.NEXT_ALARM_CLOCK_CHANGED" />
 
+    <protected-broadcast android:name="android.app.action.BUGREPORT_SHARING_DECLINED" />
+    <protected-broadcast android:name="android.app.action.BUGREPORT_FAILED" />
+    <protected-broadcast android:name="android.app.action.BUGREPORT_SHARE" />
+
     <protected-broadcast android:name="android.appwidget.action.APPWIDGET_UPDATE_OPTIONS" />
     <protected-broadcast android:name="android.appwidget.action.APPWIDGET_DELETED" />
     <protected-broadcast android:name="android.appwidget.action.APPWIDGET_DISABLED" />
@@ -100,10 +109,11 @@
 
     <protected-broadcast android:name="android.os.action.SETTING_RESTORED" />
 
-    <protected-broadcast android:name="android.backup.intent.RUN" />
-    <protected-broadcast android:name="android.backup.intent.CLEAR" />
-    <protected-broadcast android:name="android.backup.intent.INIT" />
+    <protected-broadcast android:name="android.app.backup.intent.RUN" />
+    <protected-broadcast android:name="android.app.backup.intent.CLEAR" />
+    <protected-broadcast android:name="android.app.backup.intent.INIT" />
 
+    <protected-broadcast android:name="android.bluetooth.intent.DISCOVERABLE_TIMEOUT" />
     <protected-broadcast android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
     <protected-broadcast android:name="android.bluetooth.adapter.action.SCAN_MODE_CHANGED" />
     <protected-broadcast android:name="android.bluetooth.adapter.action.DISCOVERY_STARTED" />
@@ -130,43 +140,43 @@
     <protected-broadcast android:name="android.bluetooth.devicepicker.action.LAUNCH" />
     <protected-broadcast android:name="android.bluetooth.devicepicker.action.DEVICE_SELECTED" />
     <protected-broadcast
-        android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED" />
+            android:name="android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" />
+            android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED" />
+            android:name="android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.AG_EVENT" />
+            android:name="android.bluetooth.headsetclient.profile.action.AG_EVENT" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED" />
+            android:name="android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.RESULT" />
+            android:name="android.bluetooth.headsetclient.profile.action.RESULT" />
     <protected-broadcast
-        android:name="android.bluetooth.headsetclient.profile.action.LAST_VTAG" />
+            android:name="android.bluetooth.headsetclient.profile.action.LAST_VTAG" />
     <protected-broadcast
-        android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED" />
+            android:name="android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED" />
+            android:name="android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED" />
-   <protected-broadcast
-        android:name="android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED" />
+            android:name="android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS" />
+            android:name="android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED" />
     <protected-broadcast
-        android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
+            android:name="android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS" />
+    <protected-broadcast
+            android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast android:name="android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED" />
     <protected-broadcast android:name="android.btopp.intent.action.INCOMING_FILE_NOTIFICATION" />
     <protected-broadcast android:name="android.btopp.intent.action.USER_CONFIRMATION_TIMEOUT" />
@@ -188,7 +198,7 @@
     <protected-broadcast android:name="android.hardware.usb.action.USB_STATE" />
     <protected-broadcast android:name="android.hardware.usb.action.USB_PORT_CHANGED" />
     <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
-    <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
+    <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" />
     <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
     <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
 
@@ -201,6 +211,7 @@
     <protected-broadcast android:name="android.media.VOLUME_CHANGED_ACTION" />
     <protected-broadcast android:name="android.media.MASTER_VOLUME_CHANGED_ACTION" />
     <protected-broadcast android:name="android.media.MASTER_MUTE_CHANGED_ACTION" />
+    <protected-broadcast android:name="android.media.MASTER_MONO_CHANGED_ACTION" />
     <protected-broadcast android:name="android.media.SCO_AUDIO_STATE_CHANGED" />
     <protected-broadcast android:name="android.media.ACTION_SCO_AUDIO_STATE_UPDATED" />
 
@@ -220,6 +231,7 @@
     <!-- @deprecated.  Only {@link android.net.ConnectivityManager.CONNECTIVITY_ACTION} is sent. -->
     <protected-broadcast android:name="android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE" />
     <protected-broadcast android:name="android.net.conn.DATA_ACTIVITY_CHANGE" />
+    <protected-broadcast android:name="android.net.conn.RESTRICT_BACKGROUND_CHANGED" />
     <protected-broadcast android:name="android.net.conn.BACKGROUND_DATA_SETTING_CHANGED" />
     <protected-broadcast android:name="android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED" />
 
@@ -240,11 +252,12 @@
     <protected-broadcast android:name="android.intent.action.DREAMING_STARTED" />
     <protected-broadcast android:name="android.intent.action.DREAMING_STOPPED" />
     <protected-broadcast android:name="android.intent.action.ANY_DATA_STATE" />
-    <protected-broadcast android:name="android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN" />
 
     <protected-broadcast android:name="com.android.server.WifiManager.action.START_SCAN" />
     <protected-broadcast android:name="com.android.server.WifiManager.action.START_PNO" />
     <protected-broadcast android:name="com.android.server.WifiManager.action.DELAYED_DRIVER_STOP" />
+    <protected-broadcast android:name="com.android.server.action.REMOTE_BUGREPORT_SHARING_ACCEPTED" />
+    <protected-broadcast android:name="com.android.server.action.REMOTE_BUGREPORT_SHARING_DECLINED" />
     <protected-broadcast android:name="android.net.wifi.WIFI_STATE_CHANGED" />
     <protected-broadcast android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
     <protected-broadcast android:name="android.net.wifi.WIFI_CREDENTIAL_CHANGED" />
@@ -274,11 +287,17 @@
     <protected-broadcast android:name="android.intent.action.AIRPLANE_MODE" />
     <protected-broadcast android:name="android.intent.action.ADVANCED_SETTINGS" />
     <protected-broadcast android:name="android.intent.action.APPLICATION_RESTRICTIONS_CHANGED" />
+    <protected-broadcast android:name="android.intent.action.BUGREPORT_STARTED" />
     <protected-broadcast android:name="android.intent.action.BUGREPORT_FINISHED" />
+    <protected-broadcast android:name="android.intent.action.REMOTE_BUGREPORT_FINISHED" />
+    <protected-broadcast android:name="android.intent.action.REMOTE_BUGREPORT_DISPATCH" />
 
+    <!-- Legacy -->
     <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" />
     <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" />
 
+    <protected-broadcast android:name="com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE" />
+
     <protected-broadcast android:name="android.intent.action.HDMI_PLUGGED" />
 
     <protected-broadcast android:name="android.intent.action.PHONE_STATE" />
@@ -294,11 +313,11 @@
     <protected-broadcast android:name="android.telecom.action.DEFAULT_DIALER_CHANGED" />
 
     <protected-broadcast
-        android:name="com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION" />
+            android:name="com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION" />
 
     <!-- Defined in RestrictionsManager -->
     <protected-broadcast
-        android:name="android.intent.action.PERMISSION_RESPONSE_RECEIVED" />
+            android:name="android.intent.action.PERMISSION_RESPONSE_RECEIVED" />
     <!-- Defined in RestrictionsManager -->
 
     <protected-broadcast android:name="android.intent.action.REQUEST_PERMISSION" />
@@ -320,6 +339,94 @@
     <protected-broadcast android:name="android.internal.policy.action.BURN_IN_PROTECTION" />
     <protected-broadcast android:name="android.app.action.SYSTEM_UPDATE_POLICY_CHANGED" />
     <protected-broadcast android:name="android.app.action.DEVICE_OWNER_CHANGED" />
+
+    <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED" />
+
+    <!-- Added in N -->
+    <protected-broadcast android:name="android.intent.action.ANR" />
+    <protected-broadcast android:name="android.intent.action.CALL" />
+    <protected-broadcast android:name="android.intent.action.DROPBOX_ENTRY_ADDED" />
+    <protected-broadcast android:name="android.intent.action.INPUT_METHOD_CHANGED" />
+    <protected-broadcast android:name="android.intent.action.internal_sim_state_changed" />
+    <protected-broadcast android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
+    <protected-broadcast android:name="android.intent.action.PRECISE_CALL_STATE" />
+    <protected-broadcast android:name="android.intent.action.PRECISE_DATA_CONNECTION_STATE_CHANGED" />
+    <protected-broadcast android:name="android.intent.action.SUBSCRIPTION_PHONE_STATE" />
+    <protected-broadcast android:name="android.intent.action.USER_INFO_CHANGED" />
+    <protected-broadcast android:name="android.intent.action.USER_UNLOCKED" />
+    <protected-broadcast android:name="android.intent.action.WALLPAPER_CHANGED" />
+
+    <protected-broadcast android:name="android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED" />
+    <protected-broadcast android:name="android.app.action.CHOOSE_PRIVATE_KEY_ALIAS" />
+    <protected-broadcast android:name="android.app.action.DEVICE_ADMIN_DISABLED" />
+    <protected-broadcast android:name="android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED" />
+    <protected-broadcast android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+    <protected-broadcast android:name="android.app.action.LOCK_TASK_ENTERING" />
+    <protected-broadcast android:name="android.app.action.LOCK_TASK_EXITING" />
+    <protected-broadcast android:name="android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE" />
+    <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_CHANGED" />
+    <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_EXPIRING" />
+    <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_FAILED" />
+    <protected-broadcast android:name="android.app.action.ACTION_PASSWORD_SUCCEEDED" />
+    <protected-broadcast android:name="com.android.server.ACTION_EXPIRED_PASSWORD_NOTIFICATION" />
+    <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_ADDED" />
+
+    <protected-broadcast android:name="android.bluetooth.adapter.action.BLE_STATE_CHANGED" />
+    <protected-broadcast android:name="android.content.jobscheduler.JOB_DELAY_EXPIRED" />
+    <protected-broadcast android:name="android.content.syncmanager.SYNC_ALARM" />
+    <protected-broadcast android:name="android.media.INTERNAL_RINGER_MODE_CHANGED_ACTION" />
+    <protected-broadcast android:name="android.media.STREAM_DEVICES_CHANGED_ACTION" />
+    <protected-broadcast android:name="android.media.STREAM_MUTE_CHANGED_ACTION" />
+    <protected-broadcast android:name="android.net.sip.SIP_SERVICE_UP" />
+    <protected-broadcast android:name="android.nfc.action.ADAPTER_STATE_CHANGED" />
+    <protected-broadcast android:name="android.os.action.CHARGING" />
+    <protected-broadcast android:name="android.os.action.DISCHARGING" />
+    <protected-broadcast android:name="android.search.action.SEARCHABLES_CHANGED" />
+    <protected-broadcast android:name="android.security.STORAGE_CHANGED" />
+    <protected-broadcast android:name="android.telecom.action.PHONE_ACCOUNT_REGISTERED" />
+    <protected-broadcast android:name="android.telecom.action.PHONE_ACCOUNT_UNREGISTERED" />
+    <protected-broadcast android:name="android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION" />
+    <protected-broadcast android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
+
+    <protected-broadcast android:name="com.android.bluetooth.btservice.action.ALARM_WAKEUP" />
+    <protected-broadcast android:name="com.android.ims.IMS_SERVICE_UP" />
+    <protected-broadcast android:name="com.android.server.action.NETWORK_STATS_POLL" />
+    <protected-broadcast android:name="com.android.server.action.NETWORK_STATS_UPDATED" />
+    <protected-broadcast android:name="com.android.server.NetworkTimeUpdateService.action.POLL" />
+    <protected-broadcast android:name="com.android.server.telecom.intent.action.CALLS_ADD_ENTRY" />
+    <protected-broadcast android:name="com.android.settings.location.MODE_CHANGING" />
+
+    <protected-broadcast android:name="ScheduleConditionProvider.EVALUATE" />
+    <protected-broadcast android:name="wifi_scan_available" />
+
+    <protected-broadcast android:name="action.cne.started" />
+    <protected-broadcast android:name="android.content.jobscheduler.JOB_DEADLINE_EXPIRED" />
+    <protected-broadcast android:name="android.intent.action.ACTION_UNSOL_RESPONSE_OEM_HOOK_RAW" />
+    <protected-broadcast android:name="android.net.conn.CONNECTIVITY_CHANGE_SUPL" />
+    <protected-broadcast android:name="android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED" />
+    <protected-broadcast android:name="android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED" />
+    <protected-broadcast android:name="android.os.storage.action.VOLUME_STATE_CHANGED" />
+    <protected-broadcast android:name="com.android.server.action.UPDATE_TWILIGHT_STATE" />
+    <protected-broadcast android:name="com.android.server.device_idle.STEP_IDLE_STATE" />
+    <protected-broadcast android:name="com.android.server.device_idle.STEP_LIGHT_IDLE_STATE" />
+    <protected-broadcast android:name="com.android.server.Wifi.action.TOGGLE_PNO" />
+    <protected-broadcast android:name="intent.action.ACTION_RF_BAND_INFO" />
+    <protected-broadcast android:name="android.intent.action.MEDIA_RESOURCE_GRANTED" />
+    <protected-broadcast android:name="android.app.action.SECURITY_LOGS_AVAILABLE" />
+
+    <protected-broadcast android:name="android.app.action.INTERRUPTION_FILTER_CHANGED" />
+    <protected-broadcast android:name="android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL" />
+    <protected-broadcast android:name="android.app.action.NOTIFICATION_POLICY_CHANGED" />
+    <protected-broadcast android:name="android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED" />
+    <protected-broadcast android:name="android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED" />
+
+    <protected-broadcast android:name="android.permission.GET_APP_GRANTED_URI_PERMISSIONS" />
+    <protected-broadcast android:name="android.permission.CLEAR_APP_GRANTED_URI_PERMISSIONS" />
+
+    <protected-broadcast android:name="android.intent.action.DYNAMIC_SENSOR_CHANGED" />
+
+    <protected-broadcast android:name="android.intent.action.ACTION_RADIO_OFF" />
+
     <!-- ====================================================================== -->
     <!--                          RUNTIME PERMISSIONS                           -->
     <!-- ====================================================================== -->
@@ -332,28 +439,28 @@
 
     <!-- Used for runtime permissions related to user's contacts and profile. -->
     <permission-group android:name="android.permission-group.CONTACTS"
-        android:icon="@drawable/perm_group_contacts"
-        android:label="@string/permgrouplab_contacts"
-        android:description="@string/permgroupdesc_contacts"
-        android:priority="100" />
+                      android:icon="@drawable/perm_group_contacts"
+                      android:label="@string/permgrouplab_contacts"
+                      android:description="@string/permgroupdesc_contacts"
+                      android:priority="100" />
 
     <!-- Allows an application to read the user's contacts data.
         <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.READ_CONTACTS"
-        android:permissionGroup="android.permission-group.CONTACTS"
-        android:label="@string/permlab_readContacts"
-        android:description="@string/permdesc_readContacts"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.CONTACTS"
+                android:label="@string/permlab_readContacts"
+                android:description="@string/permdesc_readContacts"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to write the user's contacts data.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.WRITE_CONTACTS"
-        android:permissionGroup="android.permission-group.CONTACTS"
-        android:label="@string/permlab_writeContacts"
-        android:description="@string/permdesc_writeContacts"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.CONTACTS"
+                android:label="@string/permlab_writeContacts"
+                android:description="@string/permdesc_writeContacts"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing user's calendar                              -->
@@ -362,28 +469,28 @@
 
     <!-- Used for runtime permissions related to user's calendar. -->
     <permission-group android:name="android.permission-group.CALENDAR"
-        android:icon="@drawable/perm_group_calendar"
-        android:label="@string/permgrouplab_calendar"
-        android:description="@string/permgroupdesc_calendar"
-        android:priority="200" />
+                      android:icon="@drawable/perm_group_calendar"
+                      android:label="@string/permgrouplab_calendar"
+                      android:description="@string/permgroupdesc_calendar"
+                      android:priority="200" />
 
     <!-- Allows an application to read the user's calendar data.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.READ_CALENDAR"
-        android:permissionGroup="android.permission-group.CALENDAR"
-        android:label="@string/permlab_readCalendar"
-        android:description="@string/permdesc_readCalendar"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.CALENDAR"
+                android:label="@string/permlab_readCalendar"
+                android:description="@string/permdesc_readCalendar"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to write the user's calendar data.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.WRITE_CALENDAR"
-        android:permissionGroup="android.permission-group.CALENDAR"
-        android:label="@string/permlab_writeCalendar"
-        android:description="@string/permdesc_writeCalendar"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.CALENDAR"
+                android:label="@string/permlab_writeCalendar"
+                android:description="@string/permdesc_writeCalendar"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing and modifying user's SMS messages            -->
@@ -392,56 +499,56 @@
 
     <!-- Used for runtime permissions related to user's SMS messages. -->
     <permission-group android:name="android.permission-group.SMS"
-        android:icon="@drawable/perm_group_sms"
-        android:label="@string/permgrouplab_sms"
-        android:description="@string/permgroupdesc_sms"
-        android:priority="300" />
+                      android:icon="@drawable/perm_group_sms"
+                      android:label="@string/permgrouplab_sms"
+                      android:description="@string/permgroupdesc_sms"
+                      android:priority="300" />
 
     <!-- Allows an application to send SMS messages.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.SEND_SMS"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_sendSms"
-        android:description="@string/permdesc_sendSms"
-        android:permissionFlags="costsMoney"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_sendSms"
+                android:description="@string/permdesc_sendSms"
+                android:permissionFlags="costsMoney"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to receive SMS messages.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.RECEIVE_SMS"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_receiveSms"
-        android:description="@string/permdesc_receiveSms"
-        android:protectionLevel="dangerous"/>
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_receiveSms"
+                android:description="@string/permdesc_receiveSms"
+                android:protectionLevel="dangerous"/>
 
     <!-- Allows an application to read SMS messages.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.READ_SMS"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_readSms"
-        android:description="@string/permdesc_readSms"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_readSms"
+                android:description="@string/permdesc_readSms"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to receive WAP push messages.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.RECEIVE_WAP_PUSH"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_receiveWapPush"
-        android:description="@string/permdesc_receiveWapPush"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_receiveWapPush"
+                android:description="@string/permdesc_receiveWapPush"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to monitor incoming MMS messages.
         <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.RECEIVE_MMS"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_receiveMms"
-        android:description="@string/permdesc_receiveMms"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_receiveMms"
+                android:description="@string/permdesc_receiveMms"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to read previously received cell broadcast
          messages and to register a content observer to get notifications when
@@ -456,10 +563,10 @@
          <p>Protection level: dangerous
          @hide Pending API council approval -->
     <permission android:name="android.permission.READ_CELL_BROADCASTS"
-        android:permissionGroup="android.permission-group.SMS"
-        android:label="@string/permlab_readCellBroadcasts"
-        android:description="@string/permdesc_readCellBroadcasts"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SMS"
+                android:label="@string/permlab_readCellBroadcasts"
+                android:description="@string/permdesc_readCellBroadcasts"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing external storage                             -->
@@ -468,10 +575,10 @@
 
     <!-- Used for runtime permissions related to the shared external storage. -->
     <permission-group android:name="android.permission-group.STORAGE"
-        android:icon="@drawable/perm_group_storage"
-        android:label="@string/permgrouplab_storage"
-        android:description="@string/permgroupdesc_storage"
-        android:priority="900" />
+                      android:icon="@drawable/perm_group_storage"
+                      android:label="@string/permgrouplab_storage"
+                      android:description="@string/permgroupdesc_storage"
+                      android:priority="900" />
 
     <!-- Allows an application to read from external storage.
      <p>Any app that declares the {@link #WRITE_EXTERNAL_STORAGE} permission is implicitly
@@ -496,10 +603,10 @@
      <p>Protection level: dangerous
      -->
     <permission android:name="android.permission.READ_EXTERNAL_STORAGE"
-        android:permissionGroup="android.permission-group.STORAGE"
-        android:label="@string/permlab_sdcardRead"
-        android:description="@string/permdesc_sdcardRead"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.STORAGE"
+                android:label="@string/permlab_sdcardRead"
+                android:description="@string/permdesc_sdcardRead"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to write to external storage.
          <p class="note"><strong>Note:</strong> If <em>both</em> your <a
@@ -517,10 +624,10 @@
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
-        android:permissionGroup="android.permission-group.STORAGE"
-        android:label="@string/permlab_sdcardWrite"
-        android:description="@string/permdesc_sdcardWrite"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.STORAGE"
+                android:label="@string/permlab_sdcardWrite"
+                android:description="@string/permdesc_sdcardWrite"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing the device location                          -->
@@ -529,28 +636,28 @@
 
     <!-- Used for permissions that allow accessing the device location. -->
     <permission-group android:name="android.permission-group.LOCATION"
-        android:icon="@drawable/perm_group_location"
-        android:label="@string/permgrouplab_location"
-        android:description="@string/permgroupdesc_location"
-        android:priority="400" />
+                      android:icon="@drawable/perm_group_location"
+                      android:label="@string/permgrouplab_location"
+                      android:description="@string/permgroupdesc_location"
+                      android:priority="400" />
 
     <!-- Allows an app to access precise location.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.ACCESS_FINE_LOCATION"
-        android:permissionGroup="android.permission-group.LOCATION"
-        android:label="@string/permlab_accessFineLocation"
-        android:description="@string/permdesc_accessFineLocation"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.LOCATION"
+                android:label="@string/permlab_accessFineLocation"
+                android:description="@string/permdesc_accessFineLocation"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an app to access approximate location.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.ACCESS_COARSE_LOCATION"
-        android:permissionGroup="android.permission-group.LOCATION"
-        android:label="@string/permlab_accessCoarseLocation"
-        android:description="@string/permdesc_accessCoarseLocation"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.LOCATION"
+                android:label="@string/permlab_accessCoarseLocation"
+                android:description="@string/permdesc_accessCoarseLocation"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing the device telephony                         -->
@@ -559,10 +666,10 @@
 
     <!-- Used for permissions that are associated telephony features. -->
     <permission-group android:name="android.permission-group.PHONE"
-        android:icon="@drawable/perm_group_phone_calls"
-        android:label="@string/permgrouplab_phone"
-        android:description="@string/permgroupdesc_phone"
-        android:priority="500" />
+                      android:icon="@drawable/perm_group_phone_calls"
+                      android:label="@string/permgrouplab_phone"
+                      android:description="@string/permgroupdesc_phone"
+                      android:priority="500" />
 
     <!-- Allows read only access to phone state.
          <p class="note"><strong>Note:</strong> If <em>both</em> your <a
@@ -576,32 +683,32 @@
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.READ_PHONE_STATE"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_readPhoneState"
-        android:description="@string/permdesc_readPhoneState"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_readPhoneState"
+                android:description="@string/permdesc_readPhoneState"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to initiate a phone call without going through
         the Dialer user interface for the user to confirm the call.
         <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.CALL_PHONE"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:permissionFlags="costsMoney"
-        android:label="@string/permlab_callPhone"
-        android:description="@string/permdesc_callPhone"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:permissionFlags="costsMoney"
+                android:label="@string/permlab_callPhone"
+                android:description="@string/permdesc_callPhone"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to access the IMS call service: making and
          modifying a call
-        <p>Protection level: signature|system
+        <p>Protection level: signature|privileged
         @hide
     -->
     <permission android:name="android.permission.ACCESS_IMS_CALL_SERVICE"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_accessImsCallService"
-        android:description="@string/permdesc_accessImsCallService"
-        android:protectionLevel="signature|system" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_accessImsCallService"
+                android:description="@string/permdesc_accessImsCallService"
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to read the user's call log.
          <p class="note"><strong>Note:</strong> If your app uses the
@@ -616,13 +723,13 @@
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.READ_CALL_LOG"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_readCallLog"
-        android:description="@string/permdesc_readCallLog"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_readCallLog"
+                android:description="@string/permdesc_readCallLog"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to write (but not read) the user's
-         contacts data.
+         call log data.
          <p class="note"><strong>Note:</strong> If your app uses the
          {@link #WRITE_CONTACTS} permission and <em>both</em> your <a
          href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
@@ -635,28 +742,28 @@
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.WRITE_CALL_LOG"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_writeCallLog"
-        android:description="@string/permdesc_writeCallLog"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_writeCallLog"
+                android:description="@string/permdesc_writeCallLog"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to add voicemails into the system.
          <p>Protection level: dangerous
     -->
     <permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_addVoicemail"
-        android:description="@string/permdesc_addVoicemail"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_addVoicemail"
+                android:description="@string/permdesc_addVoicemail"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an application to use SIP service.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.USE_SIP"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:description="@string/permdesc_use_sip"
-        android:label="@string/permlab_use_sip"
-        android:protectionLevel="dangerous"/>
+                android:permissionGroup="android.permission-group.PHONE"
+                android:description="@string/permdesc_use_sip"
+                android:label="@string/permlab_use_sip"
+                android:protectionLevel="dangerous"/>
 
     <!-- Allows an application to see the number being dialed during an outgoing
          call with the option to redirect the call to a different number or
@@ -664,10 +771,10 @@
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.PROCESS_OUTGOING_CALLS"
-        android:permissionGroup="android.permission-group.PHONE"
-        android:label="@string/permlab_processOutgoingCalls"
-        android:description="@string/permdesc_processOutgoingCalls"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.PHONE"
+                android:label="@string/permlab_processOutgoingCalls"
+                android:description="@string/permdesc_processOutgoingCalls"
+                android:protectionLevel="dangerous" />
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing the device microphone                        -->
@@ -678,19 +785,19 @@
          microphone audio from the device. Note that phone calls also capture audio
          but are in a separate (more visible) permission group. -->
     <permission-group android:name="android.permission-group.MICROPHONE"
-        android:icon="@drawable/perm_group_microphone"
-        android:label="@string/permgrouplab_microphone"
-        android:description="@string/permgroupdesc_microphone"
-        android:priority="600" />
+                      android:icon="@drawable/perm_group_microphone"
+                      android:label="@string/permgrouplab_microphone"
+                      android:description="@string/permgroupdesc_microphone"
+                      android:priority="600" />
 
     <!-- Allows an application to record audio.
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.RECORD_AUDIO"
-        android:permissionGroup="android.permission-group.MICROPHONE"
-        android:label="@string/permlab_recordAudio"
-        android:description="@string/permdesc_recordAudio"
-        android:protectionLevel="dangerous"/>
+                android:permissionGroup="android.permission-group.MICROPHONE"
+                android:label="@string/permlab_recordAudio"
+                android:description="@string/permdesc_recordAudio"
+                android:protectionLevel="dangerous"/>
 
     <!-- ====================================================================== -->
     <!-- Permissions for accessing the device camera                            -->
@@ -700,25 +807,25 @@
     <!-- Used for permissions that are associated with accessing
      camera or capturing images/video from the device. -->
     <permission-group android:name="android.permission-group.CAMERA"
-        android:icon="@drawable/perm_group_camera"
-        android:label="@string/permgrouplab_camera"
-        android:description="@string/permgroupdesc_camera"
-        android:priority="700" />
+                      android:icon="@drawable/perm_group_camera"
+                      android:label="@string/permgrouplab_camera"
+                      android:description="@string/permgroupdesc_camera"
+                      android:priority="700" />
 
     <!-- Required to be able to access the camera device.
          <p>This will automatically enforce the <a
-         href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code
-         &lt;uses-feature&gt;}</a> manifest element for <em>all</em> camera features.
+         href="{@docRoot}guide/topics/manifest/uses-feature-element.html">
+         <uses-feature>}</a> manifest element for <em>all</em> camera features.
          If you do not require all camera features or can properly operate if a camera
          is not available, then you must modify your manifest as appropriate in order to
          install on devices that don't support all camera features.</p>
          <p>Protection level: dangerous
     -->
     <permission android:name="android.permission.CAMERA"
-        android:permissionGroup="android.permission-group.CAMERA"
-        android:label="@string/permlab_camera"
-        android:description="@string/permdesc_camera"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.CAMERA"
+                android:label="@string/permlab_camera"
+                android:description="@string/permdesc_camera"
+                android:protectionLevel="dangerous" />
 
 
     <!-- ====================================================================== -->
@@ -729,28 +836,28 @@
     <!-- Used for permissions that are associated with accessing
          camera or capturing images/video from the device. -->
     <permission-group android:name="android.permission-group.SENSORS"
-        android:icon="@drawable/perm_group_sensors"
-        android:label="@string/permgrouplab_sensors"
-        android:description="@string/permgroupdesc_sensors"
-        android:priority="800" />
+                      android:icon="@drawable/perm_group_sensors"
+                      android:label="@string/permgrouplab_sensors"
+                      android:description="@string/permgroupdesc_sensors"
+                      android:priority="800" />
 
     <!-- Allows an application to access data from sensors that the user uses to
          measure what is happening inside his/her body, such as heart rate.
          <p>Protection level: dangerous -->
     <permission android:name="android.permission.BODY_SENSORS"
-        android:permissionGroup="android.permission-group.SENSORS"
-        android:label="@string/permlab_bodySensors"
-        android:description="@string/permdesc_bodySensors"
-        android:protectionLevel="dangerous" />
+                android:permissionGroup="android.permission-group.SENSORS"
+                android:label="@string/permlab_bodySensors"
+                android:description="@string/permdesc_bodySensors"
+                android:protectionLevel="dangerous" />
 
     <!-- Allows an app to use fingerprint hardware.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.USE_FINGERPRINT"
-        android:permissionGroup="android.permission-group.SENSORS"
-        android:label="@string/permlab_useFingerprint"
-        android:description="@string/permdesc_useFingerprint"
-        android:protectionLevel="normal" />
+                android:permissionGroup="android.permission-group.SENSORS"
+                android:label="@string/permlab_useFingerprint"
+                android:description="@string/permdesc_useFingerprint"
+                android:protectionLevel="normal" />
 
     <!-- ====================================================================== -->
     <!-- REMOVED PERMISSIONS                                                    -->
@@ -758,78 +865,93 @@
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_PROFILE"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_PROFILE"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_SOCIAL_STREAM"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_SOCIAL_STREAM"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.READ_USER_DICTIONARY"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_USER_DICTIONARY"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.WRITE_SMS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.MANAGE_ACCOUNTS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.USE_CREDENTIALS"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.SUBSCRIBED_FEEDS_READ"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- @hide We need to keep this around for backwards compatibility -->
     <permission android:name="android.permission.SUBSCRIBED_FEEDS_WRITE"
-        android:protectionLevel="normal"
-        android:permissionFlags="hidden"/>
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
+
+    <!-- @hide We need to keep this around for backwards compatibility -->
+    <permission android:name="android.permission.FLASHLIGHT"
+                android:protectionLevel="normal"
+                android:permissionFlags="hidden"/>
 
     <!-- ====================================================================== -->
     <!-- INSTALL PERMISSIONS                                                    -->
     <!-- ====================================================================== -->
 
+    `   <!-- =========================================== -->
+    <!-- Permissions for accessing contact metadata -->
+    <!-- =========================================== -->
+    <eat-comment />
+
+    <!-- @SystemApi Allows an application to read/write contact metadata.
+         <p>Not for use by third-party applications. -->
+    <permission android:name="android.permission.READ_WRITE_CONTACT_METADATA"
+                android:protectionLevel="signature|system" />
+
     <!-- ================================== -->
     <!-- Permissions for accessing messages -->
     <!-- ================================== -->
@@ -839,31 +961,35 @@
          to handle the respond-via-message action during incoming calls.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SEND_RESPOND_VIA_MESSAGE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to filter carrier specific sms.
          @hide -->
     <permission android:name="android.permission.CARRIER_FILTER_SMS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to receive emergency cell broadcast messages,
          to record or display them to the user.
-         <p>Not for use by third-party applications.
-         @hide Pending API council approval -->
+         <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.RECEIVE_EMERGENCY_BROADCAST"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to monitor incoming Bluetooth MAP messages, to record
          or perform processing on them. -->
     <!-- @hide -->
     <permission android:name="android.permission.RECEIVE_BLUETOOTH_MAP"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows an application to execute contacts directory search.
          This should only be used by ContactsProvider.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.BIND_DIRECTORY_SEARCH"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
+
+    <!-- @SystemApi @hide Allows an application to modify cell broadcasts through the content provider.
+         <p>Not for use by third-party applications. -->
+    <permission android:name="android.permission.MODIFY_CELL_BROADCASTS"
+                android:protectionLevel="signature|privileged" />
 
     <!-- =============================================================== -->
     <!-- Permissions for setting the device alarm                        -->
@@ -874,9 +1000,9 @@
          <p>Protection level: normal
     -->
     <permission android:name="com.android.alarm.permission.SET_ALARM"
-        android:label="@string/permlab_setAlarm"
-        android:description="@string/permdesc_setAlarm"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_setAlarm"
+                android:description="@string/permdesc_setAlarm"
+                android:protectionLevel="normal" />
 
     <!-- =============================================================== -->
     <!-- Permissions for accessing the user voicemail                    -->
@@ -884,16 +1010,16 @@
     <eat-comment />
 
     <!-- Allows an application to modify and remove existing voicemails in the system
-        <p>Protection level: system|signature
+        <p>Protection level: signature|privileged
     -->
     <permission android:name="com.android.voicemail.permission.WRITE_VOICEMAIL"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to read voicemails in the system.
-         <p>Protection level: system|signature
+         <p>Protection level: signature|privileged
     -->
     <permission android:name="com.android.voicemail.permission.READ_VOICEMAIL"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ======================================= -->
     <!-- Permissions for accessing location info -->
@@ -904,26 +1030,26 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
-        android:label="@string/permlab_accessLocationExtraCommands"
-        android:description="@string/permdesc_accessLocationExtraCommands"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_accessLocationExtraCommands"
+                android:description="@string/permdesc_accessLocationExtraCommands"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows an application to install a location provider into the Location Manager.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows HDMI-CEC service to access device and configuration files.
          This should only be used by HDMI-CEC service.
     -->
     <permission android:name="android.permission.HDMI_CEC"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to use location features in hardware,
          such as the geofencing api.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.LOCATION_HARDWARE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
     <uses-permission android:name="android.permission.LOCATION_HARDWARE"/>
 
     <!-- @SystemApi Allows an application to create mock location providers for testing.
@@ -931,7 +1057,7 @@
          @hide
     -->
     <permission android:name="android.permission.ACCESS_MOCK_LOCATION"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- ======================================= -->
     <!-- Permissions for accessing networks -->
@@ -942,67 +1068,73 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.INTERNET"
-        android:description="@string/permdesc_createNetworkSockets"
-        android:label="@string/permlab_createNetworkSockets"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_createNetworkSockets"
+                android:label="@string/permlab_createNetworkSockets"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to access information about networks
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.ACCESS_NETWORK_STATE"
-        android:description="@string/permdesc_accessNetworkState"
-        android:label="@string/permlab_accessNetworkState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_accessNetworkState"
+                android:label="@string/permlab_accessNetworkState"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to access information about Wi-Fi networks.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.ACCESS_WIFI_STATE"
-        android:description="@string/permdesc_accessWifiState"
-        android:label="@string/permlab_accessWifiState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_accessWifiState"
+                android:label="@string/permlab_accessWifiState"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to change Wi-Fi connectivity state.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.CHANGE_WIFI_STATE"
-        android:description="@string/permdesc_changeWifiState"
-        android:label="@string/permlab_changeWifiState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_changeWifiState"
+                android:label="@string/permlab_changeWifiState"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi @hide Allows applications to read Wi-Fi credential.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.READ_WIFI_CREDENTIAL"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
+
+    <!-- @SystemApi @hide Allows applications to change tether state and run
+         tether carrier provisioning.
+         <p>Not for use by third-party applications. -->
+    <permission android:name="android.permission.TETHER_PRIVILEGED"
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allow system apps to receive broadcast
          when a wifi network credential is changed.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.RECEIVE_WIFI_CREDENTIAL_CHANGE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows an application to modify any wifi configuration, even if created
      by another application. Once reconfigured the original creator cannot make any further
      modifications.
      <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.OVERRIDE_WIFI_CONFIG"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @hide -->
     <permission android:name="android.permission.ACCESS_WIMAX_STATE"
-        android:description="@string/permdesc_accessWimaxState"
-        android:label="@string/permlab_accessWimaxState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_accessWimaxState"
+                android:label="@string/permlab_accessWimaxState"
+                android:protectionLevel="normal" />
 
     <!-- @hide -->
     <permission android:name="android.permission.CHANGE_WIMAX_STATE"
-        android:description="@string/permdesc_changeWimaxState"
-        android:label="@string/permlab_changeWimaxState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_changeWimaxState"
+                android:label="@string/permlab_changeWimaxState"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to act as network scorers. @hide @SystemApi-->
     <permission android:name="android.permission.SCORE_NETWORKS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ======================================= -->
     <!-- Permissions for short range, peripheral networks -->
@@ -1013,68 +1145,68 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.BLUETOOTH"
-        android:description="@string/permdesc_bluetooth"
-        android:label="@string/permlab_bluetooth"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_bluetooth"
+                android:label="@string/permlab_bluetooth"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to discover and pair bluetooth devices.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.BLUETOOTH_ADMIN"
-        android:description="@string/permdesc_bluetoothAdmin"
-        android:label="@string/permlab_bluetoothAdmin"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_bluetoothAdmin"
+                android:label="@string/permlab_bluetoothAdmin"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows applications to pair bluetooth devices without user interaction, and to
          allow or disallow phonebook access or message access.
          This is not available to third party applications. -->
     <permission android:name="android.permission.BLUETOOTH_PRIVILEGED"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Control access to email providers exclusively for Bluetooth
          @hide
     -->
     <permission android:name="android.permission.BLUETOOTH_MAP"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows bluetooth stack to access files
          @hide This should only be used by Bluetooth apk.
     -->
     <permission android:name="android.permission.BLUETOOTH_STACK"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows applications to perform I/O operations over NFC.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.NFC"
-        android:description="@string/permdesc_nfc"
-        android:label="@string/permlab_nfc"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_nfc"
+                android:label="@string/permlab_nfc"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows an internal user to use privileged ConnectivityManager APIs.
          @hide -->
     <permission android:name="android.permission.CONNECTIVITY_INTERNAL"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows a system application to access hardware packet offload capabilities.
          @hide -->
     <permission android:name="android.permission.PACKET_KEEPALIVE_OFFLOAD"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi
          @hide -->
     <permission android:name="android.permission.RECEIVE_DATA_ACTIVITY_CHANGE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows access to the loop radio (Android@Home mesh network) device.
          @hide -->
     <permission android:name="android.permission.LOOP_RADIO"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows sending and receiving handover transfer status from Wifi and Bluetooth
          @hide -->
     <permission android:name="android.permission.NFC_HANDOVER_STATUS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ================================== -->
     <!-- Permissions for accessing accounts -->
@@ -1085,15 +1217,15 @@
         <p>Protection level: normal
     -->
     <permission android:name="android.permission.GET_ACCOUNTS"
-        android:permissionGroup="android.permission-group.CONTACTS"
-        android:protectionLevel="dangerous"
-        android:description="@string/permdesc_getAccounts"
-        android:label="@string/permlab_getAccounts" />
+                android:permissionGroup="android.permission-group.CONTACTS"
+                android:protectionLevel="dangerous"
+                android:description="@string/permdesc_getAccounts"
+                android:label="@string/permlab_getAccounts" />
 
     <!-- @SystemApi Allows applications to call into AccountAuthenticators.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.ACCOUNT_MANAGER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- ================================== -->
     <!-- Permissions for accessing hardware that may effect battery life-->
@@ -1104,42 +1236,34 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"
-        android:description="@string/permdesc_changeWifiMulticastState"
-        android:label="@string/permlab_changeWifiMulticastState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_changeWifiMulticastState"
+                android:label="@string/permlab_changeWifiMulticastState"
+                android:protectionLevel="normal" />
 
     <!-- Allows access to the vibrator.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.VIBRATE"
-        android:label="@string/permlab_vibrate"
-        android:description="@string/permdesc_vibrate"
-        android:protectionLevel="normal" />
-
-    <!-- Allows access to the flashlight.
-         <p>Protection level: normal
-    -->
-    <permission android:name="android.permission.FLASHLIGHT"
-        android:label="@string/permlab_flashlight"
-        android:description="@string/permdesc_flashlight"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_vibrate"
+                android:description="@string/permdesc_vibrate"
+                android:protectionLevel="normal" />
 
     <!-- Allows using PowerManager WakeLocks to keep processor from sleeping or screen
          from dimming.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.WAKE_LOCK"
-        android:label="@string/permlab_wakeLock"
-        android:description="@string/permdesc_wakeLock"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_wakeLock"
+                android:description="@string/permdesc_wakeLock"
+                android:protectionLevel="normal" />
 
     <!-- Allows using the device's IR transmitter, if available.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.TRANSMIT_IR"
-        android:label="@string/permlab_transmitIr"
-        android:description="@string/permdesc_transmitIr"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_transmitIr"
+                android:description="@string/permdesc_transmitIr"
+                android:protectionLevel="normal" />
 
     <!-- ==================================================== -->
     <!-- Permissions related to changing audio settings   -->
@@ -1150,9 +1274,9 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"
-        android:label="@string/permlab_modifyAudioSettings"
-        android:description="@string/permdesc_modifyAudioSettings"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_modifyAudioSettings"
+                android:description="@string/permdesc_modifyAudioSettings"
+                android:protectionLevel="normal" />
 
     <!-- ================================== -->
     <!-- Permissions for accessing hardware -->
@@ -1162,68 +1286,68 @@
     <!-- @SystemApi Allows an application to manage preferences and permissions for USB devices
          @hide -->
     <permission android:name="android.permission.MANAGE_USB"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to access the MTP USB kernel driver.
          For use only by the device side MTP implementation.
          @hide -->
     <permission android:name="android.permission.ACCESS_MTP"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows access to hardware peripherals.  Intended only for hardware testing.
          <p>Not for use by third-party applications.
          @hide
     -->
     <permission android:name="android.permission.HARDWARE_TEST"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @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" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows access to configure network interfaces, configure/use IPSec, etc.
          @hide -->
     <permission android:name="android.permission.NET_ADMIN"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows registration for remote audio playback. @hide -->
     <permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows TvInputService to access underlying TV input hardware such as
          built-in tuners and HDMI-in's.
          @hide This should only be used by OEM's TvInputService's.
     -->
     <permission android:name="android.permission.TV_INPUT_HARDWARE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows to capture a frame of TV input hardware such as
          built-in tuners and HDMI-in's.
          @hide <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.CAPTURE_TV_INPUT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @hide Allows TvInputService to access DVB device.
    <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.DVB_DEVICE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @hide Allows enabling/disabling OEM unlock
    <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.OEM_UNLOCK_STATE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows querying state of PersistentDataBlock
    <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.ACCESS_PDB_STATE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows system update service to notify device owner about pending updates.
    <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.NOTIFY_PENDING_SYSTEM_UPDATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- =========================================== -->
     <!-- Permissions associated with camera and image capture -->
@@ -1234,12 +1358,12 @@
          a camera is in use by an application.
          @hide -->
     <permission android:name="android.permission.CAMERA_DISABLE_TRANSMIT_LED"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows sending the camera service notifications about system-wide events.
         @hide -->
     <permission android:name="android.permission.CAMERA_SEND_SYSTEM_EVENTS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- =========================================== -->
     <!-- Permissions associated with telephony state -->
@@ -1250,43 +1374,50 @@
          Does not include placing calls.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.MODIFY_PHONE_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows read only access to precise phone state.
          @hide Pending API council approval -->
     <permission android:name="android.permission.READ_PRECISE_PHONE_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows read access to privileged phone state.
          @hide Used internally. -->
     <permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Protects the ability to register any PhoneAccount with
          PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION. This capability indicates that the PhoneAccount
          corresponds to a device SIM.
          @hide -->
     <permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Protects the ability to register any PhoneAccount with
          PhoneAccount#CAPABILITY_CALL_PROVIDER.
          @hide -->
     <permission android:name="android.permission.REGISTER_CALL_PROVIDER"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Protects the ability to register any PhoneAccount with
          PhoneAccount#CAPABILITY_CONNECTION_MANAGER
          @hide -->
     <permission android:name="android.permission.REGISTER_CONNECTION_MANAGER"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link android.telecom.InCallService},
          to ensure that only the system can bind to it.
-         <p>Protection level: system|signature
+         <p>Protection level: signature|privileged
     -->
     <permission android:name="android.permission.BIND_INCALL_SERVICE"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
+
+    <!-- Must be required by a {@link android.telecom.CallScreeningService},
+         to ensure that only the system can bind to it.
+         <p>Protection level: signature|privileged
+    -->
+    <permission android:name="android.permission.BIND_SCREENING_SERVICE"
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link android.telecom.ConnectionService},
          to ensure that only the system can bind to it.
@@ -1295,24 +1426,24 @@
          @SystemApi
          @hide -->
     <permission android:name="android.permission.BIND_CONNECTION_SERVICE"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link android.telecom.ConnectionService},
          to ensure that only the system can bind to it.
-         <p>Protection level: system|signature
+         <p>Protection level: signature|privileged
     -->
     <permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to control the in-call experience.
          @hide -->
     <permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to receive STK related commands.
          @hide -->
     <permission android:name="android.permission.RECEIVE_STK_COMMANDS"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ================================== -->
     <!-- Permissions for sdcard interaction -->
@@ -1322,14 +1453,14 @@
     <!-- @SystemApi Allows an application to write to internal media storage
          @hide  -->
     <permission android:name="android.permission.WRITE_MEDIA_STORAGE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to manage access to documents, usually as part
          of a document picker.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.MANAGE_DOCUMENTS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- ================================== -->
     <!-- Permissions for screenlock         -->
@@ -1340,9 +1471,9 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.DISABLE_KEYGUARD"
-        android:description="@string/permdesc_disableKeyguard"
-        android:label="@string/permlab_disableKeyguard"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_disableKeyguard"
+                android:label="@string/permlab_disableKeyguard"
+                android:protectionLevel="normal" />
 
     <!-- ================================== -->
     <!-- Permissions to access other installed applications  -->
@@ -1351,9 +1482,9 @@
 
     <!-- @deprecated No longer enforced. -->
     <permission android:name="android.permission.GET_TASKS"
-        android:label="@string/permlab_getTasks"
-        android:description="@string/permdesc_getTasks"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_getTasks"
+                android:description="@string/permdesc_getTasks"
+                android:protectionLevel="normal" />
 
     <!-- New version of GET_TASKS that apps can request, since GET_TASKS doesn't really
          give access to task information.  We need this new one because there are
@@ -1366,87 +1497,93 @@
          @hide
          @SystemApi -->
     <permission android:name="android.permission.REAL_GET_TASKS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to start a task from a ActivityManager#RecentTaskInfo.
          @hide -->
     <permission android:name="android.permission.START_TASKS_FROM_RECENTS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows an application to call APIs that allow it to do interactions
          across the users on the device, using singleton services and
          user-targeted broadcasts.  This permission is not available to
          third party applications. -->
     <permission android:name="android.permission.INTERACT_ACROSS_USERS"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @hide Fuller form of {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
          that removes restrictions on where broadcasts can be sent and allows other
          types of interactions. -->
     <permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
-        android:protectionLevel="signature|installer" />
+                android:protectionLevel="signature|installer" />
 
     <!-- @SystemApi @hide Allows an application to call APIs that allow it to query and manage
          users on the device. This permission is not available to
          third party applications. -->
     <permission android:name="android.permission.MANAGE_USERS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @hide Allows an application to set the profile owners and the device owner.
          This permission is not available to third party applications.-->
     <permission android:name="android.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS"
-        android:protectionLevel="signature"
-        android:label="@string/permlab_manageProfileAndDeviceOwners"
-        android:description="@string/permdesc_manageProfileAndDeviceOwners" />
+                android:protectionLevel="signature"
+                android:label="@string/permlab_manageProfileAndDeviceOwners"
+                android:description="@string/permdesc_manageProfileAndDeviceOwners" />
 
     <!-- Allows an application to get full detailed information about
          recently running tasks, with full fidelity to the real state.
          @hide -->
     <permission android:name="android.permission.GET_DETAILED_TASKS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to change the Z-order of tasks.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.REORDER_TASKS"
-        android:label="@string/permlab_reorderTasks"
-        android:description="@string/permdesc_reorderTasks"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_reorderTasks"
+                android:description="@string/permdesc_reorderTasks"
+                android:protectionLevel="normal" />
 
     <!-- @hide Allows an application to change to remove/kill tasks -->
     <permission android:name="android.permission.REMOVE_TASKS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi @hide Allows an application to create/manage/remove stacks -->
     <permission android:name="android.permission.MANAGE_ACTIVITY_STACKS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to start any activity, regardless of permission
          protection or exported state.
          @hide -->
     <permission android:name="android.permission.START_ANY_ACTIVITY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @deprecated The {@link android.app.ActivityManager#restartPackage}
         API is no longer supported. -->
     <permission android:name="android.permission.RESTART_PACKAGES"
-        android:label="@string/permlab_killBackgroundProcesses"
-        android:description="@string/permdesc_killBackgroundProcesses"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_killBackgroundProcesses"
+                android:description="@string/permdesc_killBackgroundProcesses"
+                android:protectionLevel="normal" />
 
     <!-- Allows an application to call
         {@link android.app.ActivityManager#killBackgroundProcesses}.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"
-        android:label="@string/permlab_killBackgroundProcesses"
-        android:description="@string/permdesc_killBackgroundProcesses"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_killBackgroundProcesses"
+                android:description="@string/permdesc_killBackgroundProcesses"
+                android:protectionLevel="normal" />
+
+    <!-- @SystemApi @hide Allows an application to query process states and current
+         OOM adjustment scores.
+         <p>Not for use by third-party applications. -->
+    <permission android:name="android.permission.GET_PROCESS_STATE_AND_OOM_SCORE"
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi @hide Allows an application to retrieve a package's importance.
          This permission is not available to third party applications. -->
     <permission android:name="android.permission.GET_PACKAGE_IMPORTANCE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ================================== -->
     <!-- Permissions affecting the display of other applications  -->
@@ -1459,9 +1596,9 @@
          should use this permission; these windows are intended for
          system-level interaction with the user. -->
     <permission android:name="android.permission.SYSTEM_ALERT_WINDOW"
-        android:label="@string/permlab_systemAlertWindow"
-        android:description="@string/permdesc_systemAlertWindow"
-        android:protectionLevel="signature|preinstalled|appop|pre23|development" />
+                android:label="@string/permlab_systemAlertWindow"
+                android:description="@string/permdesc_systemAlertWindow"
+                android:protectionLevel="signature|preinstalled|appop|pre23|development" />
 
     <!-- ================================== -->
     <!-- Permissions affecting the system wallpaper -->
@@ -1472,17 +1609,17 @@
          <p>Protection level: normal
      -->
     <permission android:name="android.permission.SET_WALLPAPER"
-        android:label="@string/permlab_setWallpaper"
-        android:description="@string/permdesc_setWallpaper"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_setWallpaper"
+                android:description="@string/permdesc_setWallpaper"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to set the wallpaper hints.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.SET_WALLPAPER_HINTS"
-        android:label="@string/permlab_setWallpaperHints"
-        android:description="@string/permdesc_setWallpaperHints"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_setWallpaperHints"
+                android:description="@string/permdesc_setWallpaperHints"
+                android:protectionLevel="normal" />
 
     <!-- ============================================ -->
     <!-- Permissions for changing the system clock -->
@@ -1492,15 +1629,15 @@
     <!-- @SystemApi Allows applications to set the system time.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SET_TIME"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows applications to set the system time zone.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.SET_TIME_ZONE"
-        android:label="@string/permlab_setTimeZone"
-        android:description="@string/permdesc_setTimeZone"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_setTimeZone"
+                android:description="@string/permdesc_setTimeZone"
+                android:protectionLevel="normal" />
 
     <!-- ==================================================== -->
     <!-- Permissions related to changing status bar   -->
@@ -1511,9 +1648,9 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.EXPAND_STATUS_BAR"
-        android:label="@string/permlab_expandStatusBar"
-        android:description="@string/permdesc_expandStatusBar"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_expandStatusBar"
+                android:description="@string/permdesc_expandStatusBar"
+                android:protectionLevel="normal" />
 
     <!-- ============================================================== -->
     <!-- Permissions related to adding/removing shortcuts from Launcher -->
@@ -1524,17 +1661,17 @@
          <p>Protection level: normal
     -->
     <permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
-        android:label="@string/permlab_install_shortcut"
-        android:description="@string/permdesc_install_shortcut"
-        android:protectionLevel="normal"/>
+                android:label="@string/permlab_install_shortcut"
+                android:description="@string/permdesc_install_shortcut"
+                android:protectionLevel="normal"/>
 
     <!-- Allows an application to uninstall a shortcut in Launcher.
          <p>Protection level: normal
     -->
     <permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"
-        android:label="@string/permlab_uninstall_shortcut"
-        android:description="@string/permdesc_uninstall_shortcut"
-        android:protectionLevel="normal"/>
+                android:label="@string/permlab_uninstall_shortcut"
+                android:description="@string/permdesc_uninstall_shortcut"
+                android:protectionLevel="normal"/>
 
     <!-- ==================================================== -->
     <!-- Permissions related to accessing sync settings   -->
@@ -1545,25 +1682,25 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.READ_SYNC_SETTINGS"
-        android:description="@string/permdesc_readSyncSettings"
-        android:label="@string/permlab_readSyncSettings"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_readSyncSettings"
+                android:label="@string/permlab_readSyncSettings"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to write the sync settings.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.WRITE_SYNC_SETTINGS"
-        android:description="@string/permdesc_writeSyncSettings"
-        android:label="@string/permlab_writeSyncSettings"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_writeSyncSettings"
+                android:label="@string/permlab_writeSyncSettings"
+                android:protectionLevel="normal" />
 
     <!-- Allows applications to read the sync stats.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.READ_SYNC_STATS"
-        android:description="@string/permdesc_readSyncStats"
-        android:label="@string/permlab_readSyncStats"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_readSyncStats"
+                android:label="@string/permlab_readSyncStats"
+                android:protectionLevel="normal" />
 
     <!-- ============================================ -->
     <!-- Permissions for low-level system interaction -->
@@ -1572,62 +1709,62 @@
 
     <!-- @SystemApi @hide Change the screen compatibility mode of applications -->
     <permission android:name="android.permission.SET_SCREEN_COMPATIBILITY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to modify the current configuration, such
          as locale. -->
     <permission android:name="android.permission.CHANGE_CONFIGURATION"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- Allows an application to read or write the system settings.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.WRITE_SETTINGS"
-        android:label="@string/permlab_writeSettings"
-        android:description="@string/permdesc_writeSettings"
-        android:protectionLevel="signature|preinstalled|appop|pre23" />
+                android:label="@string/permlab_writeSettings"
+                android:description="@string/permdesc_writeSettings"
+                android:protectionLevel="signature|preinstalled|appop|pre23" />
 
     <!-- @SystemApi Allows an application to modify the Google service map.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.WRITE_GSERVICES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to call
         {@link android.app.ActivityManager#forceStopPackage}.
         @hide -->
     <permission android:name="android.permission.FORCE_STOP_PACKAGES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows an application to retrieve the content of the active window
          An active window is the window that has fired an accessibility event. -->
     <permission android:name="android.permission.RETRIEVE_WINDOW_CONTENT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Modify the global animation scaling factor.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SET_ANIMATION_SCALE"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @deprecated This functionality will be removed in the future; please do
          not use. Allow an application to make its activities persistent. -->
     <permission android:name="android.permission.PERSISTENT_ACTIVITY"
-        android:label="@string/permlab_persistentActivity"
-        android:description="@string/permdesc_persistentActivity"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_persistentActivity"
+                android:description="@string/permdesc_persistentActivity"
+                android:protectionLevel="normal" />
 
     <!-- Allows an application to find out the space used by any package.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.GET_PACKAGE_SIZE"
-        android:label="@string/permlab_getPackageSize"
-        android:description="@string/permdesc_getPackageSize"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_getPackageSize"
+                android:description="@string/permdesc_getPackageSize"
+                android:protectionLevel="normal" />
 
     <!-- @deprecated No longer useful, see
          {@link android.content.pm.PackageManager#addPackageToPreferred}
          for details. -->
     <permission android:name="android.permission.SET_PREFERRED_APPLICATIONS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to receive the
          {@link android.content.Intent#ACTION_BOOT_COMPLETED} that is
@@ -1643,9 +1780,9 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"
-        android:label="@string/permlab_receiveBootCompleted"
-        android:description="@string/permdesc_receiveBootCompleted"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_receiveBootCompleted"
+                android:description="@string/permdesc_receiveBootCompleted"
+                android:protectionLevel="normal" />
 
     <!-- Allows an application to broadcast sticky intents.  These are
          broadcasts whose data is held by the system after being finished,
@@ -1654,86 +1791,90 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.BROADCAST_STICKY"
-        android:label="@string/permlab_broadcastSticky"
-        android:description="@string/permdesc_broadcastSticky"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_broadcastSticky"
+                android:description="@string/permdesc_broadcastSticky"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows mounting and unmounting file systems for removable storage.
     <p>Not for use by third-party applications.-->
     <permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows formatting file systems for removable storage.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
+
+    <!-- @hide -->
+    <permission android:name="android.permission.STORAGE_INTERNAL"
+                android:protectionLevel="signature" />
 
     <!-- Allows access to ASEC non-destructive API calls
          @hide  -->
     <permission android:name="android.permission.ASEC_ACCESS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows creation of ASEC volumes
          @hide  -->
     <permission android:name="android.permission.ASEC_CREATE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows destruction of ASEC volumes
          @hide  -->
     <permission android:name="android.permission.ASEC_DESTROY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows mount / unmount of ASEC volumes
          @hide  -->
     <permission android:name="android.permission.ASEC_MOUNT_UNMOUNT"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows rename of ASEC volumes
          @hide  -->
     <permission android:name="android.permission.ASEC_RENAME"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows applications to write the apn settings.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.WRITE_APN_SETTINGS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows applications to change network connectivity state.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.CHANGE_NETWORK_STATE"
-        android:description="@string/permdesc_changeNetworkState"
-        android:label="@string/permlab_changeNetworkState"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_changeNetworkState"
+                android:label="@string/permlab_changeNetworkState"
+                android:protectionLevel="normal" />
 
     <!-- Allows an application to clear the caches of all installed
          applications on the device.
          <p>Protection level: system|signature
     -->
     <permission android:name="android.permission.CLEAR_APP_CACHE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to use any media decoder when decoding for playback
          @hide -->
     <permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to install and/or uninstall CA certificates on
          behalf of the user.
          @hide -->
     <permission android:name="android.permission.MANAGE_CA_CERTIFICATES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to do certain operations needed for
          interacting with the recovery (system update) system.
          @hide -->
     <permission android:name="android.permission.RECOVERY"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows the system to bind to an application's task services
          @hide -->
     <permission android:name="android.permission.BIND_JOB_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
     <uses-permission android:name="android.permission.BIND_JOB_SERVICE"/>
 
     <!-- Allows an application to initiate configuration updates
@@ -1742,7 +1883,7 @@
          it off to the various individual installer components
          @hide -->
     <permission android:name="android.permission.UPDATE_CONFIG"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- ========================================= -->
     <!-- Permissions for special development tools -->
@@ -1752,40 +1893,40 @@
     <!-- @SystemApi Allows an application to read or write the secure system settings.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.WRITE_SECURE_SETTINGS"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to retrieve state dump information from system services.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.DUMP"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to read the low-level system log files.
     <p>Not for use by third-party applications, because
     Log entries can contain the user's private information. -->
     <permission android:name="android.permission.READ_LOGS"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Configure an application for debugging.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SET_DEBUG_APP"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to set the maximum number of (not needed)
          application processes that can be running.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SET_PROCESS_LIMIT"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to control whether activities are immediately
          finished when put in the background.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SET_ALWAYS_FINISH"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allow an application to request that a signal be sent to all persistent processes.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.SIGNAL_PERSISTENT_PROCESSES"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- ==================================== -->
     <!-- Private permissions                  -->
@@ -1794,23 +1935,29 @@
 
     <!-- @SystemApi Allows access to the list of accounts in the Accounts Service. -->
     <permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows applications to RW to diagnostic resources.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.DIAGNOSTIC"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to open, close, or disable the status bar
          and its icons.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.STATUS_BAR"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to be the status bar.  Currently used only by SystemUI.apk
     @hide -->
     <permission android:name="android.permission.STATUS_BAR_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
+
+    <!-- Allows an application to bind to third party quick settings tiles.
+         <p>Should only be requested by the System, should be required by
+         TileService declarations.-->
+    <permission android:name="android.permission.BIND_QUICK_SETTINGS_TILE"
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to force a BACK operation on whatever is the
          top activity.
@@ -1818,21 +1965,21 @@
          @hide
     -->
     <permission android:name="android.permission.FORCE_BACK"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to update device statistics.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.UPDATE_DEVICE_STATS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi @hide Allows an application to collect battery statistics -->
     <permission android:name="android.permission.GET_APP_OPS_STATS"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to update application operation statistics. Not for
          use by third party apps. @hide -->
     <permission android:name="android.permission.UPDATE_APP_OPS_STATS"
-        android:protectionLevel="signature|privileged|installer" />
+                android:protectionLevel="signature|privileged|installer" />
 
     <!-- @SystemApi Allows an application to open windows that are for use by parts
          of the system user interface.
@@ -1840,7 +1987,7 @@
          @hide
     -->
     <permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to manage (create, destroy,
          Z-order) application tokens in the window manager.
@@ -1848,12 +1995,17 @@
          @hide
     -->
     <permission android:name="android.permission.MANAGE_APP_TOKENS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
+
+    <!-- Allows System UI to register listeners for events from Window Manager.
+         @hide -->
+    <permission android:name="android.permission.REGISTER_WINDOW_MANAGER_LISTENERS"
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows the application to temporarily freeze the screen for a
          full-screen transition. -->
     <permission android:name="android.permission.FREEZE_SCREEN"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to inject user events (keys, touch, trackball)
          into the event stream and deliver them to ANY window.  Without this
@@ -1862,24 +2014,24 @@
          @hide
     -->
     <permission android:name="android.permission.INJECT_EVENTS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows an application to register an input filter which filters the stream
          of user events (keys, touch, trackball) before they are dispatched to any window. -->
     <permission android:name="android.permission.FILTER_EVENTS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows an application to retrieve the window token from the accessibility manager. -->
     <permission android:name="android.permission.RETRIEVE_WINDOW_TOKEN"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows an application to collect frame statistics -->
     <permission android:name="android.permission.FRAME_STATS"
-         android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide Allows an application to temporary enable accessibility on the device. -->
     <permission android:name="android.permission.TEMPORARY_ENABLE_ACCESSIBILITY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to watch and control how activities are
          started globally in the system.  Only for is in debugging
@@ -1888,13 +2040,13 @@
          @hide
     -->
     <permission android:name="android.permission.SET_ACTIVITY_WATCHER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to call the activity manager shutdown() API
          to put the higher-level system there into a shutdown state.
          @hide -->
     <permission android:name="android.permission.SHUTDOWN"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to tell the activity manager to temporarily
          stop application switches, putting it into a special mode that
@@ -1902,7 +2054,7 @@
          critical UI such as the home screen.
          @hide -->
     <permission android:name="android.permission.STOP_APP_SWITCHES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to retrieve private information about
          the current top activity, such as any assist context it can provide.
@@ -1910,42 +2062,42 @@
          @hide
     -->
     <permission android:name="android.permission.GET_TOP_ACTIVITY_INFO"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to retrieve the current state of keys and
          switches.
          <p>Not for use by third-party applications.
          @deprecated The API that used this permission has been removed. -->
     <permission android:name="android.permission.READ_INPUT_STATE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link android.inputmethodservice.InputMethodService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_INPUT_METHOD"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link android.media.midi.MidiDeviceService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_MIDI_DEVICE_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link android.accessibilityservice.AccessibilityService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link android.printservice.PrintService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_PRINT_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link android.nfc.cardemulation.HostApduService}
          or {@link android.nfc.cardemulation.OffHostApduService} to ensure that only
@@ -1953,84 +2105,84 @@
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_NFC_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by the PrintSpooler to ensure that only the system can bind to it.
          @hide -->
     <permission android:name="android.permission.BIND_PRINT_SPOOLER_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a TextService (e.g. SpellCheckerService)
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_TEXT_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link android.net.VpnService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_VPN_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link android.service.wallpaper.WallpaperService},
          to ensure that only the system can bind to it.
          <p>Protection level: system|signature
     -->
     <permission android:name="android.permission.BIND_WALLPAPER"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link android.service.voice.VoiceInteractionService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_VOICE_INTERACTION"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by hotword enrollment application,
          to ensure that only the system can interact with it.
          @hide <p>Not for use by third-party applications.</p> -->
     <permission android:name="android.permission.MANAGE_VOICE_KEYPHRASES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link com.android.media.remotedisplay.RemoteDisplayProvider},
          to ensure that only the system can bind to it.
          @hide -->
     <permission android:name="android.permission.BIND_REMOTE_DISPLAY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link android.media.tv.TvInputService}
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_TV_INPUT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to modify parental controls
          <p>Not for use by third-party applications.
          @hide -->
     <permission android:name="android.permission.MODIFY_PARENTAL_CONTROLS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by a {@link android.media.routing.MediaRouteService}
          to ensure that only the system can interact with it.
          @hide -->
     <permission android:name="android.permission.BIND_ROUTE_PROVIDER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by device administration receiver, to ensure that only the
          system can interact with it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_DEVICE_ADMIN"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Required to add or remove another application as a device admin.
          <p>Not for use by third-party applications.
          @hide -->
     <permission android:name="android.permission.MANAGE_DEVICE_ADMINS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows low-level access to setting the orientation (actually
          rotation) of the screen.
@@ -2038,33 +2190,33 @@
          @hide
     -->
     <permission android:name="android.permission.SET_ORIENTATION"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows low-level access to setting the pointer speed.
          <p>Not for use by third-party applications.
          @hide
     -->
     <permission android:name="android.permission.SET_POINTER_SPEED"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows low-level access to setting input device calibration.
          <p>Not for use by normal applications.
          @hide -->
     <permission android:name="android.permission.SET_INPUT_CALIBRATION"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows low-level access to setting the keyboard layout.
          <p>Not for use by third-party applications.
          @hide -->
     <permission android:name="android.permission.SET_KEYBOARD_LAYOUT"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to query tablet mode state and monitor changes
          in it.
          <p>Not for use by third-party applications.
          @hide -->
     <permission android:name="android.permission.TABLET_MODE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to request installing packages. Apps
          targeting APIs greater than 22 must hold this permission in
@@ -2072,277 +2224,292 @@
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
-        android:label="@string/permlab_requestInstallPackages"
-        android:description="@string/permdesc_requestInstallPackages"
-        android:protectionLevel="normal" />
+                android:label="@string/permlab_requestInstallPackages"
+                android:description="@string/permdesc_requestInstallPackages"
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows an application to install packages.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.INSTALL_PACKAGES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to clear user data.
          <p>Not for use by third-party applications
          @hide
     -->
     <permission android:name="android.permission.CLEAR_APP_USER_DATA"
-        android:protectionLevel="signature|installer" />
+                android:protectionLevel="signature|installer" />
+
+    <!-- @hide Allows an application to get the URI permissions
+         granted to another application.
+         <p>Not for use by third-party applications
+    -->
+    <permission android:name="android.permission.GET_APP_GRANTED_URI_PERMISSIONS"
+                android:protectionLevel="signature" />
+
+    <!-- @hide Allows an application to clear the URI permissions
+         granted to another application.
+         <p>Not for use by third-party applications
+    -->
+    <permission
+            android:name="android.permission.CLEAR_APP_GRANTED_URI_PERMISSIONS"
+            android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to delete cache files.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.DELETE_CACHE_FILES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to delete packages.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.DELETE_PACKAGES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to move location of installed package.
          @hide -->
     <permission android:name="android.permission.MOVE_PACKAGE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to change whether an application component (other than its own) is
          enabled or not.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to grant specific permissions.
          @hide -->
     <permission android:name="android.permission.GRANT_RUNTIME_PERMISSIONS"
-        android:protectionLevel="signature|installer|verifier" />
+                android:protectionLevel="signature|installer|verifier" />
 
     <!-- Allows an app that has this permission and the permissions to install packages
          to request certain runtime permissions to be granted at installation.
          @hide
          @SystemApi -->
     <permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"
-        android:protectionLevel="signature|installer|verifier" />
+                android:protectionLevel="signature|installer|verifier" />
 
     <!-- Allows an application to revoke specific permissions.
         @hide
         @SystemApi -->
     <permission android:name="android.permission.REVOKE_RUNTIME_PERMISSIONS"
-         android:protectionLevel="signature|installer|verifier" />
+                android:protectionLevel="signature|installer|verifier" />
 
     <!-- @hide Allows an application to observe permission changes. -->
     <permission android:name="android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to use SurfaceFlinger's low level features.
          <p>Not for use by third-party applications.
          @hide
     -->
     <permission android:name="android.permission.ACCESS_SURFACE_FLINGER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to take screen shots and more generally
          get access to the frame buffer data.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.READ_FRAME_BUFFER"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to use InputFlinger's low level features.
          @hide -->
     <permission android:name="android.permission.ACCESS_INPUT_FLINGER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to configure and connect to Wifi displays
          @hide -->
     <permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to control low-level features of Wifi displays
          such as opening an RTSP socket.  This permission should only be used
          by the display manager.
          @hide -->
     <permission android:name="android.permission.CONTROL_WIFI_DISPLAY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to control the color transforms applied to
          displays system-wide.
          <p>Not for use by third-party applications.</p>
          @hide -->
     <permission android:name="android.permission.CONFIGURE_DISPLAY_COLOR_TRANSFORM"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to control VPN.
          <p>Not for use by third-party applications.</p>
          @hide -->
     <permission android:name="android.permission.CONTROL_VPN"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
     <uses-permission android:name="android.permission.CONTROL_VPN" />
 
     <!-- @SystemApi Allows an application to capture audio output.
          <p>Not for use by third-party applications.</p> -->
     <permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to capture audio for hotword detection.
          <p>Not for use by third-party applications.</p>
          @hide -->
     <permission android:name="android.permission.CAPTURE_AUDIO_HOTWORD"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to modify audio routing and override policy decisions.
          <p>Not for use by third-party applications.</p>
          @hide -->
     <permission android:name="android.permission.MODIFY_AUDIO_ROUTING"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to capture video output.
          <p>Not for use by third-party applications.</p> -->
     <permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to capture secure video output.
          <p>Not for use by third-party applications.</p> -->
     <permission android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to know what content is playing and control its playback.
          <p>Not for use by third-party applications due to privacy of media consumption</p>  -->
     <permission android:name="android.permission.MEDIA_CONTENT_CONTROL"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Required to be able to disable the device (very dangerous!).
          <p>Not for use by third-party applications.
          @hide
     -->
     <permission android:name="android.permission.BRICK"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Required to be able to reboot the device.
     <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.REBOOT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
-   <!-- @SystemApi Allows low-level access to power management.
-        <p>Not for use by third-party applications.
-        @hide
-    -->
-   <permission android:name="android.permission.DEVICE_POWER"
-        android:protectionLevel="signature" />
+    <!-- @SystemApi Allows low-level access to power management.
+         <p>Not for use by third-party applications.
+         @hide
+     -->
+    <permission android:name="android.permission.DEVICE_POWER"
+                android:protectionLevel="signature" />
 
-   <!-- Allows access to the PowerManager.userActivity function.
-   <p>Not for use by third-party applications. @hide @SystemApi -->
+    <!-- Allows access to the PowerManager.userActivity function.
+    <p>Not for use by third-party applications. @hide @SystemApi -->
     <permission android:name="android.permission.USER_ACTIVITY"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
-   <!-- @hide Allows low-level access to tun tap driver -->
+    <!-- @hide Allows low-level access to tun tap driver -->
     <permission android:name="android.permission.NET_TUNNELING"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Run as a manufacturer test application, running as the root user.
          Only available when the device is running in manufacturer test mode.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.FACTORY_TEST"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to broadcast a notification that an application
          package has been removed.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to broadcast an SMS receipt notification.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.BROADCAST_SMS"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to broadcast a WAP PUSH receipt notification.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.BROADCAST_WAP_PUSH"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to broadcast privileged networking requests.
          <p>Not for use by third-party applications. @hide -->
     <permission android:name="android.permission.BROADCAST_NETWORK_PRIVILEGED"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Not for use by third-party applications. -->
     <permission android:name="android.permission.MASTER_CLEAR"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to call any phone number, including emergency
          numbers, without going through the Dialer user interface for the user
          to confirm the call being placed.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.CALL_PRIVILEGED"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to perform CDMA OTA provisioning @hide -->
     <permission android:name="android.permission.PERFORM_CDMA_PROVISIONING"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to perform SIM Activation @hide -->
     <permission android:name="android.permission.PERFORM_SIM_ACTIVATION"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows enabling/disabling location update notifications from
          the radio.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.CONTROL_LOCATION_UPDATES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows read/write access to the "properties" table in the checkin
          database, to change values that get uploaded.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to collect component usage
          statistics
          <p>Declaring the permission implies intention to use the API and the user of the
          device can grant permission through the Settings application. -->
     <permission android:name="android.permission.PACKAGE_USAGE_STATS"
-        android:protectionLevel="signature|privileged|development|appop" />
+                android:protectionLevel="signature|privileged|development|appop" />
     <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
 
     <!-- @hide Allows an application to change the app idle state of an app.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.CHANGE_APP_IDLE_STATE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @hide @SystemApi Allows an application to temporarily whitelist an inactive app to
          access the network and acquire wakelocks.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Permission an application must hold in order to use
          {@link android.provider.Settings#ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}.
          This is a normal permission: an app requesting it will always be granted the
          permission, without the user needing to approve or see it. -->
     <permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"
-        android:protectionLevel="normal" />
+                android:protectionLevel="normal" />
 
     <!-- @SystemApi Allows an application to collect battery statistics -->
     <permission android:name="android.permission.BATTERY_STATS"
-        android:protectionLevel="signature|privileged|development" />
+                android:protectionLevel="signature|privileged|development" />
 
     <!-- @SystemApi Allows an application to control the backup and restore process.
     <p>Not for use by third-party applications.
          @hide pending API council -->
     <permission android:name="android.permission.BACKUP"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows a package to launch the secure full-backup confirmation UI.
          ONLY the system process may hold this permission.
          @hide -->
     <permission android:name="android.permission.CONFIRM_FULL_BACKUP"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Must be required by a {@link android.widget.RemoteViewsService},
          to ensure that only the system can bind to it. -->
     <permission android:name="android.permission.BIND_REMOTEVIEWS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to tell the AppWidget service which application
          can access AppWidget's data.  The normal user flow is that a user
@@ -2351,25 +2518,25 @@
          An application that has this permission should honor that contract.
          <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.BIND_APPWIDGET"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Private permission, to restrict who can bring up a dialog to add a new
          keyguard widget
          @hide -->
     <permission android:name="android.permission.BIND_KEYGUARD_APPWIDGET"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Internal permission allowing an application to query/set which
          applications can bind AppWidgets.
          @hide -->
     <permission android:name="android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows applications to change the background data setting.
     <p>Not for use by third-party applications.
          @hide pending API council -->
     <permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi This permission can be used on content providers to allow the global
          search system to access their data.  Typically it used when the
@@ -2380,7 +2547,7 @@
          it is used by applications to protect themselves from everyone else
          besides global search. -->
     <permission android:name="android.permission.GLOBAL_SEARCH"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Internal permission protecting access to the global search
          system: ensures that only the system can access the provider
@@ -2390,33 +2557,33 @@
          ranking).
          @hide -->
     <permission android:name="android.permission.GLOBAL_SEARCH_CONTROL"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Internal permission to allows an application to read indexable data.
         @hide -->
     <permission android:name="android.permission.READ_SEARCH_INDEXABLES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows applications to set a live wallpaper.
          @hide XXX Change to signature once the picker is moved to its
          own apk as Ghod Intended. -->
     <permission android:name="android.permission.SET_WALLPAPER_COMPONENT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows applications to read dream settings and dream state.
          @hide -->
     <permission android:name="android.permission.READ_DREAM_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows applications to write dream settings, and start or stop dreaming.
          @hide -->
     <permission android:name="android.permission.WRITE_DREAM_STATE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allow an application to read and write the cache partition.
          @hide -->
     <permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by default container service so that only
          the system can bind to it and use it to copy
@@ -2424,67 +2591,67 @@
          accessible to the system.
          @hide -->
     <permission android:name="android.permission.COPY_PROTECTED_DATA"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Internal permission protecting access to the encryption methods
         @hide
     -->
     <permission android:name="android.permission.CRYPT_KEEPER"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to read historical network usage for
          specific networks and applications. @hide -->
     <permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to manage network policies (such as warning and disable
          limits) and to define application-specific rules. @hide -->
     <permission android:name="android.permission.MANAGE_NETWORK_POLICY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to account its network traffic against other UIDs. Used
          by system services like download manager and media server. Not for use by
          third party apps. @hide -->
     <permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- C2DM permission.
          @hide Used internally.
      -->
     <permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE"
-          android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
     <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE"/>
 
     <!-- @SystemApi @hide Package verifier needs to have this permission before the PackageManager will
          trust it to verify packages.
     -->
     <permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by package verifier receiver, to ensure that only the
          system can interact with it.
          @hide
     -->
     <permission android:name="android.permission.BIND_PACKAGE_VERIFIER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi @hide Intent filter verifier needs to have this permission before the
          PackageManager will trust it to verify intent filters.
     -->
     <permission android:name="android.permission.INTENT_FILTER_VERIFICATION_AGENT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Must be required by intent filter verifier receiver, to ensure that only the
          system can interact with it.
          @hide
     -->
     <permission android:name="android.permission.BIND_INTENT_FILTER_VERIFIER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows applications to access serial ports via the SerialManager.
          @hide -->
     <permission android:name="android.permission.SERIAL_PORT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows the holder to access content providers from outside an ApplicationThread.
          This permission is enforced by the ActivityManagerService on the corresponding APIs,
@@ -2493,67 +2660,73 @@
          @hide
     -->
     <permission android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to hold an UpdateLock, recommending that a headless
          OTA reboot *not* occur while the lock is held.
          @hide -->
     <permission android:name="android.permission.UPDATE_LOCK"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to read the current set of notifications, including
          any metadata and intents attached.
          @hide -->
     <permission android:name="android.permission.ACCESS_NOTIFICATIONS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Marker permission for applications that wish to access notification policy.
          <p>Protection level: normal
     -->
     <permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"
-        android:description="@string/permdesc_access_notification_policy"
-        android:label="@string/permlab_access_notification_policy"
-        android:protectionLevel="normal" />
+                android:description="@string/permdesc_access_notification_policy"
+                android:label="@string/permlab_access_notification_policy"
+                android:protectionLevel="normal" />
+
+    <!-- Allows modification of do not disturb rules and policies. Only allowed for system
+        processes.
+        @hide -->
+    <permission android:name="android.permission.MANAGE_NOTIFICATIONS"
+                android:protectionLevel="signature" />
 
     <!-- Allows access to keyguard secure storage.  Only allowed for system processes.
         @hide -->
     <permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows managing (adding, removing) fingerprint templates. Reserved for the system. @hide -->
     <permission android:name="android.permission.MANAGE_FINGERPRINT"
-        android:protectionLevel="system|signature" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an app to reset fingerprint attempt counter. Reserved for the system. @hide -->
     <permission android:name="android.permission.RESET_FINGERPRINT_LOCKOUT"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to control keyguard.  Only allowed for system processes.
         @hide -->
     <permission android:name="android.permission.CONTROL_KEYGUARD"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Allows an application to listen to trust changes.  Only allowed for system processes.
         @hide -->
     <permission android:name="android.permission.TRUST_LISTENER"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to provide a trust agent.
          @hide For security reasons, this is a platform-only permission. -->
     <permission android:name="android.permission.PROVIDE_TRUST_AGENT"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to launch the trust agent settings activity.
         @hide -->
     <permission android:name="android.permission.LAUNCH_TRUST_AGENT_SETTINGS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Must be required by an {@link
         android.service.trust.TrustAgentService},
         to ensure that only the system can bind to it.
         @hide -->
     <permission android:name="android.permission.BIND_TRUST_AGENT"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link
          android.service.notification.NotificationListenerService},
@@ -2561,7 +2734,16 @@
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
+
+    <!-- Must be required by an {@link
+         android.service.notification.NotificationAssistantService},
+         to ensure that only the system can bind to it.
+         <p>Protection level: signature
+         @hide This is not a third-party API (intended for system apps). -->
+    -->
+    <permission android:name="android.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE"
+                android:protectionLevel="signature" />
 
     <!-- Must be required by a {@link
          android.service.chooser.ChooserTargetService}, to ensure that
@@ -2569,64 +2751,65 @@
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_CHOOSER_TARGET_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
-    <!-- @SystemApi Must be required by a {@link
+    <!-- Must be required by a {@link
          android.service.notification.ConditionProviderService},
          to ensure that only the system can bind to it.
-         @hide -->
+         <p>Protection level: signature
+         -->
     <permission android:name="android.permission.BIND_CONDITION_PROVIDER_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link android.service.dreams.DreamService},
          to ensure that only the system can bind to it.
          <p>Protection level: signature
     -->
     <permission android:name="android.permission.BIND_DREAM_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to call into a carrier setup flow. It is up to the
          carrier setup application to enforce that this permission is required
          @hide This is not a third-party API (intended for OEMs and system apps). -->
     <permission android:name="android.permission.INVOKE_CARRIER_SETUP"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to listen for network condition observations.
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.ACCESS_NETWORK_CONDITIONS"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @SystemApi Allows an application to provision and access DRM certificates
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.ACCESS_DRM_CERTIFICATES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Api Allows an application to manage media projection sessions.
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.MANAGE_MEDIA_PROJECTION"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- @SystemApi Allows an application to read install sessions
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.READ_INSTALL_SESSIONS"
-        android:label="@string/permlab_readInstallSessions"
-        android:description="@string/permdesc_readInstallSessions"
-        android:protectionLevel="normal"/>
+                android:label="@string/permlab_readInstallSessions"
+                android:description="@string/permdesc_readInstallSessions"
+                android:protectionLevel="normal"/>
 
     <!-- @SystemApi Allows an application to remove DRM certificates
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.REMOVE_DRM_CERTIFICATES"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- @deprecated Use {@link android.Manifest.permission#BIND_CARRIER_SERVICES} instead -->
     <permission android:name="android.permission.BIND_CARRIER_MESSAGING_SERVICE"
-        android:protectionLevel="signature|privileged" />
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to interact with the currently active
          {@link android.service.voice.VoiceInteractionService}.
          @hide -->
     <permission android:name="android.permission.ACCESS_VOICE_INTERACTION_SERVICE"
-        android:protectionLevel="signature" />
+                android:protectionLevel="signature" />
 
     <!-- The system process that is allowed to bind to services in carrier apps will
          have this permission. Carrier apps should use this permission to protect
@@ -2634,9 +2817,9 @@
          <p>Protection level: system|signature
     -->
     <permission android:name="android.permission.BIND_CARRIER_SERVICES"
-        android:label="@string/permlab_bindCarrierServices"
-        android:description="@string/permdesc_bindCarrierServices"
-        android:protectionLevel="signature|privileged" />
+                android:label="@string/permlab_bindCarrierServices"
+                android:description="@string/permdesc_bindCarrierServices"
+                android:protectionLevel="signature|privileged" />
 
     <!-- Allows an application to query whether DO_NOT_ASK_CREDENTIALS_ON_BOOT
          flag is set.
@@ -2667,10 +2850,53 @@
     <permission android:name="android.permission.DISPATCH_NFC_MESSAGE"
                 android:protectionLevel="signature|privileged" />
 
+    <!-- @SystemApi Allows changing day / night mode when system is configured with
+         config_lockDayNightMode set to true. If requesting app does not have permission,
+         it will be ignored.
+        @hide -->
+    <permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"
+                android:protectionLevel="signature|privileged" />
+
     <!-- The system process is explicitly the only one allowed to launch the
          confirmation UI for full backup/restore -->
     <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
 
+
+    <!-- Allows the holder to access the ephemeral applications on the device.
+    @hide -->
+    <permission android:name="android.permission.ACCESS_EPHEMERAL_APPS"
+                android:protectionLevel="signature" />
+
+    <!-- Allows receiving the usage of media resource e.g. video/audio codec and
+         graphic memory.
+         @hide -->
+    <permission android:name="android.permission.RECEIVE_MEDIA_RESOURCE_USAGE"
+                android:protectionLevel="signature|privileged" />
+
+    <!-- Must be required by system/priv apps when accessing the sound trigger
+         APIs given by {@link SoundTriggerManager}.
+         @hide <p>Not for use by third-party applications.</p> -->
+    <permission android:name="android.permission.MANAGE_SOUND_TRIGGER"
+                android:protectionLevel="signature|privileged" />
+
+    <!-- @SystemApi Allows trusted applications to dispatch managed provisioning message to Managed
+         Provisioning app. If requesting app does not have permission, it will be ignored.
+         @hide -->
+    <permission android:name="android.permission.DISPATCH_PROVISIONING_MESSAGE"
+                android:protectionLevel="signature|privileged" />
+
+    <!-- Allows the holder to read blocked numbers. See
+         {@link android.provider.BlockedNumberContract}.
+         @hide -->
+    <permission android:name="android.permission.READ_BLOCKED_NUMBERS"
+                android:protectionLevel="signature" />
+
+    <!-- Allows the holder to write blocked numbers. See
+         {@link android.provider.BlockedNumberContract}.
+         @hide -->
+    <permission android:name="android.permission.WRITE_BLOCKED_NUMBERS"
+                android:protectionLevel="signature" />
+
     <application android:process="system"
                  android:persistent="true"
                  android:hasCode="false"
@@ -2679,14 +2905,17 @@
                  android:backupAgent="com.android.server.backup.SystemBackupAgent"
                  android:killAfterRestore="false"
                  android:icon="@drawable/ic_launcher_android"
-                 android:supportsRtl="true">
+                 android:supportsRtl="true"
+                 android:theme="@style/Theme.Material.DayNight.DarkActionBar"
+                 android:forceDeviceEncrypted="true"
+                 android:encryptionAware="true">
         <activity android:name="com.android.internal.app.ChooserActivity"
-                android:theme="@style/Theme.DeviceDefault.Resolver"
-                android:finishOnCloseSystemDialogs="true"
-                android:excludeFromRecents="true"
-                android:documentLaunchMode="never"
-                android:relinquishTaskIdentity="true"
-                android:process=":ui">
+                  android:theme="@style/Theme.DeviceDefault.Resolver"
+                  android:finishOnCloseSystemDialogs="true"
+                  android:excludeFromRecents="true"
+                  android:documentLaunchMode="never"
+                  android:relinquishTaskIdentity="true"
+                  android:process=":ui">
             <intent-filter>
                 <action android:name="android.intent.action.CHOOSER" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2694,102 +2923,102 @@
             </intent-filter>
         </activity>
         <activity android:name="com.android.internal.app.IntentForwarderActivity"
-                android:finishOnCloseSystemDialogs="true"
-                android:theme="@style/Theme.NoDisplay"
-                android:excludeFromRecents="true"
-                android:label="@string/user_owner_label"
-                android:exported="true"
-                >
+                  android:finishOnCloseSystemDialogs="true"
+                  android:theme="@style/Theme.NoDisplay"
+                  android:excludeFromRecents="true"
+                  android:label="@string/user_owner_label"
+                  android:exported="true"
+        >
         </activity>
-        <activity-alias android:name="com.android.internal.app.ForwardIntentToUserOwner"
-                android:targetActivity="com.android.internal.app.IntentForwarderActivity"
-                android:exported="true"
-                android:label="@string/user_owner_label">
+        <activity-alias android:name="com.android.internal.app.ForwardIntentToParent"
+                        android:targetActivity="com.android.internal.app.IntentForwarderActivity"
+                        android:exported="true"
+                        android:label="@string/user_owner_label">
         </activity-alias>
         <activity-alias android:name="com.android.internal.app.ForwardIntentToManagedProfile"
-                android:targetActivity="com.android.internal.app.IntentForwarderActivity"
-                android:icon="@drawable/ic_corp_icon"
-                android:exported="true"
-                android:label="@string/managed_profile_label">
+                        android:targetActivity="com.android.internal.app.IntentForwarderActivity"
+                        android:icon="@drawable/ic_corp_icon"
+                        android:exported="true"
+                        android:label="@string/managed_profile_label">
         </activity-alias>
         <activity android:name="com.android.internal.app.HeavyWeightSwitcherActivity"
-                android:theme="@style/Theme.Material.Light.Dialog"
-                android:label="@string/heavy_weight_switcher_title"
-                android:finishOnCloseSystemDialogs="true"
-                android:excludeFromRecents="true"
-                android:process=":ui">
+                  android:theme="@style/Theme.Material.DayNight.Dialog"
+                  android:label="@string/heavy_weight_switcher_title"
+                  android:finishOnCloseSystemDialogs="true"
+                  android:excludeFromRecents="true"
+                  android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.PlatLogoActivity"
-                android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"
-                android:configChanges="orientation|keyboardHidden"
-                android:process=":ui">
+                  android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"
+                  android:configChanges="orientation|keyboardHidden"
+                  android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.DisableCarModeActivity"
-                android:theme="@style/Theme.NoDisplay"
-                android:excludeFromRecents="true"
-                android:process=":ui">
+                  android:theme="@style/Theme.NoDisplay"
+                  android:excludeFromRecents="true"
+                  android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.DumpHeapActivity"
-                android:theme="@style/Theme.Translucent.NoTitleBar"
-                android:label="@string/dump_heap_title"
-                android:finishOnCloseSystemDialogs="true"
-                android:noHistory="true"
-                android:excludeFromRecents="true"
-                android:process=":ui">
+                  android:theme="@style/Theme.Translucent.NoTitleBar"
+                  android:label="@string/dump_heap_title"
+                  android:finishOnCloseSystemDialogs="true"
+                  android:noHistory="true"
+                  android:excludeFromRecents="true"
+                  android:process=":ui">
         </activity>
         <provider android:name="com.android.server.am.DumpHeapProvider"
-                android:authorities="com.android.server.heapdump"
-                android:grantUriPermissions="true"
-                android:multiprocess="false"
-                android:singleUser="true" />
+                  android:authorities="com.android.server.heapdump"
+                  android:grantUriPermissions="true"
+                  android:multiprocess="false"
+                  android:singleUser="true" />
 
         <activity android:name="android.accounts.ChooseAccountActivity"
-                android:excludeFromRecents="true"
-                android:exported="true"
-                android:theme="@style/Theme.Material.Light.Dialog"
-                android:label="@string/choose_account_label"
-                android:process=":ui">
+                  android:excludeFromRecents="true"
+                  android:exported="true"
+                  android:theme="@style/Theme.Material.DayNight.Dialog"
+                  android:label="@string/choose_account_label"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="android.accounts.ChooseTypeAndAccountActivity"
-                android:excludeFromRecents="true"
-                android:exported="true"
-                android:theme="@style/Theme.Material.Light.Dialog"
-                android:label="@string/choose_account_label"
-                android:process=":ui">
+                  android:excludeFromRecents="true"
+                  android:exported="true"
+                  android:theme="@style/Theme.Material.DayNight.Dialog"
+                  android:label="@string/choose_account_label"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="android.accounts.ChooseAccountTypeActivity"
-                android:excludeFromRecents="true"
-                android:theme="@style/Theme.Material.Light.Dialog"
-                android:label="@string/choose_account_label"
-                android:process=":ui">
+                  android:excludeFromRecents="true"
+                  android:theme="@style/Theme.Material.DayNight.Dialog"
+                  android:label="@string/choose_account_label"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="android.accounts.CantAddAccountActivity"
-                android:excludeFromRecents="true"
-                android:exported="true"
-                android:theme="@style/Theme.Material.Light.Dialog.NoActionBar"
-                android:process=":ui">
+                  android:excludeFromRecents="true"
+                  android:exported="true"
+                  android:theme="@style/Theme.Material.DayNight.Dialog.NoActionBar"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="android.accounts.GrantCredentialsPermissionActivity"
-                android:excludeFromRecents="true"
-                android:exported="true"
-                android:theme="@style/Theme.Material.Light.DialogWhenLarge"
-                android:process=":ui">
+                  android:excludeFromRecents="true"
+                  android:exported="true"
+                  android:theme="@style/Theme.Material.DayNight.DialogWhenLarge"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="android.content.SyncActivityTooManyDeletes"
-               android:theme="@style/Theme.Material.Light.Dialog"
-               android:label="@string/sync_too_many_deletes"
-               android:process=":ui">
+                  android:theme="@style/Theme.Material.DayNight.Dialog"
+                  android:label="@string/sync_too_many_deletes"
+                  android:process=":ui">
         </activity>
 
         <activity android:name="com.android.internal.app.ShutdownActivity"
-            android:permission="android.permission.SHUTDOWN"
-            android:theme="@style/Theme.NoDisplay"
-            android:excludeFromRecents="true">
+                  android:permission="android.permission.SHUTDOWN"
+                  android:theme="@style/Theme.NoDisplay"
+                  android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2801,20 +3030,49 @@
         </activity>
 
         <activity android:name="com.android.internal.app.NetInitiatedActivity"
-                android:theme="@style/Theme.Material.Light.Dialog.Alert"
-                android:excludeFromRecents="true"
-                android:process=":ui">
+                  android:theme="@style/Theme.Material.DayNight.Dialog.Alert"
+                  android:excludeFromRecents="true"
+                  android:process=":ui">
+        </activity>
+
+        <activity android:name="com.android.internal.app.SystemUserHomeActivity"
+                  android:enabled="false"
+                  android:process=":ui"
+                  android:systemUserOnly="true"
+                  android:theme="@style/Theme.Translucent.NoTitleBar">
+            <intent-filter android:priority="-100">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.HOME" />
+            </intent-filter>
+        </activity>
+
+        <!-- Activity to prompt user if it's ok to create a new user sandbox for a
+             specified account. -->
+        <activity android:name="com.android.internal.app.ConfirmUserCreationActivity"
+                  android:excludeFromRecents="true"
+                  android:process=":ui"
+                  android:theme="@style/Theme.Material.DayNight.Dialog.Alert">
+            <intent-filter android:priority="1000">
+                <action android:name="android.os.action.CREATE_USER" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="com.android.internal.app.UnlaunchableAppActivity"
+                  android:theme="@style/Theme.Material.DayNight.Dialog.Alert"
+                  android:excludeFromRecents="true"
+                  android:process=":ui">
         </activity>
 
         <receiver android:name="com.android.server.BootReceiver"
-                android:primaryUserOnly="true">
+                  android:systemUserOnly="true">
             <intent-filter android:priority="1000">
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
             </intent-filter>
         </receiver>
 
         <receiver android:name="com.android.server.updates.CertPinInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_PINS" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
@@ -2822,7 +3080,7 @@
         </receiver>
 
         <receiver android:name="com.android.server.updates.IntentFirewallInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_INTENT_FIREWALL" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
@@ -2830,15 +3088,23 @@
         </receiver>
 
         <receiver android:name="com.android.server.updates.SmsShortCodesInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_SMS_SHORT_CODES" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
             </intent-filter>
         </receiver>
 
+        <receiver android:name="com.android.server.updates.ApnDbInstallReceiver"
+                  android:permission="android.permission.UPDATE_CONFIG">
+            <intent-filter>
+                <action android:name="android.intent.action.UPDATE_APN_DB" />
+                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
+            </intent-filter>
+        </receiver>
+
         <receiver android:name="com.android.server.updates.CarrierProvisioningUrlsInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_CARRIER_PROVISIONING_URLS" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
@@ -2846,7 +3112,7 @@
         </receiver>
 
         <receiver android:name="com.android.server.updates.TzDataInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_TZDATA" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
@@ -2854,7 +3120,7 @@
         </receiver>
 
         <receiver android:name="com.android.server.updates.SELinuxPolicyInstallReceiver"
-                android:permission="android.permission.UPDATE_CONFIG">
+                  android:permission="android.permission.UPDATE_CONFIG">
             <intent-filter>
                 <action android:name="android.intent.action.UPDATE_SEPOLICY" />
                 <data android:scheme="content" android:host="*" android:mimeType="*/*" />
@@ -2862,7 +3128,7 @@
         </receiver>
 
         <receiver android:name="com.android.server.MasterClearReceiver"
-            android:permission="android.permission.MASTER_CLEAR">
+                  android:permission="android.permission.MASTER_CLEAR">
             <intent-filter
                     android:priority="100" >
                 <!-- For Checkin, Settings, etc.: action=MASTER_CLEAR -->
@@ -2875,12 +3141,12 @@
         </receiver>
 
         <service android:name="android.hardware.location.GeofenceHardwareService"
-            android:permission="android.permission.LOCATION_HARDWARE"
-            android:exported="false" />
+                 android:permission="android.permission.LOCATION_HARDWARE"
+                 android:exported="false" />
 
         <service android:name="com.android.internal.backup.LocalTransportService"
-                android:permission="android.permission.CONFIRM_FULL_BACKUP"
-                android:exported="false">
+                 android:permission="android.permission.CONFIRM_FULL_BACKUP"
+                 android:exported="false">
             <intent-filter>
                 <action android:name="android.backup.TRANSPORT_HOST" />
             </intent-filter>
@@ -2900,10 +3166,14 @@
                  android:permission="android.permission.BIND_JOB_SERVICE" >
         </service>
 
+        <service android:name="com.android.server.content.SyncJobService"
+                 android:permission="android.permission.BIND_JOB_SERVICE" >
+        </service>
+
         <service
-            android:name="com.android.server.pm.BackgroundDexOptService"
-            android:exported="true"
-            android:permission="android.permission.BIND_JOB_SERVICE">
+                android:name="com.android.server.pm.BackgroundDexOptService"
+                android:exported="true"
+                android:permission="android.permission.BIND_JOB_SERVICE">
         </service>
 
     </application>
diff --git a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
index d4f81b5..af5df67 100644
--- a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
@@ -95,8 +95,8 @@
         try {
             mContentResolver.update(
                     BlockedNumbers.CONTENT_URI, getContentValues("123"), null, null);
-            fail("Should throw UnsupportedOperationException");
-        } catch (UnsupportedOperationException expected) {
+            fail("Should throw SecurityException");
+        } catch (SecurityException expected) {
         }
     }
 
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_PhoneLookup.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_PhoneLookup.java
index 434ac201..556fb2d 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_PhoneLookup.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_PhoneLookup.java
@@ -23,6 +23,7 @@
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.SipAddress;
 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.PhoneLookup;
@@ -60,7 +61,17 @@
         mBuilder.cleanup();
     }
 
-    private long[] setupTestData() throws Exception {
+    static class Id {
+        public long contactId;
+        public long dataId;
+
+        public Id (long contactId, long dataId) {
+            this.contactId = contactId;
+            this.dataId = dataId;
+        }
+    }
+
+    private Id[] setupTestData() throws Exception {
         TestRawContact rawContact = mBuilder.newRawContact()
                 .with(RawContacts.ACCOUNT_TYPE, "test_account")
                 .with(RawContacts.ACCOUNT_NAME, "test_name")
@@ -68,7 +79,7 @@
         rawContact.newDataRow(StructuredName.CONTENT_ITEM_TYPE)
                 .with(StructuredName.DISPLAY_NAME, "Hot Tamale")
                 .insert();
-        rawContact.newDataRow(Phone.CONTENT_ITEM_TYPE)
+        long dataId = rawContact.newDataRow(Phone.CONTENT_ITEM_TYPE)
                 .with(Phone.DATA, "1111222333444")
                 .with(Email.TYPE, Phone.TYPE_HOME)
                 .insert().load().getId();
@@ -82,24 +93,41 @@
         rawContact2.newDataRow(StructuredName.CONTENT_ITEM_TYPE)
                 .with(StructuredName.DISPLAY_NAME, "Cold Tamago")
                 .insert();
-        rawContact2.newDataRow(Phone.CONTENT_ITEM_TYPE)
+       long dataId2 =  rawContact2.newDataRow(Phone.CONTENT_ITEM_TYPE)
                 .with(Phone.DATA, "2111222333444")
                 .with(Phone.TYPE, Phone.TYPE_OTHER)
-                .insert().load();
-
+                .insert().load().getId();
         rawContact2.load();
         TestContact contact2 = rawContact2.getContact().load();
 
-        return new long[] {
-                contact.getId(), contact2.getId()
+        // Contact with SIP address
+        TestRawContact rawContact3 = mBuilder.newRawContact()
+                .with(RawContacts.ACCOUNT_TYPE, "test_account")
+                .with(RawContacts.ACCOUNT_NAME, "test_name")
+                .insert();
+        rawContact3.newDataRow(StructuredName.CONTENT_ITEM_TYPE)
+                .with(StructuredName.DISPLAY_NAME, "Warm Tempura")
+                .insert();
+        long dataId3 = rawContact2.newDataRow(SipAddress.CONTENT_ITEM_TYPE)
+                .with(SipAddress.SIP_ADDRESS, "777@sip.org")
+                .with(SipAddress.TYPE, SipAddress.TYPE_WORK)
+                .insert().load().getId();
+        rawContact3.load();
+        TestContact contact3 = rawContact2.getContact().load();
+
+        return new Id[] {
+                new Id(contact.getId(), dataId),
+                new Id(contact2.getId(), dataId2),
+                new Id(contact3.getId(), dataId3)
         };
+
     }
 
     /**
      * Test for {@link android.provider.ContactsContract.PhoneLookup#CONTENT_FILTER_URI}.
      */
     public void testPhoneLookup_nomatch() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.CONTENT_FILTER_URI.buildUpon()
                 .appendPath("no-such-phone-number").build();
 
@@ -110,12 +138,14 @@
      * Test for {@link android.provider.ContactsContract.PhoneLookup#CONTENT_FILTER_URI}.
      */
     public void testPhoneLookup_found1() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.CONTENT_FILTER_URI.buildUpon()
                 .appendPath("1111222333444").build();
 
         final ContentValues expected = new ContentValues();
-        expected.put(PhoneLookup._ID, ids[0]);
+        expected.put(PhoneLookup._ID, ids[0].contactId);
+        expected.put(PhoneLookup.CONTACT_ID, ids[0].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[0].dataId);
         expected.put(PhoneLookup.NUMBER, "1111222333444");
 
         assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
@@ -125,22 +155,39 @@
      * Test for {@link android.provider.ContactsContract.PhoneLookup#CONTENT_FILTER_URI}.
      */
     public void testPhoneLookup_found2() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.CONTENT_FILTER_URI.buildUpon()
                 .appendPath("2111222333444").build();
 
         final ContentValues expected = new ContentValues();
-        expected.put(PhoneLookup._ID, ids[1]);
+        expected.put(PhoneLookup._ID, ids[1].contactId);
+        expected.put(PhoneLookup.CONTACT_ID, ids[1].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[1].dataId);
         expected.put(PhoneLookup.NUMBER, "2111222333444");
 
         assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
     }
 
+    public void testPhoneLookup_sip_found() throws Exception {
+        Id[] ids = setupTestData();
+        final Uri uri = PhoneLookup.CONTENT_FILTER_URI.buildUpon()
+                .appendPath("777@sip.org")
+                .appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1")
+                .build();
+
+        final ContentValues expected = new ContentValues();
+        expected.put(PhoneLookup.CONTACT_ID, ids[2].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[2].dataId);
+        expected.put(SipAddress.SIP_ADDRESS, "777@sip.org");
+
+        assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
+    }
+
     /**
      * Test for {@link android.provider.ContactsContract.PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
      */
     public void testPhoneLookupEnterprise_nomatch() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon()
                 .appendPath("no-such-phone-number").build();
 
@@ -151,12 +198,14 @@
      * Test for {@link android.provider.ContactsContract.PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
      */
     public void testPhoneLookupEnterprise_found1() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon()
                 .appendPath("1111222333444").build();
 
         final ContentValues expected = new ContentValues();
-        expected.put(PhoneLookup._ID, ids[0]);
+        expected.put(PhoneLookup._ID, ids[0].contactId);
+        expected.put(PhoneLookup.CONTACT_ID, ids[0].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[0].dataId);
         expected.put(PhoneLookup.NUMBER, "1111222333444");
 
         assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
@@ -166,27 +215,45 @@
      * Test for {@link android.provider.ContactsContract.PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
      */
     public void testPhoneLookupEnterprise_found2() throws Exception {
-        long[] ids = setupTestData();
+        Id[] ids = setupTestData();
         final Uri uri = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon()
                 .appendPath("2111222333444").build();
 
         final ContentValues expected = new ContentValues();
-        expected.put(PhoneLookup._ID, ids[1]);
+        expected.put(PhoneLookup._ID, ids[1].contactId);
+        expected.put(PhoneLookup.CONTACT_ID, ids[1].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[1].dataId);
         expected.put(PhoneLookup.NUMBER, "2111222333444");
 
         assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
     }
 
-    private void assertCursorStoredValuesWithContactsFilter(Uri uri, long[] contactsId,
+    public void testPhoneLookupEnterprise_sip_found() throws Exception {
+        Id[] ids = setupTestData();
+        final Uri uri = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon()
+                .appendPath("777@sip.org")
+                .appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1")
+                .build();
+
+        final ContentValues expected = new ContentValues();
+        expected.put(PhoneLookup._ID, ids[2].dataId);
+        expected.put(PhoneLookup.CONTACT_ID, ids[2].contactId);
+        expected.put(PhoneLookup.DATA_ID, ids[2].dataId);
+        expected.put(SipAddress.SIP_ADDRESS, "777@sip.org");
+
+        assertCursorStoredValuesWithContactsFilter(uri, ids, expected);
+    }
+
+    private void assertCursorStoredValuesWithContactsFilter(Uri uri, Id[] ids,
             ContentValues... expected) {
         // We need this helper function to add a filter for specific contacts because
         // otherwise tests will fail if performed on a device with existing contacts data
         StringBuilder sb = new StringBuilder();
         sb.append(Contacts._ID + " in ");
         sb.append("(");
-        for (int i = 0; i < contactsId.length; i++) {
+        for (int i = 0; i < ids.length; i++) {
             if (i != 0) sb.append(",");
-            sb.append(contactsId[i]);
+            sb.append(ids[i].contactId);
         }
         sb.append(")");
         DatabaseAsserts.assertStoredValuesInUriMatchExactly(mResolver, uri, null,
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/single_source_alloc.rs b/tests/tests/renderscript/src/android/renderscript/cts/single_source_alloc.rs
index 2575d54..40566a0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/single_source_alloc.rs
+++ b/tests/tests/renderscript/src/android/renderscript/cts/single_source_alloc.rs
@@ -55,6 +55,7 @@
         _RS_ASSERT_EQU(in.w, (CT) (val + 3));                                  \
     }                                                                          \
 
+VERIFY_KERNEL(half)
 VERIFY_KERNEL(float)
 VERIFY_KERNEL(double)
 VERIFY_KERNEL(char)
@@ -182,6 +183,7 @@
                 // Store to a cell based on the type, vector size and
                 // dimensionality
                 switch (dt) {
+                    STORE_TO_ALLOC(RS_TYPE_FLOAT_16, half);
                     STORE_TO_ALLOC(RS_TYPE_FLOAT_32, float);
                     STORE_TO_ALLOC(RS_TYPE_FLOAT_64, double);
                     STORE_TO_ALLOC(RS_TYPE_SIGNED_8, char);
@@ -203,6 +205,7 @@
 
     // Launch the appropriate verify_ kernel
     switch (dt) {
+        LAUNCH_VERIFY_KERNEL(RS_TYPE_FLOAT_16, half);
         LAUNCH_VERIFY_KERNEL(RS_TYPE_FLOAT_32, float);
         LAUNCH_VERIFY_KERNEL(RS_TYPE_FLOAT_64, double);
         LAUNCH_VERIFY_KERNEL(RS_TYPE_SIGNED_8, char);
@@ -224,8 +227,7 @@
 void TestAllocationCreationAndAccess() {
     rs_data_type all_types[] = {
         RS_TYPE_BOOLEAN,
-        // Bug 24862914: Uncomment the following line to add half once the bug is fixed
-        // RS_TYPE_FLOAT_16,
+        RS_TYPE_FLOAT_16,
         RS_TYPE_FLOAT_32,
         RS_TYPE_FLOAT_64,
         RS_TYPE_SIGNED_8,
@@ -447,7 +449,7 @@
 void TestHelperFunctions() {
     failed = false;
 
-    // Bug: 24862914: Add half once the bug is fixed
+    TEST_HELPER(half);
     TEST_HELPERS(float);
     TEST_HELPERS(double);
     TEST_HELPERS(char);
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index 8ea6a96..bf229e7 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -40,10 +40,10 @@
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) \
 										$(TOP)/frameworks/native/include/media/openmax
 
-LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl libmedia libcrypto
+LOCAL_SHARED_LIBRARIES := libbinder libnativehelper_compat_libc++ liblog libdl libmedia libcrypto
 
 LOCAL_C_INCLUDES += ndk/sources/cpufeatures
-LOCAL_STATIC_LIBRARIES := cpufeatures libbinder libselinux libutils libcutils
+LOCAL_STATIC_LIBRARIES := cpufeatures libselinux libutils libcutils
 LOCAL_CXX_STL := libc++_static
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/src/android/security/cts/SELinuxTest.java b/tests/tests/security/src/android/security/cts/SELinuxTest.java
index 3df7396..736bdc9 100644
--- a/tests/tests/security/src/android/security/cts/SELinuxTest.java
+++ b/tests/tests/security/src/android/security/cts/SELinuxTest.java
@@ -73,12 +73,6 @@
         assertFalse(checkSELinuxAccess("u:r:zygote:s0", "u:object_r:runas_exec:s0", "file", "getattr", "/system/bin/run-as"));
     }
 
-    public void testNoBooleans() throws Exception {
-        // Intentionally not using JNI bindings to keep things simple
-        File[] files = new File("/sys/fs/selinux/booleans/").listFiles();
-        assertEquals(0, files.length);
-    }
-
     public void testCTSIsUntrustedApp() throws IOException {
         String found = KernelSettingsTest.getFile("/proc/self/attr/current");
         String expected = "u:r:untrusted_app:s0";
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 219dfec..932603d 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -138,7 +138,9 @@
     }
 
     protected void tearDownConnectionService(PhoneAccountHandle accountHandle) throws Exception {
-        assertNumConnections(this.connectionService, 0);
+        if (this.connectionService != null) {
+            assertNumConnections(this.connectionService, 0);
+        }
         mTelecomManager.unregisterPhoneAccount(accountHandle);
         CtsConnectionService.tearDown();
         assertCtsConnectionServiceUnbound();
@@ -814,12 +816,12 @@
                 new Condition() {
                     @Override
                     public Object expected() {
-                        return true;
+                        return false;
                     }
 
                     @Override
                     public Object actual() {
-                        return CtsConnectionService.isServiceUnbound();
+                        return CtsConnectionService.isServiceBound();
                     }
                 },
                 WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
index d8d5773..2364986 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
@@ -16,7 +16,7 @@
 
 package android.telecom.cts;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import android.content.Intent;
 import android.telecom.Conference;
@@ -52,11 +52,13 @@
     private static ConnectionService sConnectionService;
     // This is the connection service registered with Telecom
     private static ConnectionService sTelecomConnectionService;
-    private static boolean mIsServiceUnbound;
+    private static boolean mIsServiceBound = false;
 
     public CtsConnectionService() throws Exception {
         super();
         sTelecomConnectionService = this;
+        // Cant override the onBind method for ConnectionService, so reset it here.
+        mIsServiceBound = true;
     }
 
     // ConnectionService used by default as a fallback if no connection service is specified
@@ -77,13 +79,12 @@
                 throw new Exception("Mock ConnectionService exists.  Failed to call tearDown().");
             }
             sConnectionService = connectionService;
-            // Cant override the onBind method for ConnectionService, so reset it here.
-            mIsServiceUnbound = false;
         }
     }
 
     public static void tearDown() {
         synchronized(sLock) {
+            sTelecomConnectionService = null;
             sConnectionService = null;
         }
     }
@@ -188,13 +189,17 @@
 
     @Override
     public boolean onUnbind(Intent intent) {
-        Log.i(LOG_TAG, "Service unbounded");
-        assertFalse(mIsServiceUnbound);
-        mIsServiceUnbound = true;
+        Log.i(LOG_TAG, "Service has been unbound");
+        assertTrue(mIsServiceBound);
+        mIsServiceBound = false;
         return super.onUnbind(intent);
     }
 
-    public static boolean isServiceUnbound() {
-        return mIsServiceUnbound;
+    public static boolean isServiceBound() {
+        return mIsServiceBound;
+    }
+
+    public static boolean isServiceRegisteredToTelecom() {
+        return sTelecomConnectionService != null;
     }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index 02d2f15..7d71c0f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -18,7 +18,11 @@
 
 import static android.telecom.cts.TestUtils.*;
 
+import android.content.ContentValues;
 import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.BlockedNumberContract;
 import android.telecom.CallAudioState;
 import android.telecom.Call;
 import android.telecom.Connection;
@@ -204,6 +208,39 @@
         assertConnectionState(connection, Connection.STATE_ACTIVE);
     }
 
+    public void testIncomingCallFromBlockedNumber_IsRejected() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        Uri blockedUri = null;
+
+        try {
+            Uri testNumberUri = createTestNumber();
+            blockedUri = blockNumber(testNumberUri);
+
+            final Bundle extras = new Bundle();
+            extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, testNumberUri);
+            mTelecomManager.addNewIncomingCall(TEST_PHONE_ACCOUNT_HANDLE, extras);
+
+            final MockConnection connection = verifyConnectionForIncomingCall();
+            assertConnectionState(connection, Connection.STATE_DISCONNECTED);
+            assertNull(mInCallCallbacks.getService());
+        } finally {
+            if (blockedUri != null) {
+                mContext.getContentResolver().delete(blockedUri, null, null);
+            }
+        }
+    }
+
+    private Uri blockNumber(Uri phoneNumberUri) {
+        ContentValues cv = new ContentValues();
+        cv.put(BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
+                phoneNumberUri.getSchemeSpecificPart());
+        return mContext.getContentResolver().insert(
+                BlockedNumberContract.BlockedNumbers.CONTENT_URI, cv);
+    }
+
     public void testAnswerIncomingCallAsVideo_SendsCorrectVideoState() {
         if (!mShouldTestTelecom) {
             return;
diff --git a/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
new file mode 100644
index 0000000..7f5e7ce
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telecom.cts;
+
+import android.content.ComponentName;
+import android.os.Bundle;
+import android.telecom.Connection;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+import java.util.Collection;
+
+import static android.telecom.cts.TestUtils.COMPONENT;
+import static android.telecom.cts.TestUtils.PACKAGE;
+
+/**
+ * Tests valid/invalid incoming calls that are received from the ConnectionService
+ * and registered through TelecomManager
+ */
+public class IncomingCallTest extends BaseTelecomTestWithMockServices {
+
+    private static final PhoneAccountHandle TEST_INVALID_HANDLE = new PhoneAccountHandle(
+            new ComponentName(PACKAGE, COMPONENT), "WRONG_ID");
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mContext = getInstrumentation().getContext();
+    }
+
+    public void testAddNewIncomingCall_CorrectPhoneAccountHandle() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+        setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+        addAndVerifyNewIncomingCall(createTestNumber(), null);
+        final Connection connection3 = verifyConnectionForIncomingCall();
+        Collection<Connection> connections = CtsConnectionService.getAllConnectionsFromTelecom();
+        assertEquals(1, connections.size());
+        assertTrue(connections.contains(connection3));
+    }
+
+    /**
+     * Tests to be sure that new incoming calls can only be added using a valid PhoneAccountHandle
+     * (b/26864502). If a PhoneAccount has not been registered for the PhoneAccountHandle, then
+     * a SecurityException will be thrown.
+     */
+    public void testAddNewIncomingCall_IncorrectPhoneAccountHandle() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        Bundle extras = new Bundle();
+        extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, createTestNumber());
+        try {
+            mTelecomManager.addNewIncomingCall(TEST_INVALID_HANDLE, extras);
+            fail();
+        } catch (SecurityException e) {
+            // This should create a security exception!
+        }
+
+        assertFalse(CtsConnectionService.isServiceRegisteredToTelecom());
+    }
+
+    /**
+     * Tests to be sure that new incoming calls can only be added if a PhoneAccount is enabled
+     * (b/26864502). If a PhoneAccount is not enabled for the PhoneAccountHandle, then
+     * a SecurityException will be thrown.
+     */
+    public void testAddNewIncomingCall_PhoneAccountNotEnabled() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Do not enable PhoneAccount
+        setupConnectionService(null, FLAG_REGISTER);
+        assertFalse(mTelecomManager.getPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE).isEnabled());
+        try {
+            addAndVerifyNewIncomingCall(createTestNumber(), null);
+            fail();
+        } catch (SecurityException e) {
+            // This should create a security exception!
+        }
+
+        assertFalse(CtsConnectionService.isServiceRegisteredToTelecom());
+    }
+}
diff --git a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
index 916cf6d..c5b7efe 100644
--- a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
+++ b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
@@ -845,6 +845,9 @@
     }
 
     public void testBroadcastGenreEncodeDecode() {
+        if (!Utils.hasTvInputFramework(getContext())) {
+            return;
+        }
         String[] broadcastGenre = new String[] {"Animation", "Classic, opera"};
         insertProgramWithBroadcastGenre(broadcastGenre);
         try (Cursor c = mContentResolver.query(TvContract.Programs.CONTENT_URI,
@@ -857,6 +860,9 @@
     }
 
     public void testBroadcastGenreQueryChannel() {
+        if (!Utils.hasTvInputFramework(getContext())) {
+            return;
+        }
         // "Animation" is mapped to Genres.MOVIES
         // "Classic, opera" is mapped to Genres.MUSIC
         insertProgramWithBroadcastGenre(new String[]{"Animation"});
@@ -867,4 +873,12 @@
         // There are two channels which belong to MUSIC genre - channel 2 and 3.
         verifyChannelCountWithCanonicalGenre(Genres.MUSIC, 2);
     }
+
+    public void testGenresIsCanonical() {
+        if (!Utils.hasTvInputFramework(getContext())) {
+            return;
+        }
+        assertTrue(Genres.isCanonical(Genres.DRAMA));
+        assertFalse(Genres.isCanonical("Not a genre"));
+    }
 }
diff --git a/tests/tests/view/res/drawable/custom_pointer_icon.xml b/tests/tests/view/res/drawable/custom_pointer_icon.xml
new file mode 100644
index 0000000..fc5a9e1
--- /dev/null
+++ b/tests/tests/view/res/drawable/custom_pointer_icon.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+              android:bitmap="@drawable/icon_red"
+              android:hotSpotX="16dp"
+              android:hotSpotY="16dp" />
diff --git a/tests/tests/view/res/layout/view_layout.xml b/tests/tests/view/res/layout/view_layout.xml
index 07a9f0d..9769aa4 100644
--- a/tests/tests/view/res/layout/view_layout.xml
+++ b/tests/tests/view/res/layout/view_layout.xml
@@ -110,13 +110,16 @@
       <LinearLayout
           android:orientation="vertical"
           android:layout_width="match_parent"
-          android:layout_height="50px"
+          android:layout_height="70px"
           android:pointerShape="crosshair">
         <View android:layout_width="match_parent"
               android:layout_height="20px"
               android:pointerShape="help"/>
         <View android:layout_width="match_parent"
               android:layout_height="20px"/>
+        <View android:layout_width="match_parent"
+              android:layout_height="20px"
+              android:pointerShape="@drawable/custom_pointer_icon"/>
       </LinearLayout>
     </LinearLayout>
 
diff --git a/tests/tests/view/src/android/view/cts/FrameMetricsListenerTest.java b/tests/tests/view/src/android/view/cts/FrameMetricsListenerTest.java
new file mode 100644
index 0000000..860c394
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/FrameMetricsListenerTest.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.cts;
+
+import android.view.cts.R;
+
+import android.app.Activity;
+import android.app.Instrumentation;
+import android.cts.util.PollingCheck;
+import android.os.Looper;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.SystemClock;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+import android.view.FrameMetrics;
+import android.view.View;
+import android.view.Window;
+import android.widget.ScrollView;
+
+import java.lang.Thread;
+import java.lang.Exception;
+import java.lang.System;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class FrameMetricsListenerTest extends ActivityInstrumentationTestCase2<MockActivity> {
+
+    private Instrumentation mInstrumentation;
+    private Window.FrameMetricsListener mFrameMetricsListener;
+    private Activity mActivity;
+
+    public FrameMetricsListenerTest() {
+        super(MockActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mActivity = getActivity();
+        mInstrumentation = getInstrumentation();
+    }
+
+    private void layout(final int layoutId) {
+        mInstrumentation.runOnMainSync(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.setContentView(layoutId);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+    }
+
+    public void testReceiveData() throws Throwable {
+        layout(R.layout.scrollview_layout);
+        final ScrollView scrollView = (ScrollView) mActivity.findViewById(R.id.scroll_view);
+        final ArrayList<FrameMetrics> data = new ArrayList<>();
+        final Handler handler = new Handler(Looper.getMainLooper());
+        final Window myWindow = mActivity.getWindow();
+        final Window.FrameMetricsListener listener =
+            new Window.FrameMetricsListener() {
+               @Override
+               public void onMetricsAvailable(Window window, FrameMetrics frameMetrics, int dropCount) {
+                   assertEquals(myWindow, window);
+                   assertEquals(0, dropCount);
+                   data.add(new FrameMetrics(frameMetrics));
+               }
+            };
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().addFrameMetricsListener(listener, handler);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                scrollView.fling(-100);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+        new PollingCheck() {
+            @Override
+            protected boolean check() {
+                return data.size() != 0;
+            }
+        }.run();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().removeFrameMetricsListener(listener);
+                data.clear();
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                scrollView.fling(100);
+                assertEquals(0, data.size());
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+    }
+
+    public void testMultipleListeners() throws Throwable {
+        layout(R.layout.scrollview_layout);
+        final ScrollView scrollView = (ScrollView) mActivity.findViewById(R.id.scroll_view);
+        final ArrayList<FrameMetrics> data1 = new ArrayList<>();
+        final Handler handler = new Handler(Looper.getMainLooper());
+        final Window myWindow = mActivity.getWindow();
+
+        final Window.FrameMetricsListener frameMetricsListener1 =
+            new Window.FrameMetricsListener() {
+               @Override
+               public void onMetricsAvailable(Window window, FrameMetrics frameMetrics, int dropCount) {
+                   assertEquals(myWindow, window);
+                   assertEquals(0, dropCount);
+                   data1.add(new FrameMetrics(frameMetrics));
+               }
+            };
+        final ArrayList<FrameMetrics> data2 = new ArrayList<>();
+        final Window.FrameMetricsListener frameMetricsListener2 =
+            new Window.FrameMetricsListener() {
+               @Override
+               public void onMetricsAvailable(Window window, FrameMetrics frameMetrics, int dropCount) {
+                   assertEquals(myWindow, window);
+                   assertEquals(0, dropCount);
+                   data2.add(new FrameMetrics(frameMetrics));
+               }
+            };
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().addFrameMetricsListener(frameMetricsListener1, handler);
+                mActivity.getWindow().addFrameMetricsListener(frameMetricsListener2, handler);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                scrollView.fling(-100);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+        new PollingCheck() {
+            @Override
+            protected boolean check() {
+                return data1.size() != 0 && data1.size() == data2.size();
+            }
+        }.run();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().removeFrameMetricsListener(frameMetricsListener1);
+                mActivity.getWindow().removeFrameMetricsListener(frameMetricsListener2);
+            }
+        });
+    }
+
+    public void testDropCount() throws Throwable {
+        layout(R.layout.scrollview_layout);
+        final ScrollView scrollView = (ScrollView) mActivity.findViewById(R.id.scroll_view);
+
+        final Window window = mActivity.getWindow();
+        final AtomicInteger framesDropped = new AtomicInteger();
+        final AtomicInteger frameCount = new AtomicInteger();
+
+        final HandlerThread thread = new HandlerThread("Listener");
+        thread.start();
+        final Handler handler = new Handler(thread.getLooper());
+        final Window.FrameMetricsListener frameMetricsListener =
+            new Window.FrameMetricsListener() {
+               @Override
+               public void onMetricsAvailable(Window window, FrameMetrics frameMetrics, int dropCount) {
+                    try {
+                        Thread.sleep(100);
+                        framesDropped.addAndGet(dropCount);
+                    } catch (Exception e) { }
+               }
+            };
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().addFrameMetricsListener(frameMetricsListener, handler);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                scrollView.fling(-100);
+            }
+        });
+
+        mInstrumentation.waitForIdleSync();
+        new PollingCheck() {
+            @Override
+            protected boolean check() {
+                return framesDropped.get() > 0;
+            }
+        }.run();
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mActivity.getWindow().removeFrameMetricsListener(frameMetricsListener);
+            }
+        });
+    }
+}
+
+
diff --git a/tests/tests/view/src/android/view/cts/MockView.java b/tests/tests/view/src/android/view/cts/MockView.java
index d6939dc..0a56369 100644
--- a/tests/tests/view/src/android/view/cts/MockView.java
+++ b/tests/tests/view/src/android/view/cts/MockView.java
@@ -17,7 +17,6 @@
 package android.view.cts;
 
 import android.content.Context;
-import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
@@ -28,9 +27,9 @@
 import android.view.ContextMenu;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
+import android.view.PointerIcon;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.ViewParent;
 import android.view.ContextMenu.ContextMenuInfo;
 
 public class MockView extends View {
@@ -70,6 +69,7 @@
     private boolean mCalledComputeScroll = false;
     private boolean mCalledDispatchKeyEventPreIme = false;
     private boolean mCalledOnKeyPreIme = false;
+    private boolean mCalledGetPointerIcon = false;
 
     private int mOldWidth = -1;
     private int mOldHeight = -1;
@@ -606,6 +606,16 @@
         return mCalledOnKeyPreIme;
     }
 
+    @Override
+    public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+        mCalledGetPointerIcon = true;
+        return super.getPointerIcon(event, x, y);
+    }
+
+    public boolean hasCalledGetPointerIcon() {
+        return mCalledGetPointerIcon;
+    }
+
     public void reset() {
         mCalledOnCreateContextMenu = false;
 
@@ -644,6 +654,7 @@
         mCalledComputeScroll = false;
         mCalledDispatchKeyEventPreIme = false;
         mCalledOnKeyPreIme = false;
+        mCalledGetPointerIcon = false;
 
         mOldWidth = -1;
         mOldHeight = -1;
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index c3fe030..1e23660 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -18,6 +18,7 @@
 
 import static org.mockito.Mockito.*;
 
+import android.graphics.BitmapFactory;
 import com.android.internal.view.menu.ContextMenuBuilder;
 
 import android.content.Context;
@@ -353,29 +354,104 @@
         assertNull(view.getTouchDelegate());
     }
 
+    public void testMouseEventCallsGetPointerIcon() {
+        final MockView view = (MockView) mActivity.findViewById(R.id.mock_view);
+
+        final int[] xy = new int[2];
+        view.getLocationOnScreen(xy);
+        final int viewWidth = view.getWidth();
+        final int viewHeight = view.getHeight();
+        float x = xy[0] + viewWidth / 2.0f;
+        float y = xy[1] + viewHeight / 2.0f;
+
+        long eventTime = SystemClock.uptimeMillis();
+
+        MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[1];
+        pointerCoords[0] = new MotionEvent.PointerCoords();
+        pointerCoords[0].x = x;
+        pointerCoords[0].y = y;
+
+        final int[] pointerIds = new int[1];
+        pointerIds[0] = 0;
+
+        MotionEvent event = MotionEvent.obtain(0, eventTime, MotionEvent.ACTION_HOVER_MOVE,
+                1, pointerIds, pointerCoords, 0, 0, 0, 0, 0, InputDevice.SOURCE_MOUSE, 0);
+        getInstrumentation().sendPointerSync(event);
+        getInstrumentation().waitForIdleSync();
+
+        assertTrue(view.hasCalledGetPointerIcon());
+
+        final MockView view2 = (MockView) mActivity.findViewById(R.id.scroll_view);
+        assertFalse(view2.hasCalledGetPointerIcon());
+    }
+
     public void testAccessPointerShape() {
         View view = mActivity.findViewById(R.id.pointer_icon_layout);
         MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE,
                                                view.getX(), view.getY(), 0);
 
+        // First view has pointerShape="help"
         assertEquals(PointerIcon.getSystemIcon(mActivity, PointerIcon.STYLE_HELP),
                      view.getPointerIcon(event, 0, 0));
 
+        // Second view inherits pointerShape="crosshair" from the parent
         event.setLocation(0, 21);
         assertEquals(PointerIcon.getSystemIcon(mActivity, PointerIcon.STYLE_CROSSHAIR),
                      view.getPointerIcon(event, 0, 21));
+
+        // Third view has custom pointer shape defined in a resource.
         event.setLocation(0, 41);
+        assertNotNull(view.getPointerIcon(event, 0, 41));
+
+        // Parent view has pointerShape="crosshair"
+        event.setLocation(0, 61);
         assertEquals(PointerIcon.getSystemIcon(mActivity, PointerIcon.STYLE_CROSSHAIR),
-                     view.getPointerIcon(event, 0, 41));
-        event.setLocation(0, 51);
-        assertNull(view.getPointerIcon(event, 0, 51));
+                     view.getPointerIcon(event, 0, 61));
+
+        // Outside of the parent view, no pointer shape defined.
+        event.setLocation(0, 71);
+        assertNull(view.getPointerIcon(event, 0, 71));
 
         view.setPointerIcon(PointerIcon.getSystemIcon(mActivity, PointerIcon.STYLE_TEXT));
         assertEquals(PointerIcon.getSystemIcon(mActivity, PointerIcon.STYLE_TEXT),
-                     view.getPointerIcon(event, 0, 51));
+                     view.getPointerIcon(event, 0,71));
         event.recycle();
     }
 
+    public void testCreatePointerIcons() {
+        assertSystemPointerIcon(PointerIcon.STYLE_NULL);
+        assertSystemPointerIcon(PointerIcon.STYLE_DEFAULT);
+        assertSystemPointerIcon(PointerIcon.STYLE_ARROW);
+        assertSystemPointerIcon(PointerIcon.STYLE_CONTEXT_MENU);
+        assertSystemPointerIcon(PointerIcon.STYLE_HAND);
+        assertSystemPointerIcon(PointerIcon.STYLE_HELP);
+        assertSystemPointerIcon(PointerIcon.STYLE_WAIT);
+        assertSystemPointerIcon(PointerIcon.STYLE_CELL);
+        assertSystemPointerIcon(PointerIcon.STYLE_CROSSHAIR);
+        assertSystemPointerIcon(PointerIcon.STYLE_TEXT);
+        assertSystemPointerIcon(PointerIcon.STYLE_VERTICAL_TEXT);
+        assertSystemPointerIcon(PointerIcon.STYLE_ALIAS);
+        assertSystemPointerIcon(PointerIcon.STYLE_COPY);
+        assertSystemPointerIcon(PointerIcon.STYLE_NO_DROP);
+        assertSystemPointerIcon(PointerIcon.STYLE_ALL_SCROLL);
+        assertSystemPointerIcon(PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW);
+        assertSystemPointerIcon(PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW);
+        assertSystemPointerIcon(PointerIcon.STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW);
+        assertSystemPointerIcon(PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW);
+        assertSystemPointerIcon(PointerIcon.STYLE_ZOOM_IN);
+        assertSystemPointerIcon(PointerIcon.STYLE_ZOOM_OUT);
+        assertSystemPointerIcon(PointerIcon.STYLE_GRAB);
+
+        assertNotNull(PointerIcon.loadCustomIcon(mResources, R.drawable.custom_pointer_icon));
+
+        Bitmap bitmap = BitmapFactory.decodeResource(mResources, R.drawable.icon_blue);
+        assertNotNull(PointerIcon.createCustomIcon(bitmap, 0, 0));
+    }
+
+    private void assertSystemPointerIcon(int style) {
+        assertNotNull(PointerIcon.getSystemIcon(mActivity, style));
+    }
+
     @UiThreadTest
     public void testAccessTag() {
         ViewGroup viewGroup = (ViewGroup) mActivity.findViewById(R.id.viewlayout_root);
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
index 432fa20..b939346 100644
--- a/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
@@ -18,6 +18,7 @@
 
 
 import android.os.Bundle;
+import android.os.Handler;
 import android.test.AndroidTestCase;
 import android.text.TextUtils;
 import android.view.KeyEvent;
@@ -88,6 +89,9 @@
         assertTrue(inputConnection.isSetComposingRegionCalled);
         wrapper.requestCursorUpdates(InputConnection.CURSOR_UPDATE_IMMEDIATE);
         assertTrue(inputConnection.isRequestCursorUpdatesCalled);
+        assertFalse(inputConnection.isGetHandlerCalled);
+        assertNull(inputConnection.getHandler());
+        assertTrue(inputConnection.isGetHandlerCalled);
     }
 
     private class MockInputConnection implements InputConnection {
@@ -114,6 +118,7 @@
         public boolean isSetComposingRegionCalled;
         public boolean isSetSelectionCalled;
         public boolean isRequestCursorUpdatesCalled;
+        public boolean isGetHandlerCalled;
 
         public boolean beginBatchEdit() {
             isBeginBatchEditCalled = true;
@@ -229,5 +234,10 @@
             isRequestCursorUpdatesCalled = true;
             return false;
         }
+
+        public Handler getHandler() {
+            isGetHandlerCalled = true;
+            return null;
+        }
     }
 }
diff --git a/tools/cts-tradefed/res/config/basic-reporters.xml b/tools/cts-tradefed/res/config/basic-reporters.xml
new file mode 100644
index 0000000..f0f026a
--- /dev/null
+++ b/tools/cts-tradefed/res/config/basic-reporters.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Configuration with basic cts v2 reporters" >
+    <result_reporter class="com.android.compatibility.common.tradefed.result.ResultReporter" />
+</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-preconditions.xml b/tools/cts-tradefed/res/config/cts-preconditions.xml
index 9f0a8c9..c5b22d0 100644
--- a/tools/cts-tradefed/res/config/cts-preconditions.xml
+++ b/tools/cts-tradefed/res/config/cts-preconditions.xml
@@ -19,8 +19,8 @@
 
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
         <option name="target" value="host" />
-        <option name="module-name" value="cts_v2"/>
-        <option name="version-name" value="1.0"/>
+        <option name="config-filename" value="cts_v2"/>
+        <option name="version" value="1.0"/>
     </target_preparer>
 
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.StayAwakePreparer" />
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
index 66fcd44..7bde54e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
@@ -311,6 +311,8 @@
 
                 final Map<String, String> emptyMap = Collections.emptyMap();
                 mSink.testEnded(testId, emptyMap);
+            } else {
+                CLog.w("Finalization for non-pending case %s", testId);
             }
         }
 
@@ -372,6 +374,8 @@
         public void abortTest(TestIdentifier testId, String errorMessage) {
             final PendingResult result = mPendingResults.get(testId);
 
+            CLog.i("Test %s aborted with message %s", testId, errorMessage);
+
             // Mark as executed
             result.allInstancesPassed = false;
             result.errorMessages.put(mRunConfig, errorMessage);
@@ -390,37 +394,57 @@
         /**
          * Handles beginning of dEQP session.
          */
-        private void handleBeginSession(Map<String, String> values) {
+        private boolean handleBeginSession(Map<String, String> values) {
             // ignore
+            return true;
+        }
+
+        /**
+         * Handle session info
+         */
+        private boolean handleSessionInfo(Map<String, String> values) {
+            // ignore
+            return true;
         }
 
         /**
          * Handles end of dEQP session.
          */
-        private void handleEndSession(Map<String, String> values) {
+        private boolean handleEndSession(Map<String, String> values) {
             // ignore
+            return true;
         }
 
         /**
          * Handles beginning of dEQP testcase.
          */
-        private void handleBeginTestCase(Map<String, String> values) {
-            mCurrentTestId = pathToIdentifier(values.get("dEQP-BeginTestCase-TestCasePath"));
+        private boolean handleBeginTestCase(Map<String, String> values) {
+            String casePath = values.get("dEQP-BeginTestCase-TestCasePath");
+
             mCurrentTestLog = "";
             mGotTestResult = false;
 
+            if (casePath == null) {
+                CLog.w("Got null case path for test case begin event. Current test ID: %s", mCurrentTestId);
+                mCurrentTestId = null;
+                return false;
+            }
+
+            mCurrentTestId = pathToIdentifier(casePath);
+
             // mark instance as started
             if (mPendingResults.get(mCurrentTestId) != null) {
                 mPendingResults.get(mCurrentTestId).remainingConfigs.remove(mRunConfig);
             } else {
                 CLog.w("Got unexpected start of %s", mCurrentTestId);
             }
+            return true;
         }
 
         /**
          * Handles end of dEQP testcase.
          */
-        private void handleEndTestCase(Map<String, String> values) {
+        private boolean handleEndTestCase(Map<String, String> values) {
             final PendingResult result = mPendingResults.get(mCurrentTestId);
 
             if (result != null) {
@@ -442,19 +466,24 @@
                 CLog.w("Got unexpected end of %s", mCurrentTestId);
             }
             mCurrentTestId = null;
+            return true;
         }
 
         /**
          * Handles dEQP testcase result.
          */
-        private void handleTestCaseResult(Map<String, String> values) {
+        private boolean handleTestCaseResult(Map<String, String> values) {
             String code = values.get("dEQP-TestCaseResult-Code");
+            if (code == null) {
+                return false;
+            }
+
             String details = values.get("dEQP-TestCaseResult-Details");
 
             if (mPendingResults.get(mCurrentTestId) == null) {
                 CLog.w("Got unexpected result for %s", mCurrentTestId);
                 mGotTestResult = true;
-                return;
+                return true;
             }
 
             if (code.compareTo("Pass") == 0) {
@@ -480,12 +509,13 @@
                 mGotTestResult = true;
                 CLog.e("Got invalid result code '%s' for test %s", code, mCurrentTestId);
             }
+            return true;
         }
 
         /**
          * Handles terminated dEQP testcase.
          */
-        private void handleTestCaseTerminate(Map<String, String> values) {
+        private boolean handleTestCaseTerminate(Map<String, String> values) {
             final PendingResult result = mPendingResults.get(mCurrentTestId);
 
             if (result != null) {
@@ -504,40 +534,52 @@
 
             mCurrentTestId = null;
             mGotTestResult = true;
+            return true;
         }
 
         /**
          * Handles dEQP testlog data.
          */
-        private void handleTestLogData(Map<String, String> values) {
-            mCurrentTestLog = mCurrentTestLog + values.get("dEQP-TestLogData-Log");
+        private boolean handleTestLogData(Map<String, String> values) {
+            String newLog = values.get("dEQP-TestLogData-Log");
+            if (newLog == null) {
+                return false;
+            }
+            mCurrentTestLog = mCurrentTestLog + newLog;
+            return true;
         }
 
         /**
          * Handles new instrumentation status message.
+         * @return true if handled correctly, false if missing values.
          */
-        public void handleStatus(Map<String, String> values) {
+        public boolean handleStatus(Map<String, String> values) {
             String eventType = values.get("dEQP-EventType");
 
             if (eventType == null) {
-                return;
+                // Not an event, but some other line
+                return true;
             }
 
             if (eventType.compareTo("BeginSession") == 0) {
-                handleBeginSession(values);
+                return handleBeginSession(values);
+            } else if (eventType.compareTo("SessionInfo") == 0) {
+                return handleSessionInfo(values);
             } else if (eventType.compareTo("EndSession") == 0) {
-                handleEndSession(values);
+                return handleEndSession(values);
             } else if (eventType.compareTo("BeginTestCase") == 0) {
-                handleBeginTestCase(values);
+                return handleBeginTestCase(values);
             } else if (eventType.compareTo("EndTestCase") == 0) {
-                handleEndTestCase(values);
+                return handleEndTestCase(values);
             } else if (eventType.compareTo("TestCaseResult") == 0) {
-                handleTestCaseResult(values);
+                return handleTestCaseResult(values);
             } else if (eventType.compareTo("TerminateTestCase") == 0) {
-                handleTestCaseTerminate(values);
+                return handleTestCaseTerminate(values);
             } else if (eventType.compareTo("TestLogData") == 0) {
-                handleTestLogData(values);
+                return handleTestLogData(values);
             }
+            CLog.e("Unknown event type (%s)", eventType);
+            return false;
         }
 
         /**
@@ -548,6 +590,7 @@
             if (mCurrentTestId != null) {
                 // Current instance was removed from remainingConfigs when case
                 // started. Mark current instance as pending.
+                CLog.i("Batch ended with test '%s' current", mCurrentTestId);
                 if (mPendingResults.get(mCurrentTestId) != null) {
                     mPendingResults.get(mCurrentTestId).remainingConfigs.add(mRunConfig);
                 } else {
@@ -569,6 +612,7 @@
         private String mCurrentValue;
         private int mResultCode;
         private boolean mGotExitValue = false;
+        private boolean mParseSuccessful = true;
 
 
         public InstrumentationParser(TestInstanceResultListener listener) {
@@ -591,7 +635,7 @@
                         mCurrentValue = null;
                     }
 
-                    mListener.handleStatus(mValues);
+                    mParseSuccessful &= mListener.handleStatus(mValues);
                     mValues = null;
                 } else if (line.startsWith("INSTRUMENTATION_STATUS: dEQP-")) {
                     if (mCurrentName != null) {
@@ -604,16 +648,25 @@
                     String prefix = "INSTRUMENTATION_STATUS: ";
                     int nameBegin = prefix.length();
                     int nameEnd = line.indexOf('=');
-                    int valueBegin = nameEnd + 1;
-
-                    mCurrentName = line.substring(nameBegin, nameEnd);
-                    mCurrentValue = line.substring(valueBegin);
+                    if (nameEnd < 0) {
+                        CLog.e("Line does not contain value. Logcat interrupted? (%s)", line);
+                        mCurrentValue = null;
+                        mCurrentName = null;
+                        mParseSuccessful = false;
+                        return;
+                    } else {
+                        int valueBegin = nameEnd + 1;
+                        mCurrentName = line.substring(nameBegin, nameEnd);
+                        mCurrentValue = line.substring(valueBegin);
+                    }
                 } else if (line.startsWith("INSTRUMENTATION_CODE: ")) {
                     try {
                         mResultCode = Integer.parseInt(line.substring(22));
                         mGotExitValue = true;
                     } catch (NumberFormatException ex) {
-                        CLog.w("Instrumentation code format unexpected");
+                        CLog.e("Instrumentation code format unexpected");
+                        mParseSuccessful = false;
+                        return;
                     }
                 } else if (mCurrentValue != null) {
                     mCurrentValue = mCurrentValue + line;
@@ -634,7 +687,7 @@
             }
 
             if (mValues != null) {
-                mListener.handleStatus(mValues);
+                mParseSuccessful &= mListener.handleStatus(mValues);
                 mValues = null;
             }
         }
@@ -651,7 +704,7 @@
          * Returns whether target instrumentation exited normally.
          */
         public boolean wasSuccessful() {
-            return mGotExitValue;
+            return mGotExitValue && mParseSuccessful;
         }
 
         /**
@@ -1452,11 +1505,12 @@
         Throwable interruptingError = null;
 
         try {
+            CLog.d("Running command '%s'", command);
             executeShellCommandAndReadOutput(command, parser);
-        } catch (Throwable ex) {
-            interruptingError = ex;
-        } finally {
             parser.flush();
+        } catch (Throwable ex) {
+            CLog.w("Instrumented call threw '%s'", ex.getMessage());
+            interruptingError = ex;
         }
 
         final boolean progressedSinceLastCall = mInstanceListerner.getCurrentTestId() != null ||
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
index 2c8a816..2ba6b42 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
@@ -1162,6 +1162,735 @@
         EasyMock.verify(mockDevice);
     }
 
+    public void testRun_sessionInfoValueMissing() throws Exception {
+        final String instrumentationAnswerOk =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+
+        final String instrumentationAnswerBroken =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n";
+
+        final TestIdentifier[] testIds = {
+                new TestIdentifier("dEQP-GLES3.instances", "test1"),
+        };
+
+        final String[] testPaths = {
+                "dEQP-GLES3.instances.test1",
+        };
+
+        Map<String,String> config = new HashMap<>();
+        config.put("glconfig", "rgba8888d24s8");
+        config.put("rotation", "unspecified");
+        config.put("surfacetype", "window");
+
+        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
+
+        instances.put(testIds[0], new ArrayList<Map<String,String>>());
+        instances.get(testIds[0]).add(config);
+
+        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
+        for (TestIdentifier id : testIds) {
+            tests.add(id);
+        }
+
+        ITestInvocationListener mockListener
+                = EasyMock.createStrictMock(ITestInvocationListener.class);
+        IMocksControl orderedControl = EasyMock.createStrictControl();
+        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
+        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
+
+        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
+
+        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
+        deqpTest.setAbi(UnitTests.ABI);
+        deqpTest.setDevice(mockDevice);
+        deqpTest.setBuildHelper(new StubCtsBuildHelper());
+        deqpTest.setRecovery(mockRecovery);
+
+        int version = 3 << 16;
+        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
+                .andReturn(Integer.toString(version)).atLeastOnce();
+
+        mockRecovery.onExecutionProgressed();
+        EasyMock.expectLastCall().atLeastOnce();
+
+        mockRecovery.setDevice(mockDevice);
+        EasyMock.expectLastCall().atLeastOnce();
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
+            andReturn("").once();
+
+        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
+                EasyMock.eq(true),
+                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
+                .once();
+
+        // query config
+        expectRenderConfigQueryAndReturn(mockDevice,
+                "--deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-gl-major-version=3 "
+                + "--deqp-gl-minor-version=0", "Yes");
+
+        // run config and fail
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
+
+        mockRecovery.recoverComLinkKilled();
+        EasyMock.expectLastCall().once();
+
+        // Re-try
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk);
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
+                .andReturn("").once();
+
+        mockListener.testRunStarted(ID, 1);
+        EasyMock.expectLastCall().once();
+
+        // test1
+        mockListener.testStarted(EasyMock.eq(testIds[0]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        orderedControl.replay();
+        EasyMock.replay(mockListener);
+        EasyMock.replay(mockRecovery);
+        deqpTest.run(mockListener);
+
+        EasyMock.verify(mockListener);
+        orderedControl.verify();
+        EasyMock.verify(mockRecovery);
+    }
+
+    public void testRun_resultEventTypeMissing() throws Exception {
+        final String instrumentationAnswerOk =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+
+        final String instrumentationAnswerBroken =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n";
+
+        final TestIdentifier[] testIds = {
+                new TestIdentifier("dEQP-GLES3.instances", "test1"),
+        };
+
+        final String[] testPaths = {
+                "dEQP-GLES3.instances.test1",
+        };
+
+        Map<String,String> config = new HashMap<>();
+        config.put("glconfig", "rgba8888d24s8");
+        config.put("rotation", "unspecified");
+        config.put("surfacetype", "window");
+
+        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
+
+        instances.put(testIds[0], new ArrayList<Map<String,String>>());
+        instances.get(testIds[0]).add(config);
+
+        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
+        for (TestIdentifier id : testIds) {
+            tests.add(id);
+        }
+
+        ITestInvocationListener mockListener
+                = EasyMock.createStrictMock(ITestInvocationListener.class);
+        IMocksControl orderedControl = EasyMock.createStrictControl();
+        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
+        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
+
+        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
+
+        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
+        deqpTest.setAbi(UnitTests.ABI);
+        deqpTest.setDevice(mockDevice);
+        deqpTest.setBuildHelper(new StubCtsBuildHelper());
+        deqpTest.setRecovery(mockRecovery);
+
+        int version = 3 << 16;
+        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
+                .andReturn(Integer.toString(version)).atLeastOnce();
+
+        mockRecovery.onExecutionProgressed();
+        EasyMock.expectLastCall().atLeastOnce();
+
+        mockRecovery.setDevice(mockDevice);
+        EasyMock.expectLastCall().atLeastOnce();
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
+            andReturn("").once();
+
+        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
+                EasyMock.eq(true),
+                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
+                .once();
+
+        // query config
+        expectRenderConfigQueryAndReturn(mockDevice,
+                "--deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-gl-major-version=3 "
+                + "--deqp-gl-minor-version=0", "Yes");
+
+        // run config and fail
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
+
+        mockRecovery.recoverComLinkKilled();
+        EasyMock.expectLastCall().once();
+
+        // Re-try
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk);
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
+                .andReturn("").once();
+
+        mockListener.testRunStarted(ID, 1);
+        EasyMock.expectLastCall().once();
+
+        // test1
+        mockListener.testStarted(EasyMock.eq(testIds[0]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        orderedControl.replay();
+        EasyMock.replay(mockListener);
+        EasyMock.replay(mockRecovery);
+        deqpTest.run(mockListener);
+
+        EasyMock.verify(mockListener);
+        orderedControl.verify();
+        EasyMock.verify(mockRecovery);
+    }
+
+    /**
+     * Test handling of interrupted line in the instrumentation output
+     * and recovery from the error.
+     */
+    public void testRun_testCasePathInterrupted() throws Exception {
+        final String instrumentationAnswerOk1 =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+        final String instrumentationAnswerOk2 =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+        final String instrumentationAnswerBroken =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePat";
+
+        final TestIdentifier[] testIds = {
+                new TestIdentifier("dEQP-GLES3.instances", "test1"),
+                new TestIdentifier("dEQP-GLES3.instances", "test2"),
+        };
+
+        final String[] testPaths = {
+                "dEQP-GLES3.instances.test1",
+                "dEQP-GLES3.instances.test2",
+        };
+
+        Map<String,String> config = new HashMap<>();
+        config.put("glconfig", "rgba8888d24s8");
+        config.put("rotation", "unspecified");
+        config.put("surfacetype", "window");
+
+        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
+
+        instances.put(testIds[0], new ArrayList<Map<String,String>>());
+        instances.get(testIds[0]).add(config);
+        instances.put(testIds[1], new ArrayList<Map<String,String>>());
+        instances.get(testIds[1]).add(config);
+
+        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
+        for (TestIdentifier id : testIds) {
+            tests.add(id);
+        }
+
+        ITestInvocationListener mockListener
+                = EasyMock.createStrictMock(ITestInvocationListener.class);
+        IMocksControl orderedControl = EasyMock.createStrictControl();
+        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
+        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
+
+        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
+
+        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
+        deqpTest.setAbi(UnitTests.ABI);
+        deqpTest.setDevice(mockDevice);
+        deqpTest.setBuildHelper(new StubCtsBuildHelper());
+        deqpTest.setRecovery(mockRecovery);
+
+        int version = 3 << 16;
+        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
+                .andReturn(Integer.toString(version)).atLeastOnce();
+
+        mockRecovery.onExecutionProgressed();
+        EasyMock.expectLastCall().atLeastOnce();
+
+        mockRecovery.setDevice(mockDevice);
+        EasyMock.expectLastCall().atLeastOnce();
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
+            andReturn("").once();
+
+        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
+                EasyMock.eq(true),
+                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
+                .once();
+
+        // query config
+        expectRenderConfigQueryAndReturn(mockDevice,
+                "--deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-gl-major-version=3 "
+                + "--deqp-gl-minor-version=0", "Yes");
+
+        // run config and fail
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1,test2}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
+
+        mockRecovery.recoverComLinkKilled();
+        EasyMock.expectLastCall().once();
+
+        // Re-try
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk1);
+
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test2}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk2);
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
+                .andReturn("").once();
+
+        mockListener.testRunStarted(ID, 2);
+        EasyMock.expectLastCall().once();
+
+        // test1
+        mockListener.testStarted(EasyMock.eq(testIds[0]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        // test2
+        mockListener.testStarted(EasyMock.eq(testIds[1]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        orderedControl.replay();
+        EasyMock.replay(mockListener);
+        EasyMock.replay(mockRecovery);
+        deqpTest.run(mockListener);
+
+        EasyMock.verify(mockListener);
+        orderedControl.verify();
+        EasyMock.verify(mockRecovery);
+    }
+
+    /**
+     * Test handling of interrupted line in the instrumentation output
+     * and recovery from the error.
+     */
+    public void testRun_testCasePathMissing() throws Exception {
+        final String instrumentationAnswerOk1 =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+        final String instrumentationAnswerOk2 =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_CODE: 0\r\n";
+        final String instrumentationAnswerBroken =
+                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
+                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
+                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n";
+
+
+        final TestIdentifier[] testIds = {
+                new TestIdentifier("dEQP-GLES3.instances", "test1"),
+                new TestIdentifier("dEQP-GLES3.instances", "test2"),
+        };
+
+        final String[] testPaths = {
+                "dEQP-GLES3.instances.test1",
+                "dEQP-GLES3.instances.test2",
+        };
+
+        Map<String,String> config = new HashMap<>();
+        config.put("glconfig", "rgba8888d24s8");
+        config.put("rotation", "unspecified");
+        config.put("surfacetype", "window");
+
+        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
+
+        instances.put(testIds[0], new ArrayList<Map<String,String>>());
+        instances.get(testIds[0]).add(config);
+        instances.put(testIds[1], new ArrayList<Map<String,String>>());
+        instances.get(testIds[1]).add(config);
+
+        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
+        for (TestIdentifier id : testIds) {
+            tests.add(id);
+        }
+
+        ITestInvocationListener mockListener
+                = EasyMock.createStrictMock(ITestInvocationListener.class);
+        IMocksControl orderedControl = EasyMock.createStrictControl();
+        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
+        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
+
+        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
+
+        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
+        deqpTest.setAbi(UnitTests.ABI);
+        deqpTest.setDevice(mockDevice);
+        deqpTest.setBuildHelper(new StubCtsBuildHelper());
+        deqpTest.setRecovery(mockRecovery);
+
+        int version = 3 << 16;
+        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
+                .andReturn(Integer.toString(version)).atLeastOnce();
+
+        mockRecovery.onExecutionProgressed();
+        EasyMock.expectLastCall().atLeastOnce();
+
+        mockRecovery.setDevice(mockDevice);
+        EasyMock.expectLastCall().atLeastOnce();
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
+            andReturn("").once();
+
+        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
+                EasyMock.eq(true),
+                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
+                .once();
+
+        // query config
+        expectRenderConfigQueryAndReturn(mockDevice,
+                "--deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-gl-major-version=3 "
+                + "--deqp-gl-minor-version=0", "Yes");
+
+        // run config and fail
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1,test2}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
+
+        mockRecovery.recoverComLinkKilled();
+        EasyMock.expectLastCall().once();
+
+        // Re-try
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test1}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk1);
+
+        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
+                "{dEQP-GLES3{instances{test2}}}",
+                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
+                + " --deqp-gl-config-name=rgba8888d24s8 "
+                + "--deqp-screen-rotation=unspecified "
+                + "--deqp-surface-type=window "
+                + "--deqp-log-images=disable "
+                + "--deqp-watchdog=enable", instrumentationAnswerOk2);
+
+        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
+                .andReturn("").once();
+
+        mockListener.testRunStarted(ID, 2);
+        EasyMock.expectLastCall().once();
+
+        // test1
+        mockListener.testStarted(EasyMock.eq(testIds[0]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        // test2
+        mockListener.testStarted(EasyMock.eq(testIds[1]));
+        EasyMock.expectLastCall().once();
+
+        mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
+        EasyMock.expectLastCall().once();
+
+        orderedControl.replay();
+        EasyMock.replay(mockListener);
+        EasyMock.replay(mockRecovery);
+        deqpTest.run(mockListener);
+
+        EasyMock.verify(mockListener);
+        orderedControl.verify();
+        EasyMock.verify(mockRecovery);
+    }
+
     /**
      * Test dEQP with multiple instances
      */
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 4958d4e..79b7b1c 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -34,10 +34,6 @@
 # ============================================================
 include $(CLEAR_VARS)
 
-# custom variables used to generate test description. do not touch!
-LOCAL_TEST_TYPE := vmHostTest
-LOCAL_JAR_PATH := android.core.vm-tests-tf.jar
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_MODULE := cts-tf-dalvik-buildutil
@@ -57,25 +53,37 @@
 include $(CLEAR_VARS)
 
 LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
-intermediates := $(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
-vmteststf_jar := $(intermediates)/android.core.vm-tests-tf.jar
+LOCAL_MODULE := vm-tests-tf
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_BUILT_MODULE_STEM := javalib.jar
+intermediates := $(call local-intermediates-dir)
+# Install the module as $(intermediates)/android.core.vm-tests-tf.jar.
+LOCAL_INSTALLED_MODULE_STEM := android.core.vm-tests-tf.jar
+LOCAL_MODULE_PATH := $(intermediates)
+
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
 vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit.jar)
 
-$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
+$(LOCAL_BUILT_MODULE): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
 
 ifdef LOCAL_JACK_ENABLED
     vmteststf_dep_jars += $(cts-tf-dalvik-lib.jack)
 endif
 
-$(vmteststf_jar): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
-$(vmteststf_jar): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
-$(vmteststf_jar): PRIVATE_INTERMEDIATES := $(intermediates)/tests
-$(vmteststf_jar): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
-$(vmteststf_jar): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
-$(vmteststf_jar): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
-$(vmteststf_jar): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
+$(LOCAL_BUILT_MODULE): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
+$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
+$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES := $(intermediates)/tests
+$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
+$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
+$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
+$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
 ifndef LOCAL_JACK_ENABLED
-$(vmteststf_jar) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
 	# generated and compile the host side junit tests
@@ -88,13 +96,13 @@
 		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
 	$(hide) $(DX) -JXms16M -JXmx768M --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR) \
 		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
-	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
-	$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@) .
+	$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
 else # LOCAL_JACK_ENABLED
 oj_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jack
 libart_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jack
-$(vmteststf_jar): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jack):$(libart_jack):$(cts-tf-dalvik-lib.jack):$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
-$(vmteststf_jar) : $(vmteststf_dep_jars) $(JACK) $(oj_jack) $(libart_jack) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar | setup-jack-server
+$(LOCAL_BUILT_MODULE): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jack):$(libart_jack):$(cts-tf-dalvik-lib.jack):$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(JACK) $(oj_jack) $(libart_jack) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar | setup-jack-server
 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
 	# generated and compile the host side junit tests
@@ -110,13 +118,12 @@
 	$(hide) $(call call-jack,$(PRIVATE_JACK_EXTRA_ARGS)) --output-dex $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
 		$(if $(NO_OPTIMIZE_DX), -D jack.dex.optimize "false") --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
 	$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
-	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
-	$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@) .
+	$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
 oj_jack :=
 libart_jack :=
 endif # LOCAL_JACK_ENABLED
 
 # Clean up temp vars
 intermediates :=
-vmteststf_jar :=
 vmteststf_dep_jars :=