当前位置:   article > 正文

Android-系统服务-TelephonyManager_android telephonymanager

android telephonymanager

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

Telecom 框架概览  |  Android 开发者  |  Android Developers


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 开发者  |  Android Developers

android.permission.MODIFY_PHONE_STATE

  • Added in API level 1
  • Not for use by third-party applications.
  1. 2648 <!-- Allows modification of the telephony state - power on, mmi, etc.
  2. 2649 Does not include placing calls.
  3. 2650 <p>Not for use by third-party applications. -->
  4. 2651 <permission android:name="android.permission.MODIFY_PHONE_STATE"
  5. 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
  1. 10658 /**
  2. 10659 * Turns mobile data on or off.
  3. 10660 * If this object has been created with {@link #createForSubscriptionId}, applies to the given
  4. 10661 * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
  5. 10662 *
  6. 10663 * <p>Requires Permission:
  7. 10664 * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling
  8. 10665 * app has carrier privileges (see {@link #hasCarrierPrivileges}).
  9. 10666 *
  10. 10667 * @param enable Whether to enable mobile data.
  11. 10668 * @deprecated use setDataEnabledForReason with reason DATA_ENABLED_REASON_USER instead.
  12. 10669 *
  13. 10670 */
  14. 10671 @Deprecated
  15. 10672 @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
  16. 10673 @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
  17. 10674 public void setDataEnabled(boolean enable) {
  18. 10675 setDataEnabled(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()), enable);
  19. 10676 }
  1. 10678 /**
  2. 10679 * @hide
  3. 10680 * @deprecated use {@link #setDataEnabledForReason(int, boolean)} instead.
  4. 10681 */
  5. 10682 @SystemApi
  6. 10683 @Deprecated
  7. 10684 @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
  8. 10685 public void setDataEnabled(int subId, boolean enable) {
  9. 10686 try {
  10. 10687 setDataEnabledForReason(subId, DATA_ENABLED_REASON_USER, enable);
  11. 10688 } catch (RuntimeException e) {
  12. 10689 Log.e(TAG, "Error calling setDataEnabledForReason e:" + e);
  13. 10690 }
  14. 10691 }

 android.telephony.TelephonyManager.setDataEnabledForReason

  • Added in API level 31
  • Requires Manifest.permission.MODIFY_PHONE_STATE
  1. 13215 /**
  2. 13216 * Control of data connection and provide the reason triggering the data connection control.
  3. 13217 * This can be called for following reasons
  4. 13218 * <ol>
  5. 13219 * <li>data limit is passed {@link #DATA_ENABLED_REASON_POLICY}
  6. 13220 * <li>data disabled by carrier {@link #DATA_ENABLED_REASON_CARRIER}
  7. 13221 * <li>data disabled by user {@link #DATA_ENABLED_REASON_USER}
  8. 13222 * <li>data disabled due to thermal {@link #DATA_ENABLED_REASON_THERMAL}
  9. 13223 * </ol>
  10. 13224 * If any of the reason is off, then it will result in
  11. 13225 * bypassing user preference and result in data to be turned off.
  12. 13226 *
  13. 13227 * <p>If this object has been created with {@link #createForSubscriptionId}, applies
  14. 13228 * to the given subId. Otherwise, applies to
  15. 13229 * {@link SubscriptionManager#getDefaultDataSubscriptionId()}
  16. 13230 *
  17. 13231 *
  18. 13232 * @param reason the reason the data enable change is taking place
  19. 13233 * @param enabled True if enabling the data, otherwise disabling.
  20. 13234 *
  21. 13235 * <p>Requires Permission:
  22. 13236 * The calling app has carrier privileges (see {@link #hasCarrierPrivileges}) if the reason is
  23. 13237 * {@link #DATA_ENABLED_REASON_USER} or {@link #DATA_ENABLED_REASON_CARRIER} or the call app
  24. 13238 * has {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} irrespective of
  25. 13239 * the reason.
  26. 13240 * @throws IllegalStateException if the Telephony process is not currently available.
  27. 13241 */
  28. 13242 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
  29. 13243 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_DATA)
  30. 13244 public void setDataEnabledForReason(@DataEnabledReason int reason, boolean enabled) {
  31. 13245 setDataEnabledForReason(getSubId(), reason, enabled);
  32. 13246 }
  1. 13248 private void setDataEnabledForReason(int subId, @DataEnabledReason int reason,
  2. 13249 boolean enabled) {
  3. 13250 try {
  4. 13251 ITelephony service = getITelephony();
  5. 13252 if (service != null) {
  6. 13253 service.setDataEnabledForReason(subId, reason, enabled, getOpPackageName());
  7. 13254 } else {
  8. 13255 throw new IllegalStateException("telephony service is null.");
  9. 13256 }
  10. 13257 } catch (RemoteException ex) {
  11. 13258 Log.e(TAG, "Telephony#setDataEnabledForReason RemoteException", ex);
  12. 13259 ex.rethrowFromSystemServer();
  13. 13260 }
  14. 13261 }

