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

Commit 1efdea32 authored by Alice Kuo's avatar Alice Kuo
Browse files

Bring the specific transport for get_remote_service from framework

Add support to bring the specific transport for get_remote_service from the framework

Ignore-AOSP-First: avoid merge conflict
Bug: 194447999
Tag: #feature
Test: atest BluetoothInstrumentationTests
Test: Take two headphone to test the dual mode behavior
Change-Id: I4497350a41d607705de28032f757ff6195932326
Merged-In: I4497350a41d607705de28032f757ff6195932326
parent 580c589f
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1469,7 +1469,7 @@ static jboolean setDevicePropertyNative(JNIEnv* env, jobject obj,
}

static jboolean getRemoteServicesNative(JNIEnv* env, jobject obj,
                                        jbyteArray address) {
                                        jbyteArray address, jint transport) {
  ALOGV("%s", __func__);

  if (!sBluetoothInterface) return JNI_FALSE;
@@ -1480,7 +1480,8 @@ static jboolean getRemoteServicesNative(JNIEnv* env, jobject obj,
    return JNI_FALSE;
  }

  int ret = sBluetoothInterface->get_remote_services((RawAddress*)addr);
  int ret =
      sBluetoothInterface->get_remote_services((RawAddress*)addr, transport);
  env->ReleaseByteArrayElements(address, addr, 0);
  return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
@@ -1713,7 +1714,7 @@ static JNINativeMethod sMethods[] = {
    {"getConnectionStateNative", "([B)I", (void*)getConnectionStateNative},
    {"pinReplyNative", "([BZI[B)Z", (void*)pinReplyNative},
    {"sspReplyNative", "([BIZI)Z", (void*)sspReplyNative},
    {"getRemoteServicesNative", "([B)Z", (void*)getRemoteServicesNative},
    {"getRemoteServicesNative", "([BI)Z", (void*)getRemoteServicesNative},
    {"alarmFiredNative", "()V", (void*)alarmFiredNative},
    {"readEnergyInfo", "()I", (void*)readEnergyInfo},
    {"dumpNative", "(Ljava/io/FileDescriptor;[Ljava/lang/String;)V",
+9 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.bluetooth.btservice;

import static android.bluetooth.BluetoothDevice.TRANSPORT_AUTO;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.SECOND_IN_MILLIS;

@@ -1905,12 +1906,13 @@ public class AdapterService extends Service {

        @Override
        public boolean fetchRemoteUuids(BluetoothDevice device) {
            return fetchRemoteUuidsWithAttribution(device, Utils.getCallingAttributionSource());
            return fetchRemoteUuidsWithAttribution(device, TRANSPORT_AUTO,
                    Utils.getCallingAttributionSource());
        }

        @Override
        public boolean fetchRemoteUuidsWithAttribution(
                BluetoothDevice device, AttributionSource attributionSource) {
                BluetoothDevice device, int transport, AttributionSource attributionSource) {
            Attributable.setAttributionSource(device, attributionSource);
            AdapterService service = getService();
            if (service == null
@@ -1919,8 +1921,11 @@ public class AdapterService extends Service {
                            service, attributionSource, "AdapterService fetchRemoteUuids")) {
                return false;
            }
            if (transport != TRANSPORT_AUTO) {
                enforceBluetoothPrivilegedPermission(service);
            }

            service.mRemoteDevices.fetchUuids(device);
            service.mRemoteDevices.fetchUuids(device, transport);
            return true;
        }

@@ -3927,7 +3932,7 @@ public class AdapterService extends Service {
    private native boolean sspReplyNative(byte[] address, int type, boolean accept, int passkey);

    /*package*/
    native boolean getRemoteServicesNative(byte[] address);
    native boolean getRemoteServicesNative(byte[] address, int transport);

    /*package*/
    native boolean getRemoteMasInstancesNative(byte[] address);
+3 −2
Original line number Diff line number Diff line
@@ -739,7 +739,7 @@ final class RemoteDevices {
    }


    void fetchUuids(BluetoothDevice device) {
    void fetchUuids(BluetoothDevice device, int transport) {
        if (sSdpTracker.contains(device)) {
            return;
        }
@@ -759,7 +759,8 @@ final class RemoteDevices {

        // Uses cached UUIDs if we are bonding. If not, we fetch the UUIDs with SDP.
        if (deviceProperties == null || !deviceProperties.isBonding()) {
            sAdapterService.getRemoteServicesNative(Utils.getBytesFromAddress(device.getAddress()));
            sAdapterService.getRemoteServicesNative(Utils.getBytesFromAddress(device.getAddress()),
                    transport);
        }
    }