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;
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;
@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;
@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()) {
@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;
@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();
} else {
mSimState = IccCardConstants.State.UNKNOWN;
}
+ Rlog.d(TAG, "updateSimState: mSimState=" + mSimState);
}
private boolean isCdma() {
}
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
// 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() {
}
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;
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 {
mContentDescriptionPhoneSignal = mContext.getString(
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[iconLevel]);
mDataSignalIconId = TelephonyIcons.DATA_SIGNAL_STRENGTH[mInetCondition][iconLevel];
+ Rlog.d(TAG, "updateTelephonySignalStrength: iconLevel=" + iconLevel);
}
}
}
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;
}
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) {
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??
if (true/*VDBG*/) {
log("notifySignalStrengthUsingSubId: subId=" + subId
+ " signalStrength=" + signalStrength);
+ toStringLogSSC("notifySignalStrengthUsingSubId");
}
synchronized (mRecords) {
int phoneId = SubscriptionManager.getPhoneId(subId);
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);
+ }
+ }
}