mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Add GnssNavigationMessage AIDL HAL (hardware/interfaces)"
This commit is contained in:
@@ -42,6 +42,7 @@ interface IGnss {
|
||||
android.hardware.gnss.IGnssPowerIndication getExtensionGnssPowerIndication();
|
||||
@nullable android.hardware.gnss.IGnssBatching getExtensionGnssBatching();
|
||||
@nullable android.hardware.gnss.IGnssGeofence getExtensionGnssGeofence();
|
||||
@nullable android.hardware.gnss.IGnssNavigationMessageInterface getExtensionGnssNavigationMessage();
|
||||
const int ERROR_INVALID_ARGUMENT = 1;
|
||||
const int ERROR_ALREADY_INIT = 2;
|
||||
const int ERROR_GENERIC = 3;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.gnss;
|
||||
@VintfStability
|
||||
interface IGnssNavigationMessageCallback {
|
||||
void gnssNavigationMessageCb(in android.hardware.gnss.IGnssNavigationMessageCallback.GnssNavigationMessage message);
|
||||
@VintfStability
|
||||
parcelable GnssNavigationMessage {
|
||||
int svid;
|
||||
android.hardware.gnss.IGnssNavigationMessageCallback.GnssNavigationMessage.GnssNavigationMessageType type;
|
||||
int status;
|
||||
int messageId;
|
||||
int submessageId;
|
||||
byte[] data;
|
||||
const int STATUS_PARITY_PASSED = 1;
|
||||
const int STATUS_PARITY_REBUILT = 2;
|
||||
const int STATUS_UNKNOWN = 0;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum GnssNavigationMessageType {
|
||||
UNKNOWN = 0,
|
||||
GPS_L1CA = 257,
|
||||
GPS_L2CNAV = 258,
|
||||
GPS_L5CNAV = 259,
|
||||
SBS = 513,
|
||||
GPS_CNAV2 = 260,
|
||||
GLO_L1CA = 769,
|
||||
QZS_L1CA = 1025,
|
||||
BDS_D1 = 1281,
|
||||
BDS_D2 = 1282,
|
||||
BDS_CNAV1 = 1283,
|
||||
BDS_CNAV2 = 1284,
|
||||
GAL_I = 1537,
|
||||
GAL_F = 1538,
|
||||
IRN_L5CA = 1793,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.gnss;
|
||||
@VintfStability
|
||||
interface IGnssNavigationMessageInterface {
|
||||
void setCallback(in android.hardware.gnss.IGnssNavigationMessageCallback callback);
|
||||
void close();
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import android.hardware.gnss.IGnssCallback;
|
||||
import android.hardware.gnss.IGnssConfiguration;
|
||||
import android.hardware.gnss.IGnssGeofence;
|
||||
import android.hardware.gnss.IGnssMeasurementInterface;
|
||||
import android.hardware.gnss.IGnssNavigationMessageInterface;
|
||||
import android.hardware.gnss.IGnssPowerIndication;
|
||||
import android.hardware.gnss.IGnssPsds;
|
||||
|
||||
@@ -118,4 +119,11 @@ interface IGnss {
|
||||
* @return Handle to the IGnssGeofence interface.
|
||||
*/
|
||||
@nullable IGnssGeofence getExtensionGnssGeofence();
|
||||
|
||||
/**
|
||||
* This method returns the IGnssNavigationMessageInterface.
|
||||
*
|
||||
* @return Handle to the IGnssNavigationMessageInterface.
|
||||
*/
|
||||
@nullable IGnssNavigationMessageInterface getExtensionGnssNavigationMessage();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* 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 android.hardware.gnss;
|
||||
|
||||
/** Represents a GNSS navigation message (or a fragment of it). */
|
||||
@VintfStability
|
||||
interface IGnssNavigationMessageCallback {
|
||||
/**
|
||||
* Represents a reading of GNSS measurements. For devices launched in Android Q or newer, it is
|
||||
* mandatory that these be provided, on request, when the GNSS receiver is searching/tracking
|
||||
* signals.
|
||||
*
|
||||
* - Reporting of GNSS constellation measurements is mandatory.
|
||||
* - Reporting of all tracked constellations are encouraged.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable GnssNavigationMessage {
|
||||
/**
|
||||
* Status of Navigation Message
|
||||
*
|
||||
* When a message is received properly without any parity error in its
|
||||
* navigation words, the status must be set to PARITY_PASSED.
|
||||
*
|
||||
* If a message is received with words that failed a parity check, but the GNSS
|
||||
* receiver has corrected those words, the status must be set to PARITY_REBUILT.
|
||||
*
|
||||
* Do not send any navigation message that contains words with parity errors
|
||||
* that cannot be corrected.
|
||||
*/
|
||||
const int STATUS_PARITY_PASSED = (1 << 0);
|
||||
const int STATUS_PARITY_REBUILT = (1 << 1);
|
||||
const int STATUS_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* Enumeration of available values to indicate the GNSS Navigation message
|
||||
* types.
|
||||
*
|
||||
* For convenience, first byte is the GnssConstellationType on which that signal
|
||||
* is typically transmitted.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum GnssNavigationMessageType {
|
||||
UNKNOWN = 0,
|
||||
|
||||
/** GPS L1 C/A message contained in the structure. */
|
||||
GPS_L1CA = 0x0101,
|
||||
|
||||
/** GPS L2-CNAV message contained in the structure. */
|
||||
GPS_L2CNAV = 0x0102,
|
||||
|
||||
/** GPS L5-CNAV message contained in the structure. */
|
||||
GPS_L5CNAV = 0x0103,
|
||||
|
||||
/* SBAS message contained in the structure. */
|
||||
SBS = 0x0201,
|
||||
|
||||
/** GPS CNAV-2 message contained in the structure. */
|
||||
GPS_CNAV2 = 0x0104,
|
||||
|
||||
/** Glonass L1 CA message contained in the structure. */
|
||||
GLO_L1CA = 0x0301,
|
||||
|
||||
/** QZSS L1 C/A message contained in the structure. */
|
||||
QZS_L1CA = 0x0401,
|
||||
|
||||
/** Beidou D1 message contained in the structure. */
|
||||
BDS_D1 = 0x0501,
|
||||
|
||||
/** Beidou D2 message contained in the structure. */
|
||||
BDS_D2 = 0x0502,
|
||||
|
||||
/** Beidou CNAV1 message contained in the structure. */
|
||||
BDS_CNAV1 = 0x0503,
|
||||
|
||||
/** Beidou CNAV2 message contained in the structure. */
|
||||
BDS_CNAV2 = 0x0504,
|
||||
|
||||
/** Galileo I/NAV message contained in the structure. */
|
||||
GAL_I = 0x0601,
|
||||
|
||||
/** Galileo F/NAV message contained in the structure. */
|
||||
GAL_F = 0x0602,
|
||||
|
||||
/** IRNSS L5 C/A message contained in the structure. */
|
||||
IRN_L5CA = 0x0701,
|
||||
}
|
||||
|
||||
/**
|
||||
* Satellite vehicle ID number, as defined in GnssSvInfo::svid
|
||||
*
|
||||
* This is a mandatory value.
|
||||
*/
|
||||
int svid;
|
||||
|
||||
/**
|
||||
* The type of message contained in the structure.
|
||||
*
|
||||
* This is a mandatory value.
|
||||
*/
|
||||
GnssNavigationMessageType type;
|
||||
|
||||
/**
|
||||
* The status of the received navigation message.
|
||||
*
|
||||
* It is a bitfield of constants with prefix "STATUS_" defined in this structure.
|
||||
*
|
||||
* No need to send any navigation message that contains words with parity
|
||||
* errors that cannot be corrected.
|
||||
*/
|
||||
int status;
|
||||
|
||||
/**
|
||||
* Message identifier. It provides an index so the complete Navigation
|
||||
* Message can be assembled.
|
||||
*
|
||||
* - For GNSS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
|
||||
* id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
|
||||
* does not contain a 'frame id' and this value can be set to -1.)
|
||||
*
|
||||
* - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
|
||||
*
|
||||
* - For BeiDou D1, this refers to the frame number in the range of 1-24
|
||||
*
|
||||
* - For Beidou D2, this refers to the frame number, in the range of 1-120
|
||||
*
|
||||
* - For Galileo F/NAV nominal frame structure, this refers to the subframe
|
||||
* number, in the range of 1-12
|
||||
*
|
||||
* - For Galileo I/NAV nominal frame structure, this refers to the subframe
|
||||
* number in the range of 1-24
|
||||
*
|
||||
* - For SBAS and Beidou CNAV2, this is unused and can be set to -1.
|
||||
*
|
||||
* - For QZSS L1 C/A subframe 4 and 5, this value corresponds to the 'frame id' of the
|
||||
* navigation message, in the range of 1-25. (Subframe 1, 2, 3 does not contain a 'frame
|
||||
* id' and this value can be set to -1.)
|
||||
*
|
||||
* - For Beidou CNAV1 this refers to the page type number in the range of 1-63.
|
||||
*
|
||||
* - For IRNSS L5 C/A subframe 3 and 4, this value corresponds to the Message Id of the
|
||||
* navigation message, in the range of 1-63. (Subframe 1 and 2 does not contain a message
|
||||
* type id and this value can be set to -1.)
|
||||
*/
|
||||
int messageId;
|
||||
|
||||
/**
|
||||
* Sub-message identifier. If required by the message 'type', this value contains a
|
||||
* sub-index within the current message (or frame) that is being transmitted.
|
||||
*
|
||||
* - For GNSS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to the subframe
|
||||
* number of the navigation message, in the range of 1-5.
|
||||
*
|
||||
* - For Glonass L1 C/A, this refers to the String number, in the range from 1-15.
|
||||
*
|
||||
* - For Galileo F/NAV, this refers to the page type in the range 1-6.
|
||||
*
|
||||
* - For Galileo I/NAV, this refers to the word type in the range 0-10+. A value of 0 is
|
||||
* only allowed if the Satellite is transmiting a Spare Word.
|
||||
*
|
||||
* - For Galileo in particular, the type information embedded within the data bits may be
|
||||
* even more useful in interpretation, than the nominal page and word types provided in
|
||||
* this field.
|
||||
*
|
||||
* - For SBAS, the submessage id corresponds to the message type, in the range 1-63.
|
||||
*
|
||||
* - For Beidou CNAV1, the submessage id corresponds to the subframe number of the
|
||||
* navigation message, in the range of 1-3.
|
||||
*
|
||||
* - For Beidou CNAV2, the submessage id corresponds to the message type, in the range 1-63.
|
||||
*
|
||||
* - For IRNSS L5 C/A, the submessage id corresponds to the subframe number of the
|
||||
* navigation message, in the range of 1-4.
|
||||
*/
|
||||
int submessageId;
|
||||
|
||||
/**
|
||||
* The data of the reported GNSS message. The bytes (or words) are specified
|
||||
* using big endian format (MSB first).
|
||||
*
|
||||
* - For GNSS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
|
||||
* words. Each word (30 bits) must fit into the last 30 bits in a
|
||||
* 4-byte word (skip B31 and B32), with MSB first, for a total of 40
|
||||
* bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
|
||||
* The standard followed is 1995 SPS Signal specification.
|
||||
*
|
||||
* - For Glonass L1 C/A, each string contains 85 data bits, including the
|
||||
* checksum. These bits must fit into 11 bytes, with MSB first (skip
|
||||
* B86-B88), covering a time period of 2 seconds.
|
||||
* The standard followed is Glonass Interface Control Document Edition 5.1.
|
||||
*
|
||||
* - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols
|
||||
* excluded). Each word must fit into 30-bytes, with MSB first (skip
|
||||
* B239, B240), covering a time period of 10 seconds. The standard
|
||||
* followed is European GNSS(Galileo) Signal in Space Interface
|
||||
* Control Document Issue 1.2.
|
||||
*
|
||||
* - For Galileo I/NAV, each page contains 2 page parts, even and odd, with
|
||||
* a total of 2x114 = 228 bits, (sync & tail excluded) that must fit
|
||||
* into 29 bytes, with MSB first (skip B229-B232). The standard followed
|
||||
* is same as above.
|
||||
*
|
||||
* - For SBAS, each block consists of 250 data bits, that should be fit into 32 bytes. MSB
|
||||
* first (skip B251-B256).
|
||||
*
|
||||
* - For Beidou CNAV1, subframe #1 consists of 14 data bits, that should be fit into 2
|
||||
* bytes. MSB first (skip B15-B16). subframe #2 consists of 600 bits that should be fit
|
||||
* into 75 bytes. subframe #3 consists of 264 data bits that should be fit into 33 bytes.
|
||||
*
|
||||
* - For Beidou CNAV2, each subframe consists of 288 data bits, that should be fit into 36
|
||||
* bytes.
|
||||
*
|
||||
* The data reported here must be the raw data as demodulated by the GNSS receiver, not data
|
||||
* received from an external source (i.e. not from a server download.)
|
||||
*/
|
||||
byte[] data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback to report an available fragment of a GNSS navigation messages
|
||||
* from the HAL.
|
||||
*
|
||||
* @param message - The GNSS navigation submessage/subframe representation.
|
||||
*/
|
||||
void gnssNavigationMessageCb(in GnssNavigationMessage message);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 android.hardware.gnss;
|
||||
|
||||
import android.hardware.gnss.IGnssNavigationMessageCallback;
|
||||
|
||||
/**
|
||||
* Extended interface for GNSS navigation message reporting support.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IGnssNavigationMessageInterface {
|
||||
/**
|
||||
* Initializes the interface and registers the callback routines with the HAL.
|
||||
*
|
||||
* After a successful call to 'setCallback' the HAL must begin to provide updates as
|
||||
* they become available.
|
||||
*
|
||||
* @param callback handle to IGnssNavigationMessageCallack interface.
|
||||
*/
|
||||
void setCallback(in IGnssNavigationMessageCallback callback);
|
||||
|
||||
/**
|
||||
* Stops updates from the HAL, and unregisters the callback routines.
|
||||
*
|
||||
* After a call to close(), the previously registered callbacks must be
|
||||
* considered invalid by the HAL.
|
||||
*
|
||||
* If close() is invoked without a previous setCallback, this function must perform
|
||||
* no work.
|
||||
*/
|
||||
void close();
|
||||
}
|
||||
@@ -59,6 +59,7 @@ cc_binary {
|
||||
"GnssBatching.cpp",
|
||||
"GnssGeofence.cpp",
|
||||
"GnssHidlHal.cpp",
|
||||
"GnssNavigationMessageInterface.cpp",
|
||||
"GnssPowerIndication.cpp",
|
||||
"GnssPsds.cpp",
|
||||
"GnssConfiguration.cpp",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "GnssConfiguration.h"
|
||||
#include "GnssGeofence.h"
|
||||
#include "GnssMeasurementInterface.h"
|
||||
#include "GnssNavigationMessageInterface.h"
|
||||
#include "GnssPsds.h"
|
||||
|
||||
namespace aidl::android::hardware::gnss {
|
||||
@@ -104,4 +105,12 @@ ndk::ScopedAStatus Gnss::getExtensionGnssGeofence(std::shared_ptr<IGnssGeofence>
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Gnss::getExtensionGnssNavigationMessage(
|
||||
std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) {
|
||||
ALOGD("Gnss::getExtensionGnssNavigationMessage");
|
||||
|
||||
*iGnssNavigationMessage = SharedRefBase::make<GnssNavigationMessageInterface>();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::gnss
|
||||
|
||||
@@ -42,6 +42,8 @@ class Gnss : public BnGnss {
|
||||
std::shared_ptr<IGnssBatching>* iGnssBatching) override;
|
||||
ndk::ScopedAStatus getExtensionGnssGeofence(
|
||||
std::shared_ptr<IGnssGeofence>* iGnssGeofence) override;
|
||||
ndk::ScopedAStatus getExtensionGnssNavigationMessage(
|
||||
std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) override;
|
||||
|
||||
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
|
||||
std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
|
||||
|
||||
94
gnss/aidl/default/GnssNavigationMessageInterface.cpp
Normal file
94
gnss/aidl/default/GnssNavigationMessageInterface.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "GnssNavigationMessageAidl"
|
||||
|
||||
#include "GnssNavigationMessageInterface.h"
|
||||
#include <aidl/android/hardware/gnss/BnGnss.h>
|
||||
#include <log/log.h>
|
||||
#include "Utils.h"
|
||||
|
||||
namespace aidl::android::hardware::gnss {
|
||||
|
||||
using namespace ::android::hardware::gnss;
|
||||
using GnssNavigationMessage = IGnssNavigationMessageCallback::GnssNavigationMessage;
|
||||
using GnssNavigationMessageType = GnssNavigationMessage::GnssNavigationMessageType;
|
||||
|
||||
std::shared_ptr<IGnssNavigationMessageCallback> GnssNavigationMessageInterface::sCallback = nullptr;
|
||||
|
||||
GnssNavigationMessageInterface::GnssNavigationMessageInterface() : mMinIntervalMillis(1000) {}
|
||||
|
||||
GnssNavigationMessageInterface::~GnssNavigationMessageInterface() {
|
||||
stop();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus GnssNavigationMessageInterface::setCallback(
|
||||
const std::shared_ptr<IGnssNavigationMessageCallback>& callback) {
|
||||
ALOGD("setCallback");
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
sCallback = callback;
|
||||
start();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus GnssNavigationMessageInterface::close() {
|
||||
ALOGD("close");
|
||||
stop();
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
sCallback = nullptr;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
void GnssNavigationMessageInterface::start() {
|
||||
ALOGD("start");
|
||||
mIsActive = true;
|
||||
mThread = std::thread([this]() {
|
||||
while (mIsActive == true) {
|
||||
GnssNavigationMessage message = {
|
||||
.svid = 19,
|
||||
.type = GnssNavigationMessageType::GPS_L1CA,
|
||||
.status = GnssNavigationMessage::STATUS_PARITY_PASSED,
|
||||
.messageId = 2,
|
||||
.submessageId = 3,
|
||||
.data = std::vector<uint8_t>(40, 0xF9),
|
||||
};
|
||||
this->reportMessage(message);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMillis));
|
||||
}
|
||||
});
|
||||
mThread.detach();
|
||||
}
|
||||
|
||||
void GnssNavigationMessageInterface::stop() {
|
||||
ALOGD("stop");
|
||||
mIsActive = false;
|
||||
}
|
||||
|
||||
void GnssNavigationMessageInterface::reportMessage(const GnssNavigationMessage& message) {
|
||||
ALOGD("reportMessage()");
|
||||
std::shared_ptr<IGnssNavigationMessageCallback> callbackCopy;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
if (sCallback == nullptr) {
|
||||
ALOGE("%s: GnssNavigationMessageInterface::sCallback is null.", __func__);
|
||||
return;
|
||||
}
|
||||
callbackCopy = sCallback;
|
||||
}
|
||||
callbackCopy->gnssNavigationMessageCb(message);
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::gnss
|
||||
48
gnss/aidl/default/GnssNavigationMessageInterface.h
Normal file
48
gnss/aidl/default/GnssNavigationMessageInterface.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/android/hardware/gnss/BnGnssNavigationMessageInterface.h>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
namespace aidl::android::hardware::gnss {
|
||||
|
||||
struct GnssNavigationMessageInterface : public BnGnssNavigationMessageInterface {
|
||||
public:
|
||||
GnssNavigationMessageInterface();
|
||||
~GnssNavigationMessageInterface();
|
||||
ndk::ScopedAStatus setCallback(
|
||||
const std::shared_ptr<IGnssNavigationMessageCallback>& callback) override;
|
||||
ndk::ScopedAStatus close() override;
|
||||
|
||||
private:
|
||||
void start();
|
||||
void stop();
|
||||
void reportMessage(const IGnssNavigationMessageCallback::GnssNavigationMessage& message);
|
||||
|
||||
std::atomic<long> mMinIntervalMillis;
|
||||
std::atomic<bool> mIsActive;
|
||||
std::thread mThread;
|
||||
|
||||
// Guarded by mMutex
|
||||
static std::shared_ptr<IGnssNavigationMessageCallback> sCallback;
|
||||
// Synchronization lock for sCallback
|
||||
mutable std::mutex mMutex;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::gnss
|
||||
@@ -34,6 +34,7 @@ cc_test {
|
||||
"GnssCallbackAidl.cpp",
|
||||
"GnssGeofenceCallback.cpp",
|
||||
"GnssMeasurementCallbackAidl.cpp",
|
||||
"GnssNavigationMessageCallback.cpp",
|
||||
"GnssPowerIndicationCallback.cpp",
|
||||
"VtsHalGnssTargetTest.cpp",
|
||||
],
|
||||
|
||||
28
gnss/aidl/vts/GnssNavigationMessageCallback.cpp
Normal file
28
gnss/aidl/vts/GnssNavigationMessageCallback.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define LOG_TAG "GnssNavMsgCallback"
|
||||
|
||||
#include "GnssNavigationMessageCallback.h"
|
||||
#include <log/log.h>
|
||||
|
||||
android::binder::Status GnssNavigationMessageCallback::gnssNavigationMessageCb(
|
||||
const android::hardware::gnss::IGnssNavigationMessageCallback::GnssNavigationMessage& msg) {
|
||||
ALOGD("gnssNavigationMessageCb. svid=%d, type=%d, status=%d, msgId=%d, subMsgId=%d, "
|
||||
"data.size=%d",
|
||||
msg.svid, (int)msg.type, (int)msg.status, msg.messageId, msg.submessageId,
|
||||
(int)msg.data.size());
|
||||
return android::binder::Status::ok();
|
||||
}
|
||||
31
gnss/aidl/vts/GnssNavigationMessageCallback.h
Normal file
31
gnss/aidl/vts/GnssNavigationMessageCallback.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/gnss/BnGnssNavigationMessageCallback.h>
|
||||
|
||||
/** Implementation for IGnssNavigationMessageCallback. */
|
||||
class GnssNavigationMessageCallback
|
||||
: public android::hardware::gnss::BnGnssNavigationMessageCallback {
|
||||
public:
|
||||
GnssNavigationMessageCallback() {}
|
||||
~GnssNavigationMessageCallback() {}
|
||||
|
||||
android::binder::Status gnssNavigationMessageCb(
|
||||
const android::hardware::gnss::IGnssNavigationMessageCallback::GnssNavigationMessage&
|
||||
message) override;
|
||||
};
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "GnssBatchingCallback.h"
|
||||
#include "GnssGeofenceCallback.h"
|
||||
#include "GnssMeasurementCallbackAidl.h"
|
||||
#include "GnssNavigationMessageCallback.h"
|
||||
#include "GnssPowerIndicationCallback.h"
|
||||
#include "gnss_hal_test.h"
|
||||
|
||||
@@ -43,6 +44,7 @@ using android::hardware::gnss::IGnssGeofence;
|
||||
using android::hardware::gnss::IGnssGeofenceCallback;
|
||||
using android::hardware::gnss::IGnssMeasurementCallback;
|
||||
using android::hardware::gnss::IGnssMeasurementInterface;
|
||||
using android::hardware::gnss::IGnssNavigationMessageInterface;
|
||||
using android::hardware::gnss::IGnssPowerIndication;
|
||||
using android::hardware::gnss::IGnssPsds;
|
||||
using android::hardware::gnss::PsdsType;
|
||||
@@ -779,4 +781,15 @@ TEST_P(GnssHalTest, TestAllExtensions) {
|
||||
status = iGnssGeofence->setCallback(gnssGeofenceCallback);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
}
|
||||
|
||||
sp<IGnssNavigationMessageInterface> iGnssNavMsgIface;
|
||||
status = aidl_gnss_hal_->getExtensionGnssNavigationMessage(&iGnssNavMsgIface);
|
||||
if (status.isOk() && iGnssNavMsgIface != nullptr) {
|
||||
auto gnssNavMsgCallback = sp<GnssNavigationMessageCallback>::make();
|
||||
status = iGnssNavMsgIface->setCallback(gnssNavMsgCallback);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
|
||||
status = iGnssNavMsgIface->close();
|
||||
ASSERT_TRUE(status.isOk());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ Return<bool> GnssTemplate<T_IGnss>::setCallback_2_1(const sp<V2_1::IGnssCallback
|
||||
using Capabilities = V2_1::IGnssCallback::Capabilities;
|
||||
const auto capabilities = Capabilities::MEASUREMENTS | Capabilities::MEASUREMENT_CORRECTIONS |
|
||||
Capabilities::LOW_POWER_MODE | Capabilities::SATELLITE_BLACKLIST |
|
||||
Capabilities::ANTENNA_INFO;
|
||||
Capabilities::ANTENNA_INFO | Capabilities::NAV_MESSAGES;
|
||||
auto ret = sGnssCallback_2_1->gnssSetCapabilitiesCb_2_1(capabilities);
|
||||
if (!ret.isOk()) {
|
||||
ALOGE("%s: Unable to invoke callback", __func__);
|
||||
|
||||
Reference in New Issue
Block a user