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

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

Migrate AVRCP Target enable/disable to sysprops

Tag: #refactor
Bug: 217448211
Test: atest BluetoothInstrumentationTests
Merged-In: I2d3085fa1e4a660a1e78b3f8ab14359e0ea4b96e
Change-Id: I2d3085fa1e4a660a1e78b3f8ab14359e0ea4b96e
parent 7b185e47
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -113,6 +113,16 @@
            </intent-filter>
        </service>

        <!--  Audio/Video Remote Control Profile (AVRCP) target Profile Service  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.avrcp.AvrcpTargetService"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothAvrcp"/>
            </intent-filter>
        </service>

        <provider android:name=".opp.BluetoothOppProvider"
             android:authorities="com.android.bluetooth.opp"
             android:exported="true"
@@ -336,15 +346,6 @@
                <action android:name="android.intent.action.APPLICATION_PREFERENCES"/>
            </intent-filter>
        </activity>

        <service android:process="@string/process"
             android:name=".avrcp.AvrcpTargetService"
             android:enabled="@bool/profile_supported_avrcp_target"
             android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothAvrcp"/>
            </intent-filter>
        </service>
        <service android:process="@string/process"
             android:name=".avrcpcontroller.AvrcpControllerService"
             android:enabled="@bool/profile_supported_avrcp_controller"
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
    <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_avrcp_target">true</bool>
    <bool name="profile_supported_avrcp_controller">false</bool>
    <bool name="profile_supported_sap">false</bool>
    <bool name="profile_supported_pbapclient">false</bool>
+5 −13
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Looper;
import android.os.SystemProperties;
import android.os.UserManager;
import android.text.TextUtils;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
@@ -58,7 +59,6 @@ import java.util.Objects;
public class AvrcpTargetService extends ProfileService {
    private static final String TAG = "AvrcpTargetService";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
    private static final String AVRCP_ENABLE_PROPERTY = "persist.bluetooth.enablenewavrcp";

    private static final int AVRCP_MAX_VOL = 127;
    private static final int MEDIA_KEY_EVENT_LOGGER_SIZE = 20;
@@ -83,6 +83,10 @@ public class AvrcpTargetService extends ProfileService {

    private static AvrcpTargetService sInstance = null;

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

    class ListCallback implements MediaPlayerList.MediaUpdateCallback {
        @Override
        public void run(MediaData data) {
@@ -180,12 +184,6 @@ public class AvrcpTargetService extends ProfileService {
    protected void setUserUnlocked(int userId) {
        Log.i(TAG, "User unlocked, initializing the service");

        if (!SystemProperties.getBoolean(AVRCP_ENABLE_PROPERTY, true)) {
            Log.w(TAG, "Skipping initialization of the new AVRCP Target Player List");
            sInstance = null;
            return;
        }

        if (mMediaPlayerList != null) {
            mMediaPlayerList.init(new ListCallback());
        }
@@ -201,12 +199,6 @@ public class AvrcpTargetService extends ProfileService {
        Log.i(TAG, "Starting the AVRCP Target Service");
        mCurrentData = new MediaData(null, null, null);

        if (!SystemProperties.getBoolean(AVRCP_ENABLE_PROPERTY, true)) {
            Log.w(TAG, "Skipping initialization of the new AVRCP Target Service");
            sInstance = null;
            return true;
        }

        mAudioManager = getSystemService(AudioManager.class);
        sDeviceMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

+1 −1
Original line number Diff line number Diff line
@@ -111,5 +111,5 @@ class AvrcpService : public MediaCallbacks {
}  // namespace bluetooth

inline bool is_new_avrcp_enabled() {
  return osi_property_get_bool("persist.bluetooth.enablenewavrcp", true);
  return osi_property_get_bool("bluetooth.profile.avrcp.target.enabled", false);
}
+1 −1
Original line number Diff line number Diff line
@@ -1144,7 +1144,7 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
  AVRC_TRACE_DEBUG("%s handle = %u label = %u ctype = %u len = %d", __func__,
                   handle, label, ctype, p_pkt->len);
  /* Handle for AVRCP fragment */
  bool is_new_avrcp = osi_property_get_bool("persist.bluetooth.enablenewavrcp", true);
  bool is_new_avrcp = osi_property_get_bool("bluetooth.profile.avrcp.target.enabled", false);
  if (ctype >= AVRC_RSP_NOT_IMPL) cr = AVCT_RSP;

  if (p_pkt->event == AVRC_OP_VENDOR) {