Run comparison code if the data migration finished with fallback am: d451fdbb25

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2133165

Change-Id: I9e32b4e7967a78dc7402b21836d1952b274e2b95
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index 9bf0d81..168fc56 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -942,15 +942,23 @@
 
         final int targetAttempts = mDeps.getImportLegacyTargetAttempts();
         final int attempts;
+        final int fallbacks;
         try {
             attempts = mImportLegacyAttemptsCounter.get();
+            fallbacks = mImportLegacyFallbacksCounter.get();
         } catch (IOException e) {
-            Log.wtf(TAG, "Failed to read attempts counter, skip.", e);
+            Log.wtf(TAG, "Failed to read counters, skip.", e);
             return;
         }
-        if (attempts >= targetAttempts) return;
+        // If fallbacks is not zero, proceed with reading only to give signals from dogfooders.
+        // TODO: Remove fallbacks counter check before T formal release.
+        if (attempts >= targetAttempts && fallbacks == 0) return;
 
-        Log.i(TAG, "Starting import : attempts " + attempts + "/" + targetAttempts);
+        if (attempts >= targetAttempts) {
+            Log.i(TAG, "Starting import : only perform read");
+        } else{
+            Log.i(TAG, "Starting import : attempts " + attempts + "/" + targetAttempts);
+        }
 
         final MigrationInfo[] migrations = new MigrationInfo[]{
                 new MigrationInfo(mDevRecorder), new MigrationInfo(mXtRecorder),
@@ -1020,6 +1028,10 @@
                 }
             }
 
+            // For cases where the fallbacks is not zero but target attempts counts reached,
+            // only perform reads above and return here.
+            if (attempts >= targetAttempts) return;
+
             // Find the latest end time.
             for (final MigrationInfo migration : migrations) {
                 final long migrationEnd = migration.collection.getEndMillis();