2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.internal.telephony;
19 import android.telephony.Rlog;
21 import com.android.internal.telephony.Phone;
24 * Utilities that check if the phone supports specified capabilities.
26 public class TelephonyCapabilities {
27 private static final String LOG_TAG = "TelephonyCapabilities";
29 /** This class is never instantiated. */
30 private TelephonyCapabilities() {
34 * Return true if the current phone supports ECM ("Emergency Callback
35 * Mode"), which is a feature where the device goes into a special
36 * state for a short period of time after making an outgoing emergency
39 * (On current devices, that state lasts 5 minutes. It prevents data
40 * usage by other apps, to avoid conflicts with any possible incoming
41 * calls. It also puts up a notification in the status bar, showing a
42 * countdown while ECM is active, and allowing the user to exit ECM.)
44 * Currently this is assumed to be true for CDMA phones, and false
47 public static boolean supportsEcm(Phone phone) {
48 Rlog.d(LOG_TAG, "supportsEcm: Phone type = " + phone.getPhoneType() +
49 " Ims Phone = " + phone.getImsPhone());
50 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA ||
51 phone.getImsPhone() != null);
55 * Return true if the current phone supports Over The Air Service
56 * Provisioning (OTASP)
58 * Currently this is assumed to be true for CDMA phones, and false
61 * TODO: Watch out: this is also highly carrier-specific, since the
62 * OTASP procedure is different from one carrier to the next, *and* the
63 * different carriers may want very different onscreen UI as well.
64 * The procedure may even be different for different devices with the
67 * So we eventually will need a much more flexible, pluggable design.
68 * This method here is just a placeholder to reduce hardcoded
69 * "if (CDMA)" checks sprinkled throughout the phone app.
71 public static boolean supportsOtasp(Phone phone) {
72 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
76 * Return true if the current phone can retrieve the voice message count.
78 * Currently this is assumed to be true on CDMA phones and false otherwise.
80 public static boolean supportsVoiceMessageCount(Phone phone) {
81 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
85 * Return true if this phone allows the user to select which
88 * Currently this is assumed to be true only on GSM phones.
90 * TODO: Should CDMA phones allow this as well?
92 public static boolean supportsNetworkSelection(Phone phone) {
93 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM);
97 * Returns a resource ID for a label to use when displaying the
98 * "device id" of the current device. (This is currently used as the
99 * title of the "device id" dialog.)
101 * This is specific to the device's telephony technology: the device
102 * id is called "IMEI" on GSM phones and "MEID" on CDMA phones.
104 public static int getDeviceIdLabel(Phone phone) {
105 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
106 return com.android.internal.R.string.imei;
107 } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
108 return com.android.internal.R.string.meid;
110 Rlog.w(LOG_TAG, "getDeviceIdLabel: no known label for phone "
111 + phone.getPhoneName());
117 * Return true if the current phone supports the ability to explicitly
118 * manage the state of a conference call (i.e. view the participants,
119 * and hangup or separate individual callers.)
121 * The in-call screen's "Manage conference" UI is available only on
122 * devices that support this feature.
124 * Currently this is assumed to be true on GSM phones and false otherwise.
126 public static boolean supportsConferenceCallManagement(Phone phone) {
127 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)
128 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP));
132 * Return true if the current phone supports explicit "Hold" and
133 * "Unhold" actions for an active call. (If so, the in-call UI will
134 * provide onscreen "Hold" / "Unhold" buttons.)
136 * Currently this is assumed to be true on GSM phones and false
137 * otherwise. (In particular, CDMA has no concept of "putting a call
140 public static boolean supportsHoldAndUnhold(Phone phone) {
141 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)
142 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP)
143 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS));
147 * Return true if the current phone supports distinct "Answer & Hold"
148 * and "Answer & End" behaviors in the call-waiting scenario. If so,
149 * the in-call UI may provide separate buttons or menu items for these
152 * Currently this is assumed to be true on GSM phones and false
153 * otherwise. (In particular, CDMA has no concept of explicitly
154 * managing the background call, or "putting a call on hold.")
156 * TODO: It might be better to expose this capability in a more
157 * generic form, like maybe "supportsExplicitMultipleLineManagement()"
158 * rather than focusing specifically on call-waiting behavior.
160 public static boolean supportsAnswerAndHold(Phone phone) {
161 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)
162 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP));
166 * Return true if phones with the given phone type support ADN
167 * (Abbreviated Dialing Numbers).
169 * Currently this returns true when the phone type is GSM
170 * ({@link PhoneConstants#PHONE_TYPE_GSM}).
172 * This is using int for an argument for letting apps outside
173 * Phone process access to it, while other methods in this class is
174 * using Phone object.
176 * TODO: Theoretically phones other than GSM may have the ADN capability.
177 * Consider having better check here, or have better capability as part
178 * of public API, with which the argument should be replaced with
179 * something more appropriate.
181 public static boolean supportsAdn(int phoneType) {
182 return phoneType == PhoneConstants.PHONE_TYPE_GSM;
186 * Returns true if the device can distinguish the phone's dialing state
187 * (Call.State.DIALING/ALERTING) and connected state (Call.State.ACTIVE).
189 * Currently this returns true for GSM phones as we cannot know when a CDMA
190 * phone has transitioned from dialing/active to connected.
192 public static boolean canDistinguishDialingAndConnected(int phoneType) {
193 return phoneType == PhoneConstants.PHONE_TYPE_GSM;