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

Commit eb189a38 authored by Sarah Chin's avatar Sarah Chin
Browse files

Remove key from database if download URL is not set

Test: atest FrameworksTelephonyTests
Fix: 172912885
Change-Id: Ieb7078af4be07edd1ca287c01cec6e2652fb3bf8
Merged-In: Ieb7078af4be07edd1ca287c01cec6e2652fb3bf8
parent 53e83854
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ public class CarrierKeyDownloadManager extends Handler {
        } else {
            // delete any existing alarms.
            cleanupRenewalAlarms();
            mPhone.deleteCarrierInfoForImsiEncryption();
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -1874,6 +1874,11 @@ public class GsmCdmaPhone extends Phone {
        CarrierInfoManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, mContext, mPhoneId);
    }

    @Override
    public void deleteCarrierInfoForImsiEncryption() {
        CarrierInfoManager.deleteCarrierInfoForImsiEncryption(mContext);
    }

    @Override
    public int getCarrierId() {
        return mCarrierResolver != null
+7 −0
Original line number Diff line number Diff line
@@ -3814,6 +3814,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return;
    }

    /**
     * Deletes all the keys for a given Carrier from the device keystore.
     */
    public void deleteCarrierInfoForImsiEncryption() {
        return;
    }

    public int getCarrierId() {
        return TelephonyManager.UNKNOWN_CARRIER_ID;
    }
+24 −0
Original line number Diff line number Diff line
@@ -283,6 +283,30 @@ public class CarrierKeyDownloadMgrTest extends TelephonyTest {
        assertTrue(mccMnc.equals("310:260"));
    }

    /**
     * Tests sending the ACTION_CARRIER_CONFIG_CHANGED intent with an empty key.
     * Verify that the carrier keys are removed if IMSI_KEY_DOWNLOAD_URL_STRING is null.
     */
    @Test
    @SmallTest
    public void testCarrierConfigChangedEmptyKey() {
        CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        int slotId = mPhone.getPhoneId();
        PersistableBundle bundle = carrierConfigManager.getConfigForSubId(slotId);
        bundle.putInt(CarrierConfigManager.IMSI_KEY_AVAILABILITY_INT, 3);
        bundle.putString(CarrierConfigManager.IMSI_KEY_DOWNLOAD_URL_STRING, null);

        Intent mIntent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        mIntent.putExtra(PhoneConstants.PHONE_KEY, 0);
        mContext.sendBroadcast(mIntent);
        processAllMessages();
        SharedPreferences preferences = getDefaultSharedPreferences(mContext);
        String mccMnc = preferences.getString("CARRIER_KEY_DM_MCC_MNC" + slotId, null);
        assertEquals(null, mccMnc);
        verify(mPhone).deleteCarrierInfoForImsiEncryption();
    }

    /**
     * Tests sending the INTENT_KEY_RENEWAL_ALARM_PREFIX intent.
     * Verify that the right mnc/mcc gets stored in the preferences.