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

Commit 8d59880b authored by Andrew Scull's avatar Andrew Scull Committed by Android (Google) Code Review
Browse files

Merge "Handle security algorithm updates" into main

parents 28f776ec f3bb0da9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public abstract class BaseCommands implements CommandsInterface {
    protected RegistrantList mTriggerImsDeregistrationRegistrants = new RegistrantList();
    protected RegistrantList mImeiInfoRegistrants = new RegistrantList();
    protected RegistrantList mCellularIdentifierDisclosedRegistrants = new RegistrantList();
    protected RegistrantList mSecurityAlgorithmUpdatedRegistrants = new RegistrantList();

    @UnsupportedAppUsage
    protected Registrant mGsmSmsRegistrant;
@@ -1194,4 +1195,14 @@ public abstract class BaseCommands implements CommandsInterface {
    public void unregisterForCellularIdentifierDisclosures(Handler h) {
        mCellularIdentifierDisclosedRegistrants.remove(h);
    }

    @Override
    public void registerForSecurityAlgorithmUpdates(Handler h, int what, Object obj) {
        mSecurityAlgorithmUpdatedRegistrants.add(h, what, obj);
    }

    @Override
    public void unregisterForSecurityAlgorithmUpdates(Handler h) {
        mSecurityAlgorithmUpdatedRegistrants.remove(h);
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -2940,4 +2940,16 @@ public interface CommandsInterface {
     * @param h Handler to be removed from the registrant list.
     */
    default void unregisterForCellularIdentifierDisclosures(@NonNull Handler h) {}

    /**
     * Registers for security algorithm update events.
     */
    default void registerForSecurityAlgorithmUpdates(Handler h, int what, Object obj) {}

    /**
     * Unregisters for security algorithm update events.
     *
     * @param h Handler to be removed from the registrant list.
     */
    default void unregisterForSecurityAlgorithmUpdates(Handler h) {}
}
+23 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
import android.telephony.RadioAccessFamily;
import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SubscriptionInfo;
@@ -118,6 +119,7 @@ import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.security.CellularIdentifierDisclosureNotifier;
import com.android.internal.telephony.security.NullCipherNotifier;
import com.android.internal.telephony.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionManagerServiceCallback;
import com.android.internal.telephony.test.SimulatedRadioControl;
@@ -302,6 +304,7 @@ public class GsmCdmaPhone extends Phone {
    private final CallWaitingController mCallWaitingController;

    private CellularIdentifierDisclosureNotifier mIdentifierDisclosureNotifier;
    private NullCipherNotifier mNullCipherNotifier;

    // Set via Carrier Config
    private boolean mIsN1ModeAllowedByCarrier = true;
@@ -534,6 +537,17 @@ public class GsmCdmaPhone extends Phone {
                    this, EVENT_CELL_IDENTIFIER_DISCLOSURE, null);
        }

        if (mFeatureFlags.enableModemCipherTransparency()) {
            logi("enable_modem_cipher_transparency is on. Registering for security algorithm "
                    + "updates from phone " + getPhoneId());
            mNullCipherNotifier =
                    mTelephonyComponentFactory
                            .inject(NullCipherNotifier.class.getName())
                            .makeNullCipherNotifier();
            mCi.registerForSecurityAlgorithmUpdates(
                    this, EVENT_SECURITY_ALGORITHM_UPDATE, null);
        }

        initializeCarrierApps();
    }

@@ -3702,6 +3716,15 @@ public class GsmCdmaPhone extends Phone {
                mIsIdentifierDisclosureTransparencySupported = doesResultIndicateModemSupport(ar);
                break;

            case EVENT_SECURITY_ALGORITHM_UPDATE:
                logd("EVENT_SECURITY_ALGORITHM_UPDATE phoneId = " + getPhoneId());
                if (mFeatureFlags.enableModemCipherTransparency() && mNullCipherNotifier != null) {
                    ar = (AsyncResult) msg.obj;
                    SecurityAlgorithmUpdate update = (SecurityAlgorithmUpdate) ar.result;
                    mNullCipherNotifier.onSecurityAlgorithmUpdate(getPhoneId(), update);
                }
                break;

            default:
                super.handleMessage(msg);
        }
+7 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.telephony.EmergencyRegResult;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhysicalChannelConfig;
import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.text.TextUtils;
@@ -456,6 +457,12 @@ public class NetworkIndication extends IRadioNetworkIndication.Stub {
        if (mRil.isLogOrTrace()) {
            mRil.unsljLogRet(RIL_UNSOL_SECURITY_ALGORITHMS_UPDATED, securityAlgorithmUpdate);
        }

        SecurityAlgorithmUpdate update =
                RILUtils.convertSecurityAlgorithmUpdate(securityAlgorithmUpdate);

        mRil.mSecurityAlgorithmUpdatedRegistrants.notifyRegistrants(
                new AsyncResult(null, update, null));
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -257,7 +257,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_IMEI_MAPPING_CHANGED = 71;
    protected static final int EVENT_CELL_IDENTIFIER_DISCLOSURE = 72;
    protected static final int EVENT_SET_IDENTIFIER_DISCLOSURE_ENABLED_DONE = 73;
    protected static final int EVENT_LAST = EVENT_SET_IDENTIFIER_DISCLOSURE_ENABLED_DONE;
    protected static final int EVENT_SECURITY_ALGORITHM_UPDATE = 74;
    protected static final int EVENT_LAST = EVENT_SECURITY_ALGORITHM_UPDATE;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
Loading