Loading android/app/jni/com_android_bluetooth_avrcp_controller.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -848,6 +848,23 @@ static void sendRegisterAbsVolRspNative(JNIEnv *env, jobject object, jbyteArray env->ReleaseByteArrayElements(address, addr, 0); } static void getPlaybackStateNative(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", __FUNCTION__, sBluetoothAvrcpInterface); bt_status_t status = sBluetoothAvrcpInterface->get_playback_state_cmd((bt_bdaddr_t *) addr); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed sending getPlaybackStateNative command, status: %d", status); } env->ReleaseByteArrayElements(address, addr, 0); } static void getNowPlayingListNative(JNIEnv *env, jobject object, jbyteArray address, jbyte start, jbyte items) { bt_status_t status; Loading Loading @@ -1007,6 +1024,7 @@ static JNINativeMethod sMethods[] = { (void *) setPlayerApplicationSettingValuesNative}, {"sendAbsVolRspNative", "([BII)V",(void *) sendAbsVolRspNative}, {"sendRegisterAbsVolRspNative", "([BBII)V",(void *) sendRegisterAbsVolRspNative}, {"getPlaybackStateNative", "([B)V", (void *) getPlaybackStateNative}, {"getNowPlayingListNative", "([BBB)V", (void *) getNowPlayingListNative}, {"getFolderListNative", "([BBB)V", (void *) getFolderListNative}, {"getPlayerListNative", "([BBB)V", (void *) getPlayerListNative}, Loading android/app/src/com/android/bluetooth/a2dpsink/mbs/A2dpMediaBrowserService.java +25 −3 Original line number Diff line number Diff line Loading @@ -78,16 +78,20 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private static final int MSG_TRACK = 4; // Internal message sent to trigger a AVRCP action. private static final int MSG_AVRCP_PASSTHRU = 5; // Internal message to trigger a getplaystatus command to remote. private static final int MSG_AVRCP_GET_PLAY_STATUS_NATIVE = 6; // Message sent when AVRCP browse is connected. private static final int MSG_DEVICE_BROWSE_CONNECT = 6; private static final int MSG_DEVICE_BROWSE_CONNECT = 7; // Message sent when AVRCP browse is disconnected. private static final int MSG_DEVICE_BROWSE_DISCONNECT = 7; private static final int MSG_DEVICE_BROWSE_DISCONNECT = 8; // Message sent when folder list is fetched. private static final int MSG_FOLDER_LIST = 9; // Custom actions for PTS testing. private String CUSTOM_ACTION_VOL_UP = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_UP"; private String CUSTOM_ACTION_VOL_DN = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_DN"; private String CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE"; private MediaSession mSession; private MediaMetadata mA2dpMetadata; Loading Loading @@ -136,6 +140,9 @@ public class A2dpMediaBrowserService extends MediaBrowserService { case MSG_AVRCP_PASSTHRU: inst.msgPassThru((int) msg.obj); break; case MSG_AVRCP_GET_PLAY_STATUS_NATIVE: inst.msgGetPlayStatusNative(); break; case MSG_DEVICE_BROWSE_CONNECT: inst.msgDeviceBrowseConnect((BluetoothDevice) msg.obj); break; Loading Loading @@ -301,6 +308,9 @@ public class A2dpMediaBrowserService extends MediaBrowserService { mAvrcpCommandQueue.obtainMessage( MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_VOL_DOWN).sendToTarget(); } else if (CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE.equals(action)) { mAvrcpCommandQueue.obtainMessage( MSG_AVRCP_GET_PLAY_STATUS_NATIVE).sendToTarget(); }else { Log.w(TAG, "Custom action " + action + " not supported."); } Loading Loading @@ -472,6 +482,18 @@ public class A2dpMediaBrowserService extends MediaBrowserService { mA2dpDevice, cmd, AvrcpControllerService.KEY_STATE_RELEASED); } private synchronized void msgGetPlayStatusNative() { Log.d(TAG, "msgGetPlayStatusNative"); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); return; } // Ask for a non cached version. mAvrcpCtrlSrvc.getPlaybackState(mA2dpDevice, false); } private void msgDeviceBrowseConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseConnect device " + device); // We should already be connected to this device over A2DP. Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +10 −2 Original line number Diff line number Diff line Loading @@ -365,7 +365,13 @@ public class AvrcpControllerService extends ProfileService { return mAvrcpCtSm.getCurrentMetaData(); } public synchronized PlaybackState getPlaybackState(BluetoothDevice device) { public PlaybackState getPlaybackState(BluetoothDevice device) { // Get the cached state by default. return getPlaybackState(device, true); } // cached can be used to force a getPlaybackState command. Useful for PTS testing. public synchronized PlaybackState getPlaybackState(BluetoothDevice device, boolean cached) { if (DBG) { Log.d(TAG, "getPlayBackState device = " + device); } Loading @@ -381,7 +387,7 @@ public class AvrcpControllerService extends ProfileService { } enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mAvrcpCtSm.getCurrentPlayBackState(); return mAvrcpCtSm.getCurrentPlayBackState(cached); } public synchronized BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) { Loading Loading @@ -1108,6 +1114,8 @@ public class AvrcpControllerService extends ProfileService { native static void sendRegisterAbsVolRspNative(byte[] address, byte rspType, int absVol, int label); /* API used to fetch the playback state */ native static void getPlaybackStateNative(byte[] address); /* API used to fetch the current now playing list */ native static void getNowPlayingListNative(byte[] address, byte start, byte end); /* API used to fetch the current folder's listing */ Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +15 −5 Original line number Diff line number Diff line Loading @@ -890,6 +890,11 @@ class AvrcpControllerStateMachine extends StateMachine { } PlaybackState getCurrentPlayBackState() { return getCurrentPlayBackState(true); } PlaybackState getCurrentPlayBackState(boolean cached) { if (cached) { synchronized (mLock) { if (mAddressedPlayer == null) { return new PlaybackState.Builder().setState(PlaybackState.STATE_ERROR, Loading @@ -897,6 +902,11 @@ class AvrcpControllerStateMachine extends StateMachine { } return mAddressedPlayer.getPlaybackState(); } } else { // Issue a native request, we return NULL since this is only for PTS. AvrcpControllerService.getPlaybackStateNative(mRemoteDevice.getBluetoothAddress()); return null; } } // Entry point to the state machine where the services should call to fetch children Loading Loading
android/app/jni/com_android_bluetooth_avrcp_controller.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -848,6 +848,23 @@ static void sendRegisterAbsVolRspNative(JNIEnv *env, jobject object, jbyteArray env->ReleaseByteArrayElements(address, addr, 0); } static void getPlaybackStateNative(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", __FUNCTION__, sBluetoothAvrcpInterface); bt_status_t status = sBluetoothAvrcpInterface->get_playback_state_cmd((bt_bdaddr_t *) addr); if (status != BT_STATUS_SUCCESS) { ALOGE("Failed sending getPlaybackStateNative command, status: %d", status); } env->ReleaseByteArrayElements(address, addr, 0); } static void getNowPlayingListNative(JNIEnv *env, jobject object, jbyteArray address, jbyte start, jbyte items) { bt_status_t status; Loading Loading @@ -1007,6 +1024,7 @@ static JNINativeMethod sMethods[] = { (void *) setPlayerApplicationSettingValuesNative}, {"sendAbsVolRspNative", "([BII)V",(void *) sendAbsVolRspNative}, {"sendRegisterAbsVolRspNative", "([BBII)V",(void *) sendRegisterAbsVolRspNative}, {"getPlaybackStateNative", "([B)V", (void *) getPlaybackStateNative}, {"getNowPlayingListNative", "([BBB)V", (void *) getNowPlayingListNative}, {"getFolderListNative", "([BBB)V", (void *) getFolderListNative}, {"getPlayerListNative", "([BBB)V", (void *) getPlayerListNative}, Loading
android/app/src/com/android/bluetooth/a2dpsink/mbs/A2dpMediaBrowserService.java +25 −3 Original line number Diff line number Diff line Loading @@ -78,16 +78,20 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private static final int MSG_TRACK = 4; // Internal message sent to trigger a AVRCP action. private static final int MSG_AVRCP_PASSTHRU = 5; // Internal message to trigger a getplaystatus command to remote. private static final int MSG_AVRCP_GET_PLAY_STATUS_NATIVE = 6; // Message sent when AVRCP browse is connected. private static final int MSG_DEVICE_BROWSE_CONNECT = 6; private static final int MSG_DEVICE_BROWSE_CONNECT = 7; // Message sent when AVRCP browse is disconnected. private static final int MSG_DEVICE_BROWSE_DISCONNECT = 7; private static final int MSG_DEVICE_BROWSE_DISCONNECT = 8; // Message sent when folder list is fetched. private static final int MSG_FOLDER_LIST = 9; // Custom actions for PTS testing. private String CUSTOM_ACTION_VOL_UP = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_UP"; private String CUSTOM_ACTION_VOL_DN = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_DN"; private String CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE"; private MediaSession mSession; private MediaMetadata mA2dpMetadata; Loading Loading @@ -136,6 +140,9 @@ public class A2dpMediaBrowserService extends MediaBrowserService { case MSG_AVRCP_PASSTHRU: inst.msgPassThru((int) msg.obj); break; case MSG_AVRCP_GET_PLAY_STATUS_NATIVE: inst.msgGetPlayStatusNative(); break; case MSG_DEVICE_BROWSE_CONNECT: inst.msgDeviceBrowseConnect((BluetoothDevice) msg.obj); break; Loading Loading @@ -301,6 +308,9 @@ public class A2dpMediaBrowserService extends MediaBrowserService { mAvrcpCommandQueue.obtainMessage( MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_VOL_DOWN).sendToTarget(); } else if (CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE.equals(action)) { mAvrcpCommandQueue.obtainMessage( MSG_AVRCP_GET_PLAY_STATUS_NATIVE).sendToTarget(); }else { Log.w(TAG, "Custom action " + action + " not supported."); } Loading Loading @@ -472,6 +482,18 @@ public class A2dpMediaBrowserService extends MediaBrowserService { mA2dpDevice, cmd, AvrcpControllerService.KEY_STATE_RELEASED); } private synchronized void msgGetPlayStatusNative() { Log.d(TAG, "msgGetPlayStatusNative"); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); return; } // Ask for a non cached version. mAvrcpCtrlSrvc.getPlaybackState(mA2dpDevice, false); } private void msgDeviceBrowseConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseConnect device " + device); // We should already be connected to this device over A2DP. Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +10 −2 Original line number Diff line number Diff line Loading @@ -365,7 +365,13 @@ public class AvrcpControllerService extends ProfileService { return mAvrcpCtSm.getCurrentMetaData(); } public synchronized PlaybackState getPlaybackState(BluetoothDevice device) { public PlaybackState getPlaybackState(BluetoothDevice device) { // Get the cached state by default. return getPlaybackState(device, true); } // cached can be used to force a getPlaybackState command. Useful for PTS testing. public synchronized PlaybackState getPlaybackState(BluetoothDevice device, boolean cached) { if (DBG) { Log.d(TAG, "getPlayBackState device = " + device); } Loading @@ -381,7 +387,7 @@ public class AvrcpControllerService extends ProfileService { } enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mAvrcpCtSm.getCurrentPlayBackState(); return mAvrcpCtSm.getCurrentPlayBackState(cached); } public synchronized BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) { Loading Loading @@ -1108,6 +1114,8 @@ public class AvrcpControllerService extends ProfileService { native static void sendRegisterAbsVolRspNative(byte[] address, byte rspType, int absVol, int label); /* API used to fetch the playback state */ native static void getPlaybackStateNative(byte[] address); /* API used to fetch the current now playing list */ native static void getNowPlayingListNative(byte[] address, byte start, byte end); /* API used to fetch the current folder's listing */ Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +15 −5 Original line number Diff line number Diff line Loading @@ -890,6 +890,11 @@ class AvrcpControllerStateMachine extends StateMachine { } PlaybackState getCurrentPlayBackState() { return getCurrentPlayBackState(true); } PlaybackState getCurrentPlayBackState(boolean cached) { if (cached) { synchronized (mLock) { if (mAddressedPlayer == null) { return new PlaybackState.Builder().setState(PlaybackState.STATE_ERROR, Loading @@ -897,6 +902,11 @@ class AvrcpControllerStateMachine extends StateMachine { } return mAddressedPlayer.getPlaybackState(); } } else { // Issue a native request, we return NULL since this is only for PTS. AvrcpControllerService.getPlaybackStateNative(mRemoteDevice.getBluetoothAddress()); return null; } } // Entry point to the state machine where the services should call to fetch children Loading