From 138455f16127f64054724bb796bbaba01c9ae9fb Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Fri, 30 Nov 2018 14:48:50 -0800 Subject: Add AIDL for number verification request API Add the new method to ITelephony and call it in the requestNumberVerification API. Bug: 119675160 Test: GTS later + testapps Change-Id: I89baba023cdae746bc4afd96432f8348114d47cf --- .../java/android/telephony/TelephonyManager.java | 31 ++++++++++++++++++---- .../com/android/internal/telephony/ITelephony.aidl | 13 +++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index d4788e3b726e..15b540889977 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5516,19 +5516,40 @@ public class TelephonyManager { public void requestNumberVerification(@NonNull PhoneNumberRange range, long timeoutMillis, @NonNull @CallbackExecutor Executor executor, @NonNull NumberVerificationCallback callback) { + if (executor == null) { + throw new NullPointerException("Executor must be non-null"); + } + if (callback == null) { + throw new NullPointerException("Callback must be non-null"); + } + INumberVerificationCallback internalCallback = new INumberVerificationCallback.Stub() { @Override - public void onCallReceived(String phoneNumber) throws RemoteException { - Binder.withCleanCallingIdentity(() -> callback.onCallReceived(phoneNumber)); + public void onCallReceived(String phoneNumber) { + Binder.withCleanCallingIdentity(() -> + executor.execute(() -> + callback.onCallReceived(phoneNumber))); } @Override - public void onVerificationFailed(int reason) throws RemoteException { - Binder.withCleanCallingIdentity(() -> callback.onVerificationFailed(reason)); + public void onVerificationFailed(int reason) { + Binder.withCleanCallingIdentity(() -> + executor.execute(() -> + callback.onVerificationFailed(reason))); } }; - // TODO -- call the aidl method + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + telephony.requestNumberVerification(range, timeoutMillis, internalCallback, + getOpPackageName()); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "requestNumberVerification RemoteException", ex); + executor.execute(() -> + callback.onVerificationFailed(NumberVerificationCallback.REASON_UNSPECIFIED)); + } } /** diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 1b17a8aabc07..8a1fb7bc8ff0 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -35,6 +35,7 @@ import android.telephony.ICellInfoCallback; import android.telephony.ModemActivityInfo; import android.telephony.NeighboringCellInfo; import android.telephony.NetworkScanRequest; +import android.telephony.PhoneNumberRange; import android.telephony.RadioAccessFamily; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -49,6 +50,7 @@ import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.aidl.IImsRegistrationCallback; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.telephony.CellNetworkScanResult; +import com.android.internal.telephony.INumberVerificationCallback; import com.android.internal.telephony.OperatorInfo; import java.util.List; @@ -870,6 +872,17 @@ interface ITelephony { */ String getCdmaMin(int subId); + /** + * Request that the next incoming call from a number matching {@code range} be intercepted. + * @param range The range of phone numbers the caller expects a phone call from. + * @param timeoutMillis The amount of time to wait for such a call, or + * {@link #MAX_NUMBER_VERIFICATION_TIMEOUT_MILLIS}, whichever is lesser. + * @param callback the callback aidl + * @param callingPackage the calling package name. + */ + void requestNumberVerification(in PhoneNumberRange range, long timeoutMillis, + in INumberVerificationCallback callback, String callingPackage); + /** * Has the calling application been granted special privileges by the carrier. * -- cgit v1.2.3-59-g8ed1b