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

Commit bf7df198 authored by Aritra Sen's avatar Aritra Sen Committed by Gerrit Code Review
Browse files

Merge "Remove all ACTION_CONNECTION_STATE_CHANGED for A2DP, A2DP Sink, HFP,...

Merge "Remove all ACTION_CONNECTION_STATE_CHANGED for A2DP, A2DP Sink, HFP, HFP Client, LE Audio in Scan Manager." into main
parents 3acfa858 2a627c45
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,12 +17,10 @@
package com.android.bluetooth.a2dp;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.bluetooth.Utils.enforceCdmAssociation;
import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
@@ -1282,6 +1280,8 @@ public class A2dpService extends ProfileService {
        if (mFactory.getAvrcpTargetService() != null) {
            mFactory.getAvrcpTargetService().handleA2dpConnectionStateChanged(device, toState);
        }
        mAdapterService.notifyProfileConnectionStateChangeToGatt(
                BluetoothProfile.A2DP, fromState, toState);
        mAdapterService
                .getActiveDeviceManager()
                .profileConnectionStateChanged(BluetoothProfile.A2DP, device, fromState, toState);
+5 −0
Original line number Diff line number Diff line
@@ -640,4 +640,9 @@ public class A2dpSinkService extends ProfileService {
        A2dpSinkStateMachine stateMachine = getStateMachineForDevice(device);
        stateMachine.onStackEvent(event);
    }

    void connectionStateChanged(BluetoothDevice device, int fromState, int toState) {
        mAdapterService.notifyProfileConnectionStateChangeToGatt(
                BluetoothProfile.A2DP_SINK, fromState, toState);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -318,6 +318,7 @@ class A2dpSinkStateMachine extends StateMachine {
        intent.putExtra(BluetoothProfile.EXTRA_STATE, currentState);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        mService.connectionStateChanged(mDevice, mMostRecentState, currentState);
        mMostRecentState = currentState;
        Utils.sendBroadcast(mService, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
+12 −0
Original line number Diff line number Diff line
@@ -6845,6 +6845,18 @@ public class AdapterService extends Service {
        }
    }

    /**
     * Notify GATT of a Bluetooth profile's connection state change for a given {@link
     * BluetoothProfile}.
     */
    public void notifyProfileConnectionStateChangeToGatt(int profile, int fromState, int toState) {
        if (mGattService == null) {
            Log.w(TAG, "GATT Service is not running!");
            return;
        }
        mGattService.notifyProfileConnectionStateChange(profile, fromState, toState);
    }

    static int convertScanModeToHal(int mode) {
        switch (mode) {
            case BluetoothAdapter.SCAN_MODE_NONE:
+9 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.bluetooth.gatt;

import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE;

import static com.android.bluetooth.Utils.callerIsSystemOrActiveOrManagedUser;
import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
@@ -497,6 +496,15 @@ public class GattService extends ProfileService {
        return super.onStartCommand(intent, flags, startId);
    }

    /** Notify Scan manager of bluetooth profile connection state changes */
    public void notifyProfileConnectionStateChange(int profile, int fromState, int toState) {
        if (mScanManager == null) {
            Log.w(TAG, "scan manager is null");
            return;
        }
        mScanManager.handleBluetoothProfileConnectionStateChanged(profile, fromState, toState);
    }

    /**
     * DeathReceipient handlers used to unregister applications that
     * disconnect ungracefully (ie. crash or forced close).
Loading