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

Commit 7683ad52 authored by Ajay Panicker's avatar Ajay Panicker Committed by Gerrit Code Review
Browse files

Merge "AVRCP 1.6: media browsing support on Target(3/3)"

parents d664dc02 391ad6a3
Loading
Loading
Loading
Loading
+1291 −101

File changed.

Preview size limit exceeded, changes collapsed.

+20 −7
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -56,18 +56,31 @@ static bool checkCallbackThread() {
    return true;
}

static void btavrcp_passthrough_response_callback(int id, int pressed) {
    ALOGI("%s", __FUNCTION__);
static void btavrcp_passthrough_response_callback(int id, int pressed, bt_bdaddr_t* bd_addr) {
    jbyteArray addr;

    ALOGI("%s", __func__);
    ALOGI("id: %d, pressed: %d", id, pressed);

    if (!checkCallbackThread()) {
        ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
        ALOGE("Callback: '%s' is not called on the correct thread", __func__);
        return;
    }
    addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
    if (!addr) {
        ALOGE("Fail to new jbyteArray bd addr for passthrough response");
        checkAndClearExceptionFromCallback(sCallbackEnv, __func__);
        return;
    }

    sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*) bd_addr);

    sCallbackEnv->CallVoidMethod(mCallbacksObj, method_handlePassthroughRsp, (jint)id,
                                                                             (jint)pressed);
    checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
                                                                             (jint)pressed,
                                                                             addr);
    checkAndClearExceptionFromCallback(sCallbackEnv, __func__);

    sCallbackEnv->DeleteLocalRef(addr);
}

