如何用root来切换飞行模式在Android 4.2? [英] How to toggle Airplane Mode on Android 4.2 using root?

查看:559
本文介绍了如何用root来切换飞行模式在Android 4.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,在Android 4.2系统唯一的应用程序可以切换飞行模式。但我认为这必须是可用于植根设备。我想impliment它在我的应用程序与Build.VERSION.SDK_INT> = 17植根设备。 如何切换飞行模式植根设备与Android 4.2?

As is known, on Android 4.2 only system applications can toggle Airplane Mode. But I think it must be available for rooted devices. And I want to impliment it in my application for rooted devices with Build.VERSION.SDK_INT>=17. How to toggle Airplane Mode on rooted devices with Android 4.2?

推荐答案

有一个新的设置二进制中的Andr​​oid 4.2 你也可以使用它,而苏,那么你的应用程序需要改变你的应用程序的清单中声明(这将是WRITE_SECURE_SETTINGS飞行模式4.2 - 这是唯一授予安装在系统分区的应用程序),此设置所需的权限。

There is a new "settings" binary in Android 4.2 You can also use it without su, then your app needs the permission required to change this setting declared in your app's manifest (which would be WRITE_SECURE_SETTINGS for flight mode in 4.2 - which is only granted to apps installed on system partition).

启用

su 
settings put global airplane_mode_on 1
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true

停用

su
settings put global airplane_mode_on 0
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

有关其他Android版本和其他设置(飞行模式可以在没有根4.2之前被激活),可以使用在settings.db SQL其注入

For other android versions and other settings (flight mode can be activated without root before 4.2) you can use sql injects in settings.db

su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
insert into global values(null, 'airplane_mode_on', 1);

替换全球与制度或安全和airplane_mode_on'你所需的表项的关键。对于一些设置,你需要事后发送某些广播,看上面的例子飞行模式。

Replace "global" with "system" or "secure" and 'airplane_mode_on' with the key of your desired table entry. For some settings you need to send certain broadcasts afterwards, see example above for flight mode.

要探索你的settings.db在终端应用程序运行这样的:

To explore your settings.db run this in a terminal app:

su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
.tables
select * from global
select * from secure
select * from system

这篇关于如何用root来切换飞行模式在Android 4.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