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

Commit 327f2872 authored by Sal Savage's avatar Sal Savage
Browse files

Migrate HID host/device enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I0d81eb91a6576818e0f83df7ac3a6bf0ac6c8b97
Change-Id: I0d81eb91a6576818e0f83df7ac3a6bf0ac6c8b97
parent 417b0396
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -221,6 +221,26 @@
            </intent-filter>
        </service>

        <!--  Human Interface Device (HID) host Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hid.HidHostService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHidHost"/>
            </intent-filter>
        </service>

        <!--  Human Interface Device (HID) device Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hid.HidDeviceService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHidDevice"/>
            </intent-filter>
        </service>

        <!--  Media Control Profile (MCP) server Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.mcp.McpService"
@@ -451,22 +471,6 @@
                <action android:name="android.bluetooth.IBluetoothHeadset"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".hid.HidHostService"
             android:enabled="@bool/profile_supported_hid_host"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHidHost"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".hid.HidDeviceService"
             android:enabled="@bool/profile_supported_hid_device"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHidDevice"/>
            </intent-filter>
        </service>
        <service
             android:process="@string/process"
             android:name=".pan.PanService"
+0 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
    <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_hid_host">true</bool>
    <bool name="profile_supported_opp">true</bool>
    <bool name="profile_supported_pan">true</bool>
    <bool name="profile_supported_pbap">true</bool>
@@ -26,7 +25,6 @@
    <bool name="profile_supported_sap">false</bool>
    <bool name="profile_supported_pbapclient">false</bool>
    <bool name="profile_supported_mapmce">false</bool>
    <bool name="profile_supported_hid_device">true</bool>

    <!-- If true, we will require location to be enabled on the device to
         fire Bluetooth LE scan result callbacks in addition to having one
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.os.IBinder;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
@@ -85,6 +86,10 @@ public class HidDeviceService extends ProfileService {

    private HidDeviceServiceHandler mHandler;

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

    private class HidDeviceServiceHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.UserHandle;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import androidx.annotation.VisibleForTesting;
@@ -87,6 +88,10 @@ public class HidHostService extends ProfileService {
        classInitNative();
    }

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

    @Override
    public IProfileServiceBinder initBinder() {
        return new BluetoothHidHostBinder(this);
+2 −2
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ public class HidDeviceTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HidDeviceService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_hid_device));
                HidDeviceService.isEnabled());
        if (Looper.myLooper() == null) {
            Looper.prepare();
        }
@@ -145,7 +145,7 @@ public class HidDeviceTest {

    @After
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_hid_device)) {
        if (!HidDeviceService.isEnabled()) {
            return;
        }
        TestUtils.stopService(mServiceRule, HidDeviceService.class);
Loading