summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2016-05-13 12:54:15 -0700
committerSantos Cordon <santoscordon@google.com>2016-05-17 15:42:11 -0700
commit226ac3ad92a383436a13da89959178d51a0cec1b (patch)
tree627773f511a1fee5daf8bb8a74870ad34bae5a22
parentf08fe9659343327dc29da410b64597b33613c732 (diff)
downloadvoip-226ac3ad92a383436a13da89959178d51a0cec1b.tar.gz
Bug: 28560740 Change-Id: I995ea8ae639816579c95d6d0fa27fefb0ffe9419
-rw-r--r--src/java/com/android/server/sip/SipService.java51
-rw-r--r--src/java/com/android/server/sip/SipSessionGroup.java2
2 files changed, 46 insertions, 7 deletions
diff --git a/src/java/com/android/server/sip/SipService.java b/src/java/com/android/server/sip/SipService.java
index 97abfb7..d14a8d6 100644
--- a/src/java/com/android/server/sip/SipService.java
+++ b/src/java/com/android/server/sip/SipService.java
@@ -54,6 +54,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
+
import javax.sip.SipException;
/**
@@ -169,7 +170,7 @@ public final class SipService extends ISipService.Stub {
+ "the profile is not opened");
return;
}
- if (DBG) log("open3: " + localProfile.getUriString() + ": "
+ if (DBG) log("open3: " + obfuscateSipUri(localProfile.getUriString()) + ": "
+ incomingCallPendingIntent + ": " + listener);
try {
SipSessionGroupExt group = createGroup(localProfile,
@@ -528,13 +529,13 @@ public final class SipService extends ISipService.Stub {
mIncomingCallPendingIntent = pIntent;
}
- public void openToReceiveCalls() throws SipException {
+ public void openToReceiveCalls() {
mOpenedToReceiveCalls = true;
if (mNetworkType != -1) {
mSipGroup.openToReceiveCalls(this);
mAutoRegistration.start(mSipGroup);
}
- if (SSGE_DBG) log("openToReceiveCalls: " + getUri() + ": "
+ if (SSGE_DBG) log("openToReceiveCalls: " + obfuscateSipUri(getUri()) + ": "
+ mIncomingCallPendingIntent);
}
@@ -542,7 +543,7 @@ public final class SipService extends ISipService.Stub {
throws SipException {
if (SSGE_DBG) {
log("onConnectivityChanged: connected=" + connected + " uri="
- + getUri() + ": " + mIncomingCallPendingIntent);
+ + obfuscateSipUri(getUri()) + ": " + mIncomingCallPendingIntent);
}
mSipGroup.onConnectivityChanged();
if (connected) {
@@ -558,7 +559,8 @@ public final class SipService extends ISipService.Stub {
mOpenedToReceiveCalls = false;
mSipGroup.close();
mAutoRegistration.stop();
- if (SSGE_DBG) log("close: " + getUri() + ": " + mIncomingCallPendingIntent);
+ if (SSGE_DBG) log("close: " + obfuscateSipUri(getUri()) + ": "
+ + mIncomingCallPendingIntent);
}
public ISipSession createSession(ISipSessionListener listener) {
@@ -826,7 +828,8 @@ public final class SipService extends ISipService.Stub {
// in registration to avoid adding duplicate entries to server
mMyWakeLock.acquire(mSession);
mSession.unregister();
- SAR_TAG = "SipAutoReg:" + mSession.getLocalProfile().getUriString();
+ SAR_TAG = "SipAutoReg:" +
+ obfuscateSipUri(mSession.getLocalProfile().getUriString());
if (SAR_DBG) log("start: group=" + group);
}
}
@@ -1283,4 +1286,40 @@ public final class SipService extends ISipService.Stub {
private void loge(String s, Throwable e) {
Rlog.e(TAG, s, e);
}
+
+ public static String obfuscateSipUri(String sipUri) {
+ StringBuilder sb = new StringBuilder();
+ int start = 0;
+ sipUri = sipUri.trim();
+ if (sipUri.startsWith("sip:")) {
+ start = 4;
+ sb.append("sip:");
+ }
+
+ char prevC = '\0';
+ int len = sipUri.length();
+ for (int i = start; i < len; i++) {
+ char c = sipUri.charAt(i);
+ char nextC = (i + 1 < len) ? sipUri.charAt(i + 1) : '\0';
+ char charToAppend = '*';
+
+ // This logic allows the first and last letter before an '@' sign to show up without
+ // obfuscation as well as the first and last letter an '@' sign.
+ // e.g.: brad@comment.it => b**d@c******.*t
+ if ((i - start < 1) ||
+ (i + 1 == len) ||
+ isAllowedCharacter(c) ||
+ (prevC == '@') ||
+ (nextC == '@')) {
+ charToAppend = c;
+ }
+ sb.append(charToAppend);
+ prevC = c;
+ }
+ return sb.toString();
+ }
+
+ private static boolean isAllowedCharacter(char c) {
+ return c == '@' || c == '.';
+ }
}
diff --git a/src/java/com/android/server/sip/SipSessionGroup.java b/src/java/com/android/server/sip/SipSessionGroup.java
index e820f35..9510b9a 100644
--- a/src/java/com/android/server/sip/SipSessionGroup.java
+++ b/src/java/com/android/server/sip/SipSessionGroup.java
@@ -237,7 +237,7 @@ class SipSessionGroup implements SipListener {
}
public synchronized void close() {
- if (DBG) log("close: " + mLocalProfile.getUriString());
+ if (DBG) log("close: " + SipService.obfuscateSipUri(mLocalProfile.getUriString()));
onConnectivityChanged();
mSessionMap.clear();
closeToNotReceiveCalls();