[Settings] Cannot use UnsupportedAppUsage API, use #hasIccCard() to replace

Bug: 145967955
Test: make
Change-Id: I8b948d1d416e1eb79e34be073b8ad81645d5ebb1
This commit is contained in:
zoey chen
2019-12-10 17:44:05 +08:00
parent e7e4dd905a
commit 73038f556d
2 changed files with 6 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ public class SimLockPreferenceController extends BasePreferenceController {
private final CarrierConfigManager mCarrierConfigManager;
private final UserManager mUserManager;
private final SubscriptionManager mSubscriptionManager;
private final TelephonyManager mTelephonyManager;
private TelephonyManager mTelephonyManager;
public SimLockPreferenceController(Context context) {
super(context, KEY_SIM_LOCK);
@@ -99,7 +99,9 @@ public class SimLockPreferenceController extends BasePreferenceController {
if (subInfoList != null) {
for (SubscriptionInfo subInfo : subInfoList) {
if (mTelephonyManager.hasIccCard(subInfo.getSimSlotIndex())) {
mTelephonyManager = mTelephonyManager
.createForSubscriptionId(subInfo.getSimSlotIndex());
if (mTelephonyManager.hasIccCard()) {
return true;
}
}

View File

@@ -141,7 +141,8 @@ public class SimLockPreferenceControllerTest {
final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
SubscriptionInfo info = mock(SubscriptionInfo.class);
subscriptionInfoList.add(info);
when(mTelephonyManager.hasIccCard(anyInt())).thenReturn(true);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mTelephonyManager.hasIccCard()).thenReturn(true);
when(mSubscriptionManager.getActiveSubscriptionInfoList(eq(true)))
.thenReturn(subscriptionInfoList);
}