Merge "Fixed the obsolete logging" into oc-dev
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 7c1a609..dd4d906 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -32,37 +32,39 @@
import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.telephony.CellLocation;
-import android.telephony.Rlog;
-import android.telephony.TelephonyManager;
-import android.telephony.SubscriptionManager;
-import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
-import android.telephony.SignalStrength;
import android.telephony.CellInfo;
-import android.telephony.VoLteServiceState;
+import android.telephony.CellLocation;
import android.telephony.DisconnectCause;
+import android.telephony.PhoneStateListener;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
import android.telephony.PreciseDisconnectCause;
+import android.telephony.Rlog;
+import android.telephony.ServiceState;
+import android.telephony.SignalStrength;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.telephony.VoLteServiceState;
import android.text.TextUtils;
-import android.text.format.Time;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
+import android.util.LocalLog;
import com.android.internal.app.IBatteryStats;
import com.android.internal.telephony.IOnSubscriptionsChangedListener;
-import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.IPhoneStateListener;
+import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.PhoneConstantConversions;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.DumpUtils;
+import com.android.internal.util.IndentingPrintWriter;
import com.android.server.am.BatteryStatsService;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
/**
* Since phone process can be restarted, this class provides a centralized place
* that applications can register and be called back from.
@@ -159,8 +161,6 @@
private String[] mDataConnectionReason;
- private String[] mDataConnectionApn;
-
private ArrayList<String>[] mConnectedApns;
private LinkProperties[] mDataConnectionLinkProperties;
@@ -191,6 +191,8 @@
private boolean mCarrierNetworkChangeState = false;
+ private final LocalLog mLocalLog = new LocalLog(100);
+
private PreciseDataConnectionState mPreciseDataConnectionState =
new PreciseDataConnectionState();
@@ -310,7 +312,6 @@
mMessageWaiting = new boolean[numPhones];
mDataConnectionPossible = new boolean[numPhones];
mDataConnectionReason = new String[numPhones];
- mDataConnectionApn = new String[numPhones];
mCallForwarding = new boolean[numPhones];
mCellLocation = new Bundle[numPhones];
mDataConnectionLinkProperties = new LinkProperties[numPhones];
@@ -329,7 +330,6 @@
mCallForwarding[i] = false;
mDataConnectionPossible[i] = false;
mDataConnectionReason[i] = "";
- mDataConnectionApn[i] = "";
mCellLocation[i] = new Bundle();
mCellInfo.add(i, null);
mConnectedApns[i] = new ArrayList<String>();
@@ -536,7 +536,6 @@
if (DBG) {
log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
}
- if (VDBG) toStringLogSSC("listen");
if (notifyNow && validatePhoneId(phoneId)) {
if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
try {
@@ -780,14 +779,14 @@
}
synchronized (mRecords) {
+ String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
+ + " state=" + state;
if (VDBG) {
- log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
- + " state=" + state);
+ log(str);
}
+ mLocalLog.log(str);
if (validatePhoneId(phoneId)) {
mServiceState[phoneId] = state;
- logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
- if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
for (Record r : mRecords) {
if (VDBG) {
@@ -885,7 +884,6 @@
if (VDBG) {
log("notifySignalStrengthForPhoneId: subId=" + subId
+" phoneId=" + phoneId + " signalStrength=" + signalStrength);
- toStringLogSSC("notifySignalStrengthForPhoneId");
}
synchronized (mRecords) {
@@ -1137,18 +1135,20 @@
modified = true;
}
if (modified) {
- if (DBG) {
- log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
- + ", " + mDataConnectionNetworkType[phoneId] + ")");
- }
+ String str = "onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
+ + ", " + mDataConnectionNetworkType[phoneId] + ")";
+ log(str);
+ mLocalLog.log(str);
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) &&
idMatch(r.subId, subId, phoneId)) {
try {
- log("Notify data connection state changed on sub: " +
- subId);
- r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
+ if (DBG) {
+ log("Notify data connection state changed on sub: " + subId);
+ }
+ r.callback.onDataConnectionStateChanged(
+ mDataConnectionState[phoneId],
mDataConnectionNetworkType[phoneId]);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
@@ -1163,7 +1163,8 @@
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
try {
- r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ r.callback.onPreciseDataConnectionStateChanged(
+ mPreciseDataConnectionState);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
@@ -1391,36 +1392,58 @@
}
@Override
- public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
+ final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
+
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
+
synchronized (mRecords) {
final int recordCount = mRecords.size();
pw.println("last known state:");
+ pw.increaseIndent();
for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
- pw.println(" Phone Id=" + i);
- pw.println(" mCallState=" + mCallState[i]);
- pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
- pw.println(" mServiceState=" + mServiceState[i]);
- pw.println(" mVoiceActivationState= " + mVoiceActivationState[i]);
- pw.println(" mDataActivationState= " + mDataActivationState[i]);
- pw.println(" mSignalStrength=" + mSignalStrength[i]);
- pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
- pw.println(" mCallForwarding=" + mCallForwarding[i]);
- pw.println(" mDataActivity=" + mDataActivity[i]);
- pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
- pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
- pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
- pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
- pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
- pw.println(" mDataConnectionNetworkCapabilities=" +
+ pw.println("Phone Id=" + i);
+ pw.increaseIndent();
+ pw.println("mCallState=" + mCallState[i]);
+ pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]);
+ pw.println("mServiceState=" + mServiceState[i]);
+ pw.println("mVoiceActivationState= " + mVoiceActivationState[i]);
+ pw.println("mDataActivationState= " + mDataActivationState[i]);
+ pw.println("mSignalStrength=" + mSignalStrength[i]);
+ pw.println("mMessageWaiting=" + mMessageWaiting[i]);
+ pw.println("mCallForwarding=" + mCallForwarding[i]);
+ pw.println("mDataActivity=" + mDataActivity[i]);
+ pw.println("mDataConnectionState=" + mDataConnectionState[i]);
+ pw.println("mDataConnectionPossible=" + mDataConnectionPossible[i]);
+ pw.println("mDataConnectionReason=" + mDataConnectionReason[i]);
+ pw.println("mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
+ pw.println("mDataConnectionNetworkCapabilities=" +
mDataConnectionNetworkCapabilities[i]);
- pw.println(" mCellLocation=" + mCellLocation[i]);
- pw.println(" mCellInfo=" + mCellInfo.get(i));
+ pw.println("mCellLocation=" + mCellLocation[i]);
+ pw.println("mCellInfo=" + mCellInfo.get(i));
+ pw.decreaseIndent();
}
+ pw.println("mConnectedApns=" + Arrays.toString(mConnectedApns));
+ pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState);
+ pw.println("mPreciseCallState=" + mPreciseCallState);
+ pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
+ pw.println("mRingingCallState=" + mRingingCallState);
+ pw.println("mForegroundCallState=" + mForegroundCallState);
+ pw.println("mBackgroundCallState=" + mBackgroundCallState);
+ pw.println("mVoLteServiceState=" + mVoLteServiceState);
+
+ pw.decreaseIndent();
+
+ pw.println("local logs:");
+ pw.increaseIndent();
+ mLocalLog.dump(fd, pw, args);
+ pw.decreaseIndent();
pw.println("registrations: count=" + recordCount);
+ pw.increaseIndent();
for (Record r : mRecords) {
- pw.println(" " + r);
+ pw.println(r);
}
+ pw.decreaseIndent();
}
}
@@ -1705,63 +1728,6 @@
Rlog.d(TAG, s);
}
- private static class LogSSC {
- private Time mTime;
- private String mS;
- private int mSubId;
- private int mPhoneId;
- private ServiceState mState;
-
- public void set(Time t, String s, int subId, int phoneId, ServiceState state) {
- mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
- }
-
- @Override
- public String toString() {
- return mS + " Time " + mTime.toString() + " mSubId " + mSubId + " mPhoneId "
- + mPhoneId + " mState " + mState;
- }
- }
-
- private LogSSC logSSC [] = new LogSSC[10];
- private int next = 0;
-
- private void logServiceStateChanged(String s, int 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);
- log(prompt + ": ----------------");
- }
- }
-
boolean idMatch(int rSubId, int subId, int phoneId) {
if(subId < 0) {