Android对飞行模式下BT、WiFi开关控制

Android对飞行模式下Wifi和蓝牙的控制通过如下两个数据库中的值控制:

airplane_mode_radiosairplane_mode_toggleable_radios,其值保存在Setting数据库Global表中.

/**

 * A comma separated list of radios that need to be disabled when airplane mode

 * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are

 * included in the comma separated list.

 */

public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios";

通过注释,可以看出,该值表示在打开飞行模式的时候需要关闭的radios,以逗号分隔。

若需要在打开飞行模式的时候关闭wifi和bluetooth,这该值为”wifi,bluetooth”

 

/**

 * A comma separated list of radios that should to be disabled when airplane mode 

 * is on, but can be manually reenabled by the user. For example, if RADIO_WIFI is

 * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
 
 * will be turned off when entering airplane mode, but the user will be able to reenable

 * Wifi in the Settings app.

 *

 * {@hide}

 */

public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";

通过注释,可以看出,该值表示在飞行模式下还能打开的radios(用户可以手动打开),以逗号分隔。

若需要在飞行模式下仍能够开启wifi和bluetooth,这该值为”wifi,bluetooth”

Radios列表项:

/**

 * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.

 */ 
public static final String RADIO_BLUETOOTH = "bluetooth";

/**

 * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.

 */ 
public static final String RADIO_WIFI = "wifi";

/**

 * {@hide}

 */ 
public static final String RADIO_WIMAX = "wimax";

/**

 * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.

 */ 
public static final String RADIO_CELL = "cell";

/**

 * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.

 */ 
public static final String RADIO_NFC = "nfc";

默认值配置的位置如下:

/frameworks/base/packages/SettingsProvider/res/values/defaults.xml

<bool name="def_airplane_mode_on">false</bool>

<bool name="def_theater_mode_on">false</bool>

<!-- Comma-separated list of bluetooth, wifi, and cell. -->

<string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi,nfc,wimax</string>

<string name="airplane_mode_toggleable_radios" translatable="false">bluetooth,wifi,nfc</string>

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值