Add a condition for preventing NPE when accessing SatelliteManager
There could be a case that FEATURE_TELEPHONY_SATELLITE is false but KEY_SATELLITE_ATTACH_SUPPORTED_BOOL it true
Since SatelliteManager can be returned only when FEATURE_TELEPHONY_SATELLITE is enabled, added a condition checks whether SatelliteManager is null or not
Bug: 347057183
Test: atest SatelliteManagerTest SatelliteManagerTestOnMockServiceTest
manually e2e test with FEATURE_TELEPHONY_SATELLITE disabled
Change-Id: I3f51e6805ccab3366d9d01be2e999818cd18354f
This commit is contained in:
@@ -92,6 +92,14 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
|
||||||
|
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
|
||||||
|
if (mSatelliteManager == null) {
|
||||||
|
Log.d(TAG, "SatelliteManager is null, do nothing.");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
|
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
|
||||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
|
|
||||||
@@ -104,7 +112,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
|
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
|
||||||
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ public class SatelliteSettingPreferenceController extends
|
|||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mSatelliteManager == null) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||||
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
|
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
|
||||||
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
|
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
|
||||||
|
|||||||
Reference in New Issue
Block a user