如何使用root在Android 4.2及更高版本上切换飞行模式? [英] How to toggle Airplane Mode on Android 4.2 and above using root?

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

问题描述

众所周知,在Android 4.2上,只有系统应用程序才能切换飞行模式.但是我认为它必须可用于有根设备.我想在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?

推荐答案

Android 4.2中有一个新的设置"二进制文件 您也可以在不使用su的情况下使用它,然后您的应用程序需要更改该应用程序清单中声明的​​此设置所需的权限(对于4.2中的飞行模式,此设置为WRITE_SECURE_SETTINGS-仅授予安装在系统分区上的应用程序.)

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之前没有root的情况下激活飞行模式),可以在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天全站免登陆