summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Junyu Lai <junyulai@google.com> 2022-01-25 07:40:06 +0000
committer Junyu Lai <junyulai@google.com> 2022-01-25 09:59:38 +0000
commit154cdf1b7735d7cf39068ccd6d9008a12d37695e (patch)
treefcf239a71aabc5d85471e9d14d47ec589929206a
parent96bc724b39108fa1d0d88ef8eecaec5e99fa639d (diff)
[MS69.1] Fix TrafficStats.init crashs for supplemental process
Supplemental apps has limited capabilities and service discovery is restricted. Hence, calling TrafficStats.init would result in crash. This change includes: 1. Print log instead of crashing process when running into any unexpected cases. Test: atest SupplementalProcessManagerTests Bug: 216062904 Change-Id: I7f827ccc485c997745779053b5936a6cb30e8219
-rw-r--r--packages/ConnectivityT/framework-t/src/android/net/TrafficStats.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/ConnectivityT/framework-t/src/android/net/TrafficStats.java b/packages/ConnectivityT/framework-t/src/android/net/TrafficStats.java
index 77b7f16671a0..c2f0cdfb048c 100644
--- a/packages/ConnectivityT/framework-t/src/android/net/TrafficStats.java
+++ b/packages/ConnectivityT/framework-t/src/android/net/TrafficStats.java
@@ -31,6 +31,7 @@ import android.media.MediaPlayer;
import android.os.Binder;
import android.os.Build;
import android.os.RemoteException;
+import android.util.Log;
import com.android.server.NetworkManagementSocketTagger;
@@ -212,6 +213,13 @@ public class TrafficStats {
}
final NetworkStatsManager statsManager =
context.getSystemService(NetworkStatsManager.class);
+ if (statsManager == null) {
+ // TODO: Currently Process.isSupplemental is not working yet, because it depends on
+ // process to run in a certain UID range, which is not true for now. Change this
+ // to Log.wtf once Process.isSupplemental is ready.
+ Log.e(TAG, "TrafficStats not initialized, uid=" + Binder.getCallingUid());
+ return;
+ }
sStatsService = statsManager.getBinder();
}