Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −2 Original line number Diff line number Diff line Loading @@ -837,7 +837,7 @@ public class SubscriptionInfoUpdater extends Handler { private void broadcastSimCardStateChanged(int phoneId, int state) { if (state != sSimCardState[phoneId]) { sSimCardState[phoneId] = state; Intent i = new Intent(Intent.ACTION_SIM_CARD_STATE_CHANGED); Intent i = new Intent(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED); i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.putExtra(TelephonyManager.EXTRA_SIM_STATE, state); SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId); Loading @@ -855,7 +855,7 @@ public class SubscriptionInfoUpdater extends Handler { || (state == TelephonyManager.SIM_STATE_NOT_READY && sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN))) { sSimApplicationState[phoneId] = state; Intent i = new Intent(Intent.ACTION_SIM_APPLICATION_STATE_CHANGED); Intent i = new Intent(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED); i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.putExtra(TelephonyManager.EXTRA_SIM_STATE, state); SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId); Loading src/java/com/android/internal/telephony/uicc/IccSlotStatus.java +18 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.uicc; import android.telephony.SubscriptionInfo; import android.text.TextUtils; /** * This class represents the status of the physical UICC slots. Loading Loading @@ -85,4 +86,21 @@ public class IccSlotStatus { return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } IccSlotStatus that = (IccSlotStatus) obj; return (cardState == that.cardState) && (slotState == that.slotState) && (logicalSlotIndex == that.logicalSlotIndex) && (TextUtils.equals(atr, that.atr)) && (TextUtils.equals(iccid, that.iccid)); } } src/java/com/android/internal/telephony/uicc/UiccController.java +55 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.uicc; import android.content.Context; import android.content.Intent; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; Loading Loading @@ -107,6 +108,7 @@ public class UiccController extends Handler { private static final Object mLock = new Object(); private static UiccController mInstance; private static ArrayList<IccSlotStatus> sLastSlotStatus; private Context mContext; Loading Loading @@ -243,6 +245,37 @@ public class UiccController extends Handler { } } /** * API to get UiccSlot object for a given cardId * @param cardId Identifier for a SIM. This can be an ICCID, or an EID in case of an eSIM. * @return int Index of UiccSlot for the given cardId if one is found, {@link #INVALID_SLOT_ID} * otherwise */ public int getUiccSlotForCardId(String cardId) { synchronized (mLock) { // first look up based on cardId for (int idx = 0; idx < mUiccSlots.length; idx++) { if (mUiccSlots[idx] != null) { UiccCard uiccCard = mUiccSlots[idx].getUiccCard(); if (uiccCard != null) { // todo: uncomment this once getCardId() is added //if (cardId.equals(uiccCard.getCardId())) { if (false) { return idx; } } } } // if a match is not found, do a lookup based on ICCID for (int idx = 0; idx < mUiccSlots.length; idx++) { if (mUiccSlots[idx] != null && cardId.equals(mUiccSlots[idx].getIccId())) { return idx; } } return INVALID_SLOT_ID; } } // Easy to use API public IccRecords getIccRecords(int phoneId, int family) { synchronized (mLock) { Loading Loading @@ -442,6 +475,11 @@ public class UiccController extends Handler { ArrayList<IccSlotStatus> status = (ArrayList<IccSlotStatus>) ar.result; if (!slotStatusChanged(status)) { log("onGetSlotStatusDone: No change in slot status"); return; } int numActiveSlots = 0; for (int i = 0; i < status.size(); i++) { IccSlotStatus iss = status.get(i); Loading Loading @@ -479,10 +517,26 @@ public class UiccController extends Handler { Set<Integer> slotIds = new HashSet<>(); for (int slotId : mPhoneIdToSlotId) { if (slotIds.contains(slotId)) { throw new RuntimeException("slotId " + slotId + " mapped to muptiple phoneIds"); throw new RuntimeException("slotId " + slotId + " mapped to multiple phoneIds"); } slotIds.add(slotId); } // broadcast slot status changed Intent intent = new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); } private boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) { if (sLastSlotStatus == null || sLastSlotStatus.size() != slotStatusList.size()) { return true; } for (IccSlotStatus iccSlotStatus : slotStatusList) { if (!sLastSlotStatus.contains(iccSlotStatus)) { return true; } } return false; } private void logPhoneIdToSlotIdMapping() { Loading src/java/com/android/internal/telephony/uicc/UiccSlot.java +7 −1 Original line number Diff line number Diff line Loading @@ -174,7 +174,13 @@ public class UiccSlot extends Handler { } public String getIccId() { if (mIccId != null) { return mIccId; } else if (mUiccCard != null) { return mUiccCard.getIccId(); } else { return null; } } @Override Loading Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −2 Original line number Diff line number Diff line Loading @@ -837,7 +837,7 @@ public class SubscriptionInfoUpdater extends Handler { private void broadcastSimCardStateChanged(int phoneId, int state) { if (state != sSimCardState[phoneId]) { sSimCardState[phoneId] = state; Intent i = new Intent(Intent.ACTION_SIM_CARD_STATE_CHANGED); Intent i = new Intent(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED); i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.putExtra(TelephonyManager.EXTRA_SIM_STATE, state); SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId); Loading @@ -855,7 +855,7 @@ public class SubscriptionInfoUpdater extends Handler { || (state == TelephonyManager.SIM_STATE_NOT_READY && sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN))) { sSimApplicationState[phoneId] = state; Intent i = new Intent(Intent.ACTION_SIM_APPLICATION_STATE_CHANGED); Intent i = new Intent(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED); i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.putExtra(TelephonyManager.EXTRA_SIM_STATE, state); SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId); Loading
src/java/com/android/internal/telephony/uicc/IccSlotStatus.java +18 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.uicc; import android.telephony.SubscriptionInfo; import android.text.TextUtils; /** * This class represents the status of the physical UICC slots. Loading Loading @@ -85,4 +86,21 @@ public class IccSlotStatus { return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } IccSlotStatus that = (IccSlotStatus) obj; return (cardState == that.cardState) && (slotState == that.slotState) && (logicalSlotIndex == that.logicalSlotIndex) && (TextUtils.equals(atr, that.atr)) && (TextUtils.equals(iccid, that.iccid)); } }
src/java/com/android/internal/telephony/uicc/UiccController.java +55 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.uicc; import android.content.Context; import android.content.Intent; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; Loading Loading @@ -107,6 +108,7 @@ public class UiccController extends Handler { private static final Object mLock = new Object(); private static UiccController mInstance; private static ArrayList<IccSlotStatus> sLastSlotStatus; private Context mContext; Loading Loading @@ -243,6 +245,37 @@ public class UiccController extends Handler { } } /** * API to get UiccSlot object for a given cardId * @param cardId Identifier for a SIM. This can be an ICCID, or an EID in case of an eSIM. * @return int Index of UiccSlot for the given cardId if one is found, {@link #INVALID_SLOT_ID} * otherwise */ public int getUiccSlotForCardId(String cardId) { synchronized (mLock) { // first look up based on cardId for (int idx = 0; idx < mUiccSlots.length; idx++) { if (mUiccSlots[idx] != null) { UiccCard uiccCard = mUiccSlots[idx].getUiccCard(); if (uiccCard != null) { // todo: uncomment this once getCardId() is added //if (cardId.equals(uiccCard.getCardId())) { if (false) { return idx; } } } } // if a match is not found, do a lookup based on ICCID for (int idx = 0; idx < mUiccSlots.length; idx++) { if (mUiccSlots[idx] != null && cardId.equals(mUiccSlots[idx].getIccId())) { return idx; } } return INVALID_SLOT_ID; } } // Easy to use API public IccRecords getIccRecords(int phoneId, int family) { synchronized (mLock) { Loading Loading @@ -442,6 +475,11 @@ public class UiccController extends Handler { ArrayList<IccSlotStatus> status = (ArrayList<IccSlotStatus>) ar.result; if (!slotStatusChanged(status)) { log("onGetSlotStatusDone: No change in slot status"); return; } int numActiveSlots = 0; for (int i = 0; i < status.size(); i++) { IccSlotStatus iss = status.get(i); Loading Loading @@ -479,10 +517,26 @@ public class UiccController extends Handler { Set<Integer> slotIds = new HashSet<>(); for (int slotId : mPhoneIdToSlotId) { if (slotIds.contains(slotId)) { throw new RuntimeException("slotId " + slotId + " mapped to muptiple phoneIds"); throw new RuntimeException("slotId " + slotId + " mapped to multiple phoneIds"); } slotIds.add(slotId); } // broadcast slot status changed Intent intent = new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); } private boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) { if (sLastSlotStatus == null || sLastSlotStatus.size() != slotStatusList.size()) { return true; } for (IccSlotStatus iccSlotStatus : slotStatusList) { if (!sLastSlotStatus.contains(iccSlotStatus)) { return true; } } return false; } private void logPhoneIdToSlotIdMapping() { Loading
src/java/com/android/internal/telephony/uicc/UiccSlot.java +7 −1 Original line number Diff line number Diff line Loading @@ -174,7 +174,13 @@ public class UiccSlot extends Handler { } public String getIccId() { if (mIccId != null) { return mIccId; } else if (mUiccCard != null) { return mUiccCard.getIccId(); } else { return null; } } @Override Loading