Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dffd4899 authored by Zhengyu Zhan's avatar Zhengyu Zhan Committed by Denis Hsu
Browse files

Fix print sensitive log IMSI

Bug: 159398197
Test: manual test pass
Change-Id: I04611b2c789b776da47b72b0eff04d812179984c
parent 6f400a1c
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.ParcelUuid;
import android.os.RegistrantList;
@@ -1959,13 +1960,26 @@ public class SubscriptionController extends ISub.Stub {
        return result;
    }

    /**
     * Scrub given IMSI on production builds.
     */
    private String scrubImsi(String imsi) {
        if (Build.IS_ENG) {
            return imsi;
        } else if (imsi != null) {
            return imsi.substring(0, Math.min(6, imsi.length())) + "...";
        } else {
            return "null";
        }
    }

    /**
     * Set IMSI by subscription ID
     * @param imsi IMSI (International Mobile Subscriber Identity)
     * @return the number of records updated
     */
    public int setImsi(String imsi, int subId) {
        if (DBG) logd("[setImsi]+ imsi:" + imsi + " subId:" + subId);
        if (DBG) logd("[setImsi]+ imsi:" + scrubImsi(imsi) + " subId:" + subId);
        ContentValues value = new ContentValues(1);
        value.put(SubscriptionManager.IMSI, imsi);