OSDN Git Service

Improved the debug message
authorJack Yu <jackyu@google.com>
Thu, 4 Apr 2019 22:10:17 +0000 (15:10 -0700)
committerJack Yu <jackyu@google.com>
Fri, 5 Apr 2019 17:03:13 +0000 (10:03 -0700)
Improved the log readability by printed out data state
in string format instead of integer. Also added listen
local log.

Bug: 129631771
Test: Manual

Merged-In: If786d51b35380f606bc388e29a441bb24a2792e0
Change-Id: If786d51b35380f606bc388e29a441bb24a2792e0
(cherry picked from commit 0c92c2395124c95acc9d0e184ff8d472bd562245)

services/core/java/com/android/server/TelephonyRegistry.java
telephony/java/android/telephony/TelephonyManager.java

index 7a8d23a..85787f2 100644 (file)
@@ -248,6 +248,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
 
     private final LocalLog mLocalLog = new LocalLog(100);
 
+    private final LocalLog mListenLog = new LocalLog(100);
+
     private PreciseDataConnectionState mPreciseDataConnectionState =
                 new PreciseDataConnectionState();
 
@@ -305,6 +307,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                     }
                     mDefaultSubId = newDefaultSubId;
                     mDefaultPhoneId = newDefaultPhoneId;
+                    mLocalLog.log("Default subscription updated: mDefaultPhoneId="
+                            + mDefaultPhoneId + ", mDefaultSubId" + mDefaultSubId);
                 }
             }
         }
@@ -598,10 +602,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
             boolean notifyNow, int subId) {
         int callerUserId = UserHandle.getCallingUserId();
         mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
-        if (VDBG) {
-            log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
+        String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
                 + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
-                + UserHandle.myUserId() + " callerUserId=" + callerUserId);
+                + UserHandle.myUserId() + " callerUserId=" + callerUserId;
+        mListenLog.log(str);
+        if (VDBG) {
+            log(str);
         }
 
         if (events != PhoneStateListener.LISTEN_NONE) {
@@ -1399,8 +1405,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                 if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType)
                         && (mDataConnectionState[phoneId] != state
                         || mDataConnectionNetworkType[phoneId] != networkType)) {
-                    String str = "onDataConnectionStateChanged(" + state
-                            + ", " + networkType + ")";
+                    String str = "onDataConnectionStateChanged("
+                            + TelephonyManager.dataStateToString(state)
+                            + ", " + TelephonyManager.getNetworkTypeName(networkType)
+                            + ") subId=" + subId + ", phoneId=" + phoneId;
                     log(str);
                     mLocalLog.log(str);
                     for (Record r : mRecords) {
@@ -1916,12 +1924,16 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
             pw.println("mEmergencyNumberList=" + mEmergencyNumberList);
             pw.println("mCallQuality=" + mCallQuality);
             pw.println("mCallAttributes=" + mCallAttributes);
+            pw.println("mDefaultPhoneId" + mDefaultPhoneId);
+            pw.println("mDefaultSubId" + mDefaultSubId);
 
             pw.decreaseIndent();
 
             pw.println("local logs:");
             pw.increaseIndent();
             mLocalLog.dump(fd, pw, args);
+            pw.println("listen logs:");
+            mListenLog.dump(fd, pw, args);
             pw.decreaseIndent();
             pw.println("registrations: count=" + recordCount);
             pw.increaseIndent();
index e6e54ea..f9d9bab 100644 (file)
@@ -2647,7 +2647,7 @@ public class TelephonyManager {
      */
     /** {@hide} */
     @UnsupportedAppUsage
-    public static String getNetworkTypeName(int type) {
+    public static String getNetworkTypeName(@NetworkType int type) {
         switch (type) {
             case NETWORK_TYPE_GPRS:
                 return "GPRS";
@@ -4788,6 +4788,22 @@ public class TelephonyManager {
         }
     }
 
+    /**
+     * Convert data state to string
+     *
+     * @return The data state in string format.
+     * @hide
+     */
+    public static String dataStateToString(@DataState int state) {
+        switch (state) {
+            case DATA_DISCONNECTED: return "DISCONNECTED";
+            case DATA_CONNECTING: return "CONNECTING";
+            case DATA_CONNECTED: return "CONNECTED";
+            case DATA_SUSPENDED: return "SUSPENDED";
+        }
+        return "UNKNOWN(" + state + ")";
+    }
+
    /**
     * @hide
     */