Home | History | Annotate | Download | only in telephony
      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.telephony.Rlog;
     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         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);
     52     }
     53 
     54     /**
     55      * Return true if the current phone supports Over The Air Service
     56      * Provisioning (OTASP)
     57      *
     58      * Currently this is assumed to be true for CDMA phones, and false
     59      * otherwise.
     60      *
     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
     65      * same carrier.
     66      *
     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.
     70      */
     71     public static boolean supportsOtasp(Phone phone) {
     72         return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
     73     }
     74 
     75     /**
     76      * Return true if the current phone supports voice message count.
     77      * and the count is available
     78      * Both CDMA and GSM phones support voice message count
     79      */
     80     public static boolean supportsVoiceMessageCount(Phone phone) {
     81         return (phone.getVoiceMessageCount() != -1);
     82     }
     83 
     84     /**
     85      * Return true if this phone allows the user to select which
     86      * network to use.
     87      *
     88      * Currently this is assumed to be true only on GSM phones.
     89      *
     90      * TODO: Should CDMA phones allow this as well?
     91      */
     92     public static boolean supportsNetworkSelection(Phone phone) {
     93         return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM);
     94     }
     95 
     96     /**
     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.)
    100      *
    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.
    103      */
    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;
    109         } else {
    110             Rlog.w(LOG_TAG, "getDeviceIdLabel: no known label for phone "
    111                   + phone.getPhoneName());
    112             return 0;
    113         }
    114     }
    115 
    116     /**
    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.)
    120      *
    121      * The in-call screen's "Manage conference" UI is available only on
    122      * devices that support this feature.
    123      *
    124      * Currently this is assumed to be true on GSM phones and false otherwise.
    125      */
    126     public static boolean supportsConferenceCallManagement(Phone phone) {
    127         return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)
    128                 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP));
    129     }
    130 
    131     /**
    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.)
    135      *
    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
    138      * on hold.")
    139      */
    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));
    144     }
    145 
    146     /**
    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
    150      * two actions.
    151      *
    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.")
    155      *
    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.
    159      */
    160     public static boolean supportsAnswerAndHold(Phone phone) {
    161         return ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)
    162                 || (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP));
    163     }
    164 
    165     /**
    166      * Return true if phones with the given phone type support ADN
    167      * (Abbreviated Dialing Numbers).
    168      *
    169      * Currently this returns true when the phone type is GSM
    170      * ({@link PhoneConstants#PHONE_TYPE_GSM}).
    171      *
    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.
    175      *
    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.
    180      */
    181     public static boolean supportsAdn(int phoneType) {
    182         return phoneType == PhoneConstants.PHONE_TYPE_GSM;
    183     }
    184 
    185     /**
    186      * Returns true if the device can distinguish the phone's dialing state
    187      * (Call.State.DIALING/ALERTING) and connected state (Call.State.ACTIVE).
    188      *
    189      * Currently this returns true for GSM phones as we cannot know when a CDMA
    190      * phone has transitioned from dialing/active to connected.
    191      */
    192     public static boolean canDistinguishDialingAndConnected(int phoneType) {
    193         return phoneType == PhoneConstants.PHONE_TYPE_GSM;
    194     }
    195 }
    196