From afea7de9b95d81c4c2be4343fdf0e3bf8af06c3e Mon Sep 17 00:00:00 2001 From: Shi Yuanjie Date: Thu, 19 Jul 2018 20:30:10 +0900 Subject: [PATCH] Fix to hide phone number printed in the log The ConnectionRequest and ImsConferenceState fields may include phone numbers and it is output to the log. Since PII should not be printed in the log, mask it using Log.pii(). Bug: 111812270 Test: manual - Checked that phone number is not printed in the log when receive an incoming call and make an IMS conference call. Change-Id: I462ae7f923128a2d06d0415bcde0c779e932139f --- .../android/telecom/ConnectionRequest.java | 26 ++++++++++++++++++- .../telephony/ims/ImsConferenceState.java | 15 ++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/telecomm/java/android/telecom/ConnectionRequest.java b/telecomm/java/android/telecom/ConnectionRequest.java index b6e6b0ed82701..d69d2cd756dce 100644 --- a/telecomm/java/android/telecom/ConnectionRequest.java +++ b/telecomm/java/android/telecom/ConnectionRequest.java @@ -337,7 +337,31 @@ public final class ConnectionRequest implements Parcelable { mAddress == null ? Uri.EMPTY : Connection.toLogSafePhoneNumber(mAddress.toString()), - mExtras == null ? "" : mExtras); + bundleToString(mExtras)); + } + + private static String bundleToString(Bundle extras){ + if (extras == null) { + return ""; + } + StringBuilder sb = new StringBuilder(); + sb.append("Bundle["); + for (String key : extras.keySet()) { + sb.append(key); + sb.append("="); + switch (key) { + case TelecomManager.EXTRA_INCOMING_CALL_ADDRESS: + case TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE: + sb.append(Log.pii(extras.get(key))); + break; + default: + sb.append(extras.get(key)); + break; + } + sb.append(", "); + } + sb.append("]"); + return sb.toString(); } public static final Creator CREATOR = new Creator () { diff --git a/telephony/java/android/telephony/ims/ImsConferenceState.java b/telephony/java/android/telephony/ims/ImsConferenceState.java index 66d2f8d929d3a..8af8cffcd878c 100644 --- a/telephony/java/android/telephony/ims/ImsConferenceState.java +++ b/telephony/java/android/telephony/ims/ImsConferenceState.java @@ -16,17 +16,18 @@ package android.telephony.ims; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.Set; - import android.annotation.SystemApi; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.telecom.Call; import android.telecom.Connection; +import android.telecom.Log; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Set; /** * Provides the conference information (defined in RFC 4575) for IMS conference call. @@ -189,7 +190,7 @@ public final class ImsConferenceState implements Parcelable { sb.append("<"); while (iterator.hasNext()) { Entry entry = iterator.next(); - sb.append(entry.getKey()); + sb.append(Log.pii(entry.getKey())); sb.append(": "); Bundle participantData = entry.getValue(); @@ -197,7 +198,7 @@ public final class ImsConferenceState implements Parcelable { sb.append(key); sb.append("="); if (ENDPOINT.equals(key) || USER.equals(key)) { - sb.append(android.telecom.Log.pii(participantData.get(key))); + sb.append(Log.pii(participantData.get(key))); } else { sb.append(participantData.get(key)); }