blob: b00c57351589c7ab7790d549bae8e235e80d8049 [file] [log] [blame]
Hall Liu53140362018-11-28 10:44:22 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.telephony;
18
19import android.annotation.IntDef;
20import android.annotation.NonNull;
21import android.annotation.SystemApi;
22
23/**
24 * A callback for number verification. After a request for number verification is received,
25 * the system will call {@link #onCallReceived(String)} if a phone call was received from a number
26 * matching the provided {@link PhoneNumberRange} or it will call {@link #onVerificationFailed(int)}
27 * if an error occurs.
28 * @hide
29 */
30@SystemApi
31public interface NumberVerificationCallback {
32 /** @hide */
33 @IntDef(value = {REASON_UNSPECIFIED, REASON_TIMED_OUT, REASON_NETWORK_NOT_AVAILABLE,
34 REASON_TOO_MANY_CALLS, REASON_CONCURRENT_REQUESTS, REASON_IN_ECBM,
35 REASON_IN_EMERGENCY_CALL},
36 prefix = {"REASON_"})
37 @interface NumberVerificationFailureReason {}
38
39 /**
40 * Verification failed for an unspecified reason.
41 */
42 int REASON_UNSPECIFIED = 0;
43
44 /**
45 * Verification failed because no phone call was received from a matching number within the
46 * provided timeout.
47 */
48 int REASON_TIMED_OUT = 1;
49
50 /**
51 * Verification failed because no cellular voice network is available.
52 */
53 int REASON_NETWORK_NOT_AVAILABLE = 2;
54
55 /**
56 * Verification failed because there are currently too many ongoing phone calls for a new
57 * incoming phone call to be received.
58 */
59 int REASON_TOO_MANY_CALLS = 3;
60
61 /**
62 * Verification failed because a previous request for verification has not yet completed.
63 */
64 int REASON_CONCURRENT_REQUESTS = 4;
65
66 /**
67 * Verification failed because the phone is in emergency callback mode.
68 */
69 int REASON_IN_ECBM = 5;
70
71 /**
72 * Verification failed because the phone is currently in an emergency call.
73 */
74 int REASON_IN_EMERGENCY_CALL = 6;
75
76 /**
77 * Called when the device receives a phone call from the provided {@link PhoneNumberRange}.
78 * @param phoneNumber The phone number within the range that called. May or may not contain the
79 * country code, but will be entirely numeric.
80 */
81 default void onCallReceived(@NonNull String phoneNumber) { }
82
83 /**
84 * Called when verification fails for some reason.
85 * @param reason The reason for failure.
86 */
87 default void onVerificationFailed(@NumberVerificationFailureReason int reason) { }
88}