[Settings] Remove null checking for TelephonyManager
1. TelephonyManager#createForSubscriptionId(int) never returns null Remove null checking. 2. Adopting context#getSystemService(SubscriptionManager.class) Bug: None Test: make Change-Id: Ie36dea80a4dfabbc34d9d25c50e60e4928b2f936
This commit is contained in:
@@ -174,9 +174,6 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
final TelephonyManager updatedTelephonyManager =
|
final TelephonyManager updatedTelephonyManager =
|
||||||
mTelephonyManager.createForSubscriptionId(subId);
|
mTelephonyManager.createForSubscriptionId(subId);
|
||||||
if (updatedTelephonyManager == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// restart monitoring when subscription has been changed
|
// restart monitoring when subscription has been changed
|
||||||
mTelephonyManager.listen(mPhoneStateListener,
|
mTelephonyManager.listen(mPhoneStateListener,
|
||||||
|
@@ -278,12 +278,11 @@ public class SubscriptionUtil {
|
|||||||
* Get phoneId or logical slot index for a subId if active, or INVALID_PHONE_INDEX if inactive.
|
* 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) {
|
public static int getPhoneId(Context context, int subId) {
|
||||||
SubscriptionManager subManager = (SubscriptionManager)
|
final SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
|
||||||
context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
||||||
if (subManager == null) {
|
if (subManager == null) {
|
||||||
return INVALID_SIM_SLOT_INDEX;
|
return INVALID_SIM_SLOT_INDEX;
|
||||||
}
|
}
|
||||||
SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
|
final SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return INVALID_SIM_SLOT_INDEX;
|
return INVALID_SIM_SLOT_INDEX;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user