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