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

Commit 53fad0c9 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6408566 from 0765363d to mainline-release

Change-Id: I34f54b085c76211edba8fdd99227df9808b7f5d0
parents dd4badd5 0765363d
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class AvrcpControllerService extends ProfileService {
    protected Map<BluetoothDevice, AvrcpControllerStateMachine> mDeviceStateMap =
            new ConcurrentHashMap<>(1);

    private boolean mCoverArtEnabled;
    private boolean mCoverArtEnabled = false;
    protected AvrcpCoverArtManager mCoverArtManager;

    private class ImageDownloadCallback implements AvrcpCoverArtManager.Callback {
@@ -127,7 +127,7 @@ public class AvrcpControllerService extends ProfileService {
    }

    @Override
    protected boolean start() {
    protected synchronized boolean start() {
        initNative();
        mCoverArtEnabled = getResources().getBoolean(R.bool.avrcp_controller_enable_cover_art);
        if (mCoverArtEnabled) {
@@ -143,7 +143,7 @@ public class AvrcpControllerService extends ProfileService {
    }

    @Override
    protected boolean stop() {
    protected synchronized boolean stop() {
        Intent stopIntent = new Intent(this, BluetoothMediaBrowserService.class);
        stopService(stopIntent);
        for (AvrcpControllerStateMachine stateMachine : mDeviceStateMap.values()) {
@@ -152,8 +152,10 @@ public class AvrcpControllerService extends ProfileService {

        sService = null;
        sBrowseTree = null;
        if (mCoverArtManager != null) {
            mCoverArtManager.cleanup();
            mCoverArtManager = null;
        }
        return true;
    }

+22 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.net.Uri;
import android.os.SystemProperties;
import android.util.Log;

import java.util.Map;
@@ -38,10 +39,17 @@ public class AvrcpCoverArtManager {
    private static final String TAG = "AvrcpCoverArtManager";
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);

    // Image Download Schemes for cover art
    public static final String AVRCP_CONTROLLER_COVER_ART_SCHEME =
            "persist.bluetooth.avrcpcontroller.BIP_DOWNLOAD_SCHEME";
    public static final String SCHEME_NATIVE = "native";
    public static final String SCHEME_THUMBNAIL = "thumbnail";

    private final Context mContext;
    protected final Map<BluetoothDevice, AvrcpBipClient> mClients = new ConcurrentHashMap<>(1);
    private final AvrcpCoverArtStorage mCoverArtStorage;
    private final Callback mCallback;
    private final String mDownloadScheme;

    /**
     * An object representing an image download event. Contains the information necessary to
@@ -77,6 +85,8 @@ public class AvrcpCoverArtManager {
        mContext = context;
        mCoverArtStorage = new AvrcpCoverArtStorage(mContext);
        mCallback = callback;
        mDownloadScheme =
                SystemProperties.get(AVRCP_CONTROLLER_COVER_ART_SCHEME, SCHEME_THUMBNAIL);
        mCoverArtStorage.clear();
    }

@@ -222,10 +232,18 @@ public class AvrcpCoverArtManager {
     * @return A descriptor containing the desirable download format
     */
    private BipImageDescriptor determineImageDescriptor(BipImageProperties properties) {
        // AVRCP 1.6.2 defined "thumbnail" size is guaranteed so we'll do that for now
        BipImageDescriptor.Builder builder = new BipImageDescriptor.Builder();
        switch (mDownloadScheme) {
            // BIP Specification says a blank/null descriptor signals to pull the native format
            case SCHEME_NATIVE:
                return null;
            // AVRCP 1.6.2 defined "thumbnail" size is guaranteed so we'll do that for now
            case SCHEME_THUMBNAIL:
            default:
                builder.setEncoding(BipEncoding.JPEG);
                builder.setFixedDimensions(200, 200);
                break;
        }
        return builder.build();
    }

@@ -289,6 +307,7 @@ public class AvrcpCoverArtManager {
    @Override
    public String toString() {
        String s = "CoverArtManager:\n";
        s += "     Download Scheme: " + mDownloadScheme + "\n";
        for (BluetoothDevice device : mClients.keySet()) {
            AvrcpBipClient client = getClient(device);
            s += "    " + client.toString() + "\n";
+6 −3
Original line number Diff line number Diff line
@@ -42,12 +42,15 @@ public class RequestGetImage extends BipRequest {
        mImageHandle = imageHandle;
        mImageDescriptor = descriptor;

        debug("GetImage - handle: " + mImageHandle + ", descriptor: "
                + mImageDescriptor.toString());
        debug("GetImage - handle: " + mImageHandle + ", descriptor: " + mImageDescriptor);

        mHeaderSet.setHeader(HeaderSet.TYPE, TYPE);
        mHeaderSet.setHeader(HEADER_ID_IMG_HANDLE, mImageHandle);
        if (mImageDescriptor != null) {
            mHeaderSet.setHeader(HEADER_ID_IMG_DESCRIPTOR, mImageDescriptor.serialize());
        } else {
            mHeaderSet.setHeader(HEADER_ID_IMG_DESCRIPTOR, null);
        }
    }

    @Override
+8 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class MapClientService extends ProfileService {
    private MnsService mMnsServer;
    private BluetoothAdapter mAdapter;
    private static MapClientService sMapClientService;
    private MapBroadcastReceiver mMapReceiver = new MapBroadcastReceiver();
    private MapBroadcastReceiver mMapReceiver;

    public static synchronized MapClientService getMapClientService() {
        if (sMapClientService == null) {
@@ -285,7 +285,7 @@ public class MapClientService extends ProfileService {
    }

    @Override
    protected boolean start() {
    protected synchronized boolean start() {
        Log.e(TAG, "start()");

        if (mMnsServer == null) {
@@ -299,6 +299,7 @@ public class MapClientService extends ProfileService {

        mAdapter = BluetoothAdapter.getDefaultAdapter();

        mMapReceiver = new MapBroadcastReceiver();
        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothDevice.ACTION_SDP_RECORD);
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
@@ -313,7 +314,11 @@ public class MapClientService extends ProfileService {
        if (DBG) {
            Log.d(TAG, "stop()");
        }

        if (mMapReceiver != null) {
            unregisterReceiver(mMapReceiver);
            mMapReceiver = null;
        }
        if (mMnsServer != null) {
            mMnsServer.stop();
        }
+4 −3
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class AdapterServiceTest {
    private @Mock android.app.Application mApplication;

    private static final int CONTEXT_SWITCH_MS = 100;
    private static final int GATT_START_TIME_MS = 500;
    private static final int ONE_SECOND_MS = 1000;
    private static final int NATIVE_INIT_MS = 8000;
    private static final int NATIVE_DISABLE_MS = 1000;
@@ -201,7 +202,7 @@ public class AdapterServiceTest {
                invocationNumber + 1, CONTEXT_SWITCH_MS);

        // Start GATT
        verify(mMockContext, timeout(CONTEXT_SWITCH_MS).times(
        verify(mMockContext, timeout(GATT_START_TIME_MS).times(
                startServiceCalls * invocationNumber + 1)).startService(any());
        mAdapterService.addProfile(mMockGattService);
        mAdapterService.onProfileServiceStateChanged(mMockGattService, BluetoothAdapter.STATE_ON);
@@ -331,7 +332,7 @@ public class AdapterServiceTest {
                CONTEXT_SWITCH_MS);

        // Start GATT
        verify(mMockContext, timeout(CONTEXT_SWITCH_MS).times(1)).startService(any());
        verify(mMockContext, timeout(GATT_START_TIME_MS).times(1)).startService(any());
        mAdapterService.addProfile(mMockGattService);

        verifyStateChange(BluetoothAdapter.STATE_BLE_TURNING_ON,
@@ -398,7 +399,7 @@ public class AdapterServiceTest {
                CONTEXT_SWITCH_MS);

        // Start GATT
        verify(mMockContext, timeout(CONTEXT_SWITCH_MS).times(1)).startService(any());
        verify(mMockContext, timeout(GATT_START_TIME_MS).times(1)).startService(any());
        mAdapterService.addProfile(mMockGattService);
        mAdapterService.onProfileServiceStateChanged(mMockGattService, BluetoothAdapter.STATE_ON);