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

Commit 008b78e4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12241618 from 5f20bff6 to 24Q4-release

Change-Id: I2efb6ae90ca5b3898264986f329e5dafd4f966e0
parents be234330 5f20bff6
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -125,9 +126,16 @@ final class A2dpStateMachine extends StateMachine {

    public void doQuit() {
        log("doQuit for device " + mDevice);
        if (Flags.a2dpBroadcastConnectionStateWhenTurnedOff()
                && mConnectionState != BluetoothProfile.STATE_DISCONNECTED
                && mLastConnectionState != -1) {
            // Broadcast CONNECTION_STATE_CHANGED when A2dpService is turned off while
            // the device is connected
            broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTED, mConnectionState);
        }
        if (mIsPlaying) {
            // Stop if auido is still playing
            log("doQuit: stopped playing " + mDevice);
            // Broadcast AUDIO_STATE_CHANGED when A2dpService is turned off while
            // the device is playing
            mIsPlaying = false;
            broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING);
        }
+29 −0
Original line number Diff line number Diff line
@@ -776,6 +776,7 @@ class AdapterProperties {
                                        BluetoothAdapter.EXTRA_PREVIOUS_CONNECTION_STATE,
                                        prevAdapterState)
                                .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
                logProfileConnectionStateChange(device, newState, prevState);
                Log.d(TAG, "updateOnProfileConnectionChanged: " + logInfo);
                mService.sendBroadcastAsUser(
                        intent,
@@ -786,6 +787,34 @@ class AdapterProperties {
        }
    }

    private void logProfileConnectionStateChange(BluetoothDevice device, int state, int prevState) {

        switch (state) {
            case BluetoothAdapter.STATE_CONNECTED:
                MetricsLogger.getInstance()
                        .logBluetoothEvent(
                                device,
                                BluetoothStatsLog
                                        .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION,
                                BluetoothStatsLog
                                        .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS,
                                0);
                break;
            case BluetoothAdapter.STATE_DISCONNECTED:
                if (prevState == BluetoothAdapter.STATE_CONNECTING) {
                    MetricsLogger.getInstance()
                            .logBluetoothEvent(
                                    device,
                                    BluetoothStatsLog
                                            .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION,
                                    BluetoothStatsLog
                                            .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__FAIL,
                                    0);
                }
                break;
        }
    }

    private boolean validateProfileConnectionState(int state) {
        return (state == BluetoothProfile.STATE_DISCONNECTED
                || state == BluetoothProfile.STATE_CONNECTING
+15 −0
Original line number Diff line number Diff line
@@ -2884,6 +2884,13 @@ public class AdapterService extends Service {
                            + device
                            + ", from "
                            + Utils.getUidPidString());
            MetricsLogger.getInstance()
                    .logBluetoothEvent(
                            device,
                            BluetoothStatsLog
                                    .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__INITIATOR_CONNECTION,
                            BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__START,
                            source.getUid());

            try {
                return service.connectAllEnabledProfiles(device);
@@ -4793,6 +4800,14 @@ public class AdapterService extends Service {
        }
        if (setData) {
            msg.setData(remoteOobDatasBundle);
        } else {
            MetricsLogger.getInstance()
                    .logBluetoothEvent(
                            device,
                            BluetoothStatsLog
                                    .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__BONDING,
                            BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__START,
                            Binder.getCallingUid());
        }
        mBondStateMachine.sendMessage(msg);
        return true;
+12 −2
Original line number Diff line number Diff line
@@ -782,7 +782,12 @@ public class ScanManager {
            if (upgradeScanModeByOneLevel(client)) {
                Message msg = obtainMessage(MSG_REVERT_SCAN_MODE_UPGRADE);
                msg.obj = client;
                Log.d(TAG, "scanMode is upgraded for " + client);
                Log.d(
                        TAG,
                        "scanMode is upgraded to "
                                + getScanModeString(client.settings.getScanMode())
                                + " for "
                                + client);
                sendMessageDelayed(msg, mAdapterService.getScanUpgradeDurationMillis());
                return true;
            }
@@ -809,7 +814,12 @@ public class ScanManager {
                return;
            }
            if (client.updateScanMode(client.scanModeApp)) {
                Log.d(TAG, "scanMode upgrade is reverted for " + client);
                Log.d(
                        TAG,
                        "scanMode upgrade is reverted to "
                                + getScanModeString(client.scanModeApp)
                                + " for "
                                + client);
                mScanNative.configureRegularScanParams();
            }
        }
+12 −1
Original line number Diff line number Diff line
@@ -104,7 +104,9 @@ public class A2dpServiceTest {

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(Flags.FLAG_A2DP_SERVICE_LOOPER);
        return FlagsParameterization.allCombinationsOf(
                Flags.FLAG_A2DP_SERVICE_LOOPER,
                Flags.FLAG_A2DP_BROADCAST_CONNECTION_STATE_WHEN_TURNED_OFF);
    }

    public A2dpServiceTest(FlagsParameterization flags) {
@@ -198,6 +200,15 @@ public class A2dpServiceTest {
        mA2dpService.stop();
        dispatchAtLeastOneMessage();

        if (Flags.a2dpBroadcastConnectionStateWhenTurnedOff()) {
            // Verify that the intent CONNECTION_STATE_CHANGED is generated
            // for the existing connections.
            verifyConnectionStateIntent(
                    sTestDevice,
                    BluetoothProfile.STATE_DISCONNECTED,
                    BluetoothProfile.STATE_CONNECTED);
        }

        // Verify that setActiveDevice(null) was called during shutdown
        verify(mMockNativeInterface).setActiveDevice(null);
        mA2dpService.start();
Loading