1 /* 2 * Copyright (C) 2010 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.phone; 18 19 import android.content.Context; 20 import android.provider.Settings; 21 import android.util.Log; 22 23 import com.android.internal.telephony.Phone; 24 25 /** 26 * TODO: This is intended as a temporary repository for behavior policy 27 * functions that depend upon the type of phone or the carrier. Ultimately 28 * these sorts of questions should be answered by the telephony layer. 29 */ 30 public class TelephonyCapabilities { 31 private static final String LOG_TAG = "TelephonyCapabilities"; 32 33 /** This class is never instantiated. */ 34 private TelephonyCapabilities() { 35 } 36 37 /** 38 * On GSM devices, we never use short tones. 39 * On CDMA devices, it depends upon the settings. 40 * TODO: I don't think this has anything to do with GSM versus CDMA, 41 * should we be looking only at the setting? 42 */ 43 /* package */ static boolean useShortDtmfTones(Phone phone, Context context) { 44 int phoneType = phone.getPhoneType(); 45 if (phoneType == Phone.PHONE_TYPE_GSM) { 46 return false; 47 } else if (phoneType == Phone.PHONE_TYPE_CDMA) { 48 int toneType = android.provider.Settings.System.getInt( 49 context.getContentResolver(), 50 Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 51 CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL); 52 if (toneType == CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL) { 53 return true; 54 } else { 55 return false; 56 } 57 } else if (phoneType == Phone.PHONE_TYPE_SIP) { 58 // TODO: confirm SipPhone supports this 59 return true; 60 } else { 61 throw new IllegalStateException("Unexpected phone type: " + phoneType); 62 } 63 } 64 65 /** 66 * Return true if the current phone supports ECM ("Emergency Callback 67 * Mode"), which is a feature where the device goes into a special 68 * state for a short period of time after making an outgoing emergency 69 * call. 70 * 71 * (On current devices, that state lasts 5 minutes. It prevents data 72 * usage by other apps, to avoid conflicts with any possible incoming 73 * calls. It also puts up a notification in the status bar, showing a 74 * countdown while ECM is active, and allowing the user to exit ECM.) 75 * 76 * Currently this is assumed to be true for CDMA phones, and false 77 * otherwise. 78 * 79 * TODO: This capability should really be exposed by the telephony 80 * layer, since it depends on the underlying telephony technology. 81 * (Or, is this actually carrier-specific? Is it VZW-only?) 82 */ 83 /* package */ static boolean supportsEcm(Phone phone) { 84 return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); 85 } 86 87 /** 88 * Return true if the current phone supports Over The Air Service 89 * Provisioning (OTASP) 90 * 91 * Currently this is assumed to be true for CDMA phones, and false 92 * otherwise. 93 * 94 * TODO: This capability should really be exposed by the telephony 95 * layer, since it depends on the underlying telephony technology. 96 * 97 * TODO: Watch out: this is also highly carrier-specific, since the 98 * OTA procedure is different from one carrier to the next, *and* the 99 * different carriers may want very different onscreen UI as well. 100 * The procedure may even be different for different devices with the 101 * same carrier. 102 * 103 * So we eventually will need a much more flexible, pluggable design. 104 * This method here is just a placeholder to reduce hardcoded 105 * "if (CDMA)" checks sprinkled throughout the rest of the phone app. 106 * 107 * TODO: consider using the term "OTASP" rather "OTA" everywhere in the 108 * phone app, since OTA can also mean over-the-air software updates. 109 */ 110 /* package */ static boolean supportsOtasp(Phone phone) { 111 return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); 112 } 113 114 /** 115 * Return true if the current phone can retrieve the voice message count. 116 * 117 * Currently this is assumed to be true on CDMA phones and false otherwise. 118 * 119 * TODO: This capability should really be exposed by the telephony 120 * layer, since it depends on the underlying telephony technology. 121 */ 122 /* package */ static boolean supportsVoiceMessageCount(Phone phone) { 123 return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); 124 } 125 126 /** 127 * Return true if this phone allows the user to select which 128 * network to use. 129 * 130 * Currently this is assumed to be true only on GSM phones. 131 * 132 * TODO: Should CDMA phones allow this as well? 133 */ 134 /* package */ static boolean supportsNetworkSelection(Phone phone) { 135 return (phone.getPhoneType() == Phone.PHONE_TYPE_GSM); 136 } 137 138 /** 139 * Returns a resource ID for a label to use when displaying the 140 * "device id" of the current device. (This is currently used as the 141 * title of the "device id" dialog.) 142 * 143 * This is specific to the device's telephony technology: the device 144 * id is called "IMEI" on GSM phones and "MEID" on CDMA phones. 145 * TODO: ultimately this name should come directly from the 146 * telephony layer. 147 */ 148 /* package */ static int getDeviceIdLabel(Phone phone) { 149 if (phone.getPhoneType() == Phone.PHONE_TYPE_GSM) { 150 return R.string.imei; 151 } else if (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { 152 return R.string.meid; 153 } else { 154 Log.w(LOG_TAG, "getDeviceIdLabel: no known label for phone " 155 + phone.getPhoneName()); 156 return 0; 157 } 158 } 159 160 /** 161 * Return true if the current phone supports the ability to explicitly 162 * manage the state of a conference call (i.e. view the participants, 163 * and hangup or separate individual callers.) 164 * 165 * The in-call screen's "Manage conference" UI is available only on 166 * devices that support this feature. 167 * 168 * Currently this is assumed to be true on GSM phones and false otherwise. 169 * TODO: This capability should really be exposed by the telephony 170 * layer, since it depends on the underlying telephony technology. 171 */ 172 /* package */ static boolean supportsConferenceCallManagement(Phone phone) { 173 return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) 174 || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); 175 } 176 177 /** 178 * Return true if the current phone supports explicit "Hold" and 179 * "Unhold" actions for an active call. (If so, the in-call UI will 180 * provide onscreen "Hold" / "Unhold" buttons.) 181 * 182 * Currently this is assumed to be true on GSM phones and false 183 * otherwise. (In particular, CDMA has no concept of "putting a call 184 * on hold.") 185 * TODO: This capability should really be exposed by the telephony 186 * layer, since it depends on the underlying telephony technology. 187 */ 188 /* package */ static boolean supportsHoldAndUnhold(Phone phone) { 189 return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) 190 || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); 191 } 192 193 /** 194 * Return true if the current phone supports distinct "Answer & Hold" 195 * and "Answer & End" behaviors in the call-waiting scenario. If so, 196 * the in-call UI may provide separate buttons or menu items for these 197 * two actions. 198 * 199 * Currently this is assumed to be true on GSM phones and false 200 * otherwise. (In particular, CDMA has no concept of explicitly 201 * managing the background call, or "putting a call on hold.") 202 * 203 * TODO: This capability should really be exposed by the telephony 204 * layer, since it depends on the underlying telephony technology. 205 * 206 * TODO: It might be better to expose this capability in a more 207 * generic form, like maybe "supportsExplicitMultipleLineManagement()" 208 * rather than focusing specifically on call-waiting behavior. 209 */ 210 /* package */ static boolean supportsAnswerAndHold(Phone phone) { 211 return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) 212 || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); 213 } 214 } 215