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

Commit c2278cce authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes Ic814d725,I7cf5dab4,If89c4f22

* changes:
  U on T: SdkCheck before calling createLeAudioOutputInfo
  U on T: SdkCheck before calling setLeAudioSuspended
  Bluetooth: Enable NewApi lint as error
parents 06fc043b 87ecf3e8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -256,6 +256,11 @@ android_app {
    // Add in path to Bluetooth directory because local path does not exist
    javacflags: ["-Aroom.schemaLocation=packages/modules/Bluetooth/android/app/tests/unit/src/com/android/bluetooth/btservice/storage/schemas"],

    lint: {
        error_checks: ["NewApi"],
        strict_updatability_linting: true,
    },

    optimize: {
        enabled: true,
        shrink: true,
+7506 −0

File added.

Preview size limit exceeded, changes collapsed.

+10 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.MODIFY_PHONE_STATE;

import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.modules.utils.build.SdkLevel.isAtLeastU;

import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -1852,8 +1853,10 @@ public class HeadsetService extends ProfileService {
            if (mActiveDevice != null && callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED
                    && !mSystemInterface.isCallIdle() && isCallIdleBefore) {
                mSystemInterface.getAudioManager().setA2dpSuspended(true);
                if (isAtLeastU()) {
                    mSystemInterface.getAudioManager().setLeAudioSuspended(true);
                }
            }
        });
        doForEachConnectedStateMachine(
                stateMachine -> stateMachine.sendMessage(HeadsetStateMachine.CALL_STATE_CHANGED,
@@ -1863,8 +1866,10 @@ public class HeadsetService extends ProfileService {
                    && mSystemInterface.isCallIdle() && !isAudioOn()) {
                // Resume A2DP when call ended and SCO is not connected
                mSystemInterface.getAudioManager().setA2dpSuspended(false);
                if (isAtLeastU()) {
                    mSystemInterface.getAudioManager().setLeAudioSuspended(false);
                }
            }
        });
        if (callState == HeadsetHalConstants.CALL_STATE_IDLE) {
            final HeadsetStateMachine stateMachine = mStateMachines.get(mActiveDevice);
@@ -2099,11 +2104,13 @@ public class HeadsetService extends ProfileService {
                // Unsuspend A2DP when SCO connection is gone and call state is idle
                if (mSystemInterface.isCallIdle()) {
                    mSystemInterface.getAudioManager().setA2dpSuspended(false);
                    if (isAtLeastU()) {
                        mSystemInterface.getAudioManager().setLeAudioSuspended(false);
                    }
                }
            }
        }
    }

    private void broadcastActiveDevice(BluetoothDevice device) {
        logD("broadcastActiveDevice: " + device);
+8 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.bluetooth.hfp;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.modules.utils.build.SdkLevel.isAtLeastU;

import android.annotation.RequiresPermission;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAssignedNumbers;
@@ -1147,10 +1149,14 @@ public class HeadsetStateMachine extends StateMachine {
                case CONNECT_AUDIO:
                    stateLogD("CONNECT_AUDIO, device=" + mDevice);
                    mSystemInterface.getAudioManager().setA2dpSuspended(true);
                    if (isAtLeastU()) {
                        mSystemInterface.getAudioManager().setLeAudioSuspended(true);
                    }
                    if (!mNativeInterface.connectAudio(mDevice)) {
                        mSystemInterface.getAudioManager().setA2dpSuspended(false);
                        if (isAtLeastU()) {
                            mSystemInterface.getAudioManager().setLeAudioSuspended(false);
                        }
                        stateLogE("Failed to connect SCO audio for " + mDevice);
                        // No state change involved, fire broadcast immediately
                        broadcastAudioState(mDevice, BluetoothHeadset.STATE_AUDIO_DISCONNECTED,
+25 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.bluetooth.IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID;

import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.modules.utils.build.SdkLevel.isAtLeastU;

import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
@@ -1324,9 +1325,17 @@ public class LeAudioService extends ProfileService {

            final boolean suppressNoisyIntent = hasFallbackDevice || mActiveAudioOutDevice != null;

            mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioOutDevice,
                    previousActiveOutDevice, BluetoothProfileConnectionInfo.createLeAudioOutputInfo(
                            suppressNoisyIntent, volume));
            final BluetoothProfileConnectionInfo connectionInfo;
            if (isAtLeastU()) {
                connectionInfo =
                        BluetoothProfileConnectionInfo.createLeAudioOutputInfo(
                                suppressNoisyIntent, volume);
            } else {
                connectionInfo =
                        BluetoothProfileConnectionInfo.createLeAudioInfo(suppressNoisyIntent, true);
            }
            mAudioManager.handleBluetoothActiveDeviceChanged(
                    mActiveAudioOutDevice, previousActiveOutDevice, connectionInfo);
        }

        if (isNewActiveInDevice) {
@@ -3110,9 +3119,19 @@ public class LeAudioService extends ProfileService {
            Log.i(TAG, "Sending LE Audio Output active device changed for preferred profile "
                    + "change with volume=" + volume + " and suppressNoisyIntent="
                    + suppressNoisyIntent);
            mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioOutDevice,
                    mActiveAudioOutDevice, BluetoothProfileConnectionInfo.createLeAudioOutputInfo(
                            suppressNoisyIntent, volume));

            final BluetoothProfileConnectionInfo connectionInfo;
            if (isAtLeastU()) {
                connectionInfo =
                        BluetoothProfileConnectionInfo.createLeAudioOutputInfo(
                                suppressNoisyIntent, volume);
            } else {
                connectionInfo =
                        BluetoothProfileConnectionInfo.createLeAudioInfo(suppressNoisyIntent, true);
            }

            mAudioManager.handleBluetoothActiveDeviceChanged(
                    mActiveAudioOutDevice, mActiveAudioOutDevice, connectionInfo);
            audioFrameworkCalls++;
        }