|
| 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.util.Log; |
| 20 | + |
| 21 | +import com.android.internal.telephony.Phone; |
| 22 | + |
| 23 | +/** |
| 24 | + * Utilities that check if the phone supports specified capabilities. |
| 25 | + */ |
| 26 | +public class TelephonyCapabilities { |
| 27 | + private static final String LOG_TAG = "TelephonyCapabilities"; |
| 28 | + |
| 29 | + /** This class is never instantiated. */ |
| 30 | + private TelephonyCapabilities() { |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 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 |
| 37 | + * call. |
| 38 | + * |
| 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.) |
| 43 | + * |
| 44 | + * Currently this is assumed to be true for CDMA phones, and false |
| 45 | + * otherwise. |
| 46 | + */ |
| 47 | + public static boolean supportsEcm(Phone phone) { |
| 48 | + return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Return true if the current phone supports Over The Air Service |
| 53 | + * Provisioning (OTASP) |
| 54 | + * |
| 55 | + * Currently this is assumed to be true for CDMA phones, and false |
| 56 | + * otherwise. |
| 57 | + * |
| 58 | + * TODO: Watch out: this is also highly carrier-specific, since the |
| 59 | + * OTASP procedure is different from one carrier to the next, *and* the |
| 60 | + * different carriers may want very different onscreen UI as well. |
| 61 | + * The procedure may even be different for different devices with the |
| 62 | + * same carrier. |
| 63 | + * |
| 64 | + * So we eventually will need a much more flexible, pluggable design. |
| 65 | + * This method here is just a placeholder to reduce hardcoded |
| 66 | + * "if (CDMA)" checks sprinkled throughout the phone app. |
| 67 | + */ |
| 68 | + public static boolean supportsOtasp(Phone phone) { |
| 69 | + return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Return true if the current phone can retrieve the voice message count. |
| 74 | + * |
| 75 | + * Currently this is assumed to be true on CDMA phones and false otherwise. |
| 76 | + */ |
| 77 | + public static boolean supportsVoiceMessageCount(Phone phone) { |
| 78 | + return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Return true if this phone allows the user to select which |
| 83 | + * network to use. |
| 84 | + * |
| 85 | + * Currently this is assumed to be true only on GSM phones. |
| 86 | + * |
| 87 | + * TODO: Should CDMA phones allow this as well? |
| 88 | + */ |
| 89 | + public static boolean supportsNetworkSelection(Phone phone) { |
| 90 | + return (phone.getPhoneType() == Phone.PHONE_TYPE_GSM); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Returns a resource ID for a label to use when displaying the |
| 95 | + * "device id" of the current device. (This is currently used as the |
| 96 | + * title of the "device id" dialog.) |
| 97 | + * |
| 98 | + * This is specific to the device's telephony technology: the device |
| 99 | + * id is called "IMEI" on GSM phones and "MEID" on CDMA phones. |
| 100 | + */ |
| 101 | + public static int getDeviceIdLabel(Phone phone) { |
| 102 | + if (phone.getPhoneType() == Phone.PHONE_TYPE_GSM) { |
| 103 | + return com.android.internal.R.string.imei; |
| 104 | + } else if (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { |
| 105 | + return com.android.internal.R.string.meid; |
| 106 | + } else { |
| 107 | + Log.w(LOG_TAG, "getDeviceIdLabel: no known label for phone " |
| 108 | + + phone.getPhoneName()); |
| 109 | + return 0; |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Return true if the current phone supports the ability to explicitly |
| 115 | + * manage the state of a conference call (i.e. view the participants, |
| 116 | + * and hangup or separate individual callers.) |
| 117 | + * |
| 118 | + * The in-call screen's "Manage conference" UI is available only on |
| 119 | + * devices that support this feature. |
| 120 | + * |
| 121 | + * Currently this is assumed to be true on GSM phones and false otherwise. |
| 122 | + */ |
| 123 | + public static boolean supportsConferenceCallManagement(Phone phone) { |
| 124 | + return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) |
| 125 | + || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Return true if the current phone supports explicit "Hold" and |
| 130 | + * "Unhold" actions for an active call. (If so, the in-call UI will |
| 131 | + * provide onscreen "Hold" / "Unhold" buttons.) |
| 132 | + * |
| 133 | + * Currently this is assumed to be true on GSM phones and false |
| 134 | + * otherwise. (In particular, CDMA has no concept of "putting a call |
| 135 | + * on hold.") |
| 136 | + */ |
| 137 | + public static boolean supportsHoldAndUnhold(Phone phone) { |
| 138 | + return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) |
| 139 | + || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Return true if the current phone supports distinct "Answer & Hold" |
| 144 | + * and "Answer & End" behaviors in the call-waiting scenario. If so, |
| 145 | + * the in-call UI may provide separate buttons or menu items for these |
| 146 | + * two actions. |
| 147 | + * |
| 148 | + * Currently this is assumed to be true on GSM phones and false |
| 149 | + * otherwise. (In particular, CDMA has no concept of explicitly |
| 150 | + * managing the background call, or "putting a call on hold.") |
| 151 | + * |
| 152 | + * TODO: It might be better to expose this capability in a more |
| 153 | + * generic form, like maybe "supportsExplicitMultipleLineManagement()" |
| 154 | + * rather than focusing specifically on call-waiting behavior. |
| 155 | + */ |
| 156 | + public static boolean supportsAnswerAndHold(Phone phone) { |
| 157 | + return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) |
| 158 | + || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); |
| 159 | + } |
| 160 | +} |
0 commit comments