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

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

Migrate A2DP Source enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Change-Id: I8f080212233d4b44678c1db698f3165e2b12ebe4
parent 3dc16197
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -91,7 +91,18 @@
         android:directBootAware="true"
         android:defaultToDeviceProtectedStorage="true"
         android:memtagMode="async">
        <provider android:name="com.android.bluetooth.opp.BluetoothOppProvider"

        <!--  Advanced Audio Distribution Profile (A2DP) source Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.a2dp.A2dpService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothA2dp"/>
            </intent-filter>
        </service>

        <provider android:name=".opp.BluetoothOppProvider"
             android:authorities="com.android.bluetooth.opp"
             android:exported="true"
             android:process="@string/process">
@@ -300,15 +311,7 @@
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name="com.android.bluetooth.a2dp.A2dpService"
             android:enabled="@bool/profile_supported_a2dp"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothA2dp"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name="com.android.bluetooth.a2dpsink.A2dpSinkService"
             android:name=".a2dpsink.A2dpSinkService"
             android:enabled="@bool/profile_supported_a2dp_sink"
             android:exported="true">
            <intent-filter>
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
   limitations under the License.
-->
<resources>
    <bool name="profile_supported_a2dp">true</bool>
    <bool name="profile_supported_a2dp_sink">false</bool>
    <bool name="profile_supported_hs_hfp">true</bool>
    <bool name="profile_supported_hfpclient">false</bool>
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.media.AudioManager;
import android.media.BluetoothProfileConnectionInfo;
import android.os.Build;
import android.os.HandlerThread;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
@@ -103,6 +104,10 @@ public class A2dpService extends ProfileService {
    private BroadcastReceiver mBondStateChangedReceiver;
    private BroadcastReceiver mConnectionStateChangedReceiver;

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

    @Override
    protected IProfileServiceBinder initBinder() {
        return new BluetoothA2dpBinder(this);
+2 −3
Original line number Diff line number Diff line
@@ -83,8 +83,7 @@ public class A2dpServiceTest {
    @Before
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when A2dpService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp));
        Assume.assumeTrue("Ignore test when A2dpService is not enabled", A2dpService.isEnabled());
        // Set up mocks and test assets
        MockitoAnnotations.initMocks(this);

@@ -124,7 +123,7 @@ public class A2dpServiceTest {

    @After
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp)) {
        if (!A2dpService.isEnabled()) {
            return;
        }
        stopService();
+2 −3
Original line number Diff line number Diff line
@@ -70,8 +70,7 @@ public class A2dpStateMachineTest {
    @Before
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when A2dpService is not enabled",
                mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp));
        Assume.assumeTrue("Ignore test when A2dpService is not enabled", A2dpService.isEnabled());
        // Set up mocks and test assets
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
@@ -117,7 +116,7 @@ public class A2dpStateMachineTest {

    @After
    public void tearDown() throws Exception {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp)) {
        if (!A2dpService.isEnabled()) {
            return;
        }
        mA2dpStateMachine.doQuit();
Loading