update attention management test for M release

  Edit strings to reflect new placement of Do not disturb controls.
  clean up notifications that are left over from old runs.
  Fix a potential null pointer exception while I'm here.

Bug: 22672688
Change-Id: I83c4e99bbca4aedcfd0fa2a4a859636f245ad939
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 91a62ba..3b26458 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1097,13 +1097,12 @@
         respecting user preferences about notification ranking and filtering.
     </string>
     <string name="attention_ready">I\'m done</string>
-    <string name="attention_filter_all">Please set the notification filter to \"All\" in the dialog
-        that appears when you change the device\'s volume.</string>
-    <string name="attention_filter_priority">Please set the notification filter to \"Priority\" in
-        the dialog that appears when you change the device\'s volume, and allow messages from
-        starred contacts.</string>
-    <string name="attention_filter_none">Please set the notification filter to \"None\" in the dialog
-        that appears when you change the device\'s volume.</string>
+    <string name="attention_filter_all">Please disable \"Do not disturb\" by tapping the Quick Settings tile.</string>
+    <string name="attention_filter_priority">Please select \"Priority only\" in the dialog that appears
+        when you tap the \"Do not disturb\" tile in Quick Settings, and customize the setting to allow messages from
+        starred contacts only by tapping "More settings".</string>
+    <string name="attention_filter_none">Please select \"Total silence\" in the dialog that appears
+        when you tap the \"Do not disturb\" tile in Quick Settings.</string>
     <string name="attention_create_contacts">Create contacts for notification annotations.</string>
     <string name="attention_delete_contacts">Delete test contacts.</string>
     <string name="attention_default_order">Check that ranker defaults to time order.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
index d8f196a..4898ab2 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
@@ -85,6 +85,7 @@
         tests.add(new InsertContactsTest());
         tests.add(new SetModeNoneTest());
         tests.add(new NoneInterceptsAllTest());
+        tests.add(new SetModeAllTest());
         tests.add(new SetModePriorityTest());
         tests.add(new PriorityInterceptsSomeTest());
         tests.add(new SetModeAllTest());
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
index 07d9cc9..25a36b6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
@@ -165,8 +165,9 @@
     protected void onSaveInstanceState (Bundle outState) {
         final int stateIndex = mTestList.indexOf(mCurrentTest);
         outState.putInt(STATE, stateIndex);
-        outState.putInt(STATUS, mCurrentTest.status);
-        Log.i(TAG, "saved state(" + stateIndex + "}, status(" + (mCurrentTest.status) + ")");
+        final int status = mCurrentTest == null ? SETUP : mCurrentTest.status;
+        outState.putInt(STATUS, status);
+        Log.i(TAG, "saved state(" + stateIndex + "}, status(" + status + ")");
     }
 
     @Override
@@ -383,6 +384,7 @@
 
         @Override
         void test() {
+            mNm.cancelAll();
             Intent settings = new Intent(NOTIFICATION_LISTENER_SETTINGS);
             if (settings.resolveActivity(mPackageManager) == null) {
                 logFail("no settings activity");