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

Commit 8ef4f496 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I2c1eff79,I084b4f0c,I16f88f58,I38d8867f into main

* changes:
  AICS: description set/get/onChange implementation
  AICS: pre-API definition and intdef
  AICS: callback registration
  AICS: cleanup and preliminary changes
parents 5dd48412 ab3212fc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ android_app {
    jni_uses_platform_apis: true,
    libs: [
        "app-compat-annotations",
        "bluetooth_constants_java",
        "bluetooth_flags_java_lib",
        "error_prone_annotations",
        "framework-annotations-lib",
@@ -271,7 +272,6 @@ android_app {
        "bluetooth-protos-lite",
        "bluetooth.change-ids",
        "bluetooth.mapsapi",
        "bluetooth_constants_java",
        "com.android.obex",
        "com.android.vcard",
        "guava",
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ filegroup {
    name: "Bluetooth-binder-aidl",
    srcs: [
        ":framework-bluetooth-updatable-exported-aidl-sources",
        "android/bluetooth/IAudioInputCallback.aidl",
        "android/bluetooth/IBluetooth.aidl",
        "android/bluetooth/IBluetoothA2dp.aidl",
        "android/bluetooth/IBluetoothA2dpSink.aidl",
+26 −0
Original line number Diff line number Diff line
/*
 *  Copyright 2024 The Android Open Source Project
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package android.bluetooth;

/**
 * Callback definitions for interacting with @see AudioInputControl
 *
 * @hide
 */
oneway interface IAudioInputCallback {
    void onDescriptionChanged(in String description);
}
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package android.bluetooth;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.IAudioInputCallback;
import android.bluetooth.IBluetoothVolumeControlCallback;
import android.content.AttributionSource;

@@ -72,4 +73,19 @@ interface IBluetoothVolumeControl {
    void unregisterCallback(in IBluetoothVolumeControlCallback callback, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void notifyNewRegisteredCallback(in IBluetoothVolumeControlCallback callback, in AttributionSource attributionSource);

    // ---------------------
    // AICS related methods:

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void registerAudioInputControlCallback(in AttributionSource attributionSource, in BluetoothDevice device, int instanceId, in IAudioInputCallback callback);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void unregisterAudioInputControlCallback(in AttributionSource attributionSource, in BluetoothDevice device, int instanceId, in IAudioInputCallback callback);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    String getAudioInputDescription(in AttributionSource attributionSource, in BluetoothDevice device, int instanceId);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    boolean isAudioInputDescriptionWritable(in AttributionSource attributionSource, in BluetoothDevice device, int instanceId);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    boolean setAudioInputDescription(in AttributionSource attributionSource, in BluetoothDevice device, int instanceId, in String description);
}
+7 −6
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ public:
  }

  void OnExtAudioInDescriptionChanged(const RawAddress& bd_addr, uint8_t ext_input_id,
                                      std::string descr) override {
                                      std::string description, bool is_writable) override {
    log::info("");

    std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
@@ -334,9 +334,10 @@ public:

    sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
                                     reinterpret_cast<const jbyte*>(&bd_addr));
    jstring description = sCallbackEnv->NewStringUTF(descr.c_str());
    jstring jdescription = sCallbackEnv->NewStringUTF(description.c_str());
    sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onExtAudioInDescriptionChanged,
                                 (jint)ext_input_id, description, addr.get());
                                 (jint)ext_input_id, jdescription, (jboolean)is_writable,
                                 addr.get());
  }
};

@@ -777,9 +778,9 @@ static jboolean setExtAudioInDescriptionNative(JNIEnv* env, jobject /* object */
  }

  RawAddress* tmpraw = reinterpret_cast<RawAddress*>(addr);
  sVolumeControlInterface->SetExtAudioInDescription(*tmpraw, ext_input_id, description);
  bool ret = sVolumeControlInterface->SetExtAudioInDescription(*tmpraw, ext_input_id, description);
  env->ReleaseByteArrayElements(address, addr, 0);
  return JNI_TRUE;
  return ret ? JNI_TRUE : JNI_FALSE;
}

static jboolean setExtAudioInGainSettingNative(JNIEnv* env, jobject /* object */,
@@ -911,7 +912,7 @@ int register_com_android_bluetooth_vc(JNIEnv* env) {
          {"onExtAudioInStatusChanged", "(II[B)V", &method_onExtAudioInStatusChanged},
          {"onExtAudioInTypeChanged", "(II[B)V", &method_onExtAudioInTypeChanged},
          {"onExtAudioInGainPropsChanged", "(IIII[B)V", &method_onExtAudioInGainPropsChanged},
          {"onExtAudioInDescriptionChanged", "(ILjava/lang/String;[B)V",
          {"onExtAudioInDescriptionChanged", "(ILjava/lang/String;Z[B)V",
           &method_onExtAudioInDescriptionChanged},
  };
  GET_JAVA_METHODS(env, "com/android/bluetooth/vc/VolumeControlNativeCallback", javaMethods);
Loading