Merge "Add null checker for telephonymanager" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
57da8021d0
@@ -162,8 +162,8 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus(int subId) {
|
public int getAvailabilityStatus(int subId) {
|
||||||
if (mTelephonyManager == null) {
|
if (mTelephonyManager == null) {
|
||||||
Log.w(LOG_TAG, "Telephony manager not yet initialized");
|
Log.w(LOG_TAG, "getAvailabilityStatus: Telephony manager not yet initialized");
|
||||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
boolean visible =
|
boolean visible =
|
||||||
SubscriptionManager.isUsableSubscriptionId(subId)
|
SubscriptionManager.isUsableSubscriptionId(subId)
|
||||||
@@ -189,6 +189,10 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTelephonyManager == null) {
|
||||||
|
Log.w(LOG_TAG, "isChecked: Telephony manager not yet initialized");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
||||||
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
||||||
return (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
return (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
||||||
@@ -214,6 +218,12 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {
|
if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTelephonyManager == null) {
|
||||||
|
Log.w(LOG_TAG, "setChecked: Telephony manager not yet initialized");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
||||||
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
||||||
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
||||||
|
Reference in New Issue
Block a user