OSDN Git Service

Ignore hasService in updateTelephonySignalStrength
authorWink Saville <wink@google.com>
Thu, 10 Jul 2014 20:01:52 +0000 (13:01 -0700)
committerWink Saville <wink@google.com>
Thu, 10 Jul 2014 20:02:43 +0000 (20:02 +0000)
A possible reason for empty triangle is there is no service, I'm
temporarily ignoring hasService in updateTelphonySignalStrength and
adding more debug.

Add logSSC to see history of Service State Changes.

Bug: 16148026
Change-Id: Ia463997eac7b062653b3cef00570d3fffc115ad3

packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
services/core/java/com/android/server/TelephonyRegistry.java

index 799b41f..2b08902 100644 (file)
@@ -34,6 +34,7 @@ import android.os.Message;
 import android.os.Messenger;
 import android.provider.Settings;
 import android.telephony.PhoneStateListener;
+import android.telephony.Rlog;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.telephony.TelephonyManager;
@@ -474,8 +475,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
     PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
         @Override
         public void onSignalStrengthsChanged(SignalStrength signalStrength) {
-            if (DEBUG) {
-                Log.d(TAG, "onSignalStrengthsChanged signalStrength=" + signalStrength +
+            if (true/*DEBUG*/) {
+                Rlog.d(TAG, "onSignalStrengthsChanged signalStrength=" + signalStrength +
                     ((signalStrength == null) ? "" : (" level=" + signalStrength.getLevel())));
             }
             mSignalStrength = signalStrength;
@@ -485,8 +486,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
 
         @Override
         public void onServiceStateChanged(ServiceState state) {
-            if (DEBUG) {
-                Log.d(TAG, "onServiceStateChanged voiceState=" + state.getVoiceRegState()
+            if (true/*DEBUG*/) {
+                Rlog.d(TAG, "onServiceStateChanged voiceState=" + state.getVoiceRegState()
                         + " dataState=" + state.getDataRegState());
             }
             mServiceState = state;
@@ -498,8 +499,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
 
         @Override
         public void onCallStateChanged(int state, String incomingNumber) {
-            if (DEBUG) {
-                Log.d(TAG, "onCallStateChanged state=" + state);
+            if (true/*DEBUG*/) {
+                Rlog.d(TAG, "onCallStateChanged state=" + state);
             }
             // In cdma, if a voice call is made, RSSI should switch to 1x.
             if (isCdma()) {
@@ -510,8 +511,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
 
         @Override
         public void onDataConnectionStateChanged(int state, int networkType) {
-            if (DEBUG) {
-                Log.d(TAG, "onDataConnectionStateChanged: state=" + state
+            if (true/*DEBUG*/) {
+                Rlog.d(TAG, "onDataConnectionStateChanged: state=" + state
                         + " type=" + networkType);
             }
             mDataState = state;
@@ -523,8 +524,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
 
         @Override
         public void onDataActivity(int direction) {
-            if (DEBUG) {
-                Log.d(TAG, "onDataActivity: direction=" + direction);
+            if (true/*DEBUG*/) {
+                Rlog.d(TAG, "onDataActivity: direction=" + direction);
             }
             mDataActivity = direction;
             updateDataIcon();
@@ -555,6 +556,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
         } else {
             mSimState = IccCardConstants.State.UNKNOWN;
         }
+        Rlog.d(TAG, "updateSimState: mSimState=" + mSimState);
     }
 
     private boolean isCdma() {
@@ -562,6 +564,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
     }
 
     private boolean hasService() {
+        boolean retVal;
         if (mServiceState != null) {
             // Consider the device to be in service if either voice or data service is available.
             // Some SIM cards are marketed as data-only and do not support voice service, and on
@@ -569,16 +572,18 @@ public class NetworkControllerImpl extends BroadcastReceiver
             // service" or "emergency calls only" text that indicates that voice is not available.
             switch(mServiceState.getVoiceRegState()) {
                 case ServiceState.STATE_POWER_OFF:
-                    return false;
+                    retVal = false;
                 case ServiceState.STATE_OUT_OF_SERVICE:
                 case ServiceState.STATE_EMERGENCY_ONLY:
-                    return mServiceState.getDataRegState() == ServiceState.STATE_IN_SERVICE;
+                    retVal = mServiceState.getDataRegState() == ServiceState.STATE_IN_SERVICE;
                 default:
-                    return true;
+                    retVal = true;
             }
         } else {
-            return false;
+            retVal = false;
         }
+        Rlog.d(TAG, "hasService: mServiceState=" + mServiceState + " retVal=" + retVal);
+        return retVal;
     }
 
     private void updateAirplaneMode() {
@@ -591,14 +596,15 @@ public class NetworkControllerImpl extends BroadcastReceiver
     }
 
     private final void updateTelephonySignalStrength() {
-        if (!hasService()) {
+        Rlog.d(TAG, "updateTelephonySignalStrength: hasService=" + hasService() + " ss=" + mSignalStrength);
+        if (false/*!hasService()*/) {
             if (CHATTY) Log.d(TAG, "updateTelephonySignalStrength: !hasService()");
             mPhoneSignalIconId = R.drawable.stat_sys_signal_null;
             mQSPhoneSignalIconId = R.drawable.ic_qs_signal_no_signal;
             mDataSignalIconId = R.drawable.stat_sys_signal_null;
         } else {
             if (mSignalStrength == null) {
-                if (CHATTY) Log.d(TAG, "updateTelephonySignalStrength: mSignalStrength == null");
+                if (true/*CHATTY*/) Rlog.d(TAG, "updateTelephonySignalStrength: mSignalStrength == null");
                 mPhoneSignalIconId = R.drawable.stat_sys_signal_null;
                 mQSPhoneSignalIconId = R.drawable.ic_qs_signal_no_signal;
                 mDataSignalIconId = R.drawable.stat_sys_signal_null;
@@ -609,7 +615,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
                 int[] iconList;
                 if (isCdma() && mAlwaysShowCdmaRssi) {
                     mLastSignalLevel = iconLevel = mSignalStrength.getCdmaLevel();
-                    if(DEBUG) Log.d(TAG, "mAlwaysShowCdmaRssi=" + mAlwaysShowCdmaRssi
+                    if(true/*DEBUG*/) Rlog.d(TAG, "updateTelephonySignalStrength: mAlwaysShowCdmaRssi=" + mAlwaysShowCdmaRssi
                             + " set to cdmaLevel=" + mSignalStrength.getCdmaLevel()
                             + " instead of level=" + mSignalStrength.getLevel());
                 } else {
@@ -636,6 +642,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
                 mContentDescriptionPhoneSignal = mContext.getString(
                         AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[iconLevel]);
                 mDataSignalIconId = TelephonyIcons.DATA_SIGNAL_STRENGTH[mInetCondition][iconLevel];
+                Rlog.d(TAG, "updateTelephonySignalStrength: iconLevel=" + iconLevel);
             }
         }
     }
index 88598c9..a19eb15 100644 (file)
@@ -47,8 +47,10 @@ import android.telephony.PreciseCallState;
 import android.telephony.PreciseDataConnectionState;
 import android.telephony.PreciseDisconnectCause;
 import android.text.TextUtils;
+import android.text.format.Time;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -354,10 +356,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                 }
                 int phoneId = SubscriptionManager.getPhoneId(subId);
                 r.events = events;
-                if (true/*DBG*/) log("listen: set events record=" + r);
+                if (true/*DBG*/) log("listen: set events record=" + r + " subId=" + subId + " phoneId=" + phoneId);
+                toStringLogSSC("listen");
                 if (notifyNow && validatePhoneId(phoneId)) {
                     if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
                         try {
+                            log("listen: call onSSC state=" + mServiceState[phoneId]);
                             r.callback.onServiceStateChanged(
                                     new ServiceState(mServiceState[phoneId]));
                         } catch (RemoteException ex) {
@@ -550,14 +554,17 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
             subId = mDefaultSubId;
             log("notifyServiceStateUsingSubId: using mDefaultSubId=" + mDefaultSubId);
         }
-        if (true/*VDBG*/) {
-            log("notifyServiceStateUsingSubId: subId=" + subId
-                + " state=" + state);
-        }
         synchronized (mRecords) {
             int phoneId = SubscriptionManager.getPhoneId(subId);
+            if (true/*VDBG*/) {
+                log("notifyServiceStateUsingSubId: subId=" + subId + " phoneId=" + phoneId
+                    + " state=" + state);
+            }
             if (validatePhoneId(phoneId)) {
                 mServiceState[phoneId] = state;
+                logServiceStateChanged("notifyServiceStateUsingSubId", subId, phoneId, state);
+                toStringLogSSC("notifyServiceStateUsingSubId");
+
                 for (Record r : mRecords) {
                     log("notifyServiceStateUsingSubId: r.events=0x" + Integer.toHexString(r.events) + " r.subId=" + r.subId + " subId=" + subId + " state=" + state);
                     // FIXME: use DEFAULT_SUB_ID instead??
@@ -591,6 +598,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
         if (true/*VDBG*/) {
             log("notifySignalStrengthUsingSubId: subId=" + subId
                 + " signalStrength=" + signalStrength);
+            toStringLogSSC("notifySignalStrengthUsingSubId");
         }
         synchronized (mRecords) {
             int phoneId = SubscriptionManager.getPhoneId(subId);
@@ -1295,4 +1303,59 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
     private static void log(String s) {
         Rlog.d(TAG, s);
     }
+
+    private static class LogSSC {
+        private Time mTime;
+        private String mS;
+        private long mSubId;
+        private int mPhoneId;
+        private ServiceState mState;
+
+        public void set(Time t, String s, long subId, int phoneId, ServiceState state) {
+            mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
+        }
+
+        @Override
+        public String toString() {
+            return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState;
+        }
+    }
+
+    private LogSSC logSSC [] = new LogSSC[10];
+    private int next = 0;
+
+    private void logServiceStateChanged(String s, long subId, int phoneId, ServiceState state) {
+        if (logSSC == null || logSSC.length == 0) {
+            return;
+        }
+        if (logSSC[next] == null) {
+            logSSC[next] = new LogSSC();
+        }
+        Time t = new Time();
+        t.setToNow();
+        logSSC[next].set(t, s, subId, phoneId, state);
+        if (++next >= logSSC.length) {
+            next = 0;
+        }
+    }
+
+    private void toStringLogSSC(String prompt) {
+        if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
+            log(prompt + ": logSSC is empty");
+        } else {
+            // There is at least one element
+            log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
+            int i = next;
+            if (logSSC[i] == null) {
+                // logSSC is not full so back to the beginning
+                i = 0;
+            }
+            do {
+                log(logSSC[i].toString());
+                if (++i >= logSSC.length) {
+                    i = 0;
+                }
+            } while (i != next);
+        }
+    }
 }