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

Commit fbe7f7f9 authored by Gil Cukierman's avatar Gil Cukierman
Browse files

Handle CellularIdentifierDisclosure events in telephony

This CL changes the previous noop logic in the RIL for handling
`cellularIdentifierDisclosed` calls from the modem.

The RIL now exposes APIs to register and deregister for disclosure
events. To avoid AIDL-based instances of CellularIdentifierDisclosure
propagating through the framework, disclosure objects are converted
to Java wrappers before notifying registrants.

We also define the first registrant for disclosures,
`CellularIdentifierDisclosureNotifier`. For now, this class is mostly a
stub and does nothing but log events. It's implementation will be
completed in future CLs. Each `Phone` instance holds on to
a reference to the singleton notifier object, and passes the disclosure
event on to the notifier when it is received.

Both initializing a `CellularIdentifierDisclosureNotifier` and
registering for `cellularIdentifierDisclosed` events are guarded by a
new feature flag.

Test: atest GsmCdmaPhoneTest
Bug: 309955068
Change-Id: I10b1f2c07c1fad82e3b7e7bbd08198aeed49ea49
parent 20d6fa48
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -13,3 +13,10 @@ flag {
  description: "Allow carriers to hide the roaming (R) icon when roaming."
  bug: "301467052"
}

flag {
  name: "enable_identifier_disclosure_transparency"
  namespace: "telephony"
  description: "Allows the framework to register for CellularIdentifierDisclosure events and emit notifications to the user about them"
  bug: "276752426"
}
+11 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ public abstract class BaseCommands implements CommandsInterface {
    protected RegistrantList mNotifyAnbrRegistrants = new RegistrantList();
    protected RegistrantList mTriggerImsDeregistrationRegistrants = new RegistrantList();
    protected RegistrantList mImeiInfoRegistrants = new RegistrantList();
    protected RegistrantList mCellularIdentifierDisclosedRegistrants = new RegistrantList();

    @UnsupportedAppUsage
    protected Registrant mGsmSmsRegistrant;
@@ -1183,4 +1184,14 @@ public abstract class BaseCommands implements CommandsInterface {
    public void registerForImeiMappingChanged(Handler h, int what, Object obj) {
        mImeiInfoRegistrants.add(h, what, obj);
    }

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

    @Override
    public void unregisterForCellularIdentifierDisclosures(Handler h) {
        mCellularIdentifierDisclosedRegistrants.remove(h);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -2927,4 +2927,17 @@ public interface CommandsInterface {
     * @param result Callback message to receive the result.
     */
    default void isSecurityAlgorithmsUpdatedEnabled(Message result) {}

    /**
     * Registers for cellular identifier disclosure events.
     */
    default void registerForCellularIdentifierDisclosures(
            @NonNull Handler h, int what, @Nullable Object obj) {}

    /**
     * Unregisters for cellular identifier disclosure events.
     *
     * @param h Handler to be removed from the registrant list.
     */
    default void unregisterForCellularIdentifierDisclosures(@NonNull Handler h) {}
}
+38 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastIdRange;
import android.telephony.CellIdentity;
import android.telephony.CellularIdentifierDisclosure;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkScanRequest;
@@ -116,6 +117,7 @@ import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
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.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionManagerServiceCallback;
import com.android.internal.telephony.test.SimulatedRadioControl;
@@ -298,6 +300,8 @@ public class GsmCdmaPhone extends Phone {
    private final SubscriptionManager.OnSubscriptionsChangedListener mSubscriptionsChangedListener;
    private final CallWaitingController mCallWaitingController;

    private CellularIdentifierDisclosureNotifier mIdentifierDisclosureNotifier;

    // Set via Carrier Config
    private boolean mIsN1ModeAllowedByCarrier = true;
    // Set via a call to the method on Phone; the only caller is IMS, and all of this code will
@@ -515,6 +519,20 @@ public class GsmCdmaPhone extends Phone {
        mCIM = new CarrierInfoManager();

        mCi.registerForImeiMappingChanged(this, EVENT_IMEI_MAPPING_CHANGED, null);

        if (mFeatureFlags.enableIdentifierDisclosureTransparency()) {
            logi(
                    "enable_identifier_disclosure_transparency is on. Registering for cellular "
                            + "identifier disclosures from phone "
                            + getPhoneId());
            mIdentifierDisclosureNotifier =
                    mTelephonyComponentFactory
                            .inject(CellularIdentifierDisclosureNotifier.class.getName())
                            .makeIdentifierDisclosureNotifier();
            mCi.registerForCellularIdentifierDisclosures(
                    this, EVENT_CELL_IDENTIFIER_DISCLOSURE, null);
        }

        initializeCarrierApps();
    }

@@ -3663,6 +3681,26 @@ public class GsmCdmaPhone extends Phone {
                parseImeiInfo(msg);
                break;

            case EVENT_CELL_IDENTIFIER_DISCLOSURE:
                logd("EVENT_CELL_IDENTIFIER_DISCLOSURE phoneId = " + getPhoneId());

                ar = (AsyncResult) msg.obj;
                if (ar == null || ar.result == null || ar.exception != null) {
                    Rlog.e(
                            LOG_TAG,
                            "Failed to process cellular identifier disclosure",
                            ar.exception);
                    break;
                }

                CellularIdentifierDisclosure disclosure = (CellularIdentifierDisclosure) ar.result;
                if (mFeatureFlags.enableIdentifierDisclosureTransparency()
                        && mIdentifierDisclosureNotifier != null
                        && disclosure != null) {
                    mIdentifierDisclosureNotifier.addDisclosure(disclosure);
                }
                break;

            default:
                super.handleMessage(msg);
        }
+6 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.telephony.AnomalyReporter;
import android.telephony.BarringInfo;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.CellularIdentifierDisclosure;
import android.telephony.EmergencyRegResult;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkRegistrationInfo;
@@ -436,7 +437,11 @@ public class NetworkIndication extends IRadioNetworkIndication.Stub {
            mRil.unsljLogRet(RIL_UNSOL_CELLULAR_IDENTIFIER_DISCLOSED, identifierDisclsoure);
        }

        // TODO (b/276752426) notify registrants of identifier disclosure
        CellularIdentifierDisclosure disclosure =
                RILUtils.convertCellularIdentifierDisclosure(identifierDisclsoure);

        mRil.mCellularIdentifierDisclosedRegistrants.notifyRegistrants(
                new AsyncResult(null, disclosure, null));
    }

    /**
Loading