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

Commit c1912d22 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clear native before removing HeadsetService" into tm-qpr-dev

parents fd842992 f631e858
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class HeadsetService extends ProfileService {
        // Step 3: Initialize system interface
        mSystemInterface = HeadsetObjectsFactory.getInstance().makeSystemInterface(this);
        // Step 4: Initialize native interface
        setHeadsetService(this);
        mMaxHeadsetConnections = mAdapterService.getMaxConnectedAudioDevices();
        mNativeInterface = HeadsetObjectsFactory.getInstance().getNativeInterface();
        // Add 1 to allow a pending device to be connecting or disconnecting
@@ -197,7 +198,6 @@ public class HeadsetService extends ProfileService {
        filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        registerReceiver(mHeadsetReceiver, filter);
        // Step 7: Mark service as started
        setHeadsetService(this);
        mStarted = true;
        BluetoothDevice activeDevice = getActiveDevice();
        String deviceAddress = activeDevice != null ?
@@ -223,7 +223,6 @@ public class HeadsetService extends ProfileService {
                AdapterService.ACTIVITY_ATTRIBUTION_NO_ACTIVE_DEVICE_ADDRESS;
        mAdapterService.notifyActivityAttributionInfo(getAttributionSource(), deviceAddress);
        mStarted = false;
        setHeadsetService(null);
        // Step 6: Tear down broadcast receivers
        unregisterReceiver(mHeadsetReceiver);
        synchronized (mStateMachines) {
@@ -256,6 +255,7 @@ public class HeadsetService extends ProfileService {
        }
        // Step 4: Destroy native interface
        mNativeInterface.cleanup();
        setHeadsetService(null);
        // Step 3: Destroy system interface
        mSystemInterface.stop();
        // Step 2: Stop handler thread