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

Commit 5866f3f3 authored by Sal Savage's avatar Sal Savage
Browse files

Migrate MAP server enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I8c399fde5bfe206393f45829a01e9cadf4c712bb
Change-Id: I87e3976b81a571d6d8960b9173161b7f452a94e5
parent 67874a77
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -270,6 +270,31 @@
            </intent-filter>
        </service>

        <!--  Message Access Profile (MAP) server Profile Service and owned Provider and Activiie  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.map.BluetoothMapService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothMap"/>
                <action android:name="android.btmap.intent.action.SHOW_MAPS_SETTINGS"/>
                <action android:name="com.android.bluetooth.map.USER_CONFIRM_TIMEOUT"/>
            </intent-filter>
        </service>
        <activity android:name="com.android.bluetooth.map.BluetoothMapSettings"
              android:process="@string/process"
              android:label="@string/bluetooth_map_settings_title"
              android:excludeFromRecents="true"
              android:configChanges="orientation|keyboardHidden"
              android:enabled="false">
        </activity>
        <provider android:name="com.android.bluetooth.map.MmsFileProvider"
             android:authorities="com.android.bluetooth.map.MmsFileProvider"
             android:enabled="false"
             android:grantUriPermissions="true"
             android:exported="false">
        </provider>

        <!--  Media Control Profile (MCP) server Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.mcp.McpService"
@@ -453,29 +478,6 @@
                <action android:name="android.bluetooth.IBluetoothPbap"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".map.BluetoothMapService"
             android:enabled="@bool/profile_supported_map"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothMap"/>
                <action android:name="android.btmap.intent.action.SHOW_MAPS_SETTINGS"/>
                <action android:name="com.android.bluetooth.map.USER_CONFIRM_TIMEOUT"/>
            </intent-filter>
        </service>
         <activity android:name=".map.BluetoothMapSettings"
              android:process="@string/process"
              android:label="@string/bluetooth_map_settings_title"
              android:excludeFromRecents="true"
              android:configChanges="orientation|keyboardHidden"
              android:enabled="@bool/profile_supported_map">
        </activity>
        <provider android:name=".map.MmsFileProvider"
             android:authorities="com.android.bluetooth.map.MmsFileProvider"
             android:enabled="true"
             android:grantUriPermissions="true"
             android:exported="false">
        </provider>
        <service android:process="@string/process"
             android:name=".mapclient.MapClientService"
             android:enabled="@bool/profile_supported_mapmce"
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
    <bool name="profile_supported_pbap">true</bool>
    <bool name="pbap_include_photos_in_vcard">true</bool>
    <bool name="pbap_use_profile_for_owner_vcard">true</bool>
    <bool name="profile_supported_map">true</bool>
    <bool name="profile_supported_sap">false</bool>
    <bool name="profile_supported_pbapclient">false</bool>
    <bool name="profile_supported_mapmce">false</bool>
+18 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.bluetooth.IBluetoothMap;
import android.bluetooth.SdpMnsRecord;
import android.content.AttributionSource;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -42,6 +43,7 @@ import android.os.Message;
import android.os.ParcelUuid;
import android.os.PowerManager;
import android.os.RemoteException;
import android.sysprop.BluetoothProperties;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -77,6 +79,13 @@ public class BluetoothMapService extends ProfileService {

    public static final boolean VERBOSE = false;

    /**
     * The component names for the owned provider and activity
     */
    private static final String MAP_SETTINGS_ACTIVITY =
            BluetoothMapSettings.class.getCanonicalName();
    private static final String MAP_FILE_PROVIDER = MmsFileProvider.class.getCanonicalName();

    /**
     * Intent indicating timeout for user confirmation, which is sent to
     * BluetoothMapActivity
@@ -155,6 +164,10 @@ public class BluetoothMapService extends ProfileService {
            BluetoothUuid.MAP, BluetoothUuid.MNS,
    };

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

    public BluetoothMapService() {
        mState = BluetoothMap.STATE_DISCONNECTED;
    }
@@ -660,6 +673,9 @@ public class BluetoothMapService extends ProfileService {
        mDatabaseManager = Objects.requireNonNull(AdapterService.getAdapterService().getDatabase(),
                "DatabaseManager cannot be null when MapService starts");

        setComponentAvailable(MAP_SETTINGS_ACTIVITY, true);
        setComponentAvailable(MAP_FILE_PROVIDER, true);

        HandlerThread thread = new HandlerThread("BluetoothMapHandler");
        thread.start();
        Looper looper = thread.getLooper();
@@ -881,6 +897,8 @@ public class BluetoothMapService extends ProfileService {
            mAppObserver.shutdown();
        }
        sendShutdownMessage();
        setComponentAvailable(MAP_SETTINGS_ACTIVITY, false);
        setComponentAvailable(MAP_FILE_PROVIDER, false);
        return true;
    }

+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public class BluetoothMapContentObserverTest {
    public void setUp() {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when BluetoothMapService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_map));
                BluetoothMapService.isEnabled());
    }

    @Test
+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class BluetoothMapServiceTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when BluetoothMapService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_map));
                BluetoothMapService.isEnabled());
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
@@ -72,7 +72,7 @@ public class BluetoothMapServiceTest {

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