android.telephony.TelephonyManager.getDataEnabled

  • @SystemApi
  • @Deprecated
  • use isDataEnabled() instead.
  1. 10693 /**
  2. 10694 * @deprecated use {@link #isDataEnabled()} instead.
  3. 10695 * @hide
  4. 10696 */
  5. 10697 @SystemApi
  6. 10698 @Deprecated
  7. 10699 public boolean getDataEnabled() {
  8. 10700 return isDataEnabled();
  9. 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
  1. 10703 /**
  2. 10704 * Returns whether mobile data is enabled or not per user setting. There are other factors
  3. 10705 * that could disable mobile data, but they are not considered here.
  4. 10706 *
  5. 10707 * If this object has been created with {@link #createForSubscriptionId}, applies to the given
  6. 10708 * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
  7. 10709 *
  8. 10710 * <p>Requires one of the following permissions:
  9. 10711 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE},
  10. 10712 * {@link android.Manifest.permission#MODIFY_PHONE_STATE}, or
  11. 10713 * {@link android.Manifest.permission#READ_BASIC_PHONE_STATE
  12. 10714 * READ_BASIC_PHONE_STATE} or that the calling app has carrier
  13. 10715 * privileges (see {@link #hasCarrierPrivileges}).
  14. 10716 *
  15. 10717 * <p>Note that this does not take into account any data restrictions that may be present on the
  16. 10718 * calling app. Such restrictions may be inspected with
  17. 10719 * {@link ConnectivityManager#getRestrictBackgroundStatus}.
  18. 10720 *
  19. 10721 * @return true if mobile data is enabled.
  20. 10722 */
  21. 10723 @RequiresPermission(anyOf = {android.Manifest.permission.ACCESS_NETWORK_STATE,
  22. 10724 android.Manifest.permission.MODIFY_PHONE_STATE,
  23. 10725 android.Manifest.permission.READ_PHONE_STATE,
  24. 10726 android.Manifest.permission.READ_BASIC_PHONE_STATE})
  25. 10727 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_DATA)
  26. 10728 public boolean isDataEnabled() {
  27. 10729 try {
  28. 10730 return isDataEnabledForReason(DATA_ENABLED_REASON_USER);
  29. 10731 } catch (IllegalStateException ise) {
  30. 10732 // TODO(b/176163590): Remove this catch once TelephonyManager is booting safely.
  31. 10733 Log.e(TAG, "Error calling #isDataEnabled, returning default (false).", ise);
  32. 10734 return false;
  33. 10735 }
  34. 10736 }

参考资料:

TelephonyManager  |  Android Developers

TelephonyManager.java - OpenGrok cross reference for /frameworks/base/telephony/java/android/telephony/TelephonyManager.java


4 示例

AndroidManifest.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.dsl.tmdemo">
  4. <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/Theme.TMDemo">
  12. <activity
  13. android:name=".MainActivity"
  14. android:exported="true">
  15. <intent-filter>
  16. <action android:name="android.intent.action.MAIN" />
  17. <category android:name="android.intent.category.LAUNCHER" />
  18. </intent-filter>
  19. </activity>
  20. </application>
  21. </manifest>

