什么是VoLTE?

文笔不好,看官多担待.度娘介绍的很清楚了,不多说了,只是在5.1Lollipop开始系统就应经有关于VoLte的开关了,中文叫:增强型4G LTE模式.

How to enable HD Voice Calling on Android 5.1 Lollipop

Google has recently rolled out the highly-anticipated Android 5.1 Lollipop update with stability and performance fixes for a slew of Android devices, which also introduces a bunch of new features including native support for multiple SIM cards, device protection and High Definition Voice Calling on compatible phones and carriers.

HD Voice Calling is a useful addition to 4G LTE capable devices such as Nexus 6, wherein users can benefit with superior call quality via Enhanced 4G LTE Mode on carriers that support the service.

获取VoLTE开关状态

之前没关注过,也没注意早在Android 5.1版本就已经有了VoLte开关了。有很多介绍VoLte开关原理的,我这里的也是就不啰嗦了。
获取VoLte开关,在6.0上比较容易,6.0之后有一个类TelephonyManager,通过源码发现TelephonyManager.isVolteEnabled(),有关于VoLTE的开关状态,太好了,比较嗨皮,做版本过滤就好了,直接获取。

   /*** Returns the Status of Volte*@hide*/public boolean isVolteEnabled() {try {return getITelephony().isVolteEnabled();} catch (RemoteException ex) {return false;} catch (NullPointerException ex) {return false;}}

6.0以上获取VoLte开关状态

if(Build.VERSION.SDK_INT >= 23){TelephonyManager telephonyManager = TheApp.GetTelephonyManager();Class<? extends TelephonyManager> teleclass = telephonyManager.getClass();Method method = teleclass.getDeclaredMethod("isVolteEnabled");method.setAccessible(true);isvoLte = (boolean) method.invoke(telephonyManager);}

最近 发现5.1系统也有,SO… 那么看看怎么获取呢?
我在翻阅资料,查看源码时发现一个类android.provider.Settings.Global

Global.java

 /*** Whether the Volte/VT is enable* Type: int (0 for false, 1 for true)* @hide*/public static final String ENHANCED_4G_MODE_ENABLED = "volte_vt_enabled";

ENHANCED_4G_MODE_ENABLED 只是存储VoLTE开关状态的对应NAME而已,我们通过它可以读取手机当前VoLTE的开关状态,反射Global。

 Class<?> GlobalClass = Global.getClass();try {Field field = GlobalClass.getDeclaredField("ENHANCED_4G_MODE_ENABLED");field.setAccessible(true);String volteStr = (String) field.get(Global);
}catch(Exception e){
}那么如何获取呢? 根据ENHANCED_4G_MODE_ENABLED Type: int (0 for false, 1 for true)我们知道它的返回是1 或 0。int VoLteState  = android.provider.Settings.Global.getInt(getContentResolver(), volteStr);

VoLteState 则就是手机当前返回的VoLTE开关,在我测试手机Coolpad Y803-9 ,Android 5.1 它的名字叫做增强型4G LTE模式,当打开时手机状态栏或显示HD字样的图标。

要想设置VoLTE开关状态,除了你需要你的应用是系统APP(system App)之外,别忘了,在AndroidManifest.xml中添加相应的权限,才能修改。这里的修改是指,开发者自定义手机的VoLTE开关(只要手机支持)。我没有试过,不过一些代码可以验证一下,代码如下:

