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

Commit cb80260c authored by Sal Savage's avatar Sal Savage
Browse files

Migrate ASHA central enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I8c399fde5bfe206393f45829a01e9cadf4c712bb
Change-Id: I8c399fde5bfe206393f45829a01e9cadf4c712bb
parent 327f2872
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -113,6 +113,16 @@
            </intent-filter>
        </service>

        <!--  Android Audio Support for Hearing Aids (ASHA) central Profile Service -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hearingaid.HearingAidService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHearingAid"/>
            </intent-filter>
        </service>

        <!--  Audio/Video Remote Control Profile (AVRCP) target Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.avrcp.AvrcpTargetService"
@@ -506,13 +516,6 @@
                <action android:name="android.bluetooth.IBluetoothPbapClient"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".hearingaid.HearingAidService"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHearingAid"/>
            </intent-filter>
        </service>
        <!-- Authenticator for PBAP account. -->
        <service android:process="@string/process"
             android:name=".pbapclient.AuthenticationService"
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.media.AudioManager;
import android.media.BluetoothProfileConnectionInfo;
import android.os.HandlerThread;
import android.os.ParcelUuid;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
@@ -90,6 +91,10 @@ public class HearingAidService extends ProfileService {

    private final ServiceFactory mFactory = new ServiceFactory();

    public static boolean isEnabled() {
        return BluetoothProperties.isProfileAshaCentralEnabled().orElse(false);
    }

    @Override
    protected IProfileServiceBinder initBinder() {
        return new BluetoothHearingAidBinder(this);
+4 −4
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class ActiveDeviceManagerTest {
    @Test
    public void hearingAidActive_clearA2dpAndHeadsetActive() {
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());

        a2dpConnected(mA2dpHeadsetDevice);
        headsetConnected(mA2dpHeadsetDevice);
@@ -237,7 +237,7 @@ public class ActiveDeviceManagerTest {
    @Test
    public void hearingAidActive_dontSetA2dpAndHeadsetActive() {
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());

        hearingAidActiveDeviceChanged(mHearingAidDevice);
        a2dpConnected(mA2dpHeadsetDevice);
@@ -254,7 +254,7 @@ public class ActiveDeviceManagerTest {
    @Test
    public void hearingAidActive_setA2dpActiveExplicitly() {
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());

        hearingAidActiveDeviceChanged(mHearingAidDevice);
        a2dpConnected(mA2dpHeadsetDevice);
@@ -274,7 +274,7 @@ public class ActiveDeviceManagerTest {
    @Test
    public void hearingAidActive_setHeadsetActiveExplicitly() {
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());

        hearingAidActiveDeviceChanged(mHearingAidDevice);
        headsetConnected(mA2dpHeadsetDevice);
+2 −2
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class HearingAidServiceTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());
        // Set up mocks and test assets
        MockitoAnnotations.initMocks(this);

@@ -127,7 +127,7 @@ public class HearingAidServiceTest {

    @After
    public void tearDown() throws Exception {
        if (!BluetoothProperties.isProfileAshaCentralEnabled().orElse(false)) {
        if (!HearingAidService.isEnabled()) {
            return;
        }
        stopService();
+2 −2
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public class HearingAidStateMachineTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HearingAidService is not enabled",
                BluetoothProperties.isProfileAshaCentralEnabled().orElse(false));
                HearingAidService.isEnabled());
        // Set up mocks and test assets
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
@@ -86,7 +86,7 @@ public class HearingAidStateMachineTest {

    @After
    public void tearDown() throws Exception {
        if (!BluetoothProperties.isProfileAshaCentralEnabled().orElse(false)) {
        if (!HearingAidService.isEnabled()) {
            return;
        }
        mHearingAidStateMachine.doQuit();