Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014, 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.telecomm; |
| 18 | |
| 19 | import android.content.ComponentName; |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.net.Uri; |
| 22 | import android.telephony.PhoneNumberUtils; |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Utilities to deal with the system telephony services. The system telephony services are treated |
| 26 | * differently from 3rd party services in some situations (emergency calls, audio focus, etc...). |
| 27 | */ |
| 28 | public final class TelephonyUtil { |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 29 | private static final String TAG = TelephonyUtil.class.getSimpleName(); |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 30 | |
Sailesh Nepal | 4a51550 | 2014-06-26 12:58:17 -0700 | [diff] [blame] | 31 | private static final String TELEPHONY_PACKAGE_NAME = "com.android.phone"; |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 32 | |
Ihab Awad | 55a3428 | 2014-06-18 10:31:09 -0700 | [diff] [blame] | 33 | private static final String PSTN_CALL_SERVICE_CLASS_NAME = |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 34 | "com.android.services.telephony.TelephonyConnectionService"; |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 35 | |
| 36 | private TelephonyUtil() {} |
| 37 | |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 38 | static boolean isPstnComponentName(ComponentName componentName) { |
Sailesh Nepal | 4a51550 | 2014-06-26 12:58:17 -0700 | [diff] [blame] | 39 | final ComponentName pstnComponentName = new ComponentName( |
| 40 | TELEPHONY_PACKAGE_NAME, PSTN_CALL_SERVICE_CLASS_NAME); |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 41 | return pstnComponentName.equals(componentName); |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 44 | static boolean shouldProcessAsEmergency(Context context, Uri handle) { |
| 45 | return handle != null && PhoneNumberUtils.isPotentialLocalEmergencyNumber( |
| 46 | context, handle.getSchemeSpecificPart()); |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame] | 47 | } |
| 48 | } |