/*
 * 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 android.hardware.gnss@1.0;

import IAGnssRilCallback;

/**
 * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface
 * Layer interface allows the GNSS chipset to request radio interface layer
 * information from Android platform. Examples of such information are reference
 * location, unique subscriber ID, phone number string and network availability changes.
 */
interface IAGnssRil {
    @export(name="", value_prefix="AGPS_SETID_TYPE_")
    enum SetIDType : uint8_t {
        NONE    = 0,
        IMSI    = 1,
        MSISDM  = 2
    };

    @export(name="", value_prefix="AGPS_RIL_NETWORK_TYPE_")
    enum NetworkType : uint8_t {
        MOBILE  = 0,
        WIFI    = 1,
        MMS     = 2,
        SUPL    = 3,
        DUN     = 4,
        HIPRI   = 5,
        WIMAX   = 6,
    };

    @export(name="", value_prefix="AGPS_REF_LOCATION_TYPE_")
    enum AGnssRefLocationType : uint8_t {
        GSM_CELLID   = 1,
        UMTS_CELLID  = 2,
        LTE_CELLID   = 4,
    };

    /** CellID for 2G, 3G and LTE, used in AGNSS. */
    struct AGnssRefLocationCellID {
        AGnssRefLocationType type;

        /** Mobile Country Code. */
        uint16_t mcc;

        /**
         * Mobile Network Code .*/
        uint16_t mnc;

        /**
         * Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
         * lac is populated with tac, to ensure that we don't break old clients that
         * might rely in the old (wrong) behavior.
         */
        uint16_t lac;

        /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
        uint32_t cid;

        /** Tracking Area Code in LTE. */
        uint16_t tac;

        /** Physical Cell id in LTE (not used in 2G and 3G) */
        uint16_t pcid;
    };

    /** Represents ref locations */
    struct AGnssRefLocation {
        AGnssRefLocationType type;

        AGnssRefLocationCellID cellID;
    };

    /**
     * Opens the AGNSS interface and provides the callback routines
     * to the implementation of this interface.
     *
     * @param callback Interface for AGnssRil callbacks.
     */
    setCallback(IAGnssRilCallback callback);

    /**
     * Sets the reference location.
     *
     * @param agnssReflocation AGNSS reference location CellID.
     */
    setRefLocation(AGnssRefLocation agnssReflocation);

    /**
     * Sets the SET ID.
     *
     * @param type Must be populated with either IMSI or MSISDN or NONE.
     * @param setid If type is IMSI then setid is populated with
     * a string representing the unique Subscriber ID, for example, the IMSI for
     * a GMS phone. If type is MSISDN, then setid must contain
     * the phone number string for line 1. For example, the MSISDN for a GSM phone.
     * If the type is NONE, then the string must be empty.
     *
     * @return success True if all parameters were valid and operation was
     * successful.
     */
    setSetId(SetIDType type, string setid) generates (bool success);

    /**
     * Notify GNSS of network status changes.
     *
     * @param connected Indicates whether network connectivity exists and
     * it is possible to establish connections and pass data.
     * @param type Indicates the kind of network, for eg. mobile, wifi etc.
     * @param roaming Indicates whether the device is currently roaming on
     * this network.
     *
     * @return success True is all parameters were valid and operation was
     * successful.
     */
    updateNetworkState(bool connected, NetworkType type, bool roaming)
        generates (bool success);

    /**
     * Notify GNSS of network status changes and current APN.
     *
     * @param available Indicates whether network connectivity is available.
     * @param apn String containing the telephony preferred Access Point Name.
     *
     * @return success True if all parameters were valid and the operation was
     * successful.
     */
    updateNetworkAvailability(bool available, string apn) generates (bool success);

};