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

Commit 45ac74a9 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Automerger Merge Worker
Browse files

Merge "Move key events to AvrcpTargetService" into main am: abe3ac92 am:...

Merge "Move key events to AvrcpTargetService" into main am: abe3ac92 am: be289e8c am: 8566c146 am: a745c838

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2757196



Change-Id: Id5f104c8712dd555d3ff2f2882d25e687dd85e8f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e1744338 a745c838
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.os.Looper;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;

import com.android.bluetooth.BluetoothEventLogger;
import com.android.bluetooth.Utils;
@@ -672,14 +671,6 @@ public class MediaPlayerList {
        sendMediaUpdate(data);
    }

    // TODO (apanicke): Add logging for media key events in dumpsys
    public 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));
        mAudioManager.dispatchMediaKeyEvent(event);
    }

    private void sendFolderUpdate(boolean availablePlayers, boolean addressedPlayers,
            boolean uids) {
        d("sendFolderUpdate");
@@ -961,7 +952,6 @@ public class MediaPlayerList {
        sb.append("\n");
        mAudioPlaybackStateLogger.dump(sb);
        sb.append("\n");
        // TODO (apanicke): Add last sent data
    }

    private static void e(String message) {
+17 −7
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.UserManager;
import android.sysprop.BluetoothProperties;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;

import com.android.bluetooth.BluetoothEventLogger;
import com.android.bluetooth.BluetoothMetricsProto;
@@ -451,15 +452,24 @@ public class AvrcpTargetService extends ProfileService {
        mMediaPlayerList.playItem(playerId, nowPlaying, mediaId);
    }

    // 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, boolean pushed) {
    void sendMediaKeyEvent(int key, boolean pushed) {
        BluetoothDevice activeDevice = getA2dpActiveDevice();
        MediaPlayerWrapper player = mMediaPlayerList.getActivePlayer();
        mMediaKeyEventLogger.logd(DEBUG, TAG, "getMediaKeyEvent:" + " device=" + activeDevice
                + " event=" + event + " pushed=" + pushed
                + " to " + (player == null ? null : player.getPackageName()));
        mMediaPlayerList.sendMediaKeyEvent(event, pushed);
        mMediaKeyEventLogger.logd(
                DEBUG,
                TAG,
                "sendMediaKeyEvent:"
                        + " device="
                        + activeDevice
                        + " key="
                        + key
                        + " pushed="
                        + pushed
                        + " to "
                        + (player == null ? null : player.getPackageName()));
        int action = pushed ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP;
        KeyEvent event = new KeyEvent(action, AvrcpPassthrough.toKeyCode(key));
        mAudioManager.dispatchMediaKeyEvent(event);
    }

    void setActiveDevice(BluetoothDevice device) {
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.bluetooth.audio_util;
package com.android.bluetooth.avrcp;

import android.bluetooth.BluetoothAvrcp;
import android.view.KeyEvent;
+1 −1
Original line number Diff line number Diff line
package com.android.bluetooth.audio_util;
package com.android.bluetooth.avrcp;

import static com.google.common.truth.Truth.assertThat;