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

Commit 977d9a5c authored by Rubin Xu's avatar Rubin Xu
Browse files

Guard against exception from TelephonyManager.getMeid()

Bug: 325625753
Test: EnrollmentSpecificIdTest
Change-Id: Idfe592e9489dae6a7114e86e4ab1bad8457577e8
parent 2b48314d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -53,7 +53,17 @@ class EnterpriseSpecificIdCalculator {
        TelephonyManager telephonyService = context.getSystemService(TelephonyManager.class);
        Preconditions.checkState(telephonyService != null, "Unable to access telephony service");
        mImei = telephonyService.getImei(0);
        mMeid = telephonyService.getMeid(0);
        String meid;
        try {
            meid = telephonyService.getMeid(0);
        } catch (UnsupportedOperationException doesNotSupportCdma) {
            // Instead of catching the exception, we could check for FEATURE_TELEPHONY_CDMA.
            // However that runs the risk of changing a device's existing ESID if on these devices
            // telephonyService.getMeid() actually returns non-null even when the device does not
            // declare FEATURE_TELEPHONY_CDMA.
            meid = null;
        }
        mMeid = meid;
        mSerialNumber = Build.getSerial();
        WifiManager wifiManager = context.getSystemService(WifiManager.class);
        Preconditions.checkState(wifiManager != null, "Unable to access WiFi service");