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

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

Migrate A2DP Sink enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Change-Id: I3e2954432f5a65cbf4ca55c07b6b87ac9dd3f7b6
parent c5a20ddc
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -102,6 +102,16 @@
            </intent-filter>
            </intent-filter>
        </service>
        </service>


        <!--  Advanced Audio Distribution Profile (A2DP) sink Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.a2dpsink.A2dpSinkService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothA2dpSink"/>
            </intent-filter>
        </service>

        <provider android:name=".opp.BluetoothOppProvider"
        <provider android:name=".opp.BluetoothOppProvider"
             android:authorities="com.android.bluetooth.opp"
             android:authorities="com.android.bluetooth.opp"
             android:exported="true"
             android:exported="true"
@@ -311,15 +321,7 @@
            </intent-filter>
            </intent-filter>
        </service>
        </service>
        <service android:process="@string/process"
        <service android:process="@string/process"
             android:name=".a2dpsink.A2dpSinkService"
             android:name=".avrcpcontroller.BluetoothMediaBrowserService"
             android:enabled="@bool/profile_supported_a2dp_sink"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothA2dpSink"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name="com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService"
             android:exported="true"
             android:exported="true"
             android:enabled="@bool/profile_supported_a2dp_sink"
             android:enabled="@bool/profile_supported_a2dp_sink"
             android:label="@string/a2dp_sink_mbs_label">
             android:label="@string/a2dp_sink_mbs_label">
+0 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,6 @@
   limitations under the License.
   limitations under the License.
-->
-->
<resources>
<resources>
    <bool name="profile_supported_a2dp_sink">false</bool>
    <bool name="profile_supported_hs_hfp">true</bool>
    <bool name="profile_supported_hs_hfp">true</bool>
    <bool name="profile_supported_hfpclient">false</bool>
    <bool name="profile_supported_hfpclient">false</bool>
    <bool name="profile_supported_hfp_incallservice">true</bool>
    <bool name="profile_supported_hfp_incallservice">true</bool>
+5 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothProfile;
import android.bluetooth.IBluetoothA2dpSink;
import android.bluetooth.IBluetoothA2dpSink;
import android.content.AttributionSource;
import android.content.AttributionSource;
import android.media.AudioManager;
import android.media.AudioManager;
import android.sysprop.BluetoothProperties;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -63,6 +64,10 @@ public class A2dpSinkService extends ProfileService {


    A2dpSinkNativeInterface mNativeInterface;
    A2dpSinkNativeInterface mNativeInterface;


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

    @Override
    @Override
    protected boolean start() {
    protected boolean start() {
        mAdapterService = Objects.requireNonNull(AdapterService.getAdapterService(),
        mAdapterService = Objects.requireNonNull(AdapterService.getAdapterService(),
+2 −2
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ public class A2dpSinkServiceTest {
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when A2dpSinkService is not enabled",
        Assume.assumeTrue("Ignore test when A2dpSinkService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp_sink));
                A2dpSinkService.isEnabled());
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);


        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -110,7 +110,7 @@ public class A2dpSinkServiceTest {


    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp_sink)) {
        if (!A2dpSinkService.isEnabled()) {
            return;
            return;
        }
        }
        TestUtils.stopService(mServiceRule, A2dpSinkService.class);
        TestUtils.stopService(mServiceRule, A2dpSinkService.class);
+2 −2
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ public class A2dpSinkStateMachineTest {
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when A2dpSinkService is not enabled",
        Assume.assumeTrue("Ignore test when A2dpSinkService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp_sink));
                A2dpSinkService.isEnabled());
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);


        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -82,7 +82,7 @@ public class A2dpSinkStateMachineTest {


    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp_sink)) {
        if (!A2dpSinkService.isEnabled()) {
            return;
            return;
        }
        }
        mStateMachine = null;
        mStateMachine = null;
Loading