Loading android/app/jni/com_android_bluetooth_avrcp_target.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ static std::shared_timed_mutex interface_mutex; static std::shared_timed_mutex callbacks_mutex; // Forward Declarations static void sendMediaKeyEvent(int, int); static void sendMediaKeyEvent(int, KeyState); static std::string getCurrentMediaId(); static SongInfo getSongInfo(); static PlayStatus getCurrentPlayStatus(); Loading Loading @@ -67,8 +67,8 @@ static void setVolume(int8_t volume); // as it is hard to get a handle on the JNI thread from here. class AvrcpMediaInterfaceImpl : public MediaInterface { public: void SendKeyEvent(uint8_t key, uint8_t status) { sendMediaKeyEvent(key, status); void SendKeyEvent(uint8_t key, KeyState state) { sendMediaKeyEvent(key, state); } void GetSongInfo(SongInfoCallback cb) override { Loading Loading @@ -169,7 +169,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { clazz, "getPlayStatus", "()Lcom/android/bluetooth/avrcp/PlayStatus;"); method_sendMediaKeyEvent = env->GetMethodID(clazz, "sendMediaKeyEvent", "(II)V"); env->GetMethodID(clazz, "sendMediaKeyEvent", "(IZ)V"); method_getCurrentMediaId = env->GetMethodID(clazz, "getCurrentMediaId", "()Ljava/lang/String;"); Loading Loading @@ -294,13 +294,14 @@ jboolean disconnectDeviceNative(JNIEnv* env, jobject object, jstring address) { : JNI_FALSE; } static void sendMediaKeyEvent(int key, int state) { static void sendMediaKeyEvent(int key, KeyState state) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; sCallbackEnv->CallVoidMethod(mJavaInterface, method_sendMediaKeyEvent, key, state); sCallbackEnv->CallVoidMethod( mJavaInterface, method_sendMediaKeyEvent, key, state == KeyState::PUSHED ? JNI_TRUE : JNI_FALSE); } static SongInfo getSongInfoFromJavaObj(JNIEnv* env, jobject metadata) { Loading android/app/src/com/android/bluetooth/newavrcp/AvrcpNativeInterface.java +3 −3 Original line number Diff line number Diff line Loading @@ -75,14 +75,14 @@ public class AvrcpNativeInterface { return mAvrcpService.getPlayState(); } void sendMediaKeyEvent(int keyEvent, int state) { d("sendMediaKeyEvent: keyEvent=" + keyEvent + " state=" + state); void sendMediaKeyEvent(int keyEvent, boolean pushed) { d("sendMediaKeyEvent: keyEvent=" + keyEvent + " pushed=" + pushed); if (mAvrcpService == null) { Log.w(TAG, "sendMediaKeyEvent(): AvrcpTargetService is null"); return; } mAvrcpService.sendMediaKeyEvent(keyEvent, state); mAvrcpService.sendMediaKeyEvent(keyEvent, pushed); } String getCurrentMediaId() { Loading android/app/src/com/android/bluetooth/newavrcp/AvrcpTargetService.java +3 −3 Original line number Diff line number Diff line Loading @@ -288,9 +288,9 @@ public class AvrcpTargetService extends ProfileService { // TODO (apanicke): Handle key events here in the service. Currently it was more convenient to // handle them there but logically they make more sense handled here. void sendMediaKeyEvent(int event, int state) { if (DEBUG) Log.d(TAG, "getMediaKeyEvent: event=" + event + " state=" + state); mMediaPlayerList.sendMediaKeyEvent(event, state); void sendMediaKeyEvent(int event, boolean pushed) { if (DEBUG) Log.d(TAG, "getMediaKeyEvent: event=" + event + " pushed=" + pushed); mMediaPlayerList.sendMediaKeyEvent(event, pushed); } void setActiveDevice(String address) { Loading android/app/src/com/android/bluetooth/newavrcp/MediaPlayerList.java +4 −4 Original line number Diff line number Diff line Loading @@ -480,10 +480,10 @@ public class MediaPlayerList { sendMediaUpdate(getActivePlayer().getCurrentMediaData()); } // TODO (apanicke): Add logging for media key events void sendMediaKeyEvent(int key, int state) { d("sendMediaKeyEvent: key=" + key + " state=" + state); int action = state == 0 ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP; // TODO (apanicke): Add logging for media key events in dumpsys void sendMediaKeyEvent(int key, boolean pushed) { d("sendMediaKeyEvent: key=" + key + " pushed=" + pushed); int action = pushed ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP; KeyEvent event = new KeyEvent(action, AvrcpPassthrough.toKeyCode(key)); mMediaSessionManager.dispatchMediaKeyEvent(event); } Loading Loading
android/app/jni/com_android_bluetooth_avrcp_target.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ static std::shared_timed_mutex interface_mutex; static std::shared_timed_mutex callbacks_mutex; // Forward Declarations static void sendMediaKeyEvent(int, int); static void sendMediaKeyEvent(int, KeyState); static std::string getCurrentMediaId(); static SongInfo getSongInfo(); static PlayStatus getCurrentPlayStatus(); Loading Loading @@ -67,8 +67,8 @@ static void setVolume(int8_t volume); // as it is hard to get a handle on the JNI thread from here. class AvrcpMediaInterfaceImpl : public MediaInterface { public: void SendKeyEvent(uint8_t key, uint8_t status) { sendMediaKeyEvent(key, status); void SendKeyEvent(uint8_t key, KeyState state) { sendMediaKeyEvent(key, state); } void GetSongInfo(SongInfoCallback cb) override { Loading Loading @@ -169,7 +169,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { clazz, "getPlayStatus", "()Lcom/android/bluetooth/avrcp/PlayStatus;"); method_sendMediaKeyEvent = env->GetMethodID(clazz, "sendMediaKeyEvent", "(II)V"); env->GetMethodID(clazz, "sendMediaKeyEvent", "(IZ)V"); method_getCurrentMediaId = env->GetMethodID(clazz, "getCurrentMediaId", "()Ljava/lang/String;"); Loading Loading @@ -294,13 +294,14 @@ jboolean disconnectDeviceNative(JNIEnv* env, jobject object, jstring address) { : JNI_FALSE; } static void sendMediaKeyEvent(int key, int state) { static void sendMediaKeyEvent(int key, KeyState state) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; sCallbackEnv->CallVoidMethod(mJavaInterface, method_sendMediaKeyEvent, key, state); sCallbackEnv->CallVoidMethod( mJavaInterface, method_sendMediaKeyEvent, key, state == KeyState::PUSHED ? JNI_TRUE : JNI_FALSE); } static SongInfo getSongInfoFromJavaObj(JNIEnv* env, jobject metadata) { Loading
android/app/src/com/android/bluetooth/newavrcp/AvrcpNativeInterface.java +3 −3 Original line number Diff line number Diff line Loading @@ -75,14 +75,14 @@ public class AvrcpNativeInterface { return mAvrcpService.getPlayState(); } void sendMediaKeyEvent(int keyEvent, int state) { d("sendMediaKeyEvent: keyEvent=" + keyEvent + " state=" + state); void sendMediaKeyEvent(int keyEvent, boolean pushed) { d("sendMediaKeyEvent: keyEvent=" + keyEvent + " pushed=" + pushed); if (mAvrcpService == null) { Log.w(TAG, "sendMediaKeyEvent(): AvrcpTargetService is null"); return; } mAvrcpService.sendMediaKeyEvent(keyEvent, state); mAvrcpService.sendMediaKeyEvent(keyEvent, pushed); } String getCurrentMediaId() { Loading
android/app/src/com/android/bluetooth/newavrcp/AvrcpTargetService.java +3 −3 Original line number Diff line number Diff line Loading @@ -288,9 +288,9 @@ public class AvrcpTargetService extends ProfileService { // TODO (apanicke): Handle key events here in the service. Currently it was more convenient to // handle them there but logically they make more sense handled here. void sendMediaKeyEvent(int event, int state) { if (DEBUG) Log.d(TAG, "getMediaKeyEvent: event=" + event + " state=" + state); mMediaPlayerList.sendMediaKeyEvent(event, state); void sendMediaKeyEvent(int event, boolean pushed) { if (DEBUG) Log.d(TAG, "getMediaKeyEvent: event=" + event + " pushed=" + pushed); mMediaPlayerList.sendMediaKeyEvent(event, pushed); } void setActiveDevice(String address) { Loading
android/app/src/com/android/bluetooth/newavrcp/MediaPlayerList.java +4 −4 Original line number Diff line number Diff line Loading @@ -480,10 +480,10 @@ public class MediaPlayerList { sendMediaUpdate(getActivePlayer().getCurrentMediaData()); } // TODO (apanicke): Add logging for media key events void sendMediaKeyEvent(int key, int state) { d("sendMediaKeyEvent: key=" + key + " state=" + state); int action = state == 0 ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP; // TODO (apanicke): Add logging for media key events in dumpsys void sendMediaKeyEvent(int key, boolean pushed) { d("sendMediaKeyEvent: key=" + key + " pushed=" + pushed); int action = pushed ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP; KeyEvent event = new KeyEvent(action, AvrcpPassthrough.toKeyCode(key)); mMediaSessionManager.dispatchMediaKeyEvent(event); } Loading