activity_main.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. tools:context=".MainActivity">
  8. <Button
  9. android:id="@+id/btnNetworkCountryIso"
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:text="getNetworkCountryIso"
  13. android:textAllCaps="false" />
  14. <Button
  15. android:id="@+id/btnSimCountryIso"
  16. android:layout_width="match_parent"
  17. android:layout_height="wrap_content"
  18. android:text="getSimCountryIso"
  19. android:textAllCaps="false" />
  20. <Button
  21. android:id="@+id/btnNetworkOperator"
  22. android:layout_width="match_parent"
  23. android:layout_height="wrap_content"
  24. android:text="getNetworkOperator"
  25. android:textAllCaps="false" />
  26. <Button
  27. android:id="@+id/btnNetworkOperatorName"
  28. android:layout_width="match_parent"
  29. android:layout_height="wrap_content"
  30. android:text="getNetworkOperatorName"
  31. android:textAllCaps="false" />
  32. <Button
  33. android:id="@+id/btnSimOperator"
  34. android:layout_width="match_parent"
  35. android:layout_height="wrap_content"
  36. android:text="getSimOperator"
  37. android:textAllCaps="false" />
  38. <Button
  39. android:id="@+id/btnSimOperatorName"
  40. android:layout_width="match_parent"
  41. android:layout_height="wrap_content"
  42. android:text="getSimOperatorName"
  43. android:textAllCaps="false" />
  44. <Button
  45. android:id="@+id/btnNetworkType"
  46. android:layout_width="match_parent"
  47. android:layout_height="wrap_content"
  48. android:text="getNetworkType"
  49. android:textAllCaps="false" />
  50. <Button
  51. android:id="@+id/btnPhoneType"
  52. android:layout_width="match_parent"
  53. android:layout_height="wrap_content"
  54. android:text="getPhoneType"
  55. android:textAllCaps="false" />
  56. <Button
  57. android:id="@+id/btnNetworkRoaming"
  58. android:layout_width="match_parent"
  59. android:layout_height="wrap_content"
  60. android:text="isNetworkRoaming"
  61. android:textAllCaps="false" />
  62. <TextView
  63. android:id="@+id/tv"
  64. android:layout_width="match_parent"
  65. android:layout_height="wrap_content" />
  66. </LinearLayout>

