Add confirm dialog before clearing CtsVerifier test results.

bug: 32488738
Change-Id: I8411f7b557d0be5830140bdadf30c48025590405
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 3b68ac9..78ada5c 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -41,6 +41,9 @@
     <string name="test_category_tv">TV</string>
     <string name="test_category_other">Other</string>
     <string name="clear">Clear</string>
+    <string name="test_results_clear_title">Remove all test results?</string>
+    <string name="test_results_clear_yes">Yes</string>
+    <string name="test_results_clear_cancel">Cancel</string>
     <string name="test_results_cleared">Test results cleared.</string>
     <string name="view">View</string>
     <string name="test_results_error">Couldn\'t create test results report.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
index 807e02a..1e3f312 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
@@ -17,7 +17,9 @@
 package com.android.cts.verifier;
 
 import android.Manifest;
+import android.app.AlertDialog;
 import android.app.ListActivity;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
@@ -126,8 +128,21 @@
     }
 
     private void handleClearItemSelected() {
-        mAdapter.clearTestResults();
-        Toast.makeText(this, R.string.test_results_cleared, Toast.LENGTH_SHORT).show();
+        new AlertDialog.Builder(this)
+            .setMessage(R.string.test_results_clear_title)
+            .setPositiveButton(R.string.test_results_clear_yes,
+                    new DialogInterface.OnClickListener() {
+                       public void onClick(DialogInterface dialog, int id) {
+                            mAdapter.clearTestResults();
+                            Toast.makeText(
+                                TestListActivity.this,
+                                R.string.test_results_cleared,
+                                Toast.LENGTH_SHORT)
+                                    .show();
+                       }
+                   })
+            .setNegativeButton(R.string.test_results_clear_cancel, null)
+            .show();
     }
 
     private void handleViewItemSelected() {