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

Commit 313e8806 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Ib147f444,Iea7472f3

* changes:
  MediaControlGattService
  Add Media Control Profile constants definitions
parents bf5e3a5c cc35e78c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -107,6 +107,16 @@ public class McpService extends ProfileService {
        }
    }

    public void onDeviceUnauthorized(BluetoothDevice device) {
        // TODO: For now just reject authorization for other than LeAudio device already authorized.
        //       Consider intent based authorization mechanism for non-LeAudio devices.
        setDeviceAuthorized(device, false);
    }

    public int getDeviceAuthorization(BluetoothDevice device) {
        return BluetoothDevice.ACCESS_ALLOWED;
    }

    void setDeviceAuthorized(BluetoothDevice device, boolean isAuthorized) {

    }
+1826 −0

File added.

Preview size limit exceeded, changes collapsed.

+52 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * 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.mcp;

import android.bluetooth.BluetoothDevice;

import java.util.Map;

/**
 * Media Control Service interface. These are sent Media Players => GATT Servers
 */
public interface MediaControlGattServiceInterface {
    /**
     * Track position unavailable definition
     */
    static final long TRACK_POSITION_UNAVAILABLE = -1L;

    /**
     * Track duration unavailable definition
     */
    static final long TRACK_DURATION_UNAVAILABLE = -1L;

    /**
     * API for Media Control Profile service control
     */
    void updatePlaybackState(MediaState state);
    void updatePlayerState(Map stateFields);
    void updateObjectID(int objField, long objectId);
    void setMediaControlRequestResult(Request request,
            Request.Results resultStatus);
    void setSearchRequestResult(SearchRequest request,
            SearchRequest.Results resultStatus, long resultObjectId);
    int getContentControlId();
    void onDeviceAuthorizationSet(BluetoothDevice device);
    void destroy();
    void dump(StringBuilder sb);
}
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * 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.mcp;

/**
 * Media Control Service callback interface. These callbacks are sent GATT servers => Media Players
 */
interface MediaControlServiceCallbacks {
    void onServiceInstanceRegistered(ServiceStatus status, MediaControlGattServiceInterface serviceProxy);
    void onServiceInstanceUnregistered(ServiceStatus status);
    void onMediaControlRequest(Request request);
    void onSearchRequest(SearchRequest request);
    void onSetObjectIdRequest(int objField, long objectId);
    void onTrackPositionSetRequest(long position);
    void onPlaybackSpeedSetRequest(float speed);
    void onPlayingOrderSetRequest(int order);
    void onCurrentTrackObjectIdSet(long objectId);
    void onNextTrackObjectIdSet(long objectId);
    void onCurrentGroupObjectIdSet(long objectId);
    void onCurrentTrackMetadataRequest();
    void onPlayerStateRequest(PlayerStateField[] stateFields);
    long onGetFeatureFlags();
    long onGetCurrentTrackPosition();
}
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * 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.mcp;

/**
 * Playback states definition
 */
public enum MediaState {
    INACTIVE(0x00),
    PLAYING(0x01),
    PAUSED(0x02),
    SEEKING(0x03);

    public static final MediaState STATE_MIN = INACTIVE;
    public static final MediaState STATE_MAX = SEEKING;
    private final int mValue;

    MediaState(int value) {
        mValue = value;
    }

    public int getValue() {
        return mValue;
    }
}
Loading