From 91c3b5af51a8226c493689e4c3e8c5dad3e16a47 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Wed, 12 Feb 2020 15:11:24 -0800 Subject: [PATCH] [Passpoint] Truncate IMSI from the SimCredential toString method Truncate IMSI from the SimCredential toString method, avoid displaying confidential IMSI information. Bug: 149422812 Test: dumpsys wifi - confirm result Change-Id: I9d542bc6ff60de1a78076abe1010c0c03a5f444b --- .../android/net/wifi/hotspot2/pps/Credential.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wifi/java/android/net/wifi/hotspot2/pps/Credential.java b/wifi/java/android/net/wifi/hotspot2/pps/Credential.java index 99901808ec3e1..9c01d3643c190 100644 --- a/wifi/java/android/net/wifi/hotspot2/pps/Credential.java +++ b/wifi/java/android/net/wifi/hotspot2/pps/Credential.java @@ -738,7 +738,16 @@ public final class Credential implements Parcelable { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("IMSI: ").append(mImsi).append("\n"); + String imsi; + if (mImsi != null) { + if (mImsi.length() > 6 && mImsi.charAt(6) != '*') { + // Truncate the full IMSI from the log + imsi = mImsi.substring(0, 6) + "****"; + } else { + imsi = mImsi; + } + builder.append("IMSI: ").append(imsi).append("\n"); + } builder.append("EAPType: ").append(mEapType).append("\n"); return builder.toString(); }