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

Commit 417b0396 authored by Sal Savage's avatar Sal Savage
Browse files

Migrate GATT enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: Iabe4eeb815c7d426496039f97119088af049aca9
Change-Id: Iabe4eeb815c7d426496039f97119088af049aca9
parent e6603c92
Loading
Loading
Loading
Loading
+11 −8
Original line number Original line Diff line number Diff line
@@ -200,6 +200,17 @@
            </intent-filter>
            </intent-filter>
        </service>
        </service>


        <!--  Generic Attribute (GATT) Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.gatt.GattService"
             android:enabled="true"
             android:exported="true"
             android:permission="android.permission.ACCESS_BLUETOOTH_SHARE">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothGatt"/>
            </intent-filter>
        </service>

        <!--  Hearing Aid Profile (HAP) client Profile Service  -->
        <!--  Hearing Aid Profile (HAP) client Profile Service  -->
        <service android:process="@string/process"
        <service android:process="@string/process"
             android:name="com.android.bluetooth.hap.HapClientService"
             android:name="com.android.bluetooth.hap.HapClientService"
@@ -432,14 +443,6 @@
                <action android:name="android.bluetooth.IBluetoothSap"/>
                <action android:name="android.bluetooth.IBluetoothSap"/>
            </intent-filter>
            </intent-filter>
        </service>
        </service>
        <service android:process="@string/process"
             android:name=".gatt.GattService"
             android:enabled="@bool/profile_supported_gatt"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothGatt"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
        <service android:process="@string/process"
             android:name=".hfp.HeadsetService"
             android:name=".hfp.HeadsetService"
             android:enabled="@bool/profile_supported_hs_hfp"
             android:enabled="@bool/profile_supported_hs_hfp"
+0 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@
    <bool name="profile_supported_opp">true</bool>
    <bool name="profile_supported_opp">true</bool>
    <bool name="profile_supported_pan">true</bool>
    <bool name="profile_supported_pan">true</bool>
    <bool name="profile_supported_pbap">true</bool>
    <bool name="profile_supported_pbap">true</bool>
    <bool name="profile_supported_gatt">true</bool>
    <bool name="pbap_include_photos_in_vcard">true</bool>
    <bool name="pbap_include_photos_in_vcard">true</bool>
    <bool name="pbap_use_profile_for_owner_vcard">true</bool>
    <bool name="pbap_use_profile_for_owner_vcard">true</bool>
    <bool name="profile_supported_map">true</bool>
    <bool name="profile_supported_map">true</bool>
+5 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ import android.os.UserHandle;
import android.os.WorkSource;
import android.os.WorkSource;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.provider.Settings;
import android.sysprop.BluetoothProperties;
import android.text.format.DateUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.Log;


@@ -269,6 +270,10 @@ public class GattService extends ProfileService {
    private Handler mTestModeHandler;
    private Handler mTestModeHandler;
    private final Object mTestModeLock = new Object();
    private final Object mTestModeLock = new Object();


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

    /**
    /**
     */
     */
    private final Predicate<ScanResult> mLocationDenylistPredicate = (scanResult) -> {
    private final Predicate<ScanResult> mLocationDenylistPredicate = (scanResult) -> {
+2 −3
Original line number Original line Diff line number Diff line
@@ -40,8 +40,7 @@ public class GattServiceTest {
    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when GattService is not enabled",
        Assume.assumeTrue("Ignore test when GattService is not enabled", GattService.isEnabled());
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_gatt));
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
@@ -52,7 +51,7 @@ public class GattServiceTest {


    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_gatt)) {
        if (!GattService.isEnabled()) {
            return;
            return;
        }
        }
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());