Fix the qtaguid test for P

For devices that are running android P, it may not have detail tagged
stats directly avalaible from qtaguid module. We should check for the
total stats to verify the app can access it's own stats instead of
checking for a specific tags.

Test: atest QtaguidPermissionTest.java
Bug: 80186678
Change-Id: I7c20a5f00f67e95881b568ab7e36996254637372
diff --git a/tests/netlegacy22.permission/src/android/net/cts/legacy/api22/permission/QtaguidPermissionTest.java b/tests/netlegacy22.permission/src/android/net/cts/legacy/api22/permission/QtaguidPermissionTest.java
index 08fd753..60d2a2a 100644
--- a/tests/netlegacy22.permission/src/android/net/cts/legacy/api22/permission/QtaguidPermissionTest.java
+++ b/tests/netlegacy22.permission/src/android/net/cts/legacy/api22/permission/QtaguidPermissionTest.java
@@ -19,8 +19,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
-
-
 public class QtaguidPermissionTest extends AndroidTestCase {
 
     private static final String QTAGUID_STATS_FILE = "/proc/net/xt_qtaguid/stats";
@@ -56,19 +54,20 @@
         }
     }
 
-    private void accessOwnTrafficStats() throws IOException {
+    private void accessOwnTrafficStats(long expectedTxBytes) throws IOException {
 
         final int ownAppUid = getContext().getApplicationInfo().uid;
 
-        boolean foundOwnDetailedStats = false;
+        long totalTxBytes = 0;
         try {
             BufferedReader qtaguidReader = new BufferedReader(new FileReader(QTAGUID_STATS_FILE));
             String line;
             while ((line = qtaguidReader.readLine()) != null) {
                 String tokens[] = line.split(" ");
                 if (tokens.length > 3 && tokens[3].equals(String.valueOf(ownAppUid))) {
-                    if (!tokens[2].equals("0x0")) {
-                      foundOwnDetailedStats = true;
+                    // Check the total stats of this uid is larger then 1MB
+                    if (tokens[2].equals("0x0")) {
+                        totalTxBytes += Integer.parseInt(tokens[7]);
                     }
                 }
             }
@@ -76,7 +75,8 @@
         } catch (FileNotFoundException e) {
             fail("Was not able to access qtaguid/stats: " + e);
         }
-        assertTrue("Was expecting to find own traffic stats", foundOwnDetailedStats);
+        assertTrue(totalTxBytes + " expected to be greater than or equal to"
+            + expectedTxBytes + "bytes", totalTxBytes >= expectedTxBytes);
     }
 
     public void testAccessOwnQtaguidTrafficStats() throws IOException {
@@ -124,6 +124,6 @@
             server.close();
         }
 
-        accessOwnTrafficStats();
+        accessOwnTrafficStats(byteCount * packetCount);
     }
 }