/*
 * Copyright (C) 2021 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.server.uwb.jni;

import com.android.server.uwb.data.UwbMulticastListUpdateStatus;
import com.android.server.uwb.data.UwbRadarData;
import com.android.server.uwb.data.UwbRangingData;
import com.android.server.uwb.rftest.RfNotificationEvent;

public interface INativeUwbManager {
    /**
     * Notifies transaction
     */
    interface SessionNotification {
        /**
         * Interface for receiving Ranging Data Notification
         *
         * @param rangingData : refer to UCI GENERIC SPECIFICATION Table 22:Ranging Data
         *                    Notification
         */
        void onRangeDataNotificationReceived(UwbRangingData rangingData);

        /**
         * Interface for receiving Session Status Notification
         *
         * @param id         : Session ID
         * @param token      : Session Token
         * @param state      : Session State
         * @param reasonCode : Reason Code - UCI GENERIC SPECIFICATION Table 15 : state change with
         *                   reason codes
         */
        void onSessionStatusNotificationReceived(long id, int token, int state, int reasonCode);

        /**
         * Interface for receiving Multicast List Update Data
         *
         * @param multicastListUpdateData : refer to SESSION_UPDATE_CONTROLLER_MULTICAST_LIST_NTF
         */
        void onMulticastListUpdateNotificationReceived(
                UwbMulticastListUpdateStatus multicastListUpdateData);

        /**
         * Interface for receiving data from the remote device in either Bypass or Logical Link
         * mode.
         *
         * @param sessionID      Session ID or Connect ID, depending on the mode.
         * @param linkLayerMode  Link layer mode (e.g., Bypass or Logical Link).
         * @param status         Status (applicable only in Bypass Mode).
         * @param sequenceNum    UCI sequence number.
         * @param address        Remote device address (applicable in Bypass Mode,
         *                          0xFFFF in Logical Link Mode).
         * @param data           Payload data received.
         */
        // TODO(b/261762781): Change the type of sessionID & sequenceNum parameters to int (to match
        // their 4-octet size in the UCI spec).
        void onDataReceived(long sessionID, int linkLayerMode, int status, long sequenceNum,
                byte[] address, byte[] data);

        /**
         * Interface for receiving the data transfer status, corresponding to a Data packet
         * earlier sent from the host to UWBS.
         *
         * @param sessionId          : Session ID
         * @param dataTransferStatus : Status codes in the DATA_TRANSFER_STATUS_NTF packet
         * @param sequenceNum        : Sequence Number
         * @param txCount            : Transmission count
         */
        void onDataSendStatus(long sessionId, int dataTransferStatus, long sequenceNum,
                int txCount);

        /**
         * Interface for receiving controlee device role change notification
         *
         * @param sessionId          : Session ID
         * @param deviceRole         : Device Role
         */
        void onControleeRoleChanged(long sessionId, int deviceRole);

        /**
         * Interface for receiving Radar Data Message
         *
         * @param radarData : refer to Android UWB Radar UCI Specification: radar Data Message
         */
        void onRadarDataMessageReceived(UwbRadarData radarData);

        /**
         * Interface for receiving the data transfer phase config notification
         *
         * @param sessionId                     : Session ID
         * @param dataTransferPhaseConfigStatus  : DATA_TRANSFER_PHASE_CONFIG_STATUS_NTF status code
         */
        void onDataTransferPhaseConfigNotificationReceived(long sessionId,
                int dataTransferPhaseConfigStatus);

        /**
         * Interface for receiving RF test notification events
         *
         * @param rfNotificationEvent  : Protocol specific notification params
         */
        void onRfTestNotificationReceived(RfNotificationEvent rfNotificationEvent);

        /**
         * Interface for receiving Logical Link Create Notification
         *
         * @param connectId : Identifier specific for the created link
         * @param status : status of Logical Link Create Notification
         */
        void onLogicalLinkCreateNotification(long connectId, int status);

        /**
         * Called when a UWBS logical link is closed by the remote device, host or due to an
         * internal condition.
         *
         * @param connectId The identifier of the logical link that was closed.
         * @param reason The reason for closure.
         */
        void onLogicalLinkClosed(long connectId, int reason);

        /**
         * Called when a UWBS logical link creation request is received from a remote device.
         *
         * @param sessionId The session ID associated with the logical link request.
         * @param connectId The identifier for the newly requested logical link.
         * @param linkLayerMode The mode of the link layer.
         * @param address The UWB address (MAC address) of the remote device initiating the request.
         */
        void onRemoteLogicalLinkRequested(
                long sessionId, long connectId, int linkLayerMode, byte[] address);
    }

    interface DeviceNotification {
        /**
         * Interface for receiving Device Status Notification
         *
         * @param state     : refer to UCI GENERIC SPECIFICATION Table 9: Device Status Notification
         * @param chipId    : identifier of UWB chip for multi-HAL devices
         */
        void onDeviceStatusNotificationReceived(int state, String chipId);

        /**
         * Interface for receiving Control Message for Generic Error
         *
         * @param status : refer to UCI GENERIC SPECIFICATION Table 12: Control Message for Generic
         *               Error
         * @param chipId : identifier of UWB chip for multi-HAL devices
         */
        void onCoreGenericErrorNotificationReceived(int status, String chipId);
    }

    interface VendorNotification {
        /**
         * Interface for receiving Vendor UCI notifications.
         */
        void onVendorUciNotificationReceived(int gid, int oid, byte[] payload);
    }
}
