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

Commit 64b76eaa authored by Sarah Chin's avatar Sarah Chin Committed by Automerger Merge Worker
Browse files

Merge "Remove key from database if download URL is not set" am: b30e0b4c

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1556390

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I078252c1664146a722d30e74fb61597469ae037f
parents 6028e0e1 b30e0b4c
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.