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

Commit b063c8c8 authored by Sarah Chin's avatar Sarah Chin Committed by Android (Google) Code Review
Browse files

Merge "Remove key from database if download URL is not set" into rvc-qpr-dev

parents d79e4463 0803ae31
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
@@ -1862,6 +1862,11 @@ public class GsmCdmaPhone extends Phone {
        CarrierInfoManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, mContext, mPhoneId);
    }

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

    @Override
    public int getCarrierId() {
        return mCarrierResolver.getCarrierId();
+7 −0
Original line number Diff line number Diff line
@@ -3677,6 +3677,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.