Main.java

  1. package com.dsl.tmdemo;
  2. import androidx.appcompat.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. import android.telecom.TelecomManager;
  5. import android.telephony.TelephonyManager;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.TextView;
  9. public class MainActivity extends AppCompatActivity implements View.OnClickListener {
  10. TelephonyManager tm;
  11. TextView tv;
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
  17. Button btnNetworkCountryIso = (Button) findViewById(R.id.btnNetworkCountryIso);
  18. Button btnSimCountryIso = (Button) findViewById(R.id.btnSimCountryIso);
  19. Button btnNetworkOperator = (Button) findViewById(R.id.btnNetworkOperator);
  20. Button btnNetworkOperatorName = (Button) findViewById(R.id.btnNetworkOperatorName);
  21. Button btnSimOperator = (Button) findViewById(R.id.btnSimOperator);
  22. Button btnSimOperatorName = (Button) findViewById(R.id.btnSimOperatorName);
  23. Button btnNetworkType = (Button) findViewById(R.id.btnNetworkType);
  24. Button btnPhoneType = (Button) findViewById(R.id.btnPhoneType);
  25. Button btnNetworkRoaming = (Button) findViewById(R.id.btnNetworkRoaming);
  26. tv = (TextView) findViewById(R.id.tv);
  27. btnNetworkCountryIso.setOnClickListener(this);
  28. btnSimCountryIso.setOnClickListener(this);
  29. btnNetworkOperator.setOnClickListener(this);
  30. }
  31. @Override
  32. public void onClick(View view) {
  33. switch (view.getId()) {
  34. case R.id.btnNetworkCountryIso:
  35. String networkCountryIso = tm.getNetworkCountryIso();
  36. tv.setText(networkCountryIso);
  37. break;
  38. case R.id.btnSimCountryIso:
  39. String simCountryIso = tm.getSimCountryIso();
  40. tv.setText(simCountryIso);
  41. break;
  42. case R.id.btnNetworkOperator:
  43. String networkOperator = tm.getNetworkOperator();
  44. tv.setText(networkOperator);
  45. break;
  46. case R.id.btnNetworkOperatorName:
  47. String networkOperatorName = tm.getNetworkOperatorName();
  48. tv.setText(networkOperatorName);
  49. break;
  50. case R.id.btnSimOperator:
  51. String simOperator = tm.getSimOperator();
  52. tv.setText(simOperator);
  53. break;
  54. case R.id.btnSimOperatorName:
  55. String simOperatorName = tm.getSimOperatorName();
  56. tv.setText(simOperatorName);
  57. break;
  58. case R.id.btnNetworkType:
  59. // 需要申请 android.permission.READ_PHONE_STATE 权限
  60. int networkType = tm.getNetworkType();
  61. tv.setText(networkType);
  62. break;
  63. case R.id.btnPhoneType:
  64. int phoneType = tm.getPhoneType();
  65. tv.setText(phoneType);
  66. break;
  67. case R.id.btnNetworkRoaming:
  68. boolean networkRoaming = tm.isNetworkRoaming();
  69. // boolean 与 String 转换
  70. tv.setText(String.valueOf(networkRoaming));
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. }


5 adb shell cmd phone 命令

adb shell cmd phone help

adb shell cmd phone data disable

adb shell cmd phone data enable

  1. C:\>adb shell cmd phone help
  2. Telephony Commands:
  3. help
  4. Print this help text.
  5. ims
  6. IMS Commands.
  7. uce
  8. RCS User Capability Exchange Commands.
  9. emergency-number-test-mode
  10. Emergency Number Test Mode Commands.
  11. end-block-suppression
  12. End Block Suppression command.
  13. data
  14. Data Test Mode Commands.
  15. cc
  16. Carrier Config Commands.
  17. gba
  18. GBA Commands.
  19. src
  20. RCS VoLTE Single Registration Config Commands.
  21. restart-modem
  22. Restart modem command.
  23. unattended-reboot
  24. Prepare for unattended reboot.
  25. has-carrier-privileges [package]
  26. Query carrier privilege status for a package. Prints true or false.
  27. get-allowed-network-types-for-users
  28. Get the Allowed Network Types.
  29. set-allowed-network-types-for-users
  30. Set the Allowed Network Types.
  31. radio
  32. Radio Commands.
  33. IMS Commands:
  34. ims set-ims-service [-s SLOT_ID] (-c | -d | -f) PACKAGE_NAME
  35. Sets the ImsService defined in PACKAGE_NAME to to be the bound
  36. ImsService. Options are:
  37. -s: the slot ID that the ImsService should be bound for. If no option
  38. is specified, it will choose the default voice SIM slot.
  39. -c: Override the ImsService defined in the carrier configuration.
  40. -d: Override the ImsService defined in the device overlay.
  41. -f: Set the feature that this override if for, if no option is
  42. specified, the new package name will be used for all features.
  43. ims get-ims-service [-s SLOT_ID] [-c | -d]
  44. Gets the package name of the currently defined ImsService.
  45. Options are:
  46. -s: The SIM slot ID for the registered ImsService. If no option
  47. is specified, it will choose the default voice SIM slot.
  48. -c: The ImsService defined as the carrier configured ImsService.
  49. -d: The ImsService defined as the device default ImsService.
  50. -f: The feature type that the query will be requested for. If none is
  51. specified, the returned package name will correspond to MMTEL.
  52. ims clear-ims-service-override [-s SLOT_ID]
  53. Clear all carrier ImsService overrides. This does not work for device
  54. configuration overrides. Options are:
  55. -s: The SIM slot ID for the registered ImsService. If no option
  56. is specified, it will choose the default voice SIM slot.
  57. ims enable [-s SLOT_ID]
  58. enables IMS for the SIM slot specified, or for the default voice SIM slot
  59. if none is specified.
  60. ims disable [-s SLOT_ID]
  61. disables IMS for the SIM slot specified, or for the default voice SIM
  62. slot if none is specified.
  63. ims conference-event-package [enable/disable]
  64. enables or disables handling or network conference event package data.
  65. User Capability Exchange Commands:
  66. uce get-eab-contact [PHONE_NUMBER]
  67. Get the EAB contacts from the EAB database.
  68. Options are:
  69. PHONE_NUMBER: The phone numbers to be removed from the EAB databases
  70. Expected output format :
  71. [PHONE_NUMBER],[RAW_CONTACT_ID],[CONTACT_ID],[DATA_ID]
  72. uce remove-eab-contact [-s SLOT_ID] [PHONE_NUMBER]
  73. Remove the EAB contacts from the EAB database.
  74. Options are:
  75. -s: The SIM slot ID to read carrier config value for. If no option
  76. is specified, it will choose the default voice SIM slot.
  77. PHONE_NUMBER: The phone numbers to be removed from the EAB databases
  78. uce get-device-enabled
  79. Get the config to check whether the device supports RCS UCE or not.
  80. uce set-device-enabled true|false
  81. Set the device config for RCS User Capability Exchange to the value.
  82. The value could be true, false.
  83. uce override-published-caps [-s SLOT_ID] add|remove|clear [CAPABILITIES]
  84. Override the existing SIP PUBLISH with different capabilities.
  85. Options are:
  86. -s: The SIM slot ID to read carrier config value for. If no option
  87. is specified, it will choose the default voice SIM slot.
  88. add [CAPABILITY]: add a new capability
  89. remove [CAPABILITY]: remove a capability
  90. clear: clear all capability overrides
  91. CAPABILITY: ":" separated list of capabilities.
  92. Valid options are: [mmtel(_vt), chat_v1, chat_v2, ft, ft_sms,
  93. geo_push, geo_push_sms, call_comp, call_post, map, sketch, chatbot,
  94. chatbot_sa, chatbot_role] as well as full length
  95. featureTag="featureValue" feature tags that are not defined here.
  96. uce get-last-publish-pidf [-s SLOT_ID]
  97. Get the PIDF XML included in the last SIP PUBLISH, or "none" if no
  98. PUBLISH is active
  99. uce remove-request-disallowed-status [-s SLOT_ID]
  100. Remove the UCE is disallowed to execute UCE requests status
  101. uce set-capabilities-request-timeout [-s SLOT_ID] [REQUEST_TIMEOUT_MS]
  102. Set the timeout for contact capabilities request.
  103. Emergency Number Test Mode Commands:
  104. emergency-number-test-mode
  105. Add(-a), Clear(-c), Print (-p) or Remove(-r) the emergency number list in the test mode
  106. -a <emergency number address>: add an emergency number address for the test mode, only allows '0'-'9', '*', '#' or '+'.
  107. -c: clear the emergency number list in the test mode.
  108. -r <emergency number address>: remove an existing emergency number address added by the test mode, only allows '0'-'9', '*', '#' or '+'.
  109. -p: get the full emergency number list in the test mode.
  110. End Block Suppression command:
  111. end-block-suppression: disable suppressing blocking by contact
  112. with emergency services.
  113. Mobile Data Test Mode Commands:
  114. data enable: enable mobile data connectivity
  115. data disable: disable mobile data connectivity
  116. Carrier Config Commands:
  117. cc get-value [-s SLOT_ID] [KEY]
  118. Print carrier config values.
  119. Options are:
  120. -s: The SIM slot ID to read carrier config value for. If no option
  121. is specified, it will choose the default voice SIM slot.
  122. KEY: The key to the carrier config value to print. All values are printed
  123. if KEY is not specified.
  124. cc set-value [-s SLOT_ID] [-p] KEY [NEW_VALUE]
  125. Set carrier config KEY to NEW_VALUE.
  126. Options are:
  127. -s: The SIM slot ID to set carrier config value for. If no option
  128. is specified, it will choose the default voice SIM slot.
  129. -p: Value will be stored persistent
  130. NEW_VALUE specifies the new value for carrier config KEY. Null will be
  131. used if NEW_VALUE is not set. Strings should be encapsulated with
  132. quotation marks. Spaces needs to be escaped. Example: "Hello\ World"
  133. Separate items in arrays with space . Example: "item1" "item2"
  134. cc set-values-from-xml [-s SLOT_ID] [-p] < XML_FILE_PATH
  135. Set carrier config based on the contents of the XML_FILE. File must be
  136. provided through standard input and follow CarrierConfig XML format.
  137. Example: packages/apps/CarrierConfig/assets/*.xml
  138. Options are:
  139. -s: The SIM slot ID to set carrier config value for. If no option
  140. is specified, it will choose the default voice SIM slot.
  141. -p: Value will be stored persistent
  142. cc clear-values [-s SLOT_ID]
  143. Clear all carrier override values that has previously been set
  144. with set-value or set-values-from-xml
  145. Options are:
  146. -s: The SIM slot ID to clear carrier config values for. If no option
  147. is specified, it will choose the default voice SIM slot.
  148. Gba Commands:
  149. gba set-service [-s SLOT_ID] PACKAGE_NAME
  150. Sets the GbaService defined in PACKAGE_NAME to to be the bound.
  151. Options are:
  152. -s: The SIM slot ID to read carrier config value for. If no option
  153. is specified, it will choose the default voice SIM slot.
  154. gba get-service [-s SLOT_ID]
  155. Gets the package name of the currently defined GbaService.
  156. Options are:
  157. -s: The SIM slot ID to read carrier config value for. If no option
  158. is specified, it will choose the default voice SIM slot.
  159. gba set-release [-s SLOT_ID] n
  160. Sets the time to release/unbind GbaService in n milli-second.
  161. Do not release/unbind if n is -1.
  162. Options are:
  163. -s: The SIM slot ID to read carrier config value for. If no option
  164. is specified, it will choose the default voice SIM slot.
  165. gba get-release [-s SLOT_ID]
  166. Gets the time to release/unbind GbaService in n milli-sencond.
  167. Options are:
  168. -s: The SIM slot ID to read carrier config value for. If no option
  169. is specified, it will choose the default voice SIM slot.
  170. RCS VoLTE Single Registration Config Commands:
  171. src set-test-enabled true|false
  172. Sets the test mode enabled for RCS VoLTE single registration.
  173. The value could be true, false, or null(undefined).
  174. src get-test-enabled
  175. Gets the test mode for RCS VoLTE single registration.
  176. src set-device-enabled true|false|null
  177. Sets the device config for RCS VoLTE single registration to the value.
  178. The value could be true, false, or null(undefined).
  179. src get-device-enabled
  180. Gets the device config for RCS VoLTE single registration.
  181. src set-carrier-enabled [-s SLOT_ID] true|false|null
  182. Sets the carrier config for RCS VoLTE single registration to the value.
  183. The value could be true, false, or null(undefined).
  184. Options are:
  185. -s: The SIM slot ID to set the config value for. If no option
  186. is specified, it will choose the default voice SIM slot.
  187. src get-carrier-enabled [-s SLOT_ID]
  188. Gets the carrier config for RCS VoLTE single registration.
  189. Options are:
  190. -s: The SIM slot ID to read the config value for. If no option
  191. is specified, it will choose the default voice SIM slot.
  192. src set-feature-validation [-s SLOT_ID] true|false|null
  193. Sets ims feature validation result.
  194. The value could be true, false, or null(undefined).
  195. Options are:
  196. -s: The SIM slot ID to set the config value for. If no option
  197. is specified, it will choose the default voice SIM slot.
  198. src get-feature-validation [-s SLOT_ID]
  199. Gets ims feature validation override value.
  200. Options are:
  201. -s: The SIM slot ID to read the config value for. If no option
  202. is specified, it will choose the default voice SIM slot.
  203. D2D Comms Commands:
  204. d2d send TYPE VALUE
  205. Sends a D2D message of specified type and value.
  206. Type: 1 - MESSAGE_CALL_RADIO_ACCESS_TYPE
  207. Type: 2 - MESSAGE_CALL_AUDIO_CODEC
  208. Type: 3 - MESSAGE_DEVICE_BATTERY_STATE
  209. Type: 4 - MESSAGE_DEVICE_NETWORK_COVERAGE
  210. d2d transport TYPE
  211. Forces the specified D2D transport TYPE to be active. Use the
  212. short class name of the transport; i.e. DtmfTransport or RtpTransport.
  213. d2d set-device-support true/default
  214. true - forces device support to be enabled for D2D.
  215. default - clear any previously set force-enable of D2D, reverting to
  216. the current device's configuration.
  217. Disable or enable a physical subscription
  218. disable-physical-subscription SUB_ID
  219. Disable the physical subscription with the provided subId, if allowed.
  220. enable-physical-subscription SUB_ID
  221. Enable the physical subscription with the provided subId, if allowed.
  222. Allowed Network Types Commands:
  223. get-allowed-network-types-for-users [-s SLOT_ID]
  224. Print allowed network types value.
  225. Options are:
  226. -s: The SIM slot ID to read allowed network types value for. If no
  227. option is specified, it will choose the default voice SIM slot.
  228. set-allowed-network-types-for-users [-s SLOT_ID] [NETWORK_TYPES_BITMASK]
  229. Sets allowed network types to NETWORK_TYPES_BITMASK.
  230. Options are:
  231. -s: The SIM slot ID to set allowed network types value for. If no
  232. option is specified, it will choose the default voice SIM slot.
  233. NETWORK_TYPES_BITMASK specifies the new network types value and this type
  234. is bitmask in binary format. Reference the NetworkTypeBitMask
  235. at TelephonyManager.java
  236. For example:
  237. NR only : 10000000000000000000
  238. NR|LTE : 11000001000000000000
  239. NR|LTE|CDMA|EVDO|GSM|WCDMA : 11001111101111111111
  240. LTE|CDMA|EVDO|GSM|WCDMA : 01001111101111111111
  241. LTE only : 01000001000000000000
  242. Radio Commands:
  243. radio set-modem-service [-s SERVICE_NAME]
  244. Sets the class name of modem service defined in SERVICE_NAME
  245. to be the bound. Options are:
  246. -s: the service name that the modem service should be bound for.
  247. If no option is specified, it will bind to the default.
  248. radio get-modem-service
  249. Gets the service name of the currently defined modem service.
  250. If it is binding to default, 'default' returns.
  251. If it doesn't bind to any modem service for some reasons,
  252. the result would be 'unknown'.
  253. IMEI Commands:
  254. get-imei [-s SLOT_ID]
  255. Gets the device IMEI. Options are:
  256. -s: the slot ID to get the IMEI. If no option
  257. is specified, it will choose the default voice SIM slot.

 


6 参考资料

Telecom 框架概览  |  Android 开发者  |  Android Developers


  • android.telephony.TelephonyManager.getPhoneType

TelephonyManager.java - OpenGrok cross reference for /frameworks/base/telephony/java/android/telephony/TelephonyManager.java

PhoneConstants.java - OpenGrok cross reference for /frameworks/base/telephony/java/com/android/internal/telephony/PhoneConstants.java

RILConstants.java - OpenGrok cross reference for /frameworks/base/telephony/java/com/android/internal/telephony/RILConstants.java


  • android.telephony.TelephonyManager.getSimState

TelephonyManager.java - OpenGrok cross reference for /frameworks/base/telephony/java/android/telephony/TelephonyManager.java


  • android.telephony.TelephonyManager.getNetworkType

TelephonyManager.java - OpenGrok cross reference for /frameworks/base/telephony/java/android/telephony/TelephonyManager.java

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/398094
推荐阅读
相关标签
  

闽ICP备14008679号