Merge "Remove hashing for PII in Telecom Logging" am: e77808d936
am: 388aca53f1
Change-Id: I6e6ab2560ef73816dad5eff2b40f632fbdcefe33
This commit is contained in:
@@ -340,24 +340,6 @@ public class Log {
|
||||
return sSessionManager;
|
||||
}
|
||||
|
||||
private static MessageDigest sMessageDigest;
|
||||
|
||||
public static void initMd5Sum() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
public Void doInBackground(Void... args) {
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
md = null;
|
||||
}
|
||||
sMessageDigest = md;
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public static void setTag(String tag) {
|
||||
TAG = tag;
|
||||
DEBUG = isLoggable(android.util.Log.DEBUG);
|
||||
@@ -425,44 +407,13 @@ public class Log {
|
||||
/**
|
||||
* Redact personally identifiable information for production users.
|
||||
* If we are running in verbose mode, return the original string,
|
||||
* and return "****" if we are running on the user build, otherwise
|
||||
* return a SHA-1 hash of the input string.
|
||||
* and return "***" otherwise.
|
||||
*/
|
||||
public static String pii(Object pii) {
|
||||
if (pii == null || VERBOSE) {
|
||||
return String.valueOf(pii);
|
||||
}
|
||||
return "[" + secureHash(String.valueOf(pii).getBytes()) + "]";
|
||||
}
|
||||
|
||||
private static String secureHash(byte[] input) {
|
||||
// Refrain from logging user personal information in user build.
|
||||
if (USER_BUILD) {
|
||||
return "****";
|
||||
}
|
||||
|
||||
if (sMessageDigest != null) {
|
||||
sMessageDigest.reset();
|
||||
sMessageDigest.update(input);
|
||||
byte[] result = sMessageDigest.digest();
|
||||
return encodeHex(result);
|
||||
} else {
|
||||
return "Uninitialized SHA1";
|
||||
}
|
||||
}
|
||||
|
||||
private static String encodeHex(byte[] bytes) {
|
||||
StringBuffer hex = new StringBuffer(bytes.length * 2);
|
||||
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
int byteIntValue = bytes[i] & 0xff;
|
||||
if (byteIntValue < 0x10) {
|
||||
hex.append("0");
|
||||
}
|
||||
hex.append(Integer.toString(byteIntValue, 16));
|
||||
}
|
||||
|
||||
return hex.toString();
|
||||
return "***";
|
||||
}
|
||||
|
||||
private static String getPrefixFromObject(Object obj) {
|
||||
|
||||
@@ -645,7 +645,6 @@ public class TelecomManager {
|
||||
mContext = context;
|
||||
}
|
||||
mTelecomServiceOverride = telecomServiceImpl;
|
||||
android.telecom.Log.initMd5Sum();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user