Android disables Bluetooth when flying mode is turned on

Source: Internet
Author: User



(1) The Alps/framework/base/packages/settingsprovider/res/values/defaults.xml
The "Bluetooth" in the face Airplane_mode_toggleable_radios label is removed.
(2) The following modifications are made in the Packages/apps/settings/src/android/settings/bluetoothangel/bluetoothenabler.java document:
1.import the following two packages:
Import Android.database.ContentObserver;
Import Com.android.settings.AirplaneModeEnabler;
Import Android.os.Handler;
2. Add the following statement at the end of the resume () method:
Add
Mcontext.getcontentresolver (). Registercontentobserver (
Settings.System.getUriFor (Settings.System.AIRPLANE_MODE_ON), True,
Mairplanemodeobserver);
Mswitch.setenabled (!shoulddisablebt ());
Add End
3. In the Pause () method, add the following statement:
Add
Mcontext.getcontentresolver (). Unregistercontentobserver (Mairplanemodeobserver);
Add End
4. Comment out the following statement in the Setswitch () method:
mswitch.setenabled (IsOn | | isoff);
Add the following statement:
Mswitch.setenabled (!shoulddisablebt ()); Add
5. Place the Bluetoothadapter.state_on,bluetoothadapter.off and default in the Handlestatechanged () method
Mswitch.setenabled (True) in these three case; modified to:
Mswitch.setenabled (!shoulddisablebt ()); Add
6. Add the following methods and member variables to the class Bluetoothenabler:
Add
Private Boolean shoulddisablebt () {
String toggleable = Settings.System.getString (Mcontext.getcontentresolver (),
Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
if (toggleable = = NULL | |!toggleable.contains (Settings.System.RADIO_BLUETOOTH)) {
Return Airplanemodeenabler.isairplanemodeon (Mcontext);
}
return false;
}

Add
Private Contentobserver Mairplanemodeobserver = new Contentobserver (new
Handler ()) {
@Override
public void OnChange (Boolean selfchange) {
Onairplanemodechanged ();
}
};
Add
private void onairplanemodechanged () {
Mswitch.setenabled (! Airplanemodeenabler.isairplanemodeon (Mcontext));
}
(3) ALPS. Jb. Mp\alps\frameworks\base\packages\systemui\src\com\android\systemui\statusbar\tool
Bar\connectionswitchpannel.java
In private broadcastreceiver mintentreceiver = new Broadcastreceiver () {
Inside the OnReceive () function.
else if (action.equals (intent.action_airplane_mode_changed)) {
This decision branch is added in the last:
Add for AIRPLAN-BT Toggle State
Mbluetoothstatetracker.setairlinemode (enabled);
Mbluetoothicon.getconfigview (). setenabled (Mbluetoothstatetracker.isclickable ());
Add End

Add the following code to the Bluetoothstatetracker class
Class Bluetoothstatetracker extends Statetracker {
Add
Private
Boolean misairlinemode = false;
public void Setairlinemode (Boolean
Enable) {
if (DBG) {
XLOG.I (TAG, "Bluetooth Setairlinemode
Called, Enabled is: "+ enable);
}
Misairlinemode = enable;
}
public Boolean isclickable () {
XLOG.I (TAG, "BT Misairlinemode
Is "+ Misairlinemode +", misuserswitching is "+ misuserswitching);
Return
!misairlinemode && super.isclickable ();
}
Add End

(4) \alps\packages\apps\settings\src\com\android\settings\widget\settingsappwidgetprovider.java
Add
Import Com.android.settings.AirplaneModeEnabler;
Add End
else if ((Featureoption.mtk_bt_support) && (ButtonID = = Button_bluetooth)) {
Sbluetoothstate.togglestate (context);
Add
if (! Airplanemodeenabler.isairplanemodeon (context)) {
Sbluetoothstate.togglestate (context);
}
Add End
}

Android disables Bluetooth when flying mode is turned on

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.