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

Commit 612ebb29 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Pipe down preferred audio profiles to the native layer" am: e521894d...

Merge "Pipe down preferred audio profiles to the native layer" am: e521894d am: 8fc28e7a am: a55e09ae

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2549335



Change-Id: I38d55098d226a6cfea669c5a6dfd2d0d4278f707
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5c90f888 a55e09ae
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -542,6 +542,19 @@ static void setInCallNative(JNIEnv* env, jobject object, jboolean inCall) {
  sLeAudioClientInterface->SetInCall(inCall);
}

static void sendAudioProfilePreferencesNative(
    JNIEnv* env, jint groupId, jboolean isOutputPreferenceLeAudio,
    jboolean isDuplexPreferenceLeAudio) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
  if (!sLeAudioClientInterface) {
    LOG(ERROR) << __func__ << ": Failed to get the Bluetooth LeAudio Interface";
    return;
  }

  sLeAudioClientInterface->SendAudioProfilePreferences(
      groupId, isOutputPreferenceLeAudio, isDuplexPreferenceLeAudio);
}

static JNINativeMethod sMethods[] = {
    {"classInitNative", "()V", (void*)classInitNative},
    {"initNative", "([Landroid/bluetooth/BluetoothLeAudioCodecConfig;)V",
@@ -558,6 +571,8 @@ static JNINativeMethod sMethods[] = {
     (void*)setCodecConfigPreferenceNative},
    {"setCcidInformationNative", "(II)V", (void*)setCcidInformationNative},
    {"setInCallNative", "(Z)V", (void*)setInCallNative},
    {"sendAudioProfilePreferencesNative", "(IZZ)V",
     (void*)sendAudioProfilePreferencesNative},
};

/* Le Audio Broadcaster */
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public final class Utils {
    private static final String ENABLE_DUAL_MODE_AUDIO =
            "persist.bluetooth.enable_dual_mode_audio";
    private static boolean sDualModeEnabled =
            SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false);;
            SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false);

    private static final String KEY_TEMP_ALLOW_LIST_DURATION_MS = "temp_allow_list_duration_ms";
    private static final long DEFAULT_TEMP_ALLOW_LIST_DURATION_MS = 20_000;
+15 −0
Original line number Diff line number Diff line
@@ -4848,6 +4848,21 @@ public class AdapterService extends Service {
                return dbResult;
            }

            int outputOnlyPreference = strippedPreferences.getInt(
                    BluetoothAdapter.AUDIO_MODE_OUTPUT_ONLY);
            if (outputOnlyPreference == 0) {
                outputOnlyPreference = previousPreferences.getInt(
                        BluetoothAdapter.AUDIO_MODE_OUTPUT_ONLY);
            }
            int duplexPreference = strippedPreferences.getInt(BluetoothAdapter.AUDIO_MODE_DUPLEX);
            if (duplexPreference == 0) {
                duplexPreference = previousPreferences.getInt(BluetoothAdapter.AUDIO_MODE_DUPLEX);
            }

            mLeAudioService.sendAudioProfilePreferencesToNative(groupId,
                    outputOnlyPreference == BluetoothProfile.LE_AUDIO,
                    duplexPreference == BluetoothProfile.LE_AUDIO);

            /* Populates the HashMap to hold requests on the groupId. We will update
            numRequestsToAudioFramework after we make requests to the audio framework */
            PendingAudioProfilePreferenceRequest holdRequest =
+21 −0
Original line number Diff line number Diff line
@@ -316,6 +316,24 @@ public class LeAudioNativeInterface {
        setInCallNative(inCall);
    }

    /**
     * Sends the audio preferences for the groupId to the native stack.
     *
     * @param groupId is the groupId corresponding to the preferences
     * @param isOutputPreferenceLeAudio whether LEA is preferred for OUTPUT_ONLY
     * @param isDuplexPreferenceLeAudio whether LEA is preferred for DUPLEX
     */
    public void sendAudioProfilePreferences(int groupId, boolean isOutputPreferenceLeAudio,
            boolean isDuplexPreferenceLeAudio) {
        if (DBG) {
            Log.d(TAG, "sendAudioProfilePreferences groupId=" + groupId
                    + ", isOutputPreferenceLeAudio=" + isOutputPreferenceLeAudio
                    + ", isDuplexPreferenceLeAudio=" + isDuplexPreferenceLeAudio);
        }
        sendAudioProfilePreferencesNative(groupId, isOutputPreferenceLeAudio,
                isDuplexPreferenceLeAudio);
    }

    // Native methods that call into the JNI interface
    private static native void classInitNative();
    private native void initNative(BluetoothLeAudioCodecConfig[] codecConfigOffloading);
@@ -330,4 +348,7 @@ public class LeAudioNativeInterface {
            BluetoothLeAudioCodecConfig outputCodecConfig);
    private native void setCcidInformationNative(int ccid, int contextType);
    private native void setInCallNative(boolean inCall);
    /*package*/
    private native void sendAudioProfilePreferencesNative(int groupId,
            boolean isOutputPreferenceLeAudio, boolean isDuplexPreferenceLeAudio);
}
+21 −0
Original line number Diff line number Diff line
@@ -2347,6 +2347,27 @@ public class LeAudioService extends ProfileService {
        mLeAudioNativeInterface.setInCall(inCall);
    }

    /**
     * Sends the preferred audio profiles for a dual mode audio device to the native stack.
     *
     * @param groupId is the group id of the device which had a preference change
     * @param isOutputPreferenceLeAudio {@code true} if {@link BluetoothProfile#LE_AUDIO} is
     * preferred for {@link BluetoothAdapter#AUDIO_MODE_OUTPUT_ONLY}, {@code false} if it is
     * {@link BluetoothProfile#A2DP}
     * @param isDuplexPreferenceLeAudio {@code true} if {@link BluetoothProfile#LE_AUDIO} is
     * preferred for {@link BluetoothAdapter#AUDIO_MODE_DUPLEX}, {@code false} if it is
     * {@link BluetoothProfile#HEADSET}
     */
    public void sendAudioProfilePreferencesToNative(int groupId, boolean isOutputPreferenceLeAudio,
            boolean isDuplexPreferenceLeAudio) {
        if (!mLeAudioNativeIsInitialized) {
            Log.e(TAG, "Le Audio not initialized properly.");
            return;
        }
        mLeAudioNativeInterface.sendAudioProfilePreferences(groupId, isOutputPreferenceLeAudio,
                isDuplexPreferenceLeAudio);
    }

    /**
     * Set Inactive by HFP during handover
     */
Loading