Moved the toString method in the parent Connection class.

Beefed up the output to get more info in the logs about
a connection.
Personal data is only logged at debug level.
This commit is contained in:
Nicolas Catania
2009-09-18 13:56:19 -07:00
parent ba9bf79d49
commit 338c48554f
3 changed files with 23 additions and 9 deletions

View File

@@ -15,6 +15,7 @@
*/ */
package com.android.internal.telephony; package com.android.internal.telephony;
import android.util.Log;
/** /**
* {@hide} * {@hide}
@@ -27,6 +28,7 @@ public abstract class Connection {
public static int PRESENTATION_UNKNOWN = 3; // no specified or unknown by network public static int PRESENTATION_UNKNOWN = 3; // no specified or unknown by network
public static int PRESENTATION_PAYPHONE = 4; // show pay phone info public static int PRESENTATION_PAYPHONE = 4; // show pay phone info
private static String LOG_TAG = "TelephonyConnection";
public enum DisconnectCause { public enum DisconnectCause {
NOT_DISCONNECTED, /* has not yet disconnected */ NOT_DISCONNECTED, /* has not yet disconnected */
@@ -269,4 +271,25 @@ public abstract class Connection {
*/ */
public abstract int getNumberPresentation(); public abstract int getNumberPresentation();
/**
* Build a human representation of a connection instance, suitable for debugging.
* Don't log personal stuff unless in debug mode.
* @return a string representing the internal state of this connection.
*/
public String toString() {
StringBuilder str = new StringBuilder(128);
if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
str.append("addr: " + getAddress())
.append(" pres.: " + getNumberPresentation())
.append(" dial: " + getOrigDialString())
.append(" postdial: " + getRemainingPostDialString())
.append(" cnap name: " + getCnapName())
.append("(" + getCnapNamePresentation() + ")");
}
str.append(" incoming: " + isIncoming())
.append(" state: " + getState())
.append(" post dial state: " + getPostDialState());
return str.toString();
}
} }

View File

@@ -221,10 +221,6 @@ public class CdmaConnection extends Connection {
return isIncoming == c.isMT && equalsHandlesNulls(address, cAddress); return isIncoming == c.isMT && equalsHandlesNulls(address, cAddress);
} }
public String
toString() {
return (isIncoming ? "incoming" : "outgoing");
}
public String getOrigDialString(){ public String getOrigDialString(){
return dialString; return dialString;

View File

@@ -180,11 +180,6 @@ public class GsmConnection extends Connection {
return isIncoming == c.isMT && equalsHandlesNulls(address, cAddress); return isIncoming == c.isMT && equalsHandlesNulls(address, cAddress);
} }
public String
toString() {
return (isIncoming ? "incoming" : "outgoing");
}
public String getAddress() { public String getAddress() {
return address; return address;
} }