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.internal.telephony; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.os.Build; 21 22 import com.android.telephony.Rlog; 23 24 /** 25 * Utilities that check if the phone supports specified capabilities. 26 */ 27 public class TelephonyCapabilities { 28 private static final String LOG_TAG = "TelephonyCapabilities"; 29 30 /** This class is never instantiated. */ TelephonyCapabilities()31 private TelephonyCapabilities() { 32 } 33 34 /** 35 * Return true if the current phone supports ECM ("Emergency Callback 36 * Mode"), which is a feature where the device goes into a special 37 * state for a short period of time after making an outgoing emergency 38 * call. 39 * 40 * (On current devices, that state lasts 5 minutes. It prevents data 41 * usage by other apps, to avoid conflicts with any possible incoming 42 * calls. It also puts up a notification in the status bar, showing a 43 * countdown while ECM is active, and allowing the user to exit ECM.) 44 * 45 * Currently this is assumed to be true for CDMA phones, and false 46 * otherwise. 47 */ supportsEcm(Phone phone)48 public static boolean supportsEcm(Phone phone) { 49 Rlog.d(LOG_TAG, "supportsEcm: Phone type = " + phone.getPhoneType() + 50 " Ims Phone = " + phone.getImsPhone()); 51 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA || 52 phone.getImsPhone() != null); 53 } 54 55 /** 56 * Return true if the current phone supports Over The Air Service 57 * Provisioning (OTASP) 58 * 59 * Currently this is assumed to be true for CDMA phones, and false 60 * otherwise. 61 * 62 * TODO: Watch out: this is also highly carrier-specific, since the 63 * OTASP procedure is different from one carrier to the next, *and* the 64 * different carriers may want very different onscreen UI as well. 65 * The procedure may even be different for different devices with the 66 * same carrier. 67 * 68 * So we eventually will need a much more flexible, pluggable design. 69 * This method here is just a placeholder to reduce hardcoded 70 * "if (CDMA)" checks sprinkled throughout the phone app. 71 */ supportsOtasp(Phone phone)72 public static boolean supportsOtasp(Phone phone) { 73 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA); 74 } 75 76 /** 77 * Return true if the current phone supports voice message count. 78 * and the count is available 79 * Both CDMA and GSM phones support voice message count 80 */ supportsVoiceMessageCount(Phone phone)81 public static boolean supportsVoiceMessageCount(Phone phone) { 82 return (phone.getVoiceMessageCount() != -1); 83 } 84 85 /** 86 * Return true if this phone allows the user to select which 87 * network to use. 88 * 89 * Currently this is assumed to be true only on GSM phones. 90 * 91 * TODO: Should CDMA phones allow this as well? 92 */ supportsNetworkSelection(Phone phone)93 public static boolean supportsNetworkSelection(Phone phone) { 94 return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM); 95 } 96 97 /** 98 * Returns a resource ID for a label to use when displaying the 99 * "device id" of the current device. (This is currently used as the 100 * title of the "device id" dialog.) 101 * 102 * This is specific to the device's telephony technology: the device 103 * id is called "IMEI" on GSM phones and "MEID" on CDMA phones. 104 */ getDeviceIdLabel(Phone phone)105 public static int getDeviceIdLabel(Phone phone) { 106 if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) { 107 return com.android.internal.R.string.imei; 108 } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { 109 return com.android.internal.R.string.meid; 110 } else { 111 Rlog.w(LOG_TAG, "getDeviceIdLabel: no known label for phone " 112 + phone.getPhoneName()); 113 return 0; 114 } 115 } 116 117 /** 118 * Return true if the current phone supports the ability to explicitly 119 * manage the state of a conference call (i.e. view the participants, 120 * and hangup or separate individual callers.) 121 * 122 * The in-call screen's "Manage conference" UI is available only on 123 * devices that support this feature. 124 * 125 * Currently this is assumed to be true on GSM phones and false otherwise. 126 */ supportsConferenceCallManagement(Phone phone)127 public static boolean supportsConferenceCallManagement(Phone phone) { 128 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) 129 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP)); 130 } 131 132 /** 133 * Return true if the current phone supports explicit "Hold" and 134 * "Unhold" actions for an active call. (If so, the in-call UI will 135 * provide onscreen "Hold" / "Unhold" buttons.) 136 * 137 * Currently this is assumed to be true on GSM phones and false 138 * otherwise. (In particular, CDMA has no concept of "putting a call 139 * on hold.") 140 */ supportsHoldAndUnhold(Phone phone)141 public static boolean supportsHoldAndUnhold(Phone phone) { 142 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) 143 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP) 144 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS)); 145 } 146 147 /** 148 * Return true if the current phone supports distinct "Answer & Hold" 149 * and "Answer & End" behaviors in the call-waiting scenario. If so, 150 * the in-call UI may provide separate buttons or menu items for these 151 * two actions. 152 * 153 * Currently this is assumed to be true on GSM phones and false 154 * otherwise. (In particular, CDMA has no concept of explicitly 155 * managing the background call, or "putting a call on hold.") 156 * 157 * TODO: It might be better to expose this capability in a more 158 * generic form, like maybe "supportsExplicitMultipleLineManagement()" 159 * rather than focusing specifically on call-waiting behavior. 160 */ supportsAnswerAndHold(Phone phone)161 public static boolean supportsAnswerAndHold(Phone phone) { 162 return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) 163 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP)); 164 } 165 166 /** 167 * Return true if phones with the given phone type support ADN 168 * (Abbreviated Dialing Numbers). 169 * 170 * Currently this returns true when the phone type is GSM 171 * ({@link PhoneConstants#PHONE_TYPE_GSM}). 172 * 173 * This is using int for an argument for letting apps outside 174 * Phone process access to it, while other methods in this class is 175 * using Phone object. 176 * 177 * TODO: Theoretically phones other than GSM may have the ADN capability. 178 * Consider having better check here, or have better capability as part 179 * of public API, with which the argument should be replaced with 180 * something more appropriate. 181 */ 182 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) supportsAdn(int phoneType)183 public static boolean supportsAdn(int phoneType) { 184 return phoneType == PhoneConstants.PHONE_TYPE_GSM; 185 } 186 187 /** 188 * Returns true if the device can distinguish the phone's dialing state 189 * (Call.State.DIALING/ALERTING) and connected state (Call.State.ACTIVE). 190 * 191 * Currently this returns true for GSM phones as we cannot know when a CDMA 192 * phone has transitioned from dialing/active to connected. 193 */ canDistinguishDialingAndConnected(int phoneType)194 public static boolean canDistinguishDialingAndConnected(int phoneType) { 195 return phoneType == PhoneConstants.PHONE_TYPE_GSM; 196 } 197 } 198