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

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

Merge "Remove use of the enable_queuing_profile_connection_change flag in Scan Manager." into main

parents f25f1883 4e5a6ed1
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.util.Log;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.BluetoothAdapterProxy;
import com.android.bluetooth.flags.FeatureFlagsImpl;

/**
 * Factory class for object initialization to help with unit testing
@@ -71,8 +70,7 @@ public class GattObjectsFactory {

    public ScanManager createScanManager(GattService service, AdapterService adapterService,
            BluetoothAdapterProxy bluetoothAdapterProxy) {
        return new ScanManager(
                service, adapterService, bluetoothAdapterProxy, new FeatureFlagsImpl());
        return new ScanManager(service, adapterService, bluetoothAdapterProxy);
    }

    public PeriodicScanManager createPeriodicScanManager(AdapterService adapterService) {
+10 −37
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import android.view.Display;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.BluetoothAdapterProxy;
import com.android.bluetooth.flags.FeatureFlags;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

@@ -57,7 +56,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -121,7 +119,6 @@ public class ScanManager {
    private int mCurUsedTrackableAdvertisements = 0;
    private final GattService mService;
    private final AdapterService mAdapterService;
    private final FeatureFlags mFeatureFlags;
    private BroadcastReceiver mBatchAlarmReceiver;
    private boolean mBatchAlarmReceiverRegistered;
    private ScanNative mScanNative;
@@ -163,8 +160,7 @@ public class ScanManager {
    ScanManager(
            GattService service,
            AdapterService adapterService,
            BluetoothAdapterProxy bluetoothAdapterProxy,
            FeatureFlags featureFlags) {
            BluetoothAdapterProxy bluetoothAdapterProxy) {
        mRegularScanClients =
                Collections.newSetFromMap(new ConcurrentHashMap<ScanClient, Boolean>());
        mBatchClients = Collections.newSetFromMap(new ConcurrentHashMap<ScanClient, Boolean>());
@@ -178,7 +174,6 @@ public class ScanManager {
        mLocationManager = mAdapterService.getSystemService(LocationManager.class);
        mBluetoothAdapterProxy = bluetoothAdapterProxy;
        mIsConnecting = false;
        mFeatureFlags = Objects.requireNonNull(featureFlags, "Feature Flags cannot be null");

        mPriorityMap.put(ScanSettings.SCAN_MODE_OPPORTUNISTIC, 0);
        mPriorityMap.put(ScanSettings.SCAN_MODE_SCREEN_OFF, 1);
@@ -2047,7 +2042,6 @@ public class ScanManager {
     */
    public void handleBluetoothProfileConnectionStateChanged(
            int profile, int fromState, int toState) {
        if (mFeatureFlags.enableQueuingProfileConnectionChange()) {
        if (mHandler == null) {
            Log.d(TAG, "handleBluetoothProfileConnectionStateChanged: mHandler is null.");
            return;
@@ -2060,25 +2054,4 @@ public class ScanManager {
                .sendToTarget();
        return;
    }
        boolean updatedConnectingState =
                updateCountersAndCheckForConnectingState(toState, fromState);
        if (DBG) {
            Log.d(
                    TAG,
                    "PROFILE_CONNECTION_STATE_CHANGE:"
                            + (" profile=" + BluetoothProfile.getProfileName(profile))
                            + (", prevState=" + fromState)
                            + (", state=" + toState)
                            + ("updatedConnectingState = " + updatedConnectingState));
        }
        if (updatedConnectingState) {
            if (!mIsConnecting) {
                sendMessage(MSG_START_CONNECTING, null);
            }
        } else {
            if (mIsConnecting) {
                sendMessage(MSG_STOP_CONNECTING, null);
            }
        }
    }
}
+1 −12
Original line number Diff line number Diff line
@@ -67,8 +67,6 @@ import com.android.bluetooth.TestUtils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.BluetoothAdapterProxy;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.flags.FakeFeatureFlagsImpl;
import com.android.bluetooth.flags.Flags;
import com.android.internal.app.IBatteryStats;

import java.util.ArrayList;
@@ -126,7 +124,6 @@ public class ScanManagerTest {
    @Mock private ScanNativeInterface mScanNativeInterface;
    @Mock private MetricsLogger  mMetricsLogger;

    private FakeFeatureFlagsImpl mFakeFlagsImpl;
    private MockContentResolver mMockContentResolver;
    @Captor ArgumentCaptor<Long> mScanDurationCaptor;

@@ -184,10 +181,7 @@ public class ScanManagerTest {
        doReturn(mTargetContext.getUser()).when(mMockGattService).getUser();
        doReturn(mTargetContext.getPackageName()).when(mMockGattService).getPackageName();

        mFakeFlagsImpl = new FakeFeatureFlagsImpl();
        mScanManager =
                new ScanManager(
                        mMockGattService, mAdapterService, mBluetoothAdapterProxy, mFakeFlagsImpl);
        mScanManager = new ScanManager(mMockGattService, mAdapterService, mBluetoothAdapterProxy);

        mHandler = mScanManager.getClientHandler();
        assertThat(mHandler).isNotNull();
@@ -1389,10 +1383,6 @@ public class ScanManagerTest {

    @Test
    public void profileConnectionStateChanged_sendStartConnectionMessage() {
        // This test shouldn't be impacted by this flag. Setting it to false to ensure it passes
        // with the older behavior. Tested flag set to true locally to make sure it doesn't fail
        // when flag is removed.
        mFakeFlagsImpl.setFlag(Flags.FLAG_ENABLE_QUEUING_PROFILE_CONNECTION_CHANGE, false);
        // Set scan downgrade duration through Mock
        when(mAdapterService.getScanDowngradeDurationMillis())
                .thenReturn((long) DELAY_SCAN_DOWNGRADE_DURATION_MS);
@@ -1411,7 +1401,6 @@ public class ScanManagerTest {
    @Test
    public void multipleProfileConnectionStateChanged_updateCountersCorrectly()
            throws ExecutionException, InterruptedException {
        mFakeFlagsImpl.setFlag(Flags.FLAG_ENABLE_QUEUING_PROFILE_CONNECTION_CHANGE, true);
        when(mAdapterService.getScanDowngradeDurationMillis())
                .thenReturn((long) DELAY_SCAN_DOWNGRADE_DURATION_MS);
        assertThat(mScanManager.mIsConnecting).isFalse();
+0 −1
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ aconfig_declarations {
        "audio_routing.aconfig",
        "framework.aconfig",
        "gap.aconfig",
        "gatt.aconfig",
        "hap.aconfig",
        "hfp.aconfig",
        "leaudio.aconfig",

flags/gatt.aconfig

deleted100644 → 0
+0 −8
Original line number Diff line number Diff line
package: "com.android.bluetooth.flags"

flag {
    name: "enable_queuing_profile_connection_change"
    namespace: "bluetooth"
    description: "Queue Profile connection change events on the ClientHandler for Scan Manager"
    bug: "306033108"
}