summaryrefslogtreecommitdiff
path: root/telecomm/java/android/telecom/Log.java
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2018-04-23 09:52:25 -0700
committerTyler Gunn <tgunn@google.com>2018-04-23 09:52:25 -0700
commit9bc35116e341cb948abf73a9d13b3ebf08c6c1ef (patch)
treeedf1b6cc413b153d5792d3dc48c6ef56de1435ae /telecomm/java/android/telecom/Log.java
parent1142ffcc9b4624887707e3e7d37e0ec777d099db (diff)
Add ability to log last 2 digits of dialed numbers in userdebug builds.
Filers of bugs often refer to specific phone numbers. Bug reports by default obscure dialed phone numbers from the Telecom logs. This makes it difficult to relate events in the bug report to what the bug filer refers to. To ease this, in userdebug builds we will now leave the last 2 digits of dialed phone numbers un-obfuscated. User builds will remain obfuscated. Test: Added unit tests to cover this case. Bug: 78457192 Change-Id: I52704cf57ed11b1fa53a55bc883d7d090af661f4
Diffstat (limited to 'telecomm/java/android/telecom/Log.java')
-rw-r--r--telecomm/java/android/telecom/Log.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/telecomm/java/android/telecom/Log.java b/telecomm/java/android/telecom/Log.java
index 83ca4702287d..0eb991777d74 100644
--- a/telecomm/java/android/telecom/Log.java
+++ b/telecomm/java/android/telecom/Log.java
@@ -46,6 +46,11 @@ public class Log {
private static final int EVENTS_TO_CACHE = 10;
private static final int EVENTS_TO_CACHE_DEBUG = 20;
+ /**
+ * When generating a bug report, include the last X dialable digits when logging phone numbers.
+ */
+ private static final int NUM_DIALABLE_DIGITS_TO_LOG = Build.IS_USER ? 0 : 2;
+
// Generic tag for all Telecom logging
@VisibleForTesting
public static String TAG = "TelecomFramework";
@@ -384,9 +389,15 @@ public class Log {
String textToObfuscate = uri.getSchemeSpecificPart();
if (PhoneAccount.SCHEME_TEL.equals(scheme)) {
+ int numDigitsToObfuscate = getDialableCount(textToObfuscate)
+ - NUM_DIALABLE_DIGITS_TO_LOG;
for (int i = 0; i < textToObfuscate.length(); i++) {
char c = textToObfuscate.charAt(i);
- sb.append(PhoneNumberUtils.isDialable(c) ? "*" : c);
+ boolean isDialable = PhoneNumberUtils.isDialable(c);
+ if (isDialable) {
+ numDigitsToObfuscate--;
+ }
+ sb.append(isDialable && numDigitsToObfuscate >= 0 ? "*" : c);
}
} else if (PhoneAccount.SCHEME_SIP.equals(scheme)) {
for (int i = 0; i < textToObfuscate.length(); i++) {
@@ -405,6 +416,21 @@ public class Log {
}
/**
+ * Determines the number of dialable characters in a string.
+ * @param toCount The string to count dialable characters in.
+ * @return The count of dialable characters.
+ */
+ private static int getDialableCount(String toCount) {
+ int numDialable = 0;
+ for (char c : toCount.toCharArray()) {
+ if (PhoneNumberUtils.isDialable(c)) {
+ numDialable++;
+ }
+ }
+ return numDialable;
+ }
+
+ /**
* Redact personally identifiable information for production users.
* If we are running in verbose mode, return the original string,
* and return "***" otherwise.