Added log to print slot/sub mapping

Fix: 269493080
Test: Boot up and exam bugreport
Merged-In: Idc002e211ed40165e0bfb817c95279a8fcfdb10c
Change-Id: Idc002e211ed40165e0bfb817c95279a8fcfdb10c
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
index 529eab0..8a49568 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
@@ -901,6 +901,7 @@
                     mSlotIndexToSubId.remove(simSlotIndex);
                 });
         updateGroupDisabled();
+        logl("markSubscriptionsInactive: " + slotMappingToString());
     }
 
     /**
@@ -1264,6 +1265,7 @@
                 mSlotIndexToSubId.put(phoneId, subId);
                 // Update the SIM slot index. This will make the subscription active.
                 mSubscriptionDatabaseManager.setSimSlotIndex(subId, phoneId);
+                logl("updateSubscriptions: " + slotMappingToString());
             }
 
             // Update the card id.
@@ -1340,6 +1342,7 @@
         } else {
             log("updateSubscriptions: No ICCID available for phone " + phoneId);
             mSlotIndexToSubId.remove(phoneId);
+            logl("updateSubscriptions: " + slotMappingToString());
         }
 
         if (areAllSubscriptionsLoaded()) {
@@ -1906,6 +1909,7 @@
                 int subId = insertSubscriptionInfo(iccId, slotIndex, displayName, subscriptionType);
                 updateGroupDisabled();
                 mSlotIndexToSubId.put(slotIndex, subId);
+                logl("addSubInfo: " + slotMappingToString());
             } else {
                 // Record already exists.
                 loge("Subscription record already existed.");
@@ -3782,6 +3786,16 @@
     }
 
     /**
+     * @return The logical SIM slot/sub mapping to string.
+     */
+    @NonNull
+    private String slotMappingToString() {
+        return mSlotIndexToSubId.entrySet().stream()
+                .map(e -> "Slot " + e.getKey() + ": subId=" + e.getValue())
+                .collect(Collectors.joining(", "));
+    }
+
+    /**
      * Log debug messages.
      *
      * @param s debug messages
@@ -3835,6 +3849,12 @@
         mSlotIndexToSubId.forEach((slotIndex, subId)
                 -> pw.println("Logical SIM slot " + slotIndex + ": subId=" + subId));
         pw.decreaseIndent();
+        pw.println("ICCID:");
+        pw.increaseIndent();
+        for (int i = 0; i < mTelephonyManager.getActiveModemCount(); i++) {
+            pw.println("slot " + i + ": " + getIccId(i));
+        }
+        pw.decreaseIndent();
         pw.println();
         pw.println("defaultSubId=" + getDefaultSubId());
         pw.println("defaultVoiceSubId=" + getDefaultVoiceSubId());