OSDN Git Service

Fixing FileLogs tests
authorSunny Goyal <sunnygoyal@google.com>
Tue, 7 Jun 2016 20:53:20 +0000 (13:53 -0700)
committerSunny Goyal <sunnygoyal@google.com>
Tue, 7 Jun 2016 20:54:50 +0000 (13:54 -0700)
During tests, the logs directory is changed. But the active thread
was not getting stopped which was causing some logs to be written
to the old location corresponding to some previous test

Change-Id: I7b8587eae0eb68fa180e3992694cab3745922483

AndroidManifest.xml
src/com/android/launcher3/logging/FileLog.java

index eb7ea0c..3a3a28d 100644 (file)
     <uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" />
     <uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS" />
 
-    <application>
+    <application
+        android:backupAgent="com.android.launcher3.LauncherBackupAgent"
+        android:fullBackupOnly="true"
+        android:fullBackupContent="@xml/backupscheme"
+        android:hardwareAccelerated="true"
+        android:icon="@mipmap/ic_launcher_home"
+        android:label="@string/app_name"
+        android:largeHeap="@bool/config_largeHeap"
+        android:restoreAnyVersion="true"
+        android:supportsRtl="true" >
 
         <!--
         Main launcher activity. When extending only change the name, and keep all the
index 68d9b8c..8629e92 100644 (file)
@@ -40,6 +40,15 @@ public final class FileLog {
     private static File sLogsDirectory = null;
 
     public static void setDir(File logsDir) {
+        if (ProviderConfig.IS_DOGFOOD_BUILD) {
+            synchronized (DATE_FORMAT) {
+                // If the target directory changes, stop any active thread.
+                if (sHandler != null && !logsDir.equals(sLogsDirectory)) {
+                    ((HandlerThread) sHandler.getLooper().getThread()).quit();
+                    sHandler = null;
+                }
+            }
+        }
         sLogsDirectory = logsDir;
     }