0 快速索引表
- 权限汇总
Manifest.permission | Android Developers
/frameworks/base/core/res/AndroidManifest.xml
android.permission.READ_PHONE_STATE
android.permission.MODIFY_PHONE_STATE
- 接口汇总
https://developer.android.google.cn/reference/android/telephony/TelephonyManager
/frameworks/base/telephony/java/android/telephony/TelephonyManager.java
android.telephony.TelephonyManager.getDeviceId
android.telephony.TelephonyManager.getImei
android.telephony.TelephonyManager.getDeviceSoftwareVersion
android.telephony.TelephonyManager.getLine1Number
android.telephony.TelephonyManager.getNetworkCountryIso
android.telephony.TelephonyManager.getSimCountryIso
android.telephony.TelephonyManager.getNetworkOperator
android.telephony.TelephonyManager.getNetworkOperatorName
android.telephony.TelephonyManager.getSimOperator
android.telephony.TelephonyManager.getSimOperatorName
android.telephony.TelephonyManager.getNetworkType
android.telephony.TelephonyManager.getPhoneType
android.telephony.TelephonyManager.getSimSerialNumber
android.telephony.TelephonyManager.getSimState
android.telephony.TelephonyManager.getSubscriberId
android.telephony.TelephonyManager.getVoiceMailAlphaTag
android.telephony.TelephonyManager.getVoiceMailNumber
android.telephony.TelephonyManager.hasIccCarda
android.telephony.TelephonyManager.isNetworkRoaming
android.telephony.TelephonyManager.listen
android.telephony.TelephonyManager.getCellLocation
android.telephony.TelephonyManager.getAllCellInfo
android.telephony.TelephonyManager.getNeighboringCellInfo
android.telephony.TelephonyManager.setDataEnabled
android.telephony.TelephonyManager.getDataEnabled
- adb 汇总
adb shell cmd phone help
adb shell cmd phone data disable
adb shell cmd phone data enable
- developer
1 需求
- 读IMEI
- 读用户本机号码
- 读IMSI
- 获取基站位置信息
- 数据开关
2 权限
android.permission.READ_PHONE_STATE
- Added in API level 1
- Protection level: dangerous
android.permission.READ_PHONE_NUMBERS
- Added in API level 26
- Protection level: dangerous
android.permission.READ_PRECISE_PHONE_STATE
- Added in API level 30
- Allows read only access to precise phone state. Allows reading of detailed information about phone state for special-use applications such as dialers, carrier applications, or ims applications.
android.permission.READ_BASIC_PHONE_STATE
- Added in API level 33
- Allows read only access to phone state with a non dangerous permission, including the information like cellular network type, software version.
android.permission.READ_PRIVILEGED_PHONE_STATE
- android:protectionLevel="signature|privileged"
- @SystemApi @TestApi Allows read access to privileged phone state.
- @hide Used internally.
参考资料:
android.permission.MODIFY_PHONE_STATE
- Added in API level 1
- Not for use by third-party applications.
2648 <!-- Allows modification of the telephony state - power on, mmi, etc.
2649 Does not include placing calls.
2650 <p>Not for use by third-party applications. -->
2651 <permission android:name="android.permission.MODIFY_PHONE_STATE"
2652 android:protectionLevel="signature|privileged|role" />
参考资料
https://developer.android.google.cn/reference/android/Manifest.permission
/frameworks/base/core/res/AndroidManifest.xml
3 接口
android.telephony.TelephonyManager.getDeviceId
- Added in API level 1
- Deprecated in API level 26
- Use getImei() which returns IMEI for GSM or getMeid() which returns MEID for CDMA.
- Requires android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
android.telephony.TelephonyManager.getImei
- Added in API level 26
- Requires android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
android.telephony.TelephonyManager.getImei
- Added in API level 26
- Requires android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
android.telephony.TelephonyManager.getDeviceSoftwareVersion
- Added in API level 1
- Requires
- Manifest.permission.READ_PHONE_STATE or
- Manifest.permission.READ_BASIC_PHONE_STATE
android.telephony.TelephonyManager.getLine1Number
- Added in API level 1
- Deprecated in API level 33
- use SubscriptionManager#getPhoneNumber(int) instead.
- Requires
- Manifest.permission.READ_PHONE_STATE or
- Manifest.permission.READ_SMS or
- Manifest.permission.READ_PHONE_NUMBERS
android.telephony.SubscriptionManager.getPhoneNumber
- Added in API level 33
- Requires Manifest.permission.READ_PHONE_NUMBERS or android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE or carrier privileges
android.telephony.TelephonyManager.getNetworkCountryIso
- Added in API level 1
android.telephony.TelephonyManager.getSimCountryIso
- Added in API level 1
android.telephony.TelephonyManager.getNetworkOperator
- Added in API level 1
android.telephony.TelephonyManager.getNetworkOperatorName
- Added in API level 1
android.telephony.TelephonyManager.getSimOperator
- Added in API level 1
android.telephony.TelephonyManager.getSimOperatorName
- Added in API level 1
android.telephony.TelephonyManager.getNetworkType
- Added in API level 1
- Deprecated in API level 30
- use getDataNetworkType() instead
- Requires Manifest.permission.READ_PHONE_STATE
android.telephony.TelephonyManager.getDataNetworkType
- Added in API level 24
- Requires
- Manifest.permission.READ_PHONE_STATE or
- Manifest.permission.READ_BASIC_PHONE_STATE
android.telephony.TelephonyManager.getPhoneType
- Added in API level 1
android.telephony.TelephonyManager.getSimSerialNumber
android.telephony.TelephonyManager.getSimState
android.telephony.TelephonyManager.getSubscriberId
android.telephony.TelephonyManager.getVoiceMailAlphaTag
android.telephony.TelephonyManager.getVoiceMailNumber
android.telephony.TelephonyManager.hasIccCarda
android.telephony.TelephonyManager.isNetworkRoaming
- Added in API level 1
android.telephony.TelephonyManager.listen
android.telephony.TelephonyManager.getCellLocation
- Added in API level 1
- Deprecated in API level 26
- use getAllCellInfo() instead
- Requires Manifest.permission.ACCESS_FINE_LOCATION
android.telephony.TelephonyManager.getAllCellInfo
- Added in API level 17
- Requires Manifest.permission.ACCESS_FINE_LOCATION
android.telephony.TelephonyManager.getNeighboringCellInfo
- @Deprecated
- use getAllCellInfo() instead
- @RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION)
android.telephony.TelephonyManager.setDataEnabled
- Added in API level 26
- Deprecated in API level 31
- use setDataEnabledForReason() instead
- Requires Manifest.permission.MODIFY_PHONE_STATE
10658 /**
10659 * Turns mobile data on or off.
10660 * If this object has been created with {@link #createForSubscriptionId}, applies to the given
10661 * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
10662 *
10663 * <p>Requires Permission:
10664 * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling
10665 * app has carrier privileges (see {@link #hasCarrierPrivileges}).
10666 *
10667 * @param enable Whether to enable mobile data.
10668 * @deprecated use setDataEnabledForReason with reason DATA_ENABLED_REASON_USER instead.
10669 *
10670 */
10671 @Deprecated
10672 @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
10673 @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
10674 public void setDataEnabled(boolean enable) {
10675 setDataEnabled(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()), enable);
10676 }
10678 /**
10679 * @hide
10680 * @deprecated use {@link #setDataEnabledForReason(int, boolean)} instead.
10681 */
10682 @SystemApi
10683 @Deprecated
10684 @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
10685 public void setDataEnabled(int subId, boolean enable) {
10686 try {
10687 setDataEnabledForReason(subId, DATA_ENABLED_REASON_USER, enable);
10688 } catch (RuntimeException e) {
10689 Log.e(TAG, "Error calling setDataEnabledForReason e:" + e);
10690 }
10691 }
android.telephony.TelephonyManager.setDataEnabledForReason
- Added in API level 31
- Requires Manifest.permission.MODIFY_PHONE_STATE
13215 /**
13216 * Control of data connection and provide the reason triggering the data connection control.
13217 * This can be called for following reasons
13218 * <ol>
13219 * <li>data limit is passed {@link #DATA_ENABLED_REASON_POLICY}
13220 * <li>data disabled by carrier {@link #DATA_ENABLED_REASON_CARRIER}
13221 * <li>data disabled by user {@link #DATA_ENABLED_REASON_USER}
13222 * <li>data disabled due to thermal {@link #DATA_ENABLED_REASON_THERMAL}
13223 * </ol>
13224 * If any of the reason is off, then it will result in
13225 * bypassing user preference and result in data to be turned off.
13226 *
13227 * <p>If this object has been created with {@link #createForSubscriptionId}, applies
13228 * to the given subId. Otherwise, applies to
13229 * {@link SubscriptionManager#getDefaultDataSubscriptionId()}
13230 *
13231 *
13232 * @param reason the reason the data enable change is taking place
13233 * @param enabled True if enabling the data, otherwise disabling.
13234 *
13235 * <p>Requires Permission:
13236 * The calling app has carrier privileges (see {@link #hasCarrierPrivileges}) if the reason is
13237 * {@link #DATA_ENABLED_REASON_USER} or {@link #DATA_ENABLED_REASON_CARRIER} or the call app
13238 * has {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} irrespective of
13239 * the reason.
13240 * @throws IllegalStateException if the Telephony process is not currently available.
13241 */
13242 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
13243 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_DATA)
13244 public void setDataEnabledForReason(@DataEnabledReason int reason, boolean enabled) {
13245 setDataEnabledForReason(getSubId(), reason, enabled);
13246 }
13248 private void setDataEnabledForReason(int subId, @DataEnabledReason int reason,
13249 boolean enabled) {
13250 try {
13251 ITelephony service = getITelephony();
13252 if (service != null) {
13253 service.setDataEnabledForReason(subId, reason, enabled, getOpPackageName());
13254 } else {
13255 throw new IllegalStateException("telephony service is null.");
13256 }
13257 } catch (RemoteException ex) {
13258 Log.e(TAG, "Telephony#setDataEnabledForReason RemoteException", ex);
13259 ex.rethrowFromSystemServer();
13260 }
13261 }
android.telephony.TelephonyManager.getDataEnabled
- @SystemApi
- @Deprecated
- use isDataEnabled() instead.
10693 /**
10694 * @deprecated use {@link #isDataEnabled()} instead.
10695 * @hide
10696 */
10697 @SystemApi
10698 @Deprecated
10699 public boolean getDataEnabled() {
10700 return isDataEnabled();
10701 }
android.telephony.TelephonyManager.isDataEnabled
- Added in API level 26
- Requires
- Manifest.permission.ACCESS_NETWORK_STATE or
- Manifest.permission.MODIFY_PHONE_STATE or
- Manifest.permission.READ_PHONE_STATE or
- Manifest.permission.READ_BASIC_PHONE_STATE
10703 /**
10704 * Returns whether mobile data is enabled or not per user setting. There are other factors
10705 * that could disable mobile data, but they are not considered here.
10706 *
10707 * If this object has been created with {@link #createForSubscriptionId}, applies to the given
10708 * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
10709 *
10710 * <p>Requires one of the following permissions:
10711 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE},
10712 * {@link android.Manifest.permission#MODIFY_PHONE_STATE}, or
10713 * {@link android.Manifest.permission#READ_BASIC_PHONE_STATE
10714 * READ_BASIC_PHONE_STATE} or that the calling app has carrier
10715 * privileges (see {@link #hasCarrierPrivileges}).
10716 *
10717 * <p>Note that this does not take into account any data restrictions that may be present on the
10718 * calling app. Such restrictions may be inspected with
10719 * {@link ConnectivityManager#getRestrictBackgroundStatus}.
10720 *
10721 * @return true if mobile data is enabled.
10722 */
10723 @RequiresPermission(anyOf = {android.Manifest.permission.ACCESS_NETWORK_STATE,
10724 android.Manifest.permission.MODIFY_PHONE_STATE,
10725 android.Manifest.permission.READ_PHONE_STATE,
10726 android.Manifest.permission.READ_BASIC_PHONE_STATE})
10727 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_DATA)
10728 public boolean isDataEnabled() {
10729 try {
10730 return isDataEnabledForReason(DATA_ENABLED_REASON_USER);
10731 } catch (IllegalStateException ise) {
10732 // TODO(b/176163590): Remove this catch once TelephonyManager is booting safely.
10733 Log.e(TAG, "Error calling #isDataEnabled, returning default (false).", ise);
10734 return false;
10735 }
10736 }
参考资料:
TelephonyManager | Android Developers
4 示例
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dsl.tmdemo">
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TMDemo">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/btnNetworkCountryIso"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getNetworkCountryIso"
android:textAllCaps="false" />
<Button
android:id="@+id/btnSimCountryIso"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getSimCountryIso"
android:textAllCaps="false" />
<Button
android:id="@+id/btnNetworkOperator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getNetworkOperator"
android:textAllCaps="false" />
<Button
android:id="@+id/btnNetworkOperatorName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getNetworkOperatorName"
android:textAllCaps="false" />
<Button
android:id="@+id/btnSimOperator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getSimOperator"
android:textAllCaps="false" />
<Button
android:id="@+id/btnSimOperatorName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getSimOperatorName"
android:textAllCaps="false" />
<Button
android:id="@+id/btnNetworkType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getNetworkType"
android:textAllCaps="false" />
<Button
android:id="@+id/btnPhoneType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="getPhoneType"
android:textAllCaps="false" />
<Button
android:id="@+id/btnNetworkRoaming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="isNetworkRoaming"
android:textAllCaps="false" />
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Main.java
package com.dsl.tmdemo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
TelephonyManager tm;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
Button btnNetworkCountryIso = (Button) findViewById(R.id.btnNetworkCountryIso);
Button btnSimCountryIso = (Button) findViewById(R.id.btnSimCountryIso);
Button btnNetworkOperator = (Button) findViewById(R.id.btnNetworkOperator);
Button btnNetworkOperatorName = (Button) findViewById(R.id.btnNetworkOperatorName);
Button btnSimOperator = (Button) findViewById(R.id.btnSimOperator);
Button btnSimOperatorName = (Button) findViewById(R.id.btnSimOperatorName);
Button btnNetworkType = (Button) findViewById(R.id.btnNetworkType);
Button btnPhoneType = (Button) findViewById(R.id.btnPhoneType);
Button btnNetworkRoaming = (Button) findViewById(R.id.btnNetworkRoaming);
tv = (TextView) findViewById(R.id.tv);
btnNetworkCountryIso.setOnClickListener(this);
btnSimCountryIso.setOnClickListener(this);
btnNetworkOperator.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btnNetworkCountryIso:
String networkCountryIso = tm.getNetworkCountryIso();
tv.setText(networkCountryIso);
break;
case R.id.btnSimCountryIso:
String simCountryIso = tm.getSimCountryIso();
tv.setText(simCountryIso);
break;
case R.id.btnNetworkOperator:
String networkOperator = tm.getNetworkOperator();
tv.setText(networkOperator);
break;
case R.id.btnNetworkOperatorName:
String networkOperatorName = tm.getNetworkOperatorName();
tv.setText(networkOperatorName);
break;
case R.id.btnSimOperator:
String simOperator = tm.getSimOperator();
tv.setText(simOperator);
break;
case R.id.btnSimOperatorName:
String simOperatorName = tm.getSimOperatorName();
tv.setText(simOperatorName);
break;
case R.id.btnNetworkType:
// 需要申请 android.permission.READ_PHONE_STATE 权限
int networkType = tm.getNetworkType();
tv.setText(networkType);
break;
case R.id.btnPhoneType:
int phoneType = tm.getPhoneType();
tv.setText(phoneType);
break;
case R.id.btnNetworkRoaming:
boolean networkRoaming = tm.isNetworkRoaming();
// boolean 与 String 转换
tv.setText(String.valueOf(networkRoaming));
break;
default:
break;
}
}
}
5 adb shell cmd phone 命令
adb shell cmd phone help
adb shell cmd phone data disable
adb shell cmd phone data enable
C:\>adb shell cmd phone help
Telephony Commands:
help
Print this help text.
ims
IMS Commands.
uce
RCS User Capability Exchange Commands.
emergency-number-test-mode
Emergency Number Test Mode Commands.
end-block-suppression
End Block Suppression command.
data
Data Test Mode Commands.
cc
Carrier Config Commands.
gba
GBA Commands.
src
RCS VoLTE Single Registration Config Commands.
restart-modem
Restart modem command.
unattended-reboot
Prepare for unattended reboot.
has-carrier-privileges [package]
Query carrier privilege status for a package. Prints true or false.
get-allowed-network-types-for-users
Get the Allowed Network Types.
set-allowed-network-types-for-users
Set the Allowed Network Types.
radio
Radio Commands.
IMS Commands:
ims set-ims-service [-s SLOT_ID] (-c | -d | -f) PACKAGE_NAME
Sets the ImsService defined in PACKAGE_NAME to to be the bound
ImsService. Options are:
-s: the slot ID that the ImsService should be bound for. If no option
is specified, it will choose the default voice SIM slot.
-c: Override the ImsService defined in the carrier configuration.
-d: Override the ImsService defined in the device overlay.
-f: Set the feature that this override if for, if no option is
specified, the new package name will be used for all features.
ims get-ims-service [-s SLOT_ID] [-c | -d]
Gets the package name of the currently defined ImsService.
Options are:
-s: The SIM slot ID for the registered ImsService. If no option
is specified, it will choose the default voice SIM slot.
-c: The ImsService defined as the carrier configured ImsService.
-d: The ImsService defined as the device default ImsService.
-f: The feature type that the query will be requested for. If none is
specified, the returned package name will correspond to MMTEL.
ims clear-ims-service-override [-s SLOT_ID]
Clear all carrier ImsService overrides. This does not work for device
configuration overrides. Options are:
-s: The SIM slot ID for the registered ImsService. If no option
is specified, it will choose the default voice SIM slot.
ims enable [-s SLOT_ID]
enables IMS for the SIM slot specified, or for the default voice SIM slot
if none is specified.
ims disable [-s SLOT_ID]
disables IMS for the SIM slot specified, or for the default voice SIM
slot if none is specified.
ims conference-event-package [enable/disable]
enables or disables handling or network conference event package data.
User Capability Exchange Commands:
uce get-eab-contact [PHONE_NUMBER]
Get the EAB contacts from the EAB database.
Options are:
PHONE_NUMBER: The phone numbers to be removed from the EAB databases
Expected output format :
[PHONE_NUMBER],[RAW_CONTACT_ID],[CONTACT_ID],[DATA_ID]
uce remove-eab-contact [-s SLOT_ID] [PHONE_NUMBER]
Remove the EAB contacts from the EAB database.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
PHONE_NUMBER: The phone numbers to be removed from the EAB databases
uce get-device-enabled
Get the config to check whether the device supports RCS UCE or not.
uce set-device-enabled true|false
Set the device config for RCS User Capability Exchange to the value.
The value could be true, false.
uce override-published-caps [-s SLOT_ID] add|remove|clear [CAPABILITIES]
Override the existing SIP PUBLISH with different capabilities.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
add [CAPABILITY]: add a new capability
remove [CAPABILITY]: remove a capability
clear: clear all capability overrides
CAPABILITY: ":" separated list of capabilities.
Valid options are: [mmtel(_vt), chat_v1, chat_v2, ft, ft_sms,
geo_push, geo_push_sms, call_comp, call_post, map, sketch, chatbot,
chatbot_sa, chatbot_role] as well as full length
featureTag="featureValue" feature tags that are not defined here.
uce get-last-publish-pidf [-s SLOT_ID]
Get the PIDF XML included in the last SIP PUBLISH, or "none" if no
PUBLISH is active
uce remove-request-disallowed-status [-s SLOT_ID]
Remove the UCE is disallowed to execute UCE requests status
uce set-capabilities-request-timeout [-s SLOT_ID] [REQUEST_TIMEOUT_MS]
Set the timeout for contact capabilities request.
Emergency Number Test Mode Commands:
emergency-number-test-mode
Add(-a), Clear(-c), Print (-p) or Remove(-r) the emergency number list in the test mode
-a <emergency number address>: add an emergency number address for the test mode, only allows '0'-'9', '*', '#' or '+'.
-c: clear the emergency number list in the test mode.
-r <emergency number address>: remove an existing emergency number address added by the test mode, only allows '0'-'9', '*', '#' or '+'.
-p: get the full emergency number list in the test mode.
End Block Suppression command:
end-block-suppression: disable suppressing blocking by contact
with emergency services.
Mobile Data Test Mode Commands:
data enable: enable mobile data connectivity
data disable: disable mobile data connectivity
Carrier Config Commands:
cc get-value [-s SLOT_ID] [KEY]
Print carrier config values.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
KEY: The key to the carrier config value to print. All values are printed
if KEY is not specified.
cc set-value [-s SLOT_ID] [-p] KEY [NEW_VALUE]
Set carrier config KEY to NEW_VALUE.
Options are:
-s: The SIM slot ID to set carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
-p: Value will be stored persistent
NEW_VALUE specifies the new value for carrier config KEY. Null will be
used if NEW_VALUE is not set. Strings should be encapsulated with
quotation marks. Spaces needs to be escaped. Example: "Hello\ World"
Separate items in arrays with space . Example: "item1" "item2"
cc set-values-from-xml [-s SLOT_ID] [-p] < XML_FILE_PATH
Set carrier config based on the contents of the XML_FILE. File must be
provided through standard input and follow CarrierConfig XML format.
Example: packages/apps/CarrierConfig/assets/*.xml
Options are:
-s: The SIM slot ID to set carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
-p: Value will be stored persistent
cc clear-values [-s SLOT_ID]
Clear all carrier override values that has previously been set
with set-value or set-values-from-xml
Options are:
-s: The SIM slot ID to clear carrier config values for. If no option
is specified, it will choose the default voice SIM slot.
Gba Commands:
gba set-service [-s SLOT_ID] PACKAGE_NAME
Sets the GbaService defined in PACKAGE_NAME to to be the bound.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
gba get-service [-s SLOT_ID]
Gets the package name of the currently defined GbaService.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
gba set-release [-s SLOT_ID] n
Sets the time to release/unbind GbaService in n milli-second.
Do not release/unbind if n is -1.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
gba get-release [-s SLOT_ID]
Gets the time to release/unbind GbaService in n milli-sencond.
Options are:
-s: The SIM slot ID to read carrier config value for. If no option
is specified, it will choose the default voice SIM slot.
RCS VoLTE Single Registration Config Commands:
src set-test-enabled true|false
Sets the test mode enabled for RCS VoLTE single registration.
The value could be true, false, or null(undefined).
src get-test-enabled
Gets the test mode for RCS VoLTE single registration.
src set-device-enabled true|false|null
Sets the device config for RCS VoLTE single registration to the value.
The value could be true, false, or null(undefined).
src get-device-enabled
Gets the device config for RCS VoLTE single registration.
src set-carrier-enabled [-s SLOT_ID] true|false|null
Sets the carrier config for RCS VoLTE single registration to the value.
The value could be true, false, or null(undefined).
Options are:
-s: The SIM slot ID to set the config value for. If no option
is specified, it will choose the default voice SIM slot.
src get-carrier-enabled [-s SLOT_ID]
Gets the carrier config for RCS VoLTE single registration.
Options are:
-s: The SIM slot ID to read the config value for. If no option
is specified, it will choose the default voice SIM slot.
src set-feature-validation [-s SLOT_ID] true|false|null
Sets ims feature validation result.
The value could be true, false, or null(undefined).
Options are:
-s: The SIM slot ID to set the config value for. If no option
is specified, it will choose the default voice SIM slot.
src get-feature-validation [-s SLOT_ID]
Gets ims feature validation override value.
Options are:
-s: The SIM slot ID to read the config value for. If no option
is specified, it will choose the default voice SIM slot.
D2D Comms Commands:
d2d send TYPE VALUE
Sends a D2D message of specified type and value.
Type: 1 - MESSAGE_CALL_RADIO_ACCESS_TYPE
Type: 2 - MESSAGE_CALL_AUDIO_CODEC
Type: 3 - MESSAGE_DEVICE_BATTERY_STATE
Type: 4 - MESSAGE_DEVICE_NETWORK_COVERAGE
d2d transport TYPE
Forces the specified D2D transport TYPE to be active. Use the
short class name of the transport; i.e. DtmfTransport or RtpTransport.
d2d set-device-support true/default
true - forces device support to be enabled for D2D.
default - clear any previously set force-enable of D2D, reverting to
the current device's configuration.
Disable or enable a physical subscription
disable-physical-subscription SUB_ID
Disable the physical subscription with the provided subId, if allowed.
enable-physical-subscription SUB_ID
Enable the physical subscription with the provided subId, if allowed.
Allowed Network Types Commands:
get-allowed-network-types-for-users [-s SLOT_ID]
Print allowed network types value.
Options are:
-s: The SIM slot ID to read allowed network types value for. If no
option is specified, it will choose the default voice SIM slot.
set-allowed-network-types-for-users [-s SLOT_ID] [NETWORK_TYPES_BITMASK]
Sets allowed network types to NETWORK_TYPES_BITMASK.
Options are:
-s: The SIM slot ID to set allowed network types value for. If no
option is specified, it will choose the default voice SIM slot.
NETWORK_TYPES_BITMASK specifies the new network types value and this type
is bitmask in binary format. Reference the NetworkTypeBitMask
at TelephonyManager.java
For example:
NR only : 10000000000000000000
NR|LTE : 11000001000000000000
NR|LTE|CDMA|EVDO|GSM|WCDMA : 11001111101111111111
LTE|CDMA|EVDO|GSM|WCDMA : 01001111101111111111
LTE only : 01000001000000000000
Radio Commands:
radio set-modem-service [-s SERVICE_NAME]
Sets the class name of modem service defined in SERVICE_NAME
to be the bound. Options are:
-s: the service name that the modem service should be bound for.
If no option is specified, it will bind to the default.
radio get-modem-service
Gets the service name of the currently defined modem service.
If it is binding to default, 'default' returns.
If it doesn't bind to any modem service for some reasons,
the result would be 'unknown'.
IMEI Commands:
get-imei [-s SLOT_ID]
Gets the device IMEI. Options are:
-s: the slot ID to get the IMEI. If no option
is specified, it will choose the default voice SIM slot.
6 参考资料
Telecom 框架概览 | Android 开发者 | Android Developers
- android.telephony.TelephonyManager.getPhoneType
- android.telephony.TelephonyManager.getSimState
- android.telephony.TelephonyManager.getNetworkType