17 | * This method catches all underlying exceptions to ensure that this method never throws any
18 | * exception.
19 | */
20 | public static boolean isBlocked(Context context, String phoneNumber) {
21 | boolean isBlocked = false;
22 | long startTimeNano = System.nanoTime();
23 |
24 | try {
25 | if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber(
26 | context, phoneNumber)) {
27 | Rlog.d(TAG, phoneNumber + " is blocked.");
28 | isBlocked = true;
29 | }
30 | } catch (Exception e) {
31 | Rlog.e(TAG, "Exception checking for blocked number: " + e);
32 | }
33 |
34 | int durationMillis = (int) ((System.nanoTime() - startTimeNano) / 1000000);
35 | if (durationMillis > 500 || VDBG) {
36 | Rlog.d(TAG, "Blocked number lookup took: " + durationMillis + " ms.");
37 | }
38 | return isBlocked;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/CallFailCause.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | /**
20 | * Call fail causes from TS 24.008 .
21 | * These are mostly the cause codes we need to distinguish for the UI.
22 | * See 22.001 Annex F.4 for mapping of cause codes to local tones.
23 | *
24 | * CDMA call failure reasons are derived from the possible call failure scenarios described
25 | * in "CDMA IS2000 - Release A (C.S0005-A v6.0)" standard.
26 | *
27 | * {@hide}
28 | *
29 | */
30 | public interface CallFailCause {
31 | // Unassigned/Unobtainable number
32 | int UNOBTAINABLE_NUMBER = 1;
33 |
34 | int NORMAL_CLEARING = 16;
35 | // Busy Tone
36 | int USER_BUSY = 17;
37 |
38 | // No Tone
39 | int NUMBER_CHANGED = 22;
40 | int STATUS_ENQUIRY = 30;
41 | int NORMAL_UNSPECIFIED = 31;
42 |
43 | // Congestion Tone
44 | int NO_CIRCUIT_AVAIL = 34;
45 | int TEMPORARY_FAILURE = 41;
46 | int SWITCHING_CONGESTION = 42;
47 | int CHANNEL_NOT_AVAIL = 44;
48 | int QOS_NOT_AVAIL = 49;
49 | int BEARER_NOT_AVAIL = 58;
50 |
51 | // others
52 | int ACM_LIMIT_EXCEEDED = 68;
53 | int CALL_BARRED = 240;
54 | int FDN_BLOCKED = 241;
55 |
56 | // Stk Call Control
57 | int DIAL_MODIFIED_TO_USSD = 244;
58 | int DIAL_MODIFIED_TO_SS = 245;
59 | int DIAL_MODIFIED_TO_DIAL = 246;
60 |
61 | int CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000;
62 | int CDMA_DROP = 1001;
63 | int CDMA_INTERCEPT = 1002;
64 | int CDMA_REORDER = 1003;
65 | int CDMA_SO_REJECT = 1004;
66 | int CDMA_RETRY_ORDER = 1005;
67 | int CDMA_ACCESS_FAILURE = 1006;
68 | int CDMA_PREEMPTED = 1007;
69 |
70 | // For non-emergency number dialed while in emergency callback mode.
71 | int CDMA_NOT_EMERGENCY = 1008;
72 |
73 | // Access Blocked by CDMA Network.
74 | int CDMA_ACCESS_BLOCKED = 1009;
75 |
76 | int ERROR_UNSPECIFIED = 0xffff;
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/CallForwardInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | /**
20 | * See also RIL_CallForwardInfo in include/telephony/ril.h
21 | *
22 | * {@hide}
23 | */
24 | public class CallForwardInfo {
25 | public int status; /*1 = active, 0 = not active */
26 | public int reason; /* from TS 27.007 7.11 "reason" */
27 | public int serviceClass; /* Saum of CommandsInterface.SERVICE_CLASS */
28 | public int toa; /* "type" from TS 27.007 7.11 */
29 | public String number; /* "number" from TS 27.007 7.11 */
30 | public int timeSeconds; /* for CF no reply only */
31 |
32 | @Override
33 | public String toString() {
34 | return super.toString() + (status == 0 ? " not active " : " active ")
35 | + " reason: " + reason
36 | + " serviceClass: " + serviceClass + " " + timeSeconds + " seconds";
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/CallStateException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | /**
20 | * {@hide}
21 | */
22 | public class CallStateException extends Exception
23 | {
24 | private int mError = ERROR_INVALID;
25 |
26 | /** The error code is not valid (Not received a disconnect cause) */
27 | public static final int ERROR_INVALID = -1;
28 |
29 | public static final int ERROR_DISCONNECTED = 1;
30 |
31 | public
32 | CallStateException()
33 | {
34 | }
35 |
36 | public
37 | CallStateException(String string)
38 | {
39 | super(string);
40 | }
41 |
42 | public
43 | CallStateException(int error, String string)
44 | {
45 | super(string);
46 | mError = error;
47 | }
48 |
49 | public int getError() {
50 | return mError;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/DebugService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 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 |
17 | package com.android.internal.telephony;
18 |
19 | import android.telephony.Rlog;
20 | import android.text.TextUtils;
21 |
22 | import com.android.internal.telephony.metrics.TelephonyMetrics;
23 |
24 | import java.io.FileDescriptor;
25 | import java.io.PrintWriter;
26 |
27 | /**
28 | * A debug service that will dump telephony's state
29 | *
30 | * Currently this "Service" has a proxy in the phone app
31 | * com.android.phone.TelephonyDebugService which actually
32 | * invokes the dump method.
33 | */
34 | public class DebugService {
35 | private static String TAG = "DebugService";
36 |
37 | /** Constructor */
38 | public DebugService() {
39 | log("DebugService:");
40 | }
41 |
42 | /**
43 | * Dump the state of various objects, add calls to other objects as desired.
44 | */
45 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
46 | if (args != null && args.length > 0) {
47 | if (TextUtils.equals(args[0], "--metrics") ||
48 | TextUtils.equals(args[0], "--metricsproto"))
49 | {
50 | log("Collecting telephony metrics..");
51 | TelephonyMetrics.getInstance().dump(fd, pw, args);
52 | return;
53 | }
54 | }
55 | log("Dump telephony.");
56 | PhoneFactory.dump(fd, pw, args);
57 | }
58 |
59 | private static void log(String s) {
60 | Rlog.d(TAG, "DebugService " + s);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/LastCallFailCause.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | public class LastCallFailCause {
20 | public int causeCode;
21 | public String vendorCause;
22 |
23 | @Override
24 | public String toString() {
25 | return super.toString()
26 | + " causeCode: " + causeCode
27 | + " vendorCause: " + vendorCause;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/MmiCode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | /**
20 | * {@hide}
21 | */
22 | public interface MmiCode
23 | {
24 | /**
25 | * {@hide}
26 | */
27 | public enum State {
28 | PENDING,
29 | CANCELLED,
30 | COMPLETE,
31 | FAILED
32 | }
33 |
34 |
35 | /**
36 | * @return Current state of MmiCode request
37 | */
38 | public State getState();
39 |
40 | /**
41 | * @return Localized message for UI display, valid only in COMPLETE
42 | * or FAILED states. null otherwise
43 | */
44 |
45 | public CharSequence getMessage();
46 |
47 | /**
48 | * @return Phone associated with the MMI/USSD message
49 | */
50 | public Phone getPhone();
51 |
52 | /**
53 | * Cancels pending MMI request.
54 | * State becomes CANCELLED unless already COMPLETE or FAILED
55 | */
56 | public void cancel();
57 |
58 | /**
59 | * @return true if the network response is a REQUEST for more user input.
60 | */
61 | public boolean isUssdRequest();
62 |
63 | /**
64 | * @return true if an outstanding request can be canceled.
65 | */
66 | public boolean isCancelable();
67 |
68 | /**
69 | * @return true if the Service Code is PIN/PIN2/PUK/PUK2-related
70 | */
71 | public boolean isPinPukCommand();
72 |
73 | /**
74 | * Process a MMI code or short code...anything that isn't a dialing number
75 | */
76 | void processCode() throws CallStateException;
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/java/com/android/internal/telephony/PhoneNotifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 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 |
17 | package com.android.internal.telephony;
18 |
19 | import android.telephony.CellInfo;
20 | import android.telephony.VoLteServiceState;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * {@hide}
26 | */
27 | public interface PhoneNotifier {
28 |
29 | public void notifyPhoneState(Phone sender);
30 |
31 | public void notifyServiceState(Phone sender);
32 |
33 | public void notifyCellLocation(Phone sender);
34 |
35 | public void notifySignalStrength(Phone sender);
36 |
37 | public void notifyMessageWaitingChanged(Phone sender);
38 |
39 | public void notifyCallForwardingChanged(Phone sender);
40 |
41 | /** TODO - reason should never be null */
42 | public void notifyDataConnection(Phone sender, String reason, String apnType,
43 | PhoneConstants.DataState state);
44 |
45 | public void notifyDataConnectionFailed(Phone sender, String reason, String apnType);
46 |
47 | public void notifyDataActivity(Phone sender);
48 |
49 | public void notifyOtaspChanged(Phone sender, int otaspMode);
50 |
51 | public void notifyCellInfo(Phone sender, List
30 | * This function implements a subset of
31 | * quoted-printable encoding specification (rule #1 and rule #2)
32 | * as defined in RFC 1521.
33 | *