Allow eSIM boot profile to broadcast APP NOT_READY

Normally, the platform blocks an APPLICATION NOT_READY broadcast if the
previous application state was UNKNOWN, but for the eSIM boot profile,
this is the terminal applications state, so it should be sent out.

Change-Id: I77af4abb2cad842771c22fc06ce9806a5818eb12
Fix: 136186052
Test: basic telephony sanity
Test: switch slots to empty eSIM, observe SIM state broadcasts includes
      APPLICATION NOT_READY
(cherry picked from commit 0914df1b785f259062d47e9bb731db1caacf4567)
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
index b265a08..cbabda9 100644
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
@@ -1064,10 +1064,14 @@
     private void broadcastSimApplicationStateChanged(int phoneId, int state) {
         // Broadcast if the state has changed, except if old state was UNKNOWN and new is NOT_READY,
         // because that's the initial state and a broadcast should be sent only on a transition
-        // after SIM is PRESENT
-        if (!(state == sSimApplicationState[phoneId]
-                || (state == TelephonyManager.SIM_STATE_NOT_READY
-                && sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN))) {
+        // after SIM is PRESENT. The only exception is eSIM boot profile, where NOT_READY is the
+        // terminal state.
+        boolean isUnknownToNotReady =
+                (sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN
+                        && state == TelephonyManager.SIM_STATE_NOT_READY);
+        IccCard iccCard = mPhone[phoneId].getIccCard();
+        boolean emptyProfile = iccCard != null && iccCard.isEmptyProfile();
+        if (state != sSimApplicationState[phoneId] && (!isUnknownToNotReady || emptyProfile)) {
             sSimApplicationState[phoneId] = state;
             Intent i = new Intent(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED);
             i.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);