diff options
| author | 2018-12-05 18:29:47 +0000 | |
|---|---|---|
| committer | 2018-12-05 18:29:47 +0000 | |
| commit | 9814a10f4268618c17ffbe0d934bcb91c3211156 (patch) | |
| tree | 151675907b6622b8169ad020b93a9e8172db1016 | |
| parent | 79db2b093aa0c1d4fe10cca5c9185147df298e1c (diff) | |
| parent | 138455f16127f64054724bb796bbaba01c9ae9fb (diff) | |
Merge "Add AIDL for number verification request API"
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 31 | ||||
| -rw-r--r-- | telephony/java/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; @@ -871,6 +873,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. * * If any of the packages in the calling UID has carrier privileges, the |