From 89d5931436e37c3063f1aa9adf2cb139291ce3df Mon Sep 17 00:00:00 2001 From: Shivakumar Neginal Date: Thu, 7 Apr 2022 12:34:09 +0000 Subject: [PATCH] [eSIM] Get sim state for active port index instead of DEFAULT_PORT_INDEX 0. MEP device port 0 might not be active(no valid logical slot index).Instead we should find any active port to check the card state. Bug: 228407530 Test: manual, atest FrameworksTelephonyTests Change-Id: Ib7fcc345431473a2d95a82fa827f11928aa58fc4 --- telephony/java/android/telephony/TelephonyManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 92cabab06134f..fc081611052eb 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -3582,7 +3582,8 @@ public class TelephonyManager { @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @Deprecated public @SimState int getSimCardState(int physicalSlotIndex) { - int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex, DEFAULT_PORT_INDEX)); + int activePort = getFirstActivePortIndex(physicalSlotIndex); + int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex, activePort)); return getSimCardStateFromSimState(simState); } @@ -3688,9 +3689,10 @@ public class TelephonyManager { @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @Deprecated public @SimState int getSimApplicationState(int physicalSlotIndex) { + int activePort = getFirstActivePortIndex(physicalSlotIndex); int simState = SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, - DEFAULT_PORT_INDEX)); + activePort)); return getSimApplicationStateFromSimState(simState); }