Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba3049eb authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Bluetooth: Check INIT flag change on audio disconnect

We also listen for A2DP or hearing aid disconnect and then reevaluate
INIT flag change.

Test: FrameworksServicesTests
Test: Push bluetooth INIT_ flags
Change-Id: I93fa880aa64506577a7937e6666b1942d28458ea
parent e96443f2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import android.Manifest;
import android.app.ActivityManager;
import android.app.AppGlobals;
import android.app.AppOpsManager;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothHearingAid;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.bluetooth.IBluetooth;
@@ -439,6 +441,15 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                        mHandler.sendMessage(msg);
                    }
                }
            } else if (BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(action)
                    || BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
                final int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
                        BluetoothProfile.STATE_CONNECTED);
                if (mHandler.hasMessages(MESSAGE_INIT_FLAGS_CHANGED)
                        && state == BluetoothProfile.STATE_DISCONNECTED
                        && !mBluetoothModeChangeHelper.isA2dpOrHearingAidConnected()) {
                    onInitFlagsChanged();
                }
            }
        }
    };
@@ -489,6 +500,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
        filter.addAction(BluetoothAdapter.ACTION_BLUETOOTH_ADDRESS_CHANGED);
        filter.addAction(Intent.ACTION_SETTING_RESTORED);
        filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
        filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
        mContext.registerReceiver(mReceiver, filter);