Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdfd24ed authored by Hakjun Choi's avatar Hakjun Choi
Browse files

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
parent 9bd19f46
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -92,6 +92,14 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
        }

        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,
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);

@@ -104,7 +112,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
        }

        mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
        mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
    }

    @Override
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ public class SatelliteSettingPreferenceController extends
            return UNSUPPORTED_ON_DEVICE;
        }

        if (mSatelliteManager == null) {
            return UNSUPPORTED_ON_DEVICE;
        }

        final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
        final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
                CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);