/*
 * Copyright (C) 2017 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.1;

import @1.0::IGnss;
import @1.0::GnssLocation;

import IGnssCallback;
import IGnssConfiguration;
import IGnssMeasurement;

/** Represents the standard GNSS (Global Navigation Satellite System) interface. */
interface IGnss extends @1.0::IGnss {
    /**
     * Opens the interface and provides the callback routines to the implementation of this
     * interface.
     *
     * The framework calls this method to instruct the GPS engine to prepare for serving requests
     * from the framework. The GNSS HAL implementation must respond to all GNSS requests from the
     * framework upon successful return from this method until cleanup() method is called to
     * close this interface.
     *
     * @param callback Callback interface for IGnss.
     *
     * @return success Returns true on success.
     */
    setCallback_1_1(IGnssCallback callback) generates (bool success);

    /**
     * Sets the GnssPositionMode parameter, its associated recurrence value,
     * the time between fixes, requested fix accuracy, time to first fix.
     *
     * @param mode Parameter must be one of MS_BASED or STANDALONE. It is allowed by the platform
     *     (and it is recommended) to fallback to MS_BASED if MS_ASSISTED is passed in, and MS_BASED
     *     is supported.
     * @param recurrence GNSS position recurrence value, either periodic or single.
     * @param minIntervalMs Represents the time between fixes in milliseconds.
     * @param preferredAccuracyMeters Represents the requested fix accuracy in meters.
     * @param preferredTimeMs Represents the requested time to first fix in milliseconds.
     * @param lowPowerMode When true, and IGnss.hal is the only client to the GNSS hardware, the
     *     GNSS hardware must make strong tradeoffs to substantially restrict power use.
     *     Specifically, in the case of a several second long minIntervalMs, the GNSS hardware must
     *     not, on average, run power hungry operations like RF and signal searches for more than
     *     one second per interval, and must make exactly one call to gnssSvStatusCb(), and either
     *     zero or one call to GnssLocationCb() at each interval. When false, HAL must operate in
     *     the nominal mode (similar to V1.0 where this flag wasn't present) and is expected to make
     *     power and performance tradoffs such as duty-cycling when signal conditions are good and
     *     more active searches to reacquire GNSS signals when no signals are present.
     *     When there are additional clients using the GNSS hardware other than IGnss.hal, the GNSS
     *     hardware may operate in a higher power mode, on behalf of those clients.
     *
     * @return success Returns true if successful.
     */
    setPositionMode_1_1(GnssPositionMode mode,
                        GnssPositionRecurrence recurrence,
                        uint32_t minIntervalMs,
                        uint32_t preferredAccuracyMeters,
                        uint32_t preferredTimeMs,
                        bool lowPowerMode)
             generates (bool success);

   /**
    * This method returns the IGnssConfiguration interface.
    *
    * @return gnssConfigurationIface Handle to the IGnssConfiguration interface.
    */
    getExtensionGnssConfiguration_1_1() generates (IGnssConfiguration gnssConfigurationIface);

   /**
    * This method returns the IGnssMeasurement interface.
    *
    * @return gnssMeasurementIface Handle to the IGnssMeasurement interface.
    */
    getExtensionGnssMeasurement_1_1() generates (IGnssMeasurement gnssMeasurementIface);

    /**
     * Injects current location from the best available location provider.
     *
     * Unlike injectLocation, this method may inject a recent GNSS location from the HAL
     * implementation, if that is the best available location known to the framework.
     *
     * @param location Location information from the best available location provider.
     *
     * @return success Returns true if successful.
     */
    injectBestLocation(GnssLocation location) generates (bool success);
};