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

Commit 4c47f34d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13518610 from 3f34d777 to 25Q3-release

Change-Id: Idcb442f8fccd006fd5e2f49f7f1d94a0d76225f5
parents c8a1a16c 3f34d777
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -127,6 +127,14 @@ flag {
    bug:"381319469"
}

# OWNER=arunvoddu TARGET=25Q4
flag {
    name: "send_imsi_key_for_duplicate_sim"
    namespace: "telephony"
    description: "This flag reset the cache if the sim phonebook is empty"
    bug:"404094844"
}

# OWNER=arunvoddu TARGET=25Q3
flag {
    name: "sim_phonebook_cache_fix"
+41 −3
Original line number Diff line number Diff line
@@ -130,6 +130,8 @@ public class CarrierKeyDownloadManager extends Handler {
    private DefaultNetworkCallback mDefaultNetworkCallback;
    private ConnectivityManager mConnectivityManager;
    private KeyguardManager mKeyguardManager;
    // This key will be used to track to send the IMSI key to modem.
    private boolean mIsKeySent = false;

    public CarrierKeyDownloadManager(Phone phone) {
        mPhone = phone;
@@ -155,6 +157,11 @@ public class CarrierKeyDownloadManager extends Handler {
        if (carrierConfigManager != null) {
            carrierConfigManager.registerCarrierConfigChangeListener(this::post,
                (slotIndex, subId, carrierId, specificCarrierId) -> {
                    if (((slotIndex == mPhone.getPhoneId())
                            && !SubscriptionManager.isValidSubscriptionId(subId))) {
                        // Resetting the key when there is a change in carrier config.
                        mIsKeySent = false;
                    }
                    if (Flags.imsiKeyRetryDownloadOnPhoneUnlock()) {
                        logd("CarrierConfig changed slotIndex = " + slotIndex + " subId = " + subId
                                + " CarrierId = " + carrierId + " phoneId = "
@@ -197,7 +204,10 @@ public class CarrierKeyDownloadManager extends Handler {
                    } else {
                        boolean isUserUnlocked = mUserManager.isUserUnlocked();

                        if (isUserUnlocked && slotIndex == mPhone.getPhoneId()) {
                        if (isUserUnlocked && (slotIndex == mPhone.getPhoneId()
                                // while another SIM is absent, attempt to look for
                                // if key needs to be sent.
                                || !SubscriptionManager.isValidSubscriptionId(subId))) {
                            Log.d(LOG_TAG, "Carrier Config changed: slotIndex=" + slotIndex);
                            handleAlarmOrConfigChange();
                        } else {
@@ -317,6 +327,8 @@ public class CarrierKeyDownloadManager extends Handler {
                    boolean hasActiveDataNetwork =
                            (mConnectivityManager.getActiveNetwork() != null);
                    boolean downloadStartedSuccessfully = hasActiveDataNetwork && downloadKey();
                    logd("handleAlarmOrConfigChange :: downloadStartedSuccessfully "
                            + downloadStartedSuccessfully);
                    // if the download was attempted, but not started successfully, and if
                    // carriers uses keys, we'll still want to renew the alarms, and try
                    // downloading the key a day later.
@@ -339,13 +351,22 @@ public class CarrierKeyDownloadManager extends Handler {
                        }
                        resetRenewalAlarm();
                    }
                } else {
                    logd("handleAlarmOrConfigChange :: mIsKeySent " + mIsKeySent);
                    if (Flags.sendImsiKeyForDuplicateSim() && !mIsKeySent) {
                        ImsiEncryptionInfo imsiEncryptionInfo = getExistingKey();
                        if (imsiEncryptionInfo != null) {
                            logd("handleAlarmOrConfigChange :: saving public key");
                            savePublicKey(imsiEncryptionInfo);
                        }
                    }
                }
                logd("handleAlarmOrConfigChange :: areCarrierKeysAbsentOrExpiring returned false");
            } else {
                cleanupRenewalAlarms();
                if (!isOtherSlotHasCarrier()) {
                    // delete any existing alarms.
                    mPhone.deleteCarrierInfoForImsiEncryption(getSimCarrierId(), getSimOperator());
                    mIsKeySent = false;
                }
                cleanupDownloadInfo();
            }
@@ -364,8 +385,19 @@ public class CarrierKeyDownloadManager extends Handler {
                // delete any existing alarms.
                cleanupRenewalAlarms();
                mPhone.deleteCarrierInfoForImsiEncryption(getSimCarrierId());
                mIsKeySent = false;
            }
        }
    }

    private ImsiEncryptionInfo getExistingKey() {
        for (int type : CARRIER_KEY_TYPES) {
            if (!isKeyEnabled(type)) {
                continue;
            }
            return mPhone.getCarrierInfoForImsiEncryption(type, false);
        }
        return null;
    }

    private boolean isOtherSlotHasCarrier() {
@@ -858,7 +890,13 @@ public class CarrierKeyDownloadManager extends Handler {
            String mcc, String mnc, int carrierId) {
        ImsiEncryptionInfo imsiEncryptionInfo = new ImsiEncryptionInfo(mcc, mnc,
                type, identifier, publicKey, new Date(expirationDate), carrierId);
        mPhone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo);
        mPhone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, true);
        mIsKeySent = true;
    }

    public void savePublicKey(ImsiEncryptionInfo imsiEncryptionInfo) {
        mPhone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, false);
        mIsKeySent = true;
    }

    /**
+6 −2
Original line number Diff line number Diff line
@@ -2121,8 +2121,12 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
        CarrierInfoManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, mContext, mPhoneId);
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo,
            boolean saveToDb) {
        if (saveToDb) {
            CarrierInfoManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, mContext,
                    mPhoneId);
        }
        mCi.setCarrierInfoForImsiEncryption(imsiEncryptionInfo, null);
    }

+2 −1
Original line number Diff line number Diff line
@@ -4026,7 +4026,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     *        IMSI and IMPI. This includes the Key type, the Public key
     *        {@link java.security.PublicKey} and the Key identifier.
     */
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo,
            boolean saveToDb) {
        return;
    }

+2 −1
Original line number Diff line number Diff line
@@ -1077,7 +1077,8 @@ public interface PhoneInternalInterface {
    *        IMSI and IMPI. This includes the Key type, the Public key
    *        {@link java.security.PublicKey} and the Key identifier.
    */
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo);
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo,
            boolean saveToDb);

    /**
     * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
Loading