2009-03-03 19:31:44 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package android.telephony;
|
|
|
|
|
|
|
|
import android.annotation.SdkConstant;
|
2009-05-15 12:05:56 -07:00
|
|
|
import android.annotation.SdkConstant.SdkConstantType;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.RemoteException;
|
|
|
|
import android.os.ServiceManager;
|
|
|
|
import android.os.SystemProperties;
|
2012-07-10 12:37:54 -07:00
|
|
|
import android.util.Log;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
import com.android.internal.telephony.IPhoneSubInfo;
|
|
|
|
import com.android.internal.telephony.ITelephony;
|
|
|
|
import com.android.internal.telephony.ITelephonyRegistry;
|
2012-07-10 12:37:54 -07:00
|
|
|
import com.android.internal.telephony.PhoneConstants;
|
|
|
|
import com.android.internal.telephony.RILConstants;
|
2009-04-02 01:37:02 -07:00
|
|
|
import com.android.internal.telephony.TelephonyProperties;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2012-07-10 12:37:54 -07:00
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.IOException;
|
2009-05-15 12:05:56 -07:00
|
|
|
import java.util.List;
|
2012-07-10 12:37:54 -07:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2009-05-15 12:05:56 -07:00
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
/**
|
|
|
|
* Provides access to information about the telephony services on
|
|
|
|
* the device. Applications can use the methods in this class to
|
|
|
|
* determine telephony services and states, as well as to access some
|
2009-04-02 01:37:02 -07:00
|
|
|
* types of subscriber information. Applications can also register
|
|
|
|
* a listener to receive notification of telephony state changes.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
|
|
|
* You do not instantiate this class directly; instead, you retrieve
|
2009-04-02 01:37:02 -07:00
|
|
|
* a reference to an instance through
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.content.Context#getSystemService
|
|
|
|
* Context.getSystemService(Context.TELEPHONY_SERVICE)}.
|
|
|
|
* <p>
|
2010-03-19 14:47:29 -07:00
|
|
|
* Note that access to some telephony information is
|
2009-04-02 01:37:02 -07:00
|
|
|
* permission-protected. Your application cannot access the protected
|
|
|
|
* information unless it has the appropriate permissions declared in
|
|
|
|
* its manifest file. Where permissions apply, they are noted in the
|
|
|
|
* the methods through which you access the protected information.
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public class TelephonyManager {
|
|
|
|
private static final String TAG = "TelephonyManager";
|
|
|
|
|
2011-02-02 08:33:11 -08:00
|
|
|
private static Context sContext;
|
|
|
|
private static ITelephonyRegistry sRegistry;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/** @hide */
|
|
|
|
public TelephonyManager(Context context) {
|
2011-02-02 08:33:11 -08:00
|
|
|
if (sContext == null) {
|
2011-11-16 11:19:50 -08:00
|
|
|
Context appContext = context.getApplicationContext();
|
|
|
|
if (appContext != null) {
|
|
|
|
sContext = appContext;
|
|
|
|
} else {
|
|
|
|
sContext = context;
|
|
|
|
}
|
2011-02-02 08:33:11 -08:00
|
|
|
|
|
|
|
sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
|
2009-03-03 19:31:44 -08:00
|
|
|
"telephony.registry"));
|
2011-02-02 08:33:11 -08:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @hide */
|
|
|
|
private TelephonyManager() {
|
|
|
|
}
|
|
|
|
|
|
|
|
private static TelephonyManager sInstance = new TelephonyManager();
|
|
|
|
|
2011-02-02 08:33:11 -08:00
|
|
|
/** @hide
|
|
|
|
/* @deprecated - use getSystemService as described above */
|
2009-03-03 19:31:44 -08:00
|
|
|
public static TelephonyManager getDefault() {
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
2012-04-04 20:40:58 -07:00
|
|
|
/** {@hide} */
|
|
|
|
public static TelephonyManager from(Context context) {
|
|
|
|
return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Broadcast Intent actions
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Broadcast intent action indicating that the call state (cellular)
|
|
|
|
* on the device has changed.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* The {@link #EXTRA_STATE} extra indicates the new call state.
|
|
|
|
* If the new state is RINGING, a second extra
|
|
|
|
* {@link #EXTRA_INCOMING_NUMBER} provides the incoming phone number as
|
|
|
|
* a String.
|
|
|
|
*
|
|
|
|
* <p class="note">
|
|
|
|
* Requires the READ_PHONE_STATE permission.
|
|
|
|
*
|
|
|
|
* <p class="note">
|
|
|
|
* This was a {@link android.content.Context#sendStickyBroadcast sticky}
|
|
|
|
* broadcast in version 1.0, but it is no longer sticky.
|
|
|
|
* Instead, use {@link #getCallState} to synchronously query the current call state.
|
|
|
|
*
|
|
|
|
* @see #EXTRA_STATE
|
|
|
|
* @see #EXTRA_INCOMING_NUMBER
|
|
|
|
* @see #getCallState
|
|
|
|
*/
|
|
|
|
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
|
|
|
public static final String ACTION_PHONE_STATE_CHANGED =
|
|
|
|
"android.intent.action.PHONE_STATE";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast
|
|
|
|
* for a String containing the new call state.
|
|
|
|
*
|
|
|
|
* @see #EXTRA_STATE_IDLE
|
|
|
|
* @see #EXTRA_STATE_RINGING
|
|
|
|
* @see #EXTRA_STATE_OFFHOOK
|
|
|
|
*
|
|
|
|
* <p class="note">
|
|
|
|
* Retrieve with
|
|
|
|
* {@link android.content.Intent#getStringExtra(String)}.
|
|
|
|
*/
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final String EXTRA_STATE = PhoneConstants.STATE_KEY;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Value used with {@link #EXTRA_STATE} corresponding to
|
|
|
|
* {@link #CALL_STATE_IDLE}.
|
|
|
|
*/
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final String EXTRA_STATE_IDLE = PhoneConstants.State.IDLE.toString();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Value used with {@link #EXTRA_STATE} corresponding to
|
|
|
|
* {@link #CALL_STATE_RINGING}.
|
|
|
|
*/
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final String EXTRA_STATE_RINGING = PhoneConstants.State.RINGING.toString();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Value used with {@link #EXTRA_STATE} corresponding to
|
|
|
|
* {@link #CALL_STATE_OFFHOOK}.
|
|
|
|
*/
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final String EXTRA_STATE_OFFHOOK = PhoneConstants.State.OFFHOOK.toString();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast
|
|
|
|
* for a String containing the incoming phone number.
|
|
|
|
* Only valid when the new call state is RINGING.
|
|
|
|
*
|
|
|
|
* <p class="note">
|
|
|
|
* Retrieve with
|
|
|
|
* {@link android.content.Intent#getStringExtra(String)}.
|
|
|
|
*/
|
|
|
|
public static final String EXTRA_INCOMING_NUMBER = "incoming_number";
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Device Info
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Returns the software version number for the device, for example,
|
2009-09-11 14:49:47 -07:00
|
|
|
* the IMEI/SV for GSM phones. Return null if the software version is
|
|
|
|
* not available.
|
2009-03-03 19:31:44 -08:00
|
|
|
*
|
2009-04-02 01:37:02 -07:00
|
|
|
* <p>Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getDeviceSoftwareVersion() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getDeviceSvn();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-09-11 14:49:47 -07:00
|
|
|
* Returns the unique device ID, for example, the IMEI for GSM and the MEID
|
2010-08-20 16:24:02 -07:00
|
|
|
* or ESN for CDMA phones. Return null if device ID is not available.
|
2009-03-03 19:31:44 -08:00
|
|
|
*
|
2009-04-02 01:37:02 -07:00
|
|
|
* <p>Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getDeviceId() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getDeviceId();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current location of the device.
|
2009-09-11 14:49:47 -07:00
|
|
|
* Return null if current location is not available.
|
2009-03-03 19:31:44 -08:00
|
|
|
*
|
2009-05-19 09:14:41 -04:00
|
|
|
* <p>Requires Permission:
|
|
|
|
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
|
|
|
|
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION}.
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public CellLocation getCellLocation() {
|
|
|
|
try {
|
|
|
|
Bundle bundle = getITelephony().getCellLocation();
|
2010-03-09 15:48:58 -08:00
|
|
|
CellLocation cl = CellLocation.newFromBundle(bundle);
|
|
|
|
if (cl.isEmpty())
|
|
|
|
return null;
|
|
|
|
return cl;
|
2009-03-03 19:31:44 -08:00
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables location update notifications. {@link PhoneStateListener#onCellLocationChanged
|
|
|
|
* PhoneStateListener.onCellLocationChanged} will be called on location updates.
|
|
|
|
*
|
2009-04-02 01:37:02 -07:00
|
|
|
* <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES
|
2009-03-03 19:31:44 -08:00
|
|
|
* CONTROL_LOCATION_UPDATES}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public void enableLocationUpdates() {
|
|
|
|
try {
|
|
|
|
getITelephony().enableLocationUpdates();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables location update notifications. {@link PhoneStateListener#onCellLocationChanged
|
|
|
|
* PhoneStateListener.onCellLocationChanged} will be called on location updates.
|
|
|
|
*
|
|
|
|
* <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES
|
|
|
|
* CONTROL_LOCATION_UPDATES}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public void disableLocationUpdates() {
|
|
|
|
try {
|
|
|
|
getITelephony().disableLocationUpdates();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the neighboring cell information of the device.
|
2009-05-15 12:05:56 -07:00
|
|
|
*
|
2009-03-03 19:31:44 -08:00
|
|
|
* @return List of NeighboringCellInfo or null if info unavailable.
|
2009-05-15 12:05:56 -07:00
|
|
|
*
|
|
|
|
* <p>Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
|
|
|
|
*/
|
|
|
|
public List<NeighboringCellInfo> getNeighboringCellInfo() {
|
2009-09-11 19:17:29 -07:00
|
|
|
try {
|
|
|
|
return getITelephony().getNeighboringCellInfo();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2009-05-15 12:05:56 -07:00
|
|
|
|
2009-09-21 15:26:10 +08:00
|
|
|
/** No phone radio. */
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final int PHONE_TYPE_NONE = PhoneConstants.PHONE_TYPE_NONE;
|
2009-09-21 15:26:10 +08:00
|
|
|
/** Phone radio is GSM. */
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final int PHONE_TYPE_GSM = PhoneConstants.PHONE_TYPE_GSM;
|
2009-09-21 15:26:10 +08:00
|
|
|
/** Phone radio is CDMA. */
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final int PHONE_TYPE_CDMA = PhoneConstants.PHONE_TYPE_CDMA;
|
2010-11-02 11:10:25 -07:00
|
|
|
/** Phone is via SIP. */
|
2012-07-10 12:37:54 -07:00
|
|
|
public static final int PHONE_TYPE_SIP = PhoneConstants.PHONE_TYPE_SIP;
|
2009-04-02 01:37:02 -07:00
|
|
|
|
|
|
|
/**
|
2011-02-01 19:22:15 -08:00
|
|
|
* Returns the current phone type.
|
|
|
|
* TODO: This is a last minute change and hence hidden.
|
2009-04-02 01:37:02 -07:00
|
|
|
*
|
2009-03-03 19:31:44 -08:00
|
|
|
* @see #PHONE_TYPE_NONE
|
|
|
|
* @see #PHONE_TYPE_GSM
|
2009-04-02 01:37:02 -07:00
|
|
|
* @see #PHONE_TYPE_CDMA
|
2010-11-02 11:10:25 -07:00
|
|
|
* @see #PHONE_TYPE_SIP
|
2011-02-01 19:22:15 -08:00
|
|
|
*
|
|
|
|
* {@hide}
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
2011-02-01 19:22:15 -08:00
|
|
|
public int getCurrentPhoneType() {
|
2009-04-02 01:37:02 -07:00
|
|
|
try{
|
2009-05-15 12:05:56 -07:00
|
|
|
ITelephony telephony = getITelephony();
|
|
|
|
if (telephony != null) {
|
2009-09-21 15:26:10 +08:00
|
|
|
return telephony.getActivePhoneType();
|
2009-04-02 01:37:02 -07:00
|
|
|
} else {
|
2009-05-15 12:05:56 -07:00
|
|
|
// This can happen when the ITelephony interface is not up yet.
|
|
|
|
return getPhoneTypeFromProperty();
|
2009-04-02 01:37:02 -07:00
|
|
|
}
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// This shouldn't happen in the normal case, as a backup we
|
|
|
|
// read from the system property.
|
|
|
|
return getPhoneTypeFromProperty();
|
|
|
|
} catch (NullPointerException ex) {
|
2009-05-15 12:05:56 -07:00
|
|
|
// This shouldn't happen in the normal case, as a backup we
|
|
|
|
// read from the system property.
|
|
|
|
return getPhoneTypeFromProperty();
|
2009-04-02 01:37:02 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-02-01 19:22:15 -08:00
|
|
|
/**
|
|
|
|
* Returns a constant indicating the device phone type. This
|
|
|
|
* indicates the type of radio used to transmit voice calls.
|
|
|
|
*
|
|
|
|
* @see #PHONE_TYPE_NONE
|
|
|
|
* @see #PHONE_TYPE_GSM
|
|
|
|
* @see #PHONE_TYPE_CDMA
|
|
|
|
* @see #PHONE_TYPE_SIP
|
|
|
|
*/
|
|
|
|
public int getPhoneType() {
|
|
|
|
if (!isVoiceCapable()) {
|
|
|
|
return PHONE_TYPE_NONE;
|
|
|
|
}
|
|
|
|
return getCurrentPhoneType();
|
|
|
|
}
|
2009-05-15 12:05:56 -07:00
|
|
|
|
|
|
|
private int getPhoneTypeFromProperty() {
|
|
|
|
int type =
|
|
|
|
SystemProperties.getInt(TelephonyProperties.CURRENT_ACTIVE_PHONE,
|
|
|
|
getPhoneTypeFromNetworkType());
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getPhoneTypeFromNetworkType() {
|
|
|
|
// When the system property CURRENT_ACTIVE_PHONE, has not been set,
|
|
|
|
// use the system property for default network type.
|
|
|
|
// This is a fail safe, and can only happen at first boot.
|
|
|
|
int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
|
|
|
|
if (mode == -1)
|
|
|
|
return PHONE_TYPE_NONE;
|
2012-07-10 12:37:54 -07:00
|
|
|
return getPhoneType(mode);
|
2009-05-15 12:05:56 -07:00
|
|
|
}
|
2012-07-10 12:37:54 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function returns the type of the phone, depending
|
|
|
|
* on the network mode.
|
|
|
|
*
|
|
|
|
* @param network mode
|
|
|
|
* @return Phone Type
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public static int getPhoneType(int networkMode) {
|
|
|
|
switch(networkMode) {
|
|
|
|
case RILConstants.NETWORK_MODE_CDMA:
|
|
|
|
case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
|
|
|
|
case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
|
|
|
|
return PhoneConstants.PHONE_TYPE_CDMA;
|
|
|
|
|
|
|
|
case RILConstants.NETWORK_MODE_WCDMA_PREF:
|
|
|
|
case RILConstants.NETWORK_MODE_GSM_ONLY:
|
|
|
|
case RILConstants.NETWORK_MODE_WCDMA_ONLY:
|
|
|
|
case RILConstants.NETWORK_MODE_GSM_UMTS:
|
|
|
|
return PhoneConstants.PHONE_TYPE_GSM;
|
|
|
|
|
|
|
|
// Use CDMA Phone for the global mode including CDMA
|
|
|
|
case RILConstants.NETWORK_MODE_GLOBAL:
|
|
|
|
case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO:
|
|
|
|
case RILConstants.NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA:
|
|
|
|
return PhoneConstants.PHONE_TYPE_CDMA;
|
|
|
|
|
|
|
|
case RILConstants.NETWORK_MODE_LTE_ONLY:
|
|
|
|
if (getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) {
|
|
|
|
return PhoneConstants.PHONE_TYPE_CDMA;
|
|
|
|
} else {
|
|
|
|
return PhoneConstants.PHONE_TYPE_GSM;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return PhoneConstants.PHONE_TYPE_GSM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The contents of the /proc/cmdline file
|
|
|
|
*/
|
|
|
|
private static String getProcCmdLine()
|
|
|
|
{
|
|
|
|
String cmdline = "";
|
|
|
|
FileInputStream is = null;
|
|
|
|
try {
|
|
|
|
is = new FileInputStream("/proc/cmdline");
|
|
|
|
byte [] buffer = new byte[2048];
|
|
|
|
int count = is.read(buffer);
|
|
|
|
if (count > 0) {
|
|
|
|
cmdline = new String(buffer, 0, count);
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.d(TAG, "No /proc/cmdline exception=" + e);
|
|
|
|
} finally {
|
|
|
|
if (is != null) {
|
|
|
|
try {
|
|
|
|
is.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log.d(TAG, "/proc/cmdline=" + cmdline);
|
|
|
|
return cmdline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Kernel command line */
|
|
|
|
private static final String sKernelCmdLine = getProcCmdLine();
|
|
|
|
|
|
|
|
/** Pattern for selecting the product type from the kernel command line */
|
|
|
|
private static final Pattern sProductTypePattern =
|
|
|
|
Pattern.compile("\\sproduct_type\\s*=\\s*(\\w+)");
|
|
|
|
|
|
|
|
/** The ProductType used for LTE on CDMA devices */
|
|
|
|
private static final String sLteOnCdmaProductType =
|
|
|
|
SystemProperties.get(TelephonyProperties.PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE, "");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return if the current radio is LTE on CDMA. This
|
|
|
|
* is a tri-state return value as for a period of time
|
|
|
|
* the mode may be unknown.
|
|
|
|
*
|
|
|
|
* @return {@link PhoneConstants#LTE_ON_CDMA_UNKNOWN}, {@link PhoneConstants#LTE_ON_CDMA_FALSE}
|
|
|
|
* or {@link PhoneConstants#LTE_ON_CDMA_TRUE}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public static int getLteOnCdmaModeStatic() {
|
|
|
|
int retVal;
|
|
|
|
int curVal;
|
|
|
|
String productType = "";
|
|
|
|
|
|
|
|
curVal = SystemProperties.getInt(TelephonyProperties.PROPERTY_LTE_ON_CDMA_DEVICE,
|
|
|
|
PhoneConstants.LTE_ON_CDMA_UNKNOWN);
|
|
|
|
retVal = curVal;
|
|
|
|
if (retVal == PhoneConstants.LTE_ON_CDMA_UNKNOWN) {
|
|
|
|
Matcher matcher = sProductTypePattern.matcher(sKernelCmdLine);
|
|
|
|
if (matcher.find()) {
|
|
|
|
productType = matcher.group(1);
|
|
|
|
if (sLteOnCdmaProductType.equals(productType)) {
|
|
|
|
retVal = PhoneConstants.LTE_ON_CDMA_TRUE;
|
|
|
|
} else {
|
|
|
|
retVal = PhoneConstants.LTE_ON_CDMA_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
retVal = PhoneConstants.LTE_ON_CDMA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log.d(TAG, "getLteOnCdmaMode=" + retVal + " curVal=" + curVal +
|
|
|
|
" product_type='" + productType +
|
|
|
|
"' lteOnCdmaProductType='" + sLteOnCdmaProductType + "'");
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
//
|
2009-04-02 01:37:02 -07:00
|
|
|
//
|
2009-03-03 19:31:44 -08:00
|
|
|
// Current Network
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2009-03-03 19:31:44 -08:00
|
|
|
* Returns the alphabetic name of current registered operator.
|
|
|
|
* <p>
|
2009-07-13 12:36:04 -07:00
|
|
|
* Availability: Only when user is registered to a network. Result may be
|
|
|
|
* unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
|
|
|
|
* on a CDMA network).
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public String getNetworkOperatorName() {
|
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ALPHA);
|
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2009-03-03 19:31:44 -08:00
|
|
|
* Returns the numeric name (MCC+MNC) of current registered operator.
|
|
|
|
* <p>
|
2009-07-13 12:36:04 -07:00
|
|
|
* Availability: Only when user is registered to a network. Result may be
|
|
|
|
* unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
|
|
|
|
* on a CDMA network).
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public String getNetworkOperator() {
|
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC);
|
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2009-03-03 19:31:44 -08:00
|
|
|
* Returns true if the device is considered roaming on the current
|
|
|
|
* network, for GSM purposes.
|
|
|
|
* <p>
|
2009-07-13 12:36:04 -07:00
|
|
|
* Availability: Only when user registered to a network.
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public boolean isNetworkRoaming() {
|
|
|
|
return "true".equals(SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING));
|
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2010-03-19 14:47:29 -07:00
|
|
|
* Returns the ISO country code equivalent of the current registered
|
2009-03-03 19:31:44 -08:00
|
|
|
* operator's MCC (Mobile Country Code).
|
|
|
|
* <p>
|
2009-07-13 12:36:04 -07:00
|
|
|
* Availability: Only when user is registered to a network. Result may be
|
|
|
|
* unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
|
|
|
|
* on a CDMA network).
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public String getNetworkCountryIso() {
|
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Network type is unknown */
|
|
|
|
public static final int NETWORK_TYPE_UNKNOWN = 0;
|
|
|
|
/** Current network is GPRS */
|
|
|
|
public static final int NETWORK_TYPE_GPRS = 1;
|
|
|
|
/** Current network is EDGE */
|
|
|
|
public static final int NETWORK_TYPE_EDGE = 2;
|
|
|
|
/** Current network is UMTS */
|
|
|
|
public static final int NETWORK_TYPE_UMTS = 3;
|
2009-04-02 01:37:02 -07:00
|
|
|
/** Current network is CDMA: Either IS95A or IS95B*/
|
|
|
|
public static final int NETWORK_TYPE_CDMA = 4;
|
2009-09-25 14:32:18 -07:00
|
|
|
/** Current network is EVDO revision 0*/
|
2009-04-02 01:37:02 -07:00
|
|
|
public static final int NETWORK_TYPE_EVDO_0 = 5;
|
2009-09-25 14:32:18 -07:00
|
|
|
/** Current network is EVDO revision A*/
|
2009-04-02 01:37:02 -07:00
|
|
|
public static final int NETWORK_TYPE_EVDO_A = 6;
|
|
|
|
/** Current network is 1xRTT*/
|
|
|
|
public static final int NETWORK_TYPE_1xRTT = 7;
|
2009-08-14 19:22:16 +08:00
|
|
|
/** Current network is HSDPA */
|
|
|
|
public static final int NETWORK_TYPE_HSDPA = 8;
|
|
|
|
/** Current network is HSUPA */
|
|
|
|
public static final int NETWORK_TYPE_HSUPA = 9;
|
|
|
|
/** Current network is HSPA */
|
|
|
|
public static final int NETWORK_TYPE_HSPA = 10;
|
2010-03-11 15:04:43 -08:00
|
|
|
/** Current network is iDen */
|
|
|
|
public static final int NETWORK_TYPE_IDEN = 11;
|
2010-04-21 14:48:03 -07:00
|
|
|
/** Current network is EVDO revision B*/
|
|
|
|
public static final int NETWORK_TYPE_EVDO_B = 12;
|
2010-11-02 11:10:25 -07:00
|
|
|
/** Current network is LTE */
|
|
|
|
public static final int NETWORK_TYPE_LTE = 13;
|
|
|
|
/** Current network is eHRPD */
|
|
|
|
public static final int NETWORK_TYPE_EHRPD = 14;
|
2011-05-27 11:29:13 -07:00
|
|
|
/** Current network is HSPA+ */
|
2011-02-02 10:13:13 -08:00
|
|
|
public static final int NETWORK_TYPE_HSPAP = 15;
|
2010-04-21 14:48:03 -07:00
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Returns a constant indicating the radio technology (network type)
|
2010-11-02 11:10:25 -07:00
|
|
|
* currently in use on the device for data transmission.
|
2009-03-03 19:31:44 -08:00
|
|
|
* @return the network type
|
|
|
|
*
|
|
|
|
* @see #NETWORK_TYPE_UNKNOWN
|
|
|
|
* @see #NETWORK_TYPE_GPRS
|
|
|
|
* @see #NETWORK_TYPE_EDGE
|
|
|
|
* @see #NETWORK_TYPE_UMTS
|
2009-08-14 19:22:16 +08:00
|
|
|
* @see #NETWORK_TYPE_HSDPA
|
|
|
|
* @see #NETWORK_TYPE_HSUPA
|
|
|
|
* @see #NETWORK_TYPE_HSPA
|
2009-04-02 01:37:02 -07:00
|
|
|
* @see #NETWORK_TYPE_CDMA
|
|
|
|
* @see #NETWORK_TYPE_EVDO_0
|
|
|
|
* @see #NETWORK_TYPE_EVDO_A
|
2010-04-21 14:48:03 -07:00
|
|
|
* @see #NETWORK_TYPE_EVDO_B
|
2009-04-02 01:37:02 -07:00
|
|
|
* @see #NETWORK_TYPE_1xRTT
|
2010-11-02 11:10:25 -07:00
|
|
|
* @see #NETWORK_TYPE_IDEN
|
|
|
|
* @see #NETWORK_TYPE_LTE
|
|
|
|
* @see #NETWORK_TYPE_EHRPD
|
2011-05-27 11:29:13 -07:00
|
|
|
* @see #NETWORK_TYPE_HSPAP
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public int getNetworkType() {
|
2009-08-14 19:22:16 +08:00
|
|
|
try{
|
|
|
|
ITelephony telephony = getITelephony();
|
|
|
|
if (telephony != null) {
|
|
|
|
return telephony.getNetworkType();
|
|
|
|
} else {
|
|
|
|
// This can happen when the ITelephony interface is not up yet.
|
|
|
|
return NETWORK_TYPE_UNKNOWN;
|
2009-04-02 01:37:02 -07:00
|
|
|
}
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch(RemoteException ex) {
|
2009-08-14 19:22:16 +08:00
|
|
|
// This shouldn't happen in the normal case
|
2009-03-03 19:31:44 -08:00
|
|
|
return NETWORK_TYPE_UNKNOWN;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return NETWORK_TYPE_UNKNOWN;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-28 20:56:34 -07:00
|
|
|
/** Unknown network class. {@hide} */
|
|
|
|
public static final int NETWORK_CLASS_UNKNOWN = 0;
|
|
|
|
/** Class of broadly defined "2G" networks. {@hide} */
|
|
|
|
public static final int NETWORK_CLASS_2_G = 1;
|
|
|
|
/** Class of broadly defined "3G" networks. {@hide} */
|
|
|
|
public static final int NETWORK_CLASS_3_G = 2;
|
|
|
|
/** Class of broadly defined "4G" networks. {@hide} */
|
|
|
|
public static final int NETWORK_CLASS_4_G = 3;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return general class of network type, such as "3G" or "4G". In cases
|
|
|
|
* where classification is contentious, this method is conservative.
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public static int getNetworkClass(int networkType) {
|
|
|
|
switch (networkType) {
|
|
|
|
case NETWORK_TYPE_GPRS:
|
|
|
|
case NETWORK_TYPE_EDGE:
|
|
|
|
case NETWORK_TYPE_CDMA:
|
|
|
|
case NETWORK_TYPE_1xRTT:
|
|
|
|
case NETWORK_TYPE_IDEN:
|
|
|
|
return NETWORK_CLASS_2_G;
|
|
|
|
case NETWORK_TYPE_UMTS:
|
|
|
|
case NETWORK_TYPE_EVDO_0:
|
|
|
|
case NETWORK_TYPE_EVDO_A:
|
|
|
|
case NETWORK_TYPE_HSDPA:
|
|
|
|
case NETWORK_TYPE_HSUPA:
|
|
|
|
case NETWORK_TYPE_HSPA:
|
|
|
|
case NETWORK_TYPE_EVDO_B:
|
|
|
|
case NETWORK_TYPE_EHRPD:
|
|
|
|
case NETWORK_TYPE_HSPAP:
|
|
|
|
return NETWORK_CLASS_3_G;
|
|
|
|
case NETWORK_TYPE_LTE:
|
|
|
|
return NETWORK_CLASS_4_G;
|
|
|
|
default:
|
|
|
|
return NETWORK_CLASS_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
/**
|
|
|
|
* Returns a string representation of the radio technology (network type)
|
|
|
|
* currently in use on the device.
|
|
|
|
* @return the name of the radio technology
|
|
|
|
*
|
|
|
|
* @hide pending API council review
|
|
|
|
*/
|
|
|
|
public String getNetworkTypeName() {
|
2011-05-28 20:56:34 -07:00
|
|
|
return getNetworkTypeName(getNetworkType());
|
|
|
|
}
|
|
|
|
|
|
|
|
/** {@hide} */
|
|
|
|
public static String getNetworkTypeName(int type) {
|
|
|
|
switch (type) {
|
2009-03-03 19:31:44 -08:00
|
|
|
case NETWORK_TYPE_GPRS:
|
|
|
|
return "GPRS";
|
|
|
|
case NETWORK_TYPE_EDGE:
|
|
|
|
return "EDGE";
|
|
|
|
case NETWORK_TYPE_UMTS:
|
|
|
|
return "UMTS";
|
2009-08-14 19:22:16 +08:00
|
|
|
case NETWORK_TYPE_HSDPA:
|
|
|
|
return "HSDPA";
|
|
|
|
case NETWORK_TYPE_HSUPA:
|
|
|
|
return "HSUPA";
|
|
|
|
case NETWORK_TYPE_HSPA:
|
|
|
|
return "HSPA";
|
2009-04-02 01:37:02 -07:00
|
|
|
case NETWORK_TYPE_CDMA:
|
|
|
|
return "CDMA";
|
|
|
|
case NETWORK_TYPE_EVDO_0:
|
|
|
|
return "CDMA - EvDo rev. 0";
|
|
|
|
case NETWORK_TYPE_EVDO_A:
|
|
|
|
return "CDMA - EvDo rev. A";
|
2010-04-21 14:48:03 -07:00
|
|
|
case NETWORK_TYPE_EVDO_B:
|
|
|
|
return "CDMA - EvDo rev. B";
|
2009-04-02 01:37:02 -07:00
|
|
|
case NETWORK_TYPE_1xRTT:
|
|
|
|
return "CDMA - 1xRTT";
|
2010-11-02 11:10:25 -07:00
|
|
|
case NETWORK_TYPE_LTE:
|
|
|
|
return "LTE";
|
|
|
|
case NETWORK_TYPE_EHRPD:
|
|
|
|
return "CDMA - eHRPD";
|
2010-12-03 16:52:36 -08:00
|
|
|
case NETWORK_TYPE_IDEN:
|
|
|
|
return "iDEN";
|
2011-05-27 11:29:13 -07:00
|
|
|
case NETWORK_TYPE_HSPAP:
|
|
|
|
return "HSPA+";
|
2009-03-03 19:31:44 -08:00
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// SIM Card
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
/** SIM card state: Unknown. Signifies that the SIM is in transition
|
|
|
|
* between states. For example, when the user inputs the SIM pin
|
2009-04-02 01:37:02 -07:00
|
|
|
* under PIN_REQUIRED state, a query for sim status returns
|
2009-03-03 19:31:44 -08:00
|
|
|
* this state before turning to SIM_STATE_READY. */
|
|
|
|
public static final int SIM_STATE_UNKNOWN = 0;
|
|
|
|
/** SIM card state: no SIM card is available in the device */
|
|
|
|
public static final int SIM_STATE_ABSENT = 1;
|
|
|
|
/** SIM card state: Locked: requires the user's SIM PIN to unlock */
|
|
|
|
public static final int SIM_STATE_PIN_REQUIRED = 2;
|
|
|
|
/** SIM card state: Locked: requires the user's SIM PUK to unlock */
|
|
|
|
public static final int SIM_STATE_PUK_REQUIRED = 3;
|
|
|
|
/** SIM card state: Locked: requries a network PIN to unlock */
|
|
|
|
public static final int SIM_STATE_NETWORK_LOCKED = 4;
|
|
|
|
/** SIM card state: Ready */
|
|
|
|
public static final int SIM_STATE_READY = 5;
|
2009-04-02 01:37:02 -07:00
|
|
|
|
2009-09-01 15:39:08 -07:00
|
|
|
/**
|
|
|
|
* @return true if a ICC card is present
|
|
|
|
*/
|
|
|
|
public boolean hasIccCard() {
|
2009-09-03 13:34:04 -07:00
|
|
|
try {
|
|
|
|
return getITelephony().hasIccCard();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// Assume no ICC card if remote exception which shouldn't happen
|
|
|
|
return false;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return false;
|
2009-09-03 13:34:04 -07:00
|
|
|
}
|
2009-09-01 15:39:08 -07:00
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
|
|
|
* Returns a constant indicating the state of the
|
2009-03-03 19:31:44 -08:00
|
|
|
* device SIM card.
|
2009-04-02 01:37:02 -07:00
|
|
|
*
|
2009-03-03 19:31:44 -08:00
|
|
|
* @see #SIM_STATE_UNKNOWN
|
|
|
|
* @see #SIM_STATE_ABSENT
|
|
|
|
* @see #SIM_STATE_PIN_REQUIRED
|
|
|
|
* @see #SIM_STATE_PUK_REQUIRED
|
|
|
|
* @see #SIM_STATE_NETWORK_LOCKED
|
|
|
|
* @see #SIM_STATE_READY
|
|
|
|
*/
|
|
|
|
public int getSimState() {
|
|
|
|
String prop = SystemProperties.get(TelephonyProperties.PROPERTY_SIM_STATE);
|
|
|
|
if ("ABSENT".equals(prop)) {
|
|
|
|
return SIM_STATE_ABSENT;
|
|
|
|
}
|
|
|
|
else if ("PIN_REQUIRED".equals(prop)) {
|
|
|
|
return SIM_STATE_PIN_REQUIRED;
|
|
|
|
}
|
|
|
|
else if ("PUK_REQUIRED".equals(prop)) {
|
|
|
|
return SIM_STATE_PUK_REQUIRED;
|
|
|
|
}
|
|
|
|
else if ("NETWORK_LOCKED".equals(prop)) {
|
|
|
|
return SIM_STATE_NETWORK_LOCKED;
|
|
|
|
}
|
|
|
|
else if ("READY".equals(prop)) {
|
|
|
|
return SIM_STATE_READY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return SIM_STATE_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2009-03-03 19:31:44 -08:00
|
|
|
* Returns the MCC+MNC (mobile country code + mobile network code) of the
|
|
|
|
* provider of the SIM. 5 or 6 decimal digits.
|
|
|
|
* <p>
|
|
|
|
* Availability: SIM state must be {@link #SIM_STATE_READY}
|
|
|
|
*
|
|
|
|
* @see #getSimState
|
|
|
|
*/
|
|
|
|
public String getSimOperator() {
|
2009-04-02 01:37:02 -07:00
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
|
|
|
* Returns the Service Provider Name (SPN).
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
|
|
|
* Availability: SIM state must be {@link #SIM_STATE_READY}
|
|
|
|
*
|
|
|
|
* @see #getSimState
|
|
|
|
*/
|
|
|
|
public String getSimOperatorName() {
|
2009-04-02 01:37:02 -07:00
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2009-04-02 01:37:02 -07:00
|
|
|
/**
|
2009-03-03 19:31:44 -08:00
|
|
|
* Returns the ISO country code equivalent for the SIM provider's country code.
|
|
|
|
*/
|
|
|
|
public String getSimCountryIso() {
|
2009-04-02 01:37:02 -07:00
|
|
|
return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-09-11 14:49:47 -07:00
|
|
|
* Returns the serial number of the SIM, if applicable. Return null if it is
|
|
|
|
* unavailable.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getSimSerialNumber() {
|
|
|
|
try {
|
2009-04-02 01:37:02 -07:00
|
|
|
return getSubscriberInfo().getIccSerialNumber();
|
2009-03-03 19:31:44 -08:00
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 22:29:44 -07:00
|
|
|
/**
|
|
|
|
* Return if the current radio is LTE on CDMA. This
|
|
|
|
* is a tri-state return value as for a period of time
|
|
|
|
* the mode may be unknown.
|
|
|
|
*
|
|
|
|
* @return {@link Phone#LTE_ON_CDMA_UNKNOWN}, {@link Phone#LTE_ON_CDMA_FALSE}
|
|
|
|
* or {@link Phone#LTE_ON_CDMA_TRUE}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public int getLteOnCdmaMode() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getLteOnCdmaMode();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// Assume no ICC card if remote exception which shouldn't happen
|
2012-07-10 12:37:54 -07:00
|
|
|
return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
|
2011-05-11 22:29:44 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
2012-07-10 12:37:54 -07:00
|
|
|
return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
|
2011-05-11 22:29:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// Subscriber Info
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
|
2009-09-11 14:49:47 -07:00
|
|
|
* Return null if it is unavailable.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getSubscriberId() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getSubscriberId();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Returns the phone number string for line 1, for example, the MSISDN
|
2009-09-11 14:49:47 -07:00
|
|
|
* for a GSM phone. Return null if it is unavailable.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getLine1Number() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getLine1Number();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Returns the alphabetic identifier associated with the line 1 number.
|
2009-09-11 14:49:47 -07:00
|
|
|
* Return null if it is unavailable.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
* @hide
|
|
|
|
* nobody seems to call this.
|
|
|
|
*/
|
|
|
|
public String getLine1AlphaTag() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getLine1AlphaTag();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 16:12:51 +09:00
|
|
|
/**
|
|
|
|
* Returns the MSISDN string.
|
|
|
|
* for a GSM phone. Return null if it is unavailable.
|
|
|
|
* <p>
|
|
|
|
* Requires Permission:
|
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String getMsisdn() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getMsisdn();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
/**
|
2009-09-11 14:49:47 -07:00
|
|
|
* Returns the voice mail number. Return null if it is unavailable.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getVoiceMailNumber() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getVoiceMailNumber();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-02 11:05:28 -07:00
|
|
|
/**
|
|
|
|
* Returns the complete voice mail number. Return null if it is unavailable.
|
|
|
|
* <p>
|
|
|
|
* Requires Permission:
|
|
|
|
* {@link android.Manifest.permission#CALL_PRIVILEGED CALL_PRIVILEGED}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String getCompleteVoiceMailNumber() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getCompleteVoiceMailNumber();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 06:51:43 -05:00
|
|
|
/**
|
2009-09-11 14:49:47 -07:00
|
|
|
* Returns the voice mail count. Return 0 if unavailable.
|
2009-06-01 06:51:43 -05:00
|
|
|
* <p>
|
|
|
|
* Requires Permission:
|
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public int getVoiceMessageCount() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getVoiceMessageCount();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return 0;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return 0;
|
2009-06-01 06:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
/**
|
|
|
|
* Retrieves the alphabetic identifier associated with the voice
|
|
|
|
* mail number.
|
|
|
|
* <p>
|
2009-04-02 01:37:02 -07:00
|
|
|
* Requires Permission:
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
|
|
|
*/
|
|
|
|
public String getVoiceMailAlphaTag() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getVoiceMailAlphaTag();
|
|
|
|
} catch (RemoteException ex) {
|
2009-09-11 14:49:47 -07:00
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:55:53 -07:00
|
|
|
/**
|
|
|
|
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
|
|
|
|
* @return the IMPI, or null if not present or not loaded
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String getIsimImpi() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getIsimImpi();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the IMS home network domain name that was loaded from the ISIM.
|
|
|
|
* @return the IMS domain name, or null if not present or not loaded
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String getIsimDomain() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getIsimDomain();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the IMS public user identities (IMPU) that were loaded from the ISIM.
|
|
|
|
* @return an array of IMPU strings, with one IMPU per string, or null if
|
|
|
|
* not present or not loaded
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String[] getIsimImpu() {
|
|
|
|
try {
|
|
|
|
return getSubscriberInfo().getIsimImpu();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// This could happen before phone restarts due to crashing
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
private IPhoneSubInfo getSubscriberInfo() {
|
|
|
|
// get it each time because that process crashes a lot
|
|
|
|
return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Device call state: No activity. */
|
|
|
|
public static final int CALL_STATE_IDLE = 0;
|
|
|
|
/** Device call state: Ringing. A new call arrived and is
|
2009-04-02 01:37:02 -07:00
|
|
|
* ringing or waiting. In the latter case, another call is
|
2009-03-03 19:31:44 -08:00
|
|
|
* already active. */
|
|
|
|
public static final int CALL_STATE_RINGING = 1;
|
2009-04-02 01:37:02 -07:00
|
|
|
/** Device call state: Off-hook. At least one call exists
|
2009-03-03 19:31:44 -08:00
|
|
|
* that is dialing, active, or on hold, and no calls are ringing
|
|
|
|
* or waiting. */
|
|
|
|
public static final int CALL_STATE_OFFHOOK = 2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a constant indicating the call state (cellular) on the device.
|
|
|
|
*/
|
|
|
|
public int getCallState() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getCallState();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return CALL_STATE_IDLE;
|
2009-06-30 12:01:35 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return CALL_STATE_IDLE;
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Data connection activity: No traffic. */
|
|
|
|
public static final int DATA_ACTIVITY_NONE = 0x00000000;
|
|
|
|
/** Data connection activity: Currently receiving IP PPP traffic. */
|
|
|
|
public static final int DATA_ACTIVITY_IN = 0x00000001;
|
|
|
|
/** Data connection activity: Currently sending IP PPP traffic. */
|
|
|
|
public static final int DATA_ACTIVITY_OUT = 0x00000002;
|
|
|
|
/** Data connection activity: Currently both sending and receiving
|
|
|
|
* IP PPP traffic. */
|
|
|
|
public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT;
|
2009-05-15 12:05:56 -07:00
|
|
|
/**
|
|
|
|
* Data connection is active, but physical link is down
|
|
|
|
*/
|
2009-05-18 21:47:50 -07:00
|
|
|
public static final int DATA_ACTIVITY_DORMANT = 0x00000004;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a constant indicating the type of activity on a data connection
|
|
|
|
* (cellular).
|
|
|
|
*
|
|
|
|
* @see #DATA_ACTIVITY_NONE
|
|
|
|
* @see #DATA_ACTIVITY_IN
|
|
|
|
* @see #DATA_ACTIVITY_OUT
|
|
|
|
* @see #DATA_ACTIVITY_INOUT
|
2009-05-18 21:47:50 -07:00
|
|
|
* @see #DATA_ACTIVITY_DORMANT
|
2009-03-03 19:31:44 -08:00
|
|
|
*/
|
|
|
|
public int getDataActivity() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getDataActivity();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return DATA_ACTIVITY_NONE;
|
2009-06-30 12:01:35 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return DATA_ACTIVITY_NONE;
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2010-11-09 10:24:40 -08:00
|
|
|
/** Data connection state: Unknown. Used before we know the state.
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public static final int DATA_UNKNOWN = -1;
|
2009-03-03 19:31:44 -08:00
|
|
|
/** Data connection state: Disconnected. IP traffic not available. */
|
|
|
|
public static final int DATA_DISCONNECTED = 0;
|
|
|
|
/** Data connection state: Currently setting up a data connection. */
|
|
|
|
public static final int DATA_CONNECTING = 1;
|
|
|
|
/** Data connection state: Connected. IP traffic should be available. */
|
|
|
|
public static final int DATA_CONNECTED = 2;
|
2009-04-02 01:37:02 -07:00
|
|
|
/** Data connection state: Suspended. The connection is up, but IP
|
|
|
|
* traffic is temporarily unavailable. For example, in a 2G network,
|
2009-03-03 19:31:44 -08:00
|
|
|
* data activity may be suspended when a voice call arrives. */
|
|
|
|
public static final int DATA_SUSPENDED = 3;
|
|
|
|
|
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Returns a constant indicating the current data connection state
|
2009-03-03 19:31:44 -08:00
|
|
|
* (cellular).
|
|
|
|
*
|
|
|
|
* @see #DATA_DISCONNECTED
|
|
|
|
* @see #DATA_CONNECTING
|
|
|
|
* @see #DATA_CONNECTED
|
|
|
|
* @see #DATA_SUSPENDED
|
|
|
|
*/
|
|
|
|
public int getDataState() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getDataState();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return DATA_DISCONNECTED;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return DATA_DISCONNECTED;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ITelephony getITelephony() {
|
|
|
|
return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// PhoneStateListener
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
2009-04-02 01:37:02 -07:00
|
|
|
* Registers a listener object to receive notification of changes
|
|
|
|
* in specified telephony states.
|
2009-03-03 19:31:44 -08:00
|
|
|
* <p>
|
|
|
|
* To register a listener, pass a {@link PhoneStateListener}
|
2009-04-02 01:37:02 -07:00
|
|
|
* and specify at least one telephony state of interest in
|
|
|
|
* the events argument.
|
|
|
|
*
|
2009-03-03 19:31:44 -08:00
|
|
|
* At registration, and when a specified telephony state
|
2009-04-02 01:37:02 -07:00
|
|
|
* changes, the telephony manager invokes the appropriate
|
|
|
|
* callback method on the listener object and passes the
|
2009-03-03 19:31:44 -08:00
|
|
|
* current (udpated) values.
|
|
|
|
* <p>
|
|
|
|
* To unregister a listener, pass the listener object and set the
|
2009-04-02 01:37:02 -07:00
|
|
|
* events argument to
|
2009-03-03 19:31:44 -08:00
|
|
|
* {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0).
|
2009-04-02 01:37:02 -07:00
|
|
|
*
|
2009-03-03 19:31:44 -08:00
|
|
|
* @param listener The {@link PhoneStateListener} object to register
|
|
|
|
* (or unregister)
|
|
|
|
* @param events The telephony state(s) of interest to the listener,
|
2009-04-02 01:37:02 -07:00
|
|
|
* as a bitwise-OR combination of {@link PhoneStateListener}
|
2009-03-03 19:31:44 -08:00
|
|
|
* LISTEN_ flags.
|
|
|
|
*/
|
|
|
|
public void listen(PhoneStateListener listener, int events) {
|
2011-02-02 08:33:11 -08:00
|
|
|
String pkgForDebug = sContext != null ? sContext.getPackageName() : "<unknown>";
|
2009-03-03 19:31:44 -08:00
|
|
|
try {
|
|
|
|
Boolean notifyNow = (getITelephony() != null);
|
2011-02-02 08:33:11 -08:00
|
|
|
sRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
|
2009-03-03 19:31:44 -08:00
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// system process dead
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
// system process dead
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
2009-05-18 21:47:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the CDMA ERI icon index to display
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public int getCdmaEriIconIndex() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getCdmaEriIconIndex();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return -1;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return -1;
|
2009-05-18 21:47:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the CDMA ERI icon mode,
|
|
|
|
* 0 - ON
|
|
|
|
* 1 - FLASHING
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public int getCdmaEriIconMode() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getCdmaEriIconMode();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return -1;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return -1;
|
2009-05-18 21:47:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the CDMA ERI text,
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public String getCdmaEriText() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getCdmaEriText();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
// the phone process is restarting.
|
|
|
|
return null;
|
2009-09-11 14:49:47 -07:00
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
2009-05-18 21:47:50 -07:00
|
|
|
}
|
|
|
|
}
|
2010-08-17 17:54:48 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the current device is "voice capable".
|
|
|
|
* <p>
|
|
|
|
* "Voice capable" means that this device supports circuit-switched
|
|
|
|
* (i.e. voice) phone calls over the telephony network, and is allowed
|
|
|
|
* to display the in-call UI while a cellular voice call is active.
|
|
|
|
* This will be false on "data only" devices which can't make voice
|
|
|
|
* calls and don't support any in-call UI.
|
|
|
|
* <p>
|
|
|
|
* Note: the meaning of this flag is subtly different from the
|
|
|
|
* PackageManager.FEATURE_TELEPHONY system feature, which is available
|
|
|
|
* on any device with a telephony radio, even if the device is
|
|
|
|
* data-only.
|
|
|
|
*
|
|
|
|
* @hide pending API review
|
|
|
|
*/
|
|
|
|
public boolean isVoiceCapable() {
|
2011-02-02 08:33:11 -08:00
|
|
|
if (sContext == null) return true;
|
|
|
|
return sContext.getResources().getBoolean(
|
2010-08-17 17:54:48 -07:00
|
|
|
com.android.internal.R.bool.config_voice_capable);
|
|
|
|
}
|
2010-12-10 14:25:27 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the current device supports sms service.
|
|
|
|
* <p>
|
|
|
|
* If true, this means that the device supports both sending and
|
|
|
|
* receiving sms via the telephony network.
|
|
|
|
* <p>
|
|
|
|
* Note: Voicemail waiting sms, cell broadcasting sms, and MMS are
|
|
|
|
* disabled when device doesn't support sms.
|
|
|
|
*
|
|
|
|
* @hide pending API review
|
|
|
|
*/
|
|
|
|
public boolean isSmsCapable() {
|
2011-02-02 08:33:11 -08:00
|
|
|
if (sContext == null) return true;
|
|
|
|
return sContext.getResources().getBoolean(
|
2010-12-10 14:25:27 -08:00
|
|
|
com.android.internal.R.bool.config_sms_capable);
|
|
|
|
}
|
2012-03-30 16:04:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all observed cell information of the device.
|
|
|
|
*
|
|
|
|
* @return List of CellInfo or null if info unavailable.
|
|
|
|
*
|
|
|
|
* <p>Requires Permission:
|
|
|
|
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
|
|
|
|
*/
|
|
|
|
public List<CellInfo> getAllCellInfo() {
|
|
|
|
try {
|
|
|
|
return getITelephony().getAllCellInfo();
|
|
|
|
} catch (RemoteException ex) {
|
|
|
|
return null;
|
|
|
|
} catch (NullPointerException ex) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|