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

Commit bb4a2f88 authored by Sungsoo Lim's avatar Sungsoo Lim Committed by Gerrit Code Review
Browse files

Merge "Clone ActiveDeviceManager to AudioRoutingManager" into main

parents 28780ab6 143e582e
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -973,6 +973,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
     *
     *
     * @return true when the fallback device is activated, false otherwise
     * @return true when the fallback device is activated, false otherwise
     */
     */
    @GuardedBy("mLock")
    private boolean setFallbackDeviceActiveLocked() {
    private boolean setFallbackDeviceActiveLocked() {
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "setFallbackDeviceActive");
            Log.d(TAG, "setFallbackDeviceActive");
@@ -1149,7 +1150,8 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
        return mLeAudioActiveDevice;
        return mLeAudioActiveDevice;
    }
    }


    long getHearingAidActiveHiSyncIdLocked() {
    @GuardedBy("mLock")
    private long getHearingAidActiveHiSyncIdLocked() {
        final HearingAidService hearingAidService = mFactory.getHearingAidService();
        final HearingAidService hearingAidService = mFactory.getHearingAidService();
        if (hearingAidService != null && !mHearingAidActiveDevices.isEmpty()) {
        if (hearingAidService != null && !mHearingAidActiveDevices.isEmpty()) {
            return hearingAidService.getHiSyncId(mHearingAidActiveDevices.iterator().next());
            return hearingAidService.getHiSyncId(mHearingAidActiveDevices.iterator().next());
+6 −1
Original line number Original line Diff line number Diff line
@@ -107,6 +107,7 @@ import android.util.SparseArray;


import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Flags;
import com.android.bluetooth.R;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.a2dp.A2dpService;
@@ -701,7 +702,11 @@ public class AdapterService extends Service {
            Log.i(TAG, "Phone policy disabled");
            Log.i(TAG, "Phone policy disabled");
        }
        }


        if (Flags.audioRoutingCentralization()) {
            mActiveDeviceManager = new AudioRoutingManager(this, new ServiceFactory());
        } else {
            mActiveDeviceManager = new ActiveDeviceManager(this, new ServiceFactory());
            mActiveDeviceManager = new ActiveDeviceManager(this, new ServiceFactory());
        }
        mActiveDeviceManager.start();
        mActiveDeviceManager.start();


        mSilenceDeviceManager = new SilenceDeviceManager(this, new ServiceFactory(), mLooper);
        mSilenceDeviceManager = new SilenceDeviceManager(this, new ServiceFactory(), mLooper);
+1227 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −5
Original line number Original line Diff line number Diff line
@@ -39,7 +39,6 @@ import android.media.AudioManager;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.SparseIntArray;
import android.util.SparseIntArray;


import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.runner.AndroidJUnit4;


@@ -47,7 +46,6 @@ import com.android.bluetooth.TestUtils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.hap.HapClientService;
import com.android.bluetooth.hearingaid.HearingAidService;
import com.android.bluetooth.hearingaid.HearingAidService;
import com.android.bluetooth.hfp.HeadsetService;
import com.android.bluetooth.hfp.HeadsetService;
import com.android.bluetooth.le_audio.LeAudioService;
import com.android.bluetooth.le_audio.LeAudioService;
@@ -70,7 +68,6 @@ import java.util.Objects;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4.class)
public class ActiveDeviceManagerTest {
public class ActiveDeviceManagerTest {
    private BluetoothAdapter mAdapter;
    private BluetoothAdapter mAdapter;
    private Context mContext;
    private BluetoothDevice mA2dpDevice;
    private BluetoothDevice mA2dpDevice;
    private BluetoothDevice mHeadsetDevice;
    private BluetoothDevice mHeadsetDevice;
    private BluetoothDevice mA2dpHeadsetDevice;
    private BluetoothDevice mA2dpHeadsetDevice;
@@ -98,11 +95,9 @@ public class ActiveDeviceManagerTest {
    @Mock private HearingAidService mHearingAidService;
    @Mock private HearingAidService mHearingAidService;
    @Mock private LeAudioService mLeAudioService;
    @Mock private LeAudioService mLeAudioService;
    @Mock private AudioManager mAudioManager;
    @Mock private AudioManager mAudioManager;
    @Mock private HapClientService mHapClientService;


    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mContext = InstrumentationRegistry.getTargetContext();
        // Set up mocks and test assets
        // Set up mocks and test assets
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        TestUtils.setAdapterService(mAdapterService);
+1376 −0

File added.

Preview size limit exceeded, changes collapsed.