Wyatt Riley | ad03ab2 | 2016-12-14 14:54:29 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.hardware.gnss@1.0; |
| 18 | |
| 19 | import IGnssBatchingCallback; |
| 20 | |
| 21 | /* |
| 22 | * Extended interface for GNSS Batching support. |
| 23 | * |
| 24 | * If this interface is supported, this batching request must be able to run in |
| 25 | * parallel with, or without, non-batched location requested by the |
| 26 | * IGnss start() & stop() - i.e. both requests must be handled independently, |
| 27 | * and not interfere with each other. |
| 28 | * |
| 29 | * For example, if a 1Hz continuous output is underway on the IGnssCallback, |
| 30 | * due to an IGnss start() operation, |
| 31 | * and then a IGnssBatching start() is called for a location every 10 |
| 32 | * seconds, the newly added batching request must not disrupt the 1Hz |
| 33 | * continuous location output on the IGnssCallback. |
| 34 | * |
| 35 | * As with GNSS Location outputs, source of location must be GNSS satellite |
| 36 | * measurements, optionally using interial and baro sensors to improve |
| 37 | * relative motion filtering. No additional absolute positioning information, |
| 38 | * such as WiFi derived location, may be mixed with the GNSS information. |
| 39 | */ |
| 40 | |
| 41 | interface IGnssBatching { |
| 42 | /* |
| 43 | * Enum which holds the bit masks for batching control. |
| 44 | */ |
| 45 | enum Flag : uint8_t { |
| 46 | /* |
| 47 | * If this flag is set, the hardware implementation |
| 48 | * must wake up the application processor when the FIFO is full, and |
| 49 | * call IGnssBatchingCallback to return the locations. |
| 50 | * |
| 51 | * If the flag is not set, the hardware implementation must drop |
| 52 | * the oldest data when the FIFO is full. |
| 53 | */ |
| 54 | WAKEUP_ON_FIFO_FULL = 0x01 |
| 55 | }; |
| 56 | |
| 57 | struct Options { |
| 58 | /* |
| 59 | * Time interval between samples in the location batch, in nano |
| 60 | * seconds. |
| 61 | */ |
| 62 | int64_t periodNanos; |
| 63 | |
| 64 | /* |
| 65 | * Flags controlling how batching should behave. |
| 66 | */ |
| 67 | bitfield<Flag> flags; |
| 68 | }; |
| 69 | |
| 70 | /* |
| 71 | * Opens the interface and provides the callback routines |
| 72 | * to the implementation of this interface. |
| 73 | * |
| 74 | * @param callback Callback interface for IGnssBatching. |
| 75 | * |
| 76 | * @return success Returns true on success. |
| 77 | */ |
| 78 | init(IGnssBatchingCallback callback) generates (bool success); |
| 79 | |
| 80 | /* |
| 81 | * Return the batch size (in number of GnssLocation objects) |
| 82 | * available in this hardware implementation. |
| 83 | * |
| 84 | * If the available size is variable, for example, based on other operations |
| 85 | * consuming memory, this is the minimum size guaranteed to be available |
| 86 | * for batching operations. |
| 87 | * |
| 88 | * This may, for example, be used by the upper layer, to decide on the |
| 89 | * batching interval and whether the AP should be woken up or not. |
| 90 | * |
| 91 | * @return batchSize number of location objects supported per batch |
| 92 | */ |
| 93 | getBatchSize() generates (uint16_t batchSize); |
| 94 | |
| 95 | /* |
| 96 | * Start batching locations. This API is primarily used when the AP is |
| 97 | * asleep and the device can batch locations in the hardware. |
| 98 | * |
| 99 | * IGnssBatchingCallback is used to return the locations. |
| 100 | * |
| 101 | * When the buffer is full and WAKEUP_ON_FIFO_FULL is used, |
| 102 | * IGnssBatchingCallback must be called to return the locations. |
| 103 | * |
| 104 | * When the buffer is full and WAKEUP_ON_FIFO_FULL is not set, |
| 105 | * the oldest location object is dropped. In this case the AP must not be |
| 106 | * woken up. The AP would then generally be responsible for using |
| 107 | * flushBatchedLocation to explicitly ask for the location as needed, |
| 108 | * to avoid it being dropped. |
| 109 | * |
| 110 | * @param options See struct Options definition. |
| 111 | * |
| 112 | * @return success Returns true on success. |
| 113 | */ |
| 114 | start(Options options) generates (bool success); |
| 115 | |
| 116 | /** |
| 117 | * Retrieve all batched locations currently stored. |
| 118 | * |
| 119 | * IGnssBatchingCallback is used to return the location. |
| 120 | * |
| 121 | * IGnssBatchingCallback must be called in response, even if there are |
| 122 | * no locations to flush (in which case the Location vector must be empty). |
| 123 | * |
| 124 | * Subsequent calls to flushBatchedLocation |
| 125 | * must not return any of the locations returned in this call. |
| 126 | */ |
| 127 | flush(); |
| 128 | |
| 129 | /** |
| 130 | * Stop batching. |
| 131 | * |
| 132 | * @return success Returns true on success. |
| 133 | */ |
| 134 | stop() generates (bool success); |
| 135 | |
| 136 | /** |
| 137 | * Closes the interface. If any batch operations are in progress, |
| 138 | * they should be stopped. |
| 139 | * |
| 140 | * init() may be called again, after this, if the interface is to be restored |
| 141 | */ |
| 142 | cleanup(); |
| 143 | |
| 144 | }; |