Mainline: remove usage of hiddepn API SubscriptionManager#getPhoneId

Bug: 140908357
Test: build
Change-Id: Idaa206c7659717a269738c0121a31d957f7d90d0
This commit is contained in:
Malcolm Chen
2019-12-12 16:23:33 -08:00
parent d8c711d891
commit 26e5dbdbfd
9 changed files with 40 additions and 12 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.network;
import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX;
import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
import static com.android.internal.util.CollectionUtils.emptyIfNull;
@@ -120,4 +121,20 @@ public class SubscriptionUtil {
public static boolean showToggleForPhysicalSim(SubscriptionManager subMgr) {
return subMgr.canDisablePhysicalSubscription();
}
/**
* Get phoneId or logical slot index for a subId if active, or INVALID_PHONE_INDEX if inactive.
*/
public static int getPhoneId(Context context, int subId) {
SubscriptionManager subManager = (SubscriptionManager)
context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
if (subManager == null) {
return INVALID_SIM_SLOT_INDEX;
}
SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
if (info == null) {
return INVALID_SIM_SLOT_INDEX;
}
return info.getSimSlotIndex();
}
}