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

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

Migrate MAP client enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I8c399fde5bfe206393f45829a01e9cadf4c712bb
Change-Id: I0290136e1de8108e271c0556170477a4a4243a34
parent 5866f3f3
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -295,6 +295,16 @@
             android:exported="false">
             android:exported="false">
        </provider>
        </provider>


        <!--  Message Access Profile (MAP) client Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.mapclient.MapClientService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothMapClient"/>
            </intent-filter>
        </service>

        <!--  Media Control Profile (MCP) server Profile Service  -->
        <!--  Media Control Profile (MCP) server Profile Service  -->
        <service android:process="@string/process"
        <service android:process="@string/process"
             android:name="com.android.bluetooth.mcp.McpService"
             android:name="com.android.bluetooth.mcp.McpService"
@@ -478,14 +488,6 @@
                <action android:name="android.bluetooth.IBluetoothPbap"/>
                <action android:name="android.bluetooth.IBluetoothPbap"/>
            </intent-filter>
            </intent-filter>
        </service>
        </service>
        <service android:process="@string/process"
             android:name=".mapclient.MapClientService"
             android:enabled="@bool/profile_supported_mapmce"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothMapClient"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
        <service android:process="@string/process"
             android:name=".sap.SapService"
             android:name=".sap.SapService"
             android:enabled="@bool/profile_supported_sap"
             android:enabled="@bool/profile_supported_sap"
+0 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@
    <bool name="pbap_use_profile_for_owner_vcard">true</bool>
    <bool name="pbap_use_profile_for_owner_vcard">true</bool>
    <bool name="profile_supported_sap">false</bool>
    <bool name="profile_supported_sap">false</bool>
    <bool name="profile_supported_pbapclient">false</bool>
    <bool name="profile_supported_pbapclient">false</bool>
    <bool name="profile_supported_mapmce">false</bool>


    <!-- If true, we will require location to be enabled on the device to
    <!-- If true, we will require location to be enabled on the device to
         fire Bluetooth LE scan result callbacks in addition to having one
         fire Bluetooth LE scan result callbacks in addition to having one
+5 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.net.Uri;
import android.net.Uri;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.sysprop.BluetoothProperties;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -65,6 +66,10 @@ public class MapClientService extends ProfileService {
    private static MapClientService sMapClientService;
    private static MapClientService sMapClientService;
    private MapBroadcastReceiver mMapReceiver;
    private MapBroadcastReceiver mMapReceiver;


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

    public static synchronized MapClientService getMapClientService() {
    public static synchronized MapClientService getMapClientService() {
        if (sMapClientService == null) {
        if (sMapClientService == null) {
            Log.w(TAG, "getMapClientService(): service is null");
            Log.w(TAG, "getMapClientService(): service is null");
+2 −2
Original line number Original line Diff line number Diff line
@@ -106,7 +106,7 @@ public class MapClientStateMachineTest {
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when MapClientService is not enabled",
        Assume.assumeTrue("Ignore test when MapClientService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_mapmce));
                MapClientService.isEnabled());
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        mMockContentProvider = new MockSmsContentProvider();
        mMockContentProvider = new MockSmsContentProvider();
        mMockContentResolver = new MockContentResolver();
        mMockContentResolver = new MockContentResolver();
@@ -142,7 +142,7 @@ public class MapClientStateMachineTest {


    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_mapmce)) {
        if (!MapClientService.isEnabled()) {
            return;
            return;
        }
        }


+2 −2
Original line number Original line Diff line number Diff line
@@ -68,7 +68,7 @@ public class MapClientTest {
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when MapClientService is not enabled",
        Assume.assumeTrue("Ignore test when MapClientService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_mapmce));
                MapClientService.isEnabled());
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        TestUtils.setAdapterService(mAdapterService);
        when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
        when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
@@ -82,7 +82,7 @@ public class MapClientTest {


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