Loading android/app/jni/com_android_bluetooth_avrcp_controller.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -1087,6 +1087,27 @@ static void sendRegisterAbsVolRspNative(JNIEnv* env, jobject object, env->ReleaseByteArrayElements(address, addr, 0); } static void getCurrentMetadataNative(JNIEnv* env, jobject object, jbyteArray address) { if (!sBluetoothAvrcpInterface) return; jbyte* addr = env->GetByteArrayElements(address, NULL); if (!addr) { jniThrowIOException(env, EINVAL); return; } ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); bt_status_t status = sBluetoothAvrcpInterface->get_current_metadata_cmd(rawAddress); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed sending getCurrentMetadataNative command, status: %d", status); } env->ReleaseByteArrayElements(address, addr, 0); } static void getPlaybackStateNative(JNIEnv* env, jobject object, jbyteArray address) { if (!sBluetoothAvrcpInterface) return; Loading Loading @@ -1276,6 +1297,7 @@ static JNINativeMethod sMethods[] = { {"sendAbsVolRspNative", "([BII)V", (void*)sendAbsVolRspNative}, {"sendRegisterAbsVolRspNative", "([BBII)V", (void*)sendRegisterAbsVolRspNative}, {"getCurrentMetadataNative", "([B)V", (void*)getCurrentMetadataNative}, {"getPlaybackStateNative", "([B)V", (void*)getPlaybackStateNative}, {"getNowPlayingListNative", "([BII)V", (void*)getNowPlayingListNative}, {"getFolderListNative", "([BII)V", (void*)getFolderListNative}, Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +9 −0 Original line number Diff line number Diff line Loading @@ -829,6 +829,15 @@ public class AvrcpControllerService extends ProfileService { public native void sendRegisterAbsVolRspNative(byte[] address, byte rspType, int absVol, int label); /** * Fetch the current track's metadata * * This method is specifically meant to allow us to fetch image handles that may not have been * sent to us yet, prior to having a BIP client connection. See the AVRCP 1.6+ specification, * section 4.1.7, for more details. */ public native void getCurrentMetadataNative(byte[] address); /** * Fetch the playback state */ Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +11 −6 Original line number Diff line number Diff line Loading @@ -18,11 +18,12 @@ package com.android.bluetooth.avrcpcontroller; 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 com.android.bluetooth.Utils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; Loading @@ -45,7 +46,7 @@ public class AvrcpCoverArtManager { public static final String SCHEME_NATIVE = "native"; public static final String SCHEME_THUMBNAIL = "thumbnail"; private final Context mContext; private final AvrcpControllerService mService; protected final Map<BluetoothDevice, AvrcpBipClient> mClients = new ConcurrentHashMap<>(1); private final AvrcpCoverArtStorage mCoverArtStorage; private final Callback mCallback; Loading Loading @@ -81,9 +82,9 @@ public class AvrcpCoverArtManager { void onImageDownloadComplete(BluetoothDevice device, DownloadEvent event); } public AvrcpCoverArtManager(Context context, Callback callback) { mContext = context; mCoverArtStorage = new AvrcpCoverArtStorage(mContext); public AvrcpCoverArtManager(AvrcpControllerService service, Callback callback) { mService = service; mCoverArtStorage = new AvrcpCoverArtStorage(mService); mCallback = callback; mDownloadScheme = SystemProperties.get(AVRCP_CONTROLLER_COVER_ART_SCHEME, SCHEME_THUMBNAIL); Loading Loading @@ -260,7 +261,11 @@ public class AvrcpCoverArtManager { @Override public void onConnectionStateChanged(int oldState, int newState) { debug(mDevice.getAddress() + ": " + oldState + " -> " + newState); if (newState == BluetoothProfile.STATE_DISCONNECTED) { if (newState == BluetoothProfile.STATE_CONNECTED) { // Once we're connected fetch the current metadata again in case the target has an // image handle they can now give us mService.getCurrentMetadataNative(Utils.getByteAddress(mDevice)); } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { disconnect(mDevice); } } Loading Loading
android/app/jni/com_android_bluetooth_avrcp_controller.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -1087,6 +1087,27 @@ static void sendRegisterAbsVolRspNative(JNIEnv* env, jobject object, env->ReleaseByteArrayElements(address, addr, 0); } static void getCurrentMetadataNative(JNIEnv* env, jobject object, jbyteArray address) { if (!sBluetoothAvrcpInterface) return; jbyte* addr = env->GetByteArrayElements(address, NULL); if (!addr) { jniThrowIOException(env, EINVAL); return; } ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); bt_status_t status = sBluetoothAvrcpInterface->get_current_metadata_cmd(rawAddress); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed sending getCurrentMetadataNative command, status: %d", status); } env->ReleaseByteArrayElements(address, addr, 0); } static void getPlaybackStateNative(JNIEnv* env, jobject object, jbyteArray address) { if (!sBluetoothAvrcpInterface) return; Loading Loading @@ -1276,6 +1297,7 @@ static JNINativeMethod sMethods[] = { {"sendAbsVolRspNative", "([BII)V", (void*)sendAbsVolRspNative}, {"sendRegisterAbsVolRspNative", "([BBII)V", (void*)sendRegisterAbsVolRspNative}, {"getCurrentMetadataNative", "([B)V", (void*)getCurrentMetadataNative}, {"getPlaybackStateNative", "([B)V", (void*)getPlaybackStateNative}, {"getNowPlayingListNative", "([BII)V", (void*)getNowPlayingListNative}, {"getFolderListNative", "([BII)V", (void*)getFolderListNative}, Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +9 −0 Original line number Diff line number Diff line Loading @@ -829,6 +829,15 @@ public class AvrcpControllerService extends ProfileService { public native void sendRegisterAbsVolRspNative(byte[] address, byte rspType, int absVol, int label); /** * Fetch the current track's metadata * * This method is specifically meant to allow us to fetch image handles that may not have been * sent to us yet, prior to having a BIP client connection. See the AVRCP 1.6+ specification, * section 4.1.7, for more details. */ public native void getCurrentMetadataNative(byte[] address); /** * Fetch the playback state */ Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +11 −6 Original line number Diff line number Diff line Loading @@ -18,11 +18,12 @@ package com.android.bluetooth.avrcpcontroller; 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 com.android.bluetooth.Utils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; Loading @@ -45,7 +46,7 @@ public class AvrcpCoverArtManager { public static final String SCHEME_NATIVE = "native"; public static final String SCHEME_THUMBNAIL = "thumbnail"; private final Context mContext; private final AvrcpControllerService mService; protected final Map<BluetoothDevice, AvrcpBipClient> mClients = new ConcurrentHashMap<>(1); private final AvrcpCoverArtStorage mCoverArtStorage; private final Callback mCallback; Loading Loading @@ -81,9 +82,9 @@ public class AvrcpCoverArtManager { void onImageDownloadComplete(BluetoothDevice device, DownloadEvent event); } public AvrcpCoverArtManager(Context context, Callback callback) { mContext = context; mCoverArtStorage = new AvrcpCoverArtStorage(mContext); public AvrcpCoverArtManager(AvrcpControllerService service, Callback callback) { mService = service; mCoverArtStorage = new AvrcpCoverArtStorage(mService); mCallback = callback; mDownloadScheme = SystemProperties.get(AVRCP_CONTROLLER_COVER_ART_SCHEME, SCHEME_THUMBNAIL); Loading Loading @@ -260,7 +261,11 @@ public class AvrcpCoverArtManager { @Override public void onConnectionStateChanged(int oldState, int newState) { debug(mDevice.getAddress() + ": " + oldState + " -> " + newState); if (newState == BluetoothProfile.STATE_DISCONNECTED) { if (newState == BluetoothProfile.STATE_CONNECTED) { // Once we're connected fetch the current metadata again in case the target has an // image handle they can now give us mService.getCurrentMetadataNative(Utils.getByteAddress(mDevice)); } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { disconnect(mDevice); } } Loading