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

Commit cc35e78c authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Jakub Pawlowski
Browse files

MediaControlGattService

This is implementation GATT Service for of Media Control Service

Bug: 150670922
Tag: #feature
Test: atest BluetoothInstrumentationTests
Sponsor: jpawlowski@
Change-Id: Ib147f4447236df53c8bd8b6e474893bdc7748b45
parent f940744f
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();
}
+1129 −0

File added.

Preview size limit exceeded, changes collapsed.