Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +22 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -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(); } Loading Loading @@ -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"; Loading android/app/src/com/android/bluetooth/avrcpcontroller/bip/RequestGetImage.java +6 −3 Original line number Diff line number Diff line Loading @@ -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 Loading android/app/src/com/android/bluetooth/mapclient/MapClientService.java +8 −3 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -285,7 +285,7 @@ public class MapClientService extends ProfileService { } @Override protected boolean start() { protected synchronized boolean start() { Log.e(TAG, "start()"); if (mMnsServer == null) { Loading @@ -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); Loading @@ -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(); } Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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, Loading Loading @@ -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); Loading Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +22 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -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(); } Loading Loading @@ -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"; Loading
android/app/src/com/android/bluetooth/avrcpcontroller/bip/RequestGetImage.java +6 −3 Original line number Diff line number Diff line Loading @@ -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 Loading
android/app/src/com/android/bluetooth/mapclient/MapClientService.java +8 −3 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -285,7 +285,7 @@ public class MapClientService extends ProfileService { } @Override protected boolean start() { protected synchronized boolean start() { Log.e(TAG, "start()"); if (mMnsServer == null) { Loading @@ -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); Loading @@ -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(); } Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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, Loading Loading @@ -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); Loading