Merge "Add Null Cipher Getter/Setter Telephony API"

This commit is contained in:
Gil Cukierman
2022-12-12 23:05:32 +00:00
committed by Android (Google) Code Review
2 changed files with 76 additions and 0 deletions

View File

@@ -17767,4 +17767,58 @@ public class TelephonyManager {
}
return TelephonyManager.SIM_STATE_UNKNOWN;
}
/**
* Set the UE's ability to accept/reject null ciphered and null integrity-protected connections.
*
* The modem is required to ignore this in case of an emergency call.
*
* <p>Requires permission: android.Manifest.MODIFY_PHONE_STATE</p>
*
* @param enabled if null ciphered and null integrity protected connections are permitted
* @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 disabling null ciphers.
* @hide
*/
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setNullCipherAndIntegrityEnabled(boolean enabled) {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
telephony.setNullCipherAndIntegrityEnabled(enabled);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
Rlog.e(TAG, "setNullCipherAndIntegrityEnabled RemoteException", ex);
ex.rethrowFromSystemServer();
}
}
/**
* Get the value of the global preference for null cipher and integriy enablement.
* Note: This does not return the state of the modem, only the persisted global preference.
*
* <p>Requires permission: android.Manifest.READ_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 disabling null ciphers.
* @hide
*/
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
public void isNullCipherAndIntegrityPreferenceEnabled() {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
telephony.isNullCipherAndIntegrityPreferenceEnabled();
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
Rlog.e(TAG, "isNullCipherAndIntegrityPreferenceEnabled RemoteException", ex);
ex.rethrowFromSystemServer();
}
}
}

View File

@@ -2636,4 +2636,26 @@ interface ITelephony {
* @param slotIndex Logical SIM slot index.
*/
int getSimStateForSlotIndex(int slotIndex);
/**
* Set whether the radio is able to connect with null ciphering or integrity
* algorithms. This is a global setting and will apply to all active subscriptions
* and all new subscriptions after this.
*
* <p>Requires Permission:
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
*
* @param enabled when true, null cipher and integrity algorithms are allowed.
* @hide
*/
void setNullCipherAndIntegrityEnabled(boolean enabled);
/**
* Get whether the radio is able to connect with null ciphering or integrity
* algorithms. Note that this retrieves the phone-global preference and not
* the state of the radio.
*
* @hide
*/
boolean isNullCipherAndIntegrityPreferenceEnabled();
}