Fixes the broken tests for AppUsageStatistics. Update the UI in the UI thread.
https://b.corp.google.com/issues/19685630

Succeeded tests log. https://paste.googleplex.com/5935381669216256

Change-Id: I9a679b80407cd02bd5cc1488a0c758aa690a8225
diff --git a/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java
index d8adb1c..bcffdea 100644
--- a/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java
+++ b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java
@@ -31,6 +31,7 @@
         extends ActivityInstrumentationTestCase2<AppUsageStatisticsActivity> {
 
     private AppUsageStatisticsActivity mTestActivity;
+
     private AppUsageStatisticsFragment mTestFragment;
 
     public AppUsageStatisticsFragmentTests() {
@@ -81,10 +82,14 @@
     }
 
     public void testUpdateAppsList() {
-        List<UsageStats> usageStatsList = mTestFragment
+        final List<UsageStats> usageStatsList = mTestFragment
                 .getUsageStatistics(UsageStatsManager.INTERVAL_DAILY);
-
-        mTestFragment.updateAppsList(usageStatsList);
+        mTestActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mTestFragment.updateAppsList(usageStatsList);
+            }
+        });
         getInstrumentation().waitForIdleSync();
 
         // The result depends on if the app is granted the access to App usage statistics.