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

Commit 54ba989c authored by Eric Shih's avatar Eric Shih Committed by Gerrit Code Review
Browse files

Merge "Set bt_stack's active device to default if java removeActiveDevice" into main

parents 3d3ef71d 8206c9d2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.internal.annotations.VisibleForTesting;

@@ -490,6 +491,10 @@ public class HeadsetNativeInterface {
     */
    @VisibleForTesting
    public boolean setActiveDevice(BluetoothDevice device) {
        // Set bt_stack's active device to default if java layer set active device to null
        if (device == null) {
            return setActiveDeviceNative(Utils.getBytesFromAddress("00:00:00:00:00:00"));
        }
        return setActiveDeviceNative(getByteAddress(device));
    }

+1 −0
Original line number Diff line number Diff line
@@ -1378,6 +1378,7 @@ public class HeadsetService extends ProfileService {
                }
            }
            mActiveDevice = null;
            mNativeInterface.setActiveDevice(null);
            broadcastActiveDevice(null);
        }
    }
+6 −2
Original line number Diff line number Diff line
@@ -243,6 +243,10 @@ void BTA_AgSetScoAllowed(bool value) {
}

void BTA_AgSetActiveDevice(const RawAddress& active_device_addr) {
  if (active_device_addr.IsEmpty()) {
    do_in_main_thread(FROM_HERE, base::BindOnce(&bta_clear_active_device));
  } else {
    do_in_main_thread(FROM_HERE, base::BindOnce(&bta_ag_api_set_active_device,
                                                active_device_addr));
  }
}
+4 −1
Original line number Diff line number Diff line
@@ -1456,7 +1456,10 @@ void bta_ag_set_sco_allowed(bool value) {

const RawAddress& bta_ag_get_active_device() { return active_device_addr; }

void bta_clear_active_device() { active_device_addr = RawAddress::kEmpty; }
void bta_clear_active_device() {
  LOG_DEBUG("Set bta active device to null");
  active_device_addr = RawAddress::kEmpty;
}

void bta_ag_api_set_active_device(const RawAddress& new_active_device) {
  if (new_active_device.IsEmpty()) {