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

Commit b1703542 authored by Wyatt Riley's avatar Wyatt Riley Committed by Android (Google) Code Review
Browse files

Merge "GnssBatching API, port from Fused Location"

parents 060d5fb8 ad03ab22
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ genrule {
        "IAGnssRil.hal",
        "IAGnssRilCallback.hal",
        "IGnss.hal",
        "IGnssBatching.hal",
        "IGnssBatchingCallback.hal",
        "IGnssCallback.hal",
        "IGnssConfiguration.hal",
        "IGnssDebug.hal",
@@ -32,6 +34,8 @@ genrule {
        "android/hardware/gnss/1.0/AGnssRilAll.cpp",
        "android/hardware/gnss/1.0/AGnssRilCallbackAll.cpp",
        "android/hardware/gnss/1.0/GnssAll.cpp",
        "android/hardware/gnss/1.0/GnssBatchingAll.cpp",
        "android/hardware/gnss/1.0/GnssBatchingCallbackAll.cpp",
        "android/hardware/gnss/1.0/GnssCallbackAll.cpp",
        "android/hardware/gnss/1.0/GnssConfigurationAll.cpp",
        "android/hardware/gnss/1.0/GnssDebugAll.cpp",
@@ -59,6 +63,8 @@ genrule {
        "IAGnssRil.hal",
        "IAGnssRilCallback.hal",
        "IGnss.hal",
        "IGnssBatching.hal",
        "IGnssBatchingCallback.hal",
        "IGnssCallback.hal",
        "IGnssConfiguration.hal",
        "IGnssDebug.hal",
@@ -100,6 +106,16 @@ genrule {
        "android/hardware/gnss/1.0/BnGnss.h",
        "android/hardware/gnss/1.0/BpGnss.h",
        "android/hardware/gnss/1.0/BsGnss.h",
        "android/hardware/gnss/1.0/IGnssBatching.h",
        "android/hardware/gnss/1.0/IHwGnssBatching.h",
        "android/hardware/gnss/1.0/BnGnssBatching.h",
        "android/hardware/gnss/1.0/BpGnssBatching.h",
        "android/hardware/gnss/1.0/BsGnssBatching.h",
        "android/hardware/gnss/1.0/IGnssBatchingCallback.h",
        "android/hardware/gnss/1.0/IHwGnssBatchingCallback.h",
        "android/hardware/gnss/1.0/BnGnssBatchingCallback.h",
        "android/hardware/gnss/1.0/BpGnssBatchingCallback.h",
        "android/hardware/gnss/1.0/BsGnssBatchingCallback.h",
        "android/hardware/gnss/1.0/IGnssCallback.h",
        "android/hardware/gnss/1.0/IHwGnssCallback.h",
        "android/hardware/gnss/1.0/BnGnssCallback.h",
+88 −0
Original line number Diff line number Diff line
@@ -164,6 +164,8 @@ $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAGnss.hal
$(GEN): $(LOCAL_PATH)/IAGnss.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAGnssRil.hal
$(GEN): $(LOCAL_PATH)/IAGnssRil.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssCallback.hal
$(GEN): $(LOCAL_PATH)/IGnssCallback.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssConfiguration.hal
@@ -194,6 +196,48 @@ $(GEN): $(LOCAL_PATH)/IGnss.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssBatching.hal
#
GEN := $(intermediates)/android/hardware/gnss/V1_0/IGnssBatching.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
        -Ljava \
        -randroid.hardware:hardware/interfaces \
        -randroid.hidl:system/libhidl/transport \
        android.hardware.gnss@1.0::IGnssBatching

$(GEN): $(LOCAL_PATH)/IGnssBatching.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssBatchingCallback.hal
#
GEN := $(intermediates)/android/hardware/gnss/V1_0/IGnssBatchingCallback.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
        -Ljava \
        -randroid.hardware:hardware/interfaces \
        -randroid.hidl:system/libhidl/transport \
        android.hardware.gnss@1.0::IGnssBatchingCallback

$(GEN): $(LOCAL_PATH)/IGnssBatchingCallback.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssCallback.hal
#
@@ -623,6 +667,8 @@ $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAGnss.hal
$(GEN): $(LOCAL_PATH)/IAGnss.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAGnssRil.hal
$(GEN): $(LOCAL_PATH)/IAGnssRil.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssCallback.hal
$(GEN): $(LOCAL_PATH)/IGnssCallback.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssConfiguration.hal
@@ -653,6 +699,48 @@ $(GEN): $(LOCAL_PATH)/IGnss.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssBatching.hal
#
GEN := $(intermediates)/android/hardware/gnss/V1_0/IGnssBatching.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IGnssBatching.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
        -Ljava \
        -randroid.hardware:hardware/interfaces \
        -randroid.hidl:system/libhidl/transport \
        android.hardware.gnss@1.0::IGnssBatching

$(GEN): $(LOCAL_PATH)/IGnssBatching.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssBatchingCallback.hal
#
GEN := $(intermediates)/android/hardware/gnss/V1_0/IGnssBatchingCallback.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IGnssBatchingCallback.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
        -Ljava \
        -randroid.hardware:hardware/interfaces \
        -randroid.hidl:system/libhidl/transport \
        android.hardware.gnss@1.0::IGnssBatchingCallback

$(GEN): $(LOCAL_PATH)/IGnssBatchingCallback.hal
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

#
# Build IGnssCallback.hal
#
+15 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.gnss@1.0;

import IAGnss;
import IAGnssRil;
import IGnssBatching;
import IGnssCallback;
import IGnssConfiguration;
import IGnssDebug;
@@ -81,14 +82,19 @@ interface IGnss {
    setCallback(IGnssCallback callback) generates (bool success);

    /*
     * Starts navigating.
     * Starts a location output stream using the IGnssCallback
     * gnssLocationCb(), following the settings from the most recent call to
     * setPositionMode().
     *
     * This output must operate independently of any GNSS location batching
     * operations, see the IGnssBatching.hal for details.
     *
     * @return success Returns true on success.
     */
    start() generates (bool success);

    /*
     * Stops navigating.
     * Stops the location output stream.
     *
     * @return success Returns true on success.
     */
@@ -218,4 +224,11 @@ interface IGnss {
     * @return debugIface Handle to the IGnssDebug interface.
     */
    getExtensionGnssDebug() generates (IGnssDebug debugIface);

    /*
     * This method returns the IGnssBatching interface.
     *
     * @return batchingIface Handle to the IGnssBatching interface.
     */
    getExtensionGnssBatching() generates (IGnssBatching batchingIface);
};
+144 −0
Original line number Diff line number Diff line
/*
 * 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 IGnssBatchingCallback;

/*
 * Extended interface for GNSS Batching support.
 *
 * If this interface is supported, this batching request must be able to run in
 * parallel with, or without, non-batched location requested by the
 * IGnss start() & stop() - i.e. both requests must be handled independently,
 * and not interfere with each other.
 *
 * For example, if a 1Hz continuous output is underway on the IGnssCallback,
 * due to an IGnss start() operation,
 * and then a IGnssBatching start() is called for a location every 10
 * seconds, the newly added batching request must not disrupt the 1Hz
 * continuous location output on the IGnssCallback.
 *
 * As with GNSS Location outputs, source of location must be GNSS satellite
 * measurements, optionally using interial and baro sensors to improve
 * relative motion filtering. No additional absolute positioning information,
 * such as WiFi derived location, may be mixed with the GNSS information.
 */

interface IGnssBatching {
    /*
     * Enum which holds the bit masks for batching control.
     */
    enum Flag : uint8_t {
        /*
         * If this flag is set, the hardware implementation
         * must wake up the application processor when the FIFO is full, and
         * call IGnssBatchingCallback to return the locations.
         *
         * If the flag is not set, the hardware implementation must drop
         * the oldest data when the FIFO is full.
         */
        WAKEUP_ON_FIFO_FULL = 0x01
    };

    struct Options {
        /*
         * Time interval between samples in the location batch, in nano
         * seconds.
         */
        int64_t periodNanos;

        /*
         * Flags controlling how batching should behave.
         */
        bitfield<Flag> flags;
    };

    /*
     * Opens the interface and provides the callback routines
     * to the implementation of this interface.
     *
     * @param callback Callback interface for IGnssBatching.
     *
     * @return success Returns true on success.
     */
    init(IGnssBatchingCallback callback) generates (bool success);

    /*
     * Return the batch size (in number of GnssLocation objects)
     * available in this hardware implementation.
     *
     * If the available size is variable, for example, based on other operations
     * consuming memory, this is the minimum size guaranteed to be available
     * for batching operations.
     *
     * This may, for example, be used by the upper layer, to decide on the
     * batching interval and whether the AP should be woken up or not.
     *
     * @return batchSize number of location objects supported per batch
     */
    getBatchSize() generates (uint16_t batchSize);

    /*
     * Start batching locations. This API is primarily used when the AP is
     * asleep and the device can batch locations in the hardware.
     *
     * IGnssBatchingCallback is used to return the locations.
     *
     * When the buffer is full and WAKEUP_ON_FIFO_FULL is used,
     * IGnssBatchingCallback must be called to return the locations.
     *
     * When the buffer is full and WAKEUP_ON_FIFO_FULL is not set,
     * the oldest location object is dropped. In this case the AP must not be
     * woken up. The AP would then generally be responsible for using
     * flushBatchedLocation to explicitly ask for the location as needed,
     * to avoid it being dropped.
     *
     * @param options See struct Options definition.
     *
     * @return success Returns true on success.
     */
    start(Options options) generates (bool success);

    /**
     * Retrieve all batched locations currently stored.
     *
     * IGnssBatchingCallback is used to return the location.
     *
     * IGnssBatchingCallback must be called in response, even if there are
     * no locations to flush (in which case the Location vector must be empty).
     *
     * Subsequent calls to flushBatchedLocation
     * must not return any of the locations returned in this call.
     */
    flush();

    /**
     * Stop batching.
     *
     * @return success Returns true on success.
     */
    stop() generates (bool success);

    /**
     * Closes the interface. If any batch operations are in progress,
     * they should be stopped.
     *
     * init() may be called again, after this, if the interface is to be restored
     */
    cleanup();

};
+33 −0
Original line number Diff line number Diff line
/*
 * 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;

/* The callback interface to report measurements from the HAL. */
interface IGnssBatchingCallback {
    /*
     * Called when a batch of locations is output, by various means, including
     * a flush request, as well as the buffer becoming full (if appropriate option
     * is set.)
     *
     * All locations returned by this callback must be cleared from the hardware
     * buffer, such the sequential calls of this callback do not return any
     * redundant locations.  (Same lat/lon, at a new time, is acceptable.)
     *
     * @param locations GNSS Location information from HAL.
     */
    gnssLocationBatchCb(vec<GnssLocation> locations);
};
Loading