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

Commit 67874a77 authored by Sal Savage's avatar Sal Savage
Browse files

Migrate HFP HF/Client enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I8c399fde5bfe206393f45829a01e9cadf4c712bb
Change-Id: I3ca9ab1332b97a09c42edf8d41d029ecf286b76b
parent cb80260c
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -231,6 +231,25 @@
            </intent-filter>
        </service>

        <!--  Hands-Free HF/Client Profile Service and owned Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hfpclient.HeadsetClientService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHeadsetClient"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hfpclient.HfpClientConnectionService"
             android:permission="android.permission.BIND_CONNECTION_SERVICE"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService"/>
            </intent-filter>
        </service>

        <!--  Human Interface Device (HID) host Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hid.HidHostService"
@@ -490,24 +509,6 @@
                <action android:name="android.bluetooth.IBluetoothPan"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".hfpclient.HeadsetClientService"
             android:enabled="@bool/profile_supported_hfpclient"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHeadsetClient"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".hfpclient.HfpClientConnectionService"
             android:permission="android.permission.BIND_CONNECTION_SERVICE"
             android:enabled="@bool/hfp_client_connection_service_enabled"
             android:exported="true">
            <intent-filter>
                <!-- Mechanism for Telecom stack to connect -->
                <action android:name="android.telecom.ConnectionService"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".pbapclient.PbapClientService"
             android:enabled="@bool/profile_supported_pbapclient"
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
-->
<resources>
    <bool name="profile_supported_hs_hfp">true</bool>
    <bool name="profile_supported_hfpclient">false</bool>
    <bool name="profile_supported_hfp_incallservice">true</bool>
    <bool name="profile_supported_opp">true</bool>
    <bool name="profile_supported_pan">true</bool>
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.BatteryManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.Message;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.Utils;
@@ -81,6 +82,10 @@ public class HeadsetClientService extends ProfileService {

    public static final String HFP_CLIENT_STOP_TAG = "hfp_client_stop_tag";

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

    @Override
    public IProfileServiceBinder initBinder() {
        return new BluetoothHeadsetClientBinder(this);
+2 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class HeadsetClientServiceTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HeadsetClientService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient));
                HeadsetClientService.isEnabled());
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
@@ -86,7 +86,7 @@ public class HeadsetClientServiceTest {

    @After
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient)) {
        if (!HeadsetClientService.isEnabled()) {
            return;
        }
        TestUtils.stopService(mServiceRule, HeadsetClientService.class);
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class HeadsetClientStateMachineTest {
    public void setUp() {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HeadsetClientService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient));
                HeadsetClientService.isEnabled());
        // Setup mocks and test assets
        MockitoAnnotations.initMocks(this);
        // Set a valid volume
@@ -104,7 +104,7 @@ public class HeadsetClientStateMachineTest {

    @After
    public void tearDown() {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient)) {
        if (!HeadsetClientService.isEnabled()) {
            return;
        }
        TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());