设置VoLTE开关 (未验证)

 /*** Whether the Volte/VT is enabled* <p>* Type: int (0 for false, 1 for true)* "volte_vt_enabled"*/public static void SetVolteEnable(boolean enable){int value = enable ? 1 : 0;String volteStr = null ;Global Global = new Global();Class<?> GlobalClass = Global.getClass();
try {
Field field =GlobalClass.getDeclaredField("ENHANCED_4G_MODE_ENABLED");field.setAccessible(true);volteStr = (String) field.get(Global);} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {e.printStackTrace();}//如果是你的App是预制为系统App的,那么直接改变即可if(checkSystemApp()){android.provider.Settings.Global.putInt(                       TheApp.getContext().getContentResolver(),volteStr, value); }if (isNonTtyOrTtyOnVolteEnabled(TheApp.getContext())) {try {SubscriptionManager subManager (SubscriptionManager)TheApp.getContext()
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);Class<? extends SubscriptionManager> sunClass = subManager.getClass();Method method1 = sunClass.getDeclaredMethod("getDefaultVoicePhoneId");method1.setAccessible(true);int phoneid = (Integer) method1.invoke(subManager);Class<?> clazz = (Class<?>)Class.forName("com.android.ims.ImsManager");Constructor ct = clazz.getDeclaredConstructor(new Class[{Context.class,int.class});ct.setAccessible(true);Object obj = ct.newInstance(new Object[{TheApp.getContext(),phoneid});    //setAdvanced4GModeMethod method = clazz.getDeclaredMethod("setAdvanced4GMode", new Class[]{boolean.class});method.setAccessible(true);method.invoke(obj, enable);
} catch (Exception e1) {e1.printStackTrace();
}       }
}/*** Indicates whether the call is non-TTY or if TTY - whether TTY on VoLTE is* supported.*/public static boolean isNonTtyOrTtyOnVolteEnabled(Context context) {if (getBooleanCarrierConfig(context,                CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) {return true;}String preferred = null ;int mode = 0;try {Secure secure = new Secure();Class<?> secureClass = secure.getClass();Field field = secureClass.getDeclaredField("PREFERRED_TTY_MODE");field.setAccessible(true);preferred = (String) field.get(secure);TelecomManager telcom = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);Class telcomClass = telcom.getClass();Field field1 = telcomClass.getDeclaredField("TTY_MODE_OFF");field1.setAccessible(true);mode = (Integer) field1.get(telcom);} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {e.printStackTrace();}//  public static final String PREFERRED_TTY_MODE =
//        "preferred_tty_mode";return Settings.Secure.getInt(context.getContentResolver(),preferred, mode)  == mode;}private static boolean getBooleanCarrierConfig(Context context, String key) {CarrierConfigManager configManager = (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE);Class configManagerClass = configManager.getClass();PersistableBundle b = null;if (configManager != null) {b = configManager.getConfig();}if (b != null) {return b.getBoolean(key);} else {try {Method method = configManagerClass.getDeclaredMethod("getDefaultConfig");method.setAccessible(true);PersistableBundle persistableBundle = (PersistableBundle) method.invoke(configManager);return persistableBundle.getBoolean(key);} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {// TODO Auto-generated catch blocke.printStackTrace();}}return false;}

好,先到这了,祝大家新年快乐!

Android VoLte 开关状态相关推荐

  1. android volte 开关,魅蓝5怎么开通VoLTE?魅蓝5开启与关闭VoLTE图文教程

    全新发布的魅蓝5跟随时代潮流,依旧支持VoLTE高清语音通话,这也是目前一项新的科技功能,相信接下来的国产手机陆陆续续会具备这一功能.当然了,要想在手机上使用这一服务,前提需要进入手机里面开通即可.那 ...

  2. [FAQ21007] 电信VoLTE开关默认值设置

    [Important Notice]CT VoLTE配置文档名称为<Operator_Specific_Document_CT入库版本准备.docx>,如贵司没有請到DCC系统进行索取,路 ...

  3. 手机modem开发(28)---开发电信VoLTE开关默认值设置

    电信VoLTE开关默认值设置 [Important Notice]CT VoLTE配置文档名称为<Operator_Specific_Document_CT入库版本准备.docx>,如贵司 ...

  4. 电信JAVA手机_手机modem开发(28)—开发电信VoLTE开关默认值设置

    电信VoLTE开关默认值设置 [Important Notice]CT VoLTE配置文档名称为<Operator_Specific_Document_CT入库版本准备.docx>,如贵司 ...

  5. Android通过广播监测Wi-Fi和便携式热点开关状态

    前言 Android端通过广播的形式动态监测Wi-Fi状态以及便携式热点开关状态,其中获取Wi-Fi状态很简单,网上很多示例,但是通过广播获取热点开关状态相关的资料少之又少,不过好在一个国外网站找到了 ...

  6. Qt for Android获取手机热点开关状态

    Qt开发android应用,从Qt端调用android原生接口获取手机热点开关状态,首先来看一下封装好的android接口类wifiHostBiz.java (以下代码来自网络) package co ...

  7. Android 监听 WiFi 开关状态

    Android 监听 WiFi 开关状态 转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/70854309 本文出自[赵彦军的博客] ...

  8. Android Studio 基础 之 获取蓝牙Bluetooth 的状态,设置的蓝牙Bluetooth 的开关状态,并监听蓝牙Bluetooth 的状态变化方法整理

    Android Studio 基础 之 获取蓝牙Bluetooth 的状态,设置的蓝牙Bluetooth 的开关状态,并监听蓝牙Bluetooth 的状态变化方法整理 目录 Android Studi ...

  9. android volte功能,Android 8.0 Volte开关流程 HD图标显示

    android 8.0的Volte开关流程.. Volte按钮: vendor/qcom/proprietary/telephont-app/NetworkSetting/src/com/qualco ...

最新文章

  1. python os 检查同名_2020Python 爬虫面试题,高薪就业Python面试必看
  2. MySQL Explain详解,分析语句为何运行慢
  3. C语言编程模拟超市抹零结账,STL实践项目之用queue模拟超市结账环节
  4. RS485接口电磁兼容设计方案
  5. 在无法单步调试的情况下找Bug的技巧
  6. TreeSet有序集合
  7. 信用评分卡 (part 1 of 7)
  8. 为PyCharm添加不同解释器
  9. iOS 深度跳转(scheme、universal link)
  10. 云服务器+Dock+搭建个人博客网站
  11. 【Java】猜数字,程序随机分配给客户一个1-100之间的整数,用户在输入对话框中输入自己的猜测,程序返回提示信息,提示信息分别是:“猜大了”、“猜小了”和“猜对了”,用户可根据提示信息再次输入猜测
  12. 中国电影的网络付费点播发行:现状与展望
  13. python3保存的npy文件,python2无法读取的可能解决方案。
  14. Kubernetes访问报错: No route to host
  15. SecureCRT工具介绍
  16. windows中不能创建的目录
  17. mysql 复制表结构(包括索引等)、表内容
  18. 纯前端导入excel表格数据
  19. 一节计算机课作文500,难忘的一堂课作文500字5篇
  20. 逝世一周,追忆乔布斯

热门文章

  1. Android Drawable缓存
  2. 宝妈怎么找副业?如何寻找副业兼职?
  3. Windows 2003 Server远程代码执行漏洞集合
  4. http协议报头详解
  5. C# StringBuilder 的使用
  6. 2k2实用球员_nba2kol2七突平民球员推荐 最新平民神器排行
  7. H3C网络设备密码不知道,如何清空?(跳过当前系统配置)
  8. 各种皮试液的配制方法
  9. Navicat数据库管理工具【免费试用14天】试用攻略
  10. 手把手教你用C++写贪吃蛇