static void btavrcp_groupnavigation_response_callback(int id, int pressed) {
@@ -429,7 +442,7 @@ static btrc_ctrl_callbacks_t sBluetoothAvrcpCallbacks = {

static void classInitNative(JNIEnv* env, jclass clazz) {
    method_handlePassthroughRsp =
        env->GetMethodID(clazz, "handlePassthroughRsp", "(II)V");
        env->GetMethodID(clazz, "handlePassthroughRsp", "(II[B)V");

    method_handleGroupNavigationRsp =
        env->GetMethodID(clazz, "handleGroupNavigationRsp", "(II)V");
+601 −0

File added.

Preview size limit exceeded, changes collapsed.

+1719 −270

File changed.File mode changed from 100755 to 100644.

Preview size limit exceeded, changes collapsed.

+146 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth.avrcp;

/*************************************************************************************************
 * Grouped all HAL constants into a file to be consistent with the stack.
 * Moved the constants used in Avrcp to this new file to be used across multiple files.
 * Helps in easier modifications and future enhancements in the constants.
 ************************************************************************************************/

/*
 * @hide
 */
final class AvrcpConstants {

    /* Do not modify without upating the HAL bt_rc.h file */
    /** Response Error codes **/
    static final byte RSP_BAD_CMD        = 0x00; /* Invalid command */
    static final byte RSP_BAD_PARAM      = 0x01; /* Invalid parameter */
    static final byte RSP_NOT_FOUND      = 0x02; /* Specified parameter is
                                                              * wrong or not found */
    static final byte RSP_INTERNAL_ERR   = 0x03; /* Internal Error */
    static final byte RSP_NO_ERROR       = 0x04; /* Operation Success */
    static final byte RSP_UID_CHANGED    = 0x05; /* UIDs changed */
    static final byte RSP_RESERVED       = 0x06; /* Reserved */
    static final byte RSP_INV_DIRN       = 0x07; /* Invalid direction */
    static final byte RSP_INV_DIRECTORY  = 0x08; /* Invalid directory */
    static final byte RSP_INV_ITEM       = 0x09; /* Invalid Item */
    static final byte RSP_INV_SCOPE      = 0x0a; /* Invalid scope */
    static final byte RSP_INV_RANGE      = 0x0b; /* Invalid range */
    static final byte RSP_DIRECTORY      = 0x0c; /* UID is a directory */
    static final byte RSP_MEDIA_IN_USE   = 0x0d; /* Media in use */
    static final byte RSP_PLAY_LIST_FULL = 0x0e; /* Playing list full */
    static final byte RSP_SRCH_NOT_SPRTD = 0x0f; /* Search not supported */
    static final byte RSP_SRCH_IN_PROG   = 0x10; /* Search in progress */
    static final byte RSP_INV_PLAYER     = 0x11; /* Invalid player */
    static final byte RSP_PLAY_NOT_BROW  = 0x12; /* Player not browsable */
    static final byte RSP_PLAY_NOT_ADDR  = 0x13; /* Player not addressed */
    static final byte RSP_INV_RESULTS    = 0x14; /* Invalid results */
    static final byte RSP_NO_AVBL_PLAY   = 0x15; /* No available players */
    static final byte RSP_ADDR_PLAY_CHGD = 0x16; /* Addressed player changed */

    /* valid scopes for get_folder_items */
    static final byte BTRC_SCOPE_PLAYER_LIST  = 0x00; /* Media Player List */
    static final byte BTRC_SCOPE_FILE_SYSTEM  = 0x01; /* Virtual File System */
    static final byte BTRC_SCOPE_SEARCH       = 0x02; /* Search */
    static final byte BTRC_SCOPE_NOW_PLAYING  = 0x03; /* Now Playing */

    /* valid directions for change path */
    static final byte DIR_UP   = 0x00;
    static final byte DIR_DOWN = 0x01;

    /* item type to browse */
    static final byte BTRC_ITEM_PLAYER  = 0x01;
    static final byte BTRC_ITEM_FOLDER  = 0x02;
    static final byte BTRC_ITEM_MEDIA   = 0x03;

    /* valid folder types */
    static final byte FOLDER_TYPE_MIXED      = 0x00;
    static final byte FOLDER_TYPE_TITLES     = 0x01;
    static final byte FOLDER_TYPE_ALBUMS     = 0x02;
    static final byte FOLDER_TYPE_ARTISTS    = 0x03;
    static final byte FOLDER_TYPE_GENRES     = 0x04;
    static final byte FOLDER_TYPE_PLAYLISTS  = 0x05;
    static final byte FOLDER_TYPE_YEARS      = 0x06;

    /* valid playable flags */
    static final byte ITEM_NOT_PLAYABLE  = 0x00;
    static final byte ITEM_PLAYABLE      = 0x01;

    /* valid Attribute ids for media elements */
    static final int ATTRID_TITLE      = 0x01;
    static final int ATTRID_ARTIST     = 0x02;
    static final int ATTRID_ALBUM      = 0x03;
    static final int ATTRID_TRACK_NUM  = 0x04;
    static final int ATTRID_NUM_TRACKS = 0x05;
    static final int ATTRID_GENRE      = 0x06;
    static final int ATTRID_PLAY_TIME  = 0x07;

    /* constants to send in Track change response */
    static final byte NO_TRACK_SELECTED = (byte)0xFF;
    static final byte TRACK_IS_SELECTED = (byte)0x00;

    /* Max UID size */
    static final int UID_SIZE = 8;

    static final short DEFAULT_UID_COUNTER = 0x0000;

    /* Bitmask size for Media Players */
    static final int AVRC_FEATURE_MASK_SIZE = 16;

    /* Maximum attributes for media item */
    static final int MAX_NUM_ATTR = 8;

    /* notification types for remote device */
    static final int NOTIFICATION_TYPE_INTERIM = 0;
    static final int NOTIFICATION_TYPE_CHANGED = 1;

    static final int TRACK_ID_SIZE = 8;

    /* player feature bit mask constants */
    static final short AVRC_PF_PLAY_BIT_NO = 40;
    static final short AVRC_PF_STOP_BIT_NO = 41;
    static final short AVRC_PF_PAUSE_BIT_NO = 42;
    static final short AVRC_PF_REWIND_BIT_NO = 44;
    static final short AVRC_PF_FAST_FWD_BIT_NO = 45;
    static final short AVRC_PF_FORWARD_BIT_NO = 47;
    static final short AVRC_PF_BACKWARD_BIT_NO = 48;
    static final short AVRC_PF_ADV_CTRL_BIT_NO = 58;
    static final short AVRC_PF_BROWSE_BIT_NO = 59;
    static final short AVRC_PF_ADD2NOWPLAY_BIT_NO = 61;
    static final short AVRC_PF_UID_UNIQUE_BIT_NO = 62;
    static final short AVRC_PF_NOW_PLAY_BIT_NO = 65;
    static final short AVRC_PF_GET_NUM_OF_ITEMS_BIT_NO = 67;

    static final byte PLAYER_TYPE_AUDIO = 1;
    static final int PLAYER_SUBTYPE_NONE = 0;

    // match up with btrc_play_status_t enum of bt_rc.h
    static final int PLAYSTATUS_STOPPED = 0;
    static final int PLAYSTATUS_PLAYING = 1;
    static final int PLAYSTATUS_PAUSED = 2;
    static final int PLAYSTATUS_FWD_SEEK = 3;
    static final int PLAYSTATUS_REV_SEEK = 4;
    static final int PLAYSTATUS_ERROR = 255;

    static final byte NUM_ATTR_ALL = (byte)0x00;
    static final byte NUM_ATTR_NONE = (byte)0xFF;

    static final int KEY_STATE_PRESS = 1;
    static final int KEY_STATE_RELEASE = 0;
}
Loading