Copy Verifier Results to Clipboard

Bug 4478619

Change-Id: Ie8c57f03332b31be3b69d65eda091810c52b980d
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 2dabc00..9bdb37a 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -40,7 +40,7 @@
         </activity>
 
         <activity android:name=".TestListActivity" android:label="@string/test_list_title" />
-        
+
         <provider android:name=".TestResultsProvider" 
                 android:authorities="com.android.cts.verifier.testresultsprovider" />
                 
diff --git a/apps/CtsVerifier/res/menu/test_list_menu.xml b/apps/CtsVerifier/res/menu/test_list_menu.xml
index 713455c..67c626c 100644
--- a/apps/CtsVerifier/res/menu/test_list_menu.xml
+++ b/apps/CtsVerifier/res/menu/test_list_menu.xml
@@ -3,6 +3,9 @@
     <item android:id="@+id/clear"
           android:icon="@android:drawable/ic_menu_delete" 
           android:title="@string/clear" />
+    <item android:id="@+id/copy"
+          android:icon="@android:drawable/ic_menu_upload"
+          android:title="@string/copy" />
     <item android:id="@+id/share"
           android:icon="@android:drawable/ic_menu_share"
           android:title="@string/share" />
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index dfc41f8..93b5078 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -23,8 +23,8 @@
     <string name="fail_button_text">Fail</string>
 
     <!-- Strings for TestResultsReport -->
-    <string name="subject_header">[CtsVerifier %1$s]</string>
-    <string name="body_header">Cts Verifier %1$s Test Results</string>
+    <string name="subject_header">[CTS Verifier %1$s]</string>
+    <string name="body_header">CTS Verifier %1$s Test Results</string>
     <string name="pass_result">PASS</string>
     <string name="fail_result">FAIL</string>
     <string name="not_executed_result">NOT_EXECUTED</string>
@@ -39,6 +39,8 @@
     <string name="test_category_other">Other</string>
     <string name="clear">Clear</string>
     <string name="test_results_cleared">Test results cleared.</string>
+    <string name="copy">Copy</string>
+    <string name="test_results_copied">Test results copied to clipboard.</string>
     <string name="share">Share</string>
     <string name="share_test_results">Share Test Results</string>
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
index 8509edb..c563e13 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
@@ -25,6 +25,7 @@
 import android.database.ContentObserver;
 import android.os.Bundle;
 import android.os.Handler;
+import android.text.ClipboardManager;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -113,6 +114,10 @@
                 handleClearItemSelected();
                 return true;
 
+            case R.id.copy:
+                handleCopyItemSelected();
+                return true;
+
             case R.id.share:
                 handleShareItemSelected();
                 return true;
@@ -128,6 +133,13 @@
         Toast.makeText(this, R.string.test_results_cleared, Toast.LENGTH_SHORT).show();
     }
 
+    private void handleCopyItemSelected() {
+        TestResultsReport report = new TestResultsReport(this, getListAdapter());
+        ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+        clipboardManager.setText(report.getBody());
+        Toast.makeText(this, R.string.test_results_copied, Toast.LENGTH_SHORT).show();
+    }
+
     private void handleShareItemSelected() {
         Intent target = new Intent(Intent.ACTION_SEND);
         target.setType("text/plain");