summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-17 22:38:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-17 22:38:49 +0000
commit31e419d691f0489a673cd78d43a3cb539cd227d5 (patch)
tree54f477b107a029c8e2b24836d6c0c2e03a39cf31
parent33718936038ef30fde8d80f1af3033ec0e30b7ca (diff)
parent14a9fd0961467c7987ec2c2355d6d283d8011ffb (diff)
downloadNfc-main.tar.gz
Merge "[nfc] remove sensitive data because Username was getting printed in logs" into mainHEADmastermain
-rw-r--r--src/com/android/nfc/Utils.java14
-rw-r--r--src/com/android/nfc/cardemulation/PreferredServices.java2
-rw-r--r--src/com/android/nfc/cardemulation/RegisteredNfcFServicesCache.java3
-rw-r--r--src/com/android/nfc/cardemulation/RegisteredServicesCache.java3
4 files changed, 19 insertions, 3 deletions
diff --git a/src/com/android/nfc/Utils.java b/src/com/android/nfc/Utils.java
index bb2e1797..38d88094 100644
--- a/src/com/android/nfc/Utils.java
+++ b/src/com/android/nfc/Utils.java
@@ -140,4 +140,18 @@ public final class Utils {
proto.write(PendingIntentProto.TARGET, pendingIntent.toString());
proto.end(token);
}
+
+ public static String maskSubstring(String original, int start) {
+ if (original == null) {
+ return "";
+ }
+ if (original.length() <= start) {
+ return original;
+ }
+ StringBuilder masked = new StringBuilder(original);
+ for (int i = start; i < original.length(); i++) {
+ masked.setCharAt(i, '*');
+ }
+ return masked.toString();
+ }
}
diff --git a/src/com/android/nfc/cardemulation/PreferredServices.java b/src/com/android/nfc/cardemulation/PreferredServices.java
index e3c91a05..e589e8f7 100644
--- a/src/com/android/nfc/cardemulation/PreferredServices.java
+++ b/src/com/android/nfc/cardemulation/PreferredServices.java
@@ -462,7 +462,7 @@ public class PreferredServices implements com.android.nfc.ForegroundUtils.Callba
if (um == null) {
return null;
}
- return um.getUserName();
+ return com.android.nfc.Utils.maskSubstring(um.getUserName(), 3);
}
/**
diff --git a/src/com/android/nfc/cardemulation/RegisteredNfcFServicesCache.java b/src/com/android/nfc/cardemulation/RegisteredNfcFServicesCache.java
index fd96f309..489cd458 100644
--- a/src/com/android/nfc/cardemulation/RegisteredNfcFServicesCache.java
+++ b/src/com/android/nfc/cardemulation/RegisteredNfcFServicesCache.java
@@ -41,6 +41,7 @@ import android.util.Xml;
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy;
+import com.android.nfc.Utils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -759,7 +760,7 @@ public class RegisteredNfcFServicesCache {
for (UserHandle uh : mUserHandles) {
UserManager um = mContext.createContextAsUser(
uh, /*flags=*/0).getSystemService(UserManager.class);
- pw.println("User " + um.getUserName() + " : ");
+ pw.println("User " + Utils.maskSubstring(um.getUserName(), 3));
UserServices userServices = findOrCreateUserLocked(uh.getIdentifier());
for (NfcFServiceInfo service : userServices.services.values()) {
service.dump(pFd, pw, args);
diff --git a/src/com/android/nfc/cardemulation/RegisteredServicesCache.java b/src/com/android/nfc/cardemulation/RegisteredServicesCache.java
index ce69f088..7e8b6f74 100644
--- a/src/com/android/nfc/cardemulation/RegisteredServicesCache.java
+++ b/src/com/android/nfc/cardemulation/RegisteredServicesCache.java
@@ -45,6 +45,7 @@ import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.XmlUtils;
+import com.android.nfc.Utils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -1044,7 +1045,7 @@ public class RegisteredServicesCache {
for (UserHandle uh : mUserHandles) {
UserManager um = mContext.createContextAsUser(
uh, /*flags=*/0).getSystemService(UserManager.class);
- pw.println("User " + um.getUserName() + " : ");
+ pw.println("User " + Utils.maskSubstring(um.getUserName(), 3));
UserServices userServices = findOrCreateUserLocked(uh.getIdentifier());
for (ApduServiceInfo service : userServices.services.values()) {
service.dump(pFd, pw, args);