From 3aedd8b21a4b2ded7034ecc6f13ee624e2340f97 Mon Sep 17 00:00:00 2001 From: Chenbo Feng Date: Fri, 8 Dec 2017 12:17:43 -0800 Subject: [PATCH] Check qtaguid support before private stats test The AccessPrivateDataTest and CreatePrivateDataTest is directly testing the proc file of xt_qtaguid module. These two test will no longer valid after we block the access from untrusted app to qtaguid proc file. So remove the AccessPrivateDataTest and added a new qtaguid test to make sure apps with SDK 28 or above cannot access qtaguid proc file. Bug: 30950746 Bug: 68774956 Test: run cts -m CtsAppSecurityHostTestCases \ -t android.appsecurity.cts.AppSecurityTests Change-Id: I957ba31fea392982e7d15eda2afd9580299192f2 --- .../src/android/net/cts/TrafficStatsTest.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/tests/cts/net/src/android/net/cts/TrafficStatsTest.java b/tests/cts/net/src/android/net/cts/TrafficStatsTest.java index 930c74255d..a8743fad7f 100755 --- a/tests/cts/net/src/android/net/cts/TrafficStatsTest.java +++ b/tests/cts/net/src/android/net/cts/TrafficStatsTest.java @@ -81,26 +81,6 @@ public class TrafficStatsTest extends AndroidTestCase { return packetCount * (20 + 32 + bytes); } - private void accessOwnTrafficStats() throws IOException { - final int ownAppUid = getContext().getApplicationInfo().uid; - Log.d(LOG_TAG, "accesOwnTrafficStatsWithTags(): about to read qtaguid stats for own uid " + ownAppUid); - - boolean foundOwnDetailedStats = false; - try { - BufferedReader qtaguidReader = new BufferedReader(new FileReader("/proc/net/xt_qtaguid/stats")); - String line; - while ((line = qtaguidReader.readLine()) != null) { - String tokens[] = line.split(" "); - if (tokens.length > 3 && tokens[3].equals(String.valueOf(ownAppUid))) { - Log.d(LOG_TAG, "accessOwnTrafficStatsWithTags(): got own stats: " + line); - } - } - qtaguidReader.close(); - } catch (FileNotFoundException e) { - fail("Was not able to access qtaguid/stats: " + e); - } - } - public void testTrafficStatsForLocalhost() throws IOException { final long mobileTxPacketsBefore = TrafficStats.getMobileTxPackets(); final long mobileRxPacketsBefore = TrafficStats.getMobileRxPackets(); @@ -132,7 +112,6 @@ public class TrafficStatsTest extends AndroidTestCase { byte[] buf = new byte[byteCount]; TrafficStats.setThreadStatsTag(0x42); TrafficStats.tagSocket(socket); - accessOwnTrafficStats(); for (int i = 0; i < packetCount; i++) { out.write(buf); out.flush(); @@ -145,7 +124,6 @@ public class TrafficStatsTest extends AndroidTestCase { } out.close(); socket.close(); - accessOwnTrafficStats(); } catch (IOException e) { Log.i(LOG_TAG, "Badness during writes to socket: " + e); }