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

Commit 962fbd7e authored by Gil Cukierman's avatar Gil Cukierman
Browse files

Add identifier disclosure transparency APIs

Two new APIs are introduced:

1. enableCellularIdentifierDisclosureNotifications
2. isCellularIdentifierDisclosureNotificationEnabled

Bug: 313475601
Test: atest android.telephony.cts.TelephonyManagerTest
Change-Id: I7dbc56ed9921a088cd84a691dca5164a5b5772e1
parent 6e80dd6e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14516,6 +14516,7 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void clearRadioPowerOffForReason(int);
    method public void dial(String);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean disableDataConnectivity();
    method @FlaggedApi("com.android.internal.telephony.flags.enable_identifier_disclosure_transparency") @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void enableCellularIdentifierDisclosureNotifications(boolean);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean enableDataConnectivity();
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean enableModemForSlot(int, boolean);
    method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void enableVideoCalling(boolean);
@@ -14588,6 +14589,7 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAnyRadioPoweredOn();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApnMetered(int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int);
    method @FlaggedApi("com.android.internal.telephony.flags.enable_identifier_disclosure_transparency") @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isCellularIdentifierDisclosureNotificationEnabled();
    method public boolean isDataConnectivityPossible();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isEmergencyAssistanceEnabled();
+58 −0
Original line number Diff line number Diff line
@@ -18008,6 +18008,64 @@ public class TelephonyManager {
        return true;
    }
    /**
     * Enable or disable notifications sent for cellular identifier disclosure events.
     *
     * Disclosure events are defined as instances where a device has sent a cellular identifier
     * on the Non-access stratum (NAS) before a security context is established. As a result the
     * identifier is sent in the clear, which has privacy implications for the user.
     *
     * @param enable if notifications about disclosure events should be enabled
     * @throws IllegalStateException if the Telephony process is not currently available
     * @throws SecurityException if the caller does not have the required privileges
     * @throws UnsupportedOperationException if the modem does not support this feature.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_ENABLE_IDENTIFIER_DISCLOSURE_TRANSPARENCY)
    @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
    @SystemApi
    public void enableCellularIdentifierDisclosureNotifications(boolean enable) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                telephony.enableCellularIdentifierDisclosureNotifications(enable);
            } else {
                throw new IllegalStateException("telephony service is null.");
            }
        } catch (RemoteException ex) {
            Rlog.e(TAG, "enableCellularIdentifierDisclosureNotifications RemoteException", ex);
            ex.rethrowFromSystemServer();
        }
    }
    /**
     * Get whether or not cellular identifier disclosure notifications are enabled.
     *
     * @throws IllegalStateException if the Telephony process is not currently available
     * @throws SecurityException if the caller does not have the required privileges
     * @throws UnsupportedOperationException if the modem does not support this feature.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_ENABLE_IDENTIFIER_DISCLOSURE_TRANSPARENCY)
    @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @SystemApi
    public boolean isCellularIdentifierDisclosureNotificationEnabled() {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.isCellularIdentifierDisclosureNotificationEnabled();
            } else {
                throw new IllegalStateException("telephony service is null.");
            }
        } catch (RemoteException ex) {
            Rlog.e(TAG, "isCellularIdentifierDisclosureNotificationEnabled RemoteException", ex);
            ex.rethrowFromSystemServer();
        }
        return false;
    }
    /**
     * Get current cell broadcast message identifier ranges.
     *
+33 −0
Original line number Diff line number Diff line
@@ -3159,4 +3159,37 @@ interface ITelephony {
     * @return {@code true} if the operation is successful, {@code false} otherwise.
     */
    boolean setShouldSendDatagramToModemInDemoMode(boolean shouldSendToModemInDemoMode);

    /**
     * Enable or disable notifications sent for cellular identifier disclosure events.
     *
     * Disclosure events are defined as instances where a device has sent a cellular identifier
     * on the Non-access stratum (NAS) before a security context is established. As a result the
     * identifier is sent in the clear, which has privacy implications for the user.
     *
     * <p>Requires permission: android.Manifest.MODIFY_PHONE_STATE</p>
     *
     * @param enabled if notifications about disclosure events should be enabled
     * @throws IllegalStateException if the Telephony process is not currently available
     * @throws SecurityException if the caller does not have the required privileges
     * @throws UnsupportedOperationException if the modem does not support this feature.
     * @hide
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
        + "android.Manifest.permission.MODIFY_PHONE_STATE)")
    void enableCellularIdentifierDisclosureNotifications(boolean enable);

    /**
     * Get whether or not cellular identifier disclosure notifications are enabled.
     *
     * <p>Requires permission: android.Manifest.READ_PRIVILEGED_PHONE_STATE</p>
     *
     * @throws IllegalStateException if the Telephony process is not currently available
     * @throws SecurityException if the caller does not have the required privileges
     * @throws UnsupportedOperationException if the modem does not support this feature.
     * @hide
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
        + "android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)")
    boolean isCellularIdentifierDisclosureNotificationEnabled();
}