mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
Merge "Add GnssVisibilityControl AIDL HAL (hardware/interfaces)"
This commit is contained in:
@@ -252,6 +252,14 @@
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.gnss.visibility_control</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IGnssVisibilityControl</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="false">
|
||||
<name>android.hardware.graphics.allocator</name>
|
||||
<!-- New, non-Go devices should use 4.0, tested in vts_treble_vintf_vendor_test -->
|
||||
|
||||
@@ -23,10 +23,28 @@ package {
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
aidl_interface {
|
||||
name: "android.hardware.gnss.visibility_control",
|
||||
vendor_available: true,
|
||||
srcs: ["android/hardware/gnss/visibility_control/*.aidl"],
|
||||
stability: "vintf",
|
||||
backend: {
|
||||
java: {
|
||||
platform_apis: true,
|
||||
},
|
||||
ndk: {
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
aidl_interface {
|
||||
name: "android.hardware.gnss",
|
||||
vendor_available: true,
|
||||
srcs: ["android/hardware/gnss/*.aidl"],
|
||||
imports: ["android.hardware.gnss.visibility_control"],
|
||||
stability: "vintf",
|
||||
backend: {
|
||||
java: {
|
||||
|
||||
@@ -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.visibility_control;
|
||||
@VintfStability
|
||||
interface IGnssVisibilityControl {
|
||||
void enableNfwLocationAccess(in String[] proxyApps);
|
||||
void setCallback(in android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.visibility_control;
|
||||
@VintfStability
|
||||
interface IGnssVisibilityControlCallback {
|
||||
void nfwNotifyCb(in android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback.NfwNotification notification);
|
||||
boolean isInEmergencySession();
|
||||
@Backing(type="int") @VintfStability
|
||||
enum NfwProtocolStack {
|
||||
CTRL_PLANE = 0,
|
||||
SUPL = 1,
|
||||
IMS = 10,
|
||||
SIM = 11,
|
||||
OTHER_PROTOCOL_STACK = 100,
|
||||
}
|
||||
@Backing(type="int") @VintfStability
|
||||
enum NfwRequestor {
|
||||
CARRIER = 0,
|
||||
OEM = 10,
|
||||
MODEM_CHIPSET_VENDOR = 11,
|
||||
GNSS_CHIPSET_VENDOR = 12,
|
||||
OTHER_CHIPSET_VENDOR = 13,
|
||||
AUTOMOBILE_CLIENT = 20,
|
||||
OTHER_REQUESTOR = 100,
|
||||
}
|
||||
@Backing(type="int") @VintfStability
|
||||
enum NfwResponseType {
|
||||
REJECTED = 0,
|
||||
ACCEPTED_NO_LOCATION_PROVIDED = 1,
|
||||
ACCEPTED_LOCATION_PROVIDED = 2,
|
||||
}
|
||||
@VintfStability
|
||||
parcelable NfwNotification {
|
||||
String proxyAppPackageName;
|
||||
android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback.NfwProtocolStack protocolStack;
|
||||
String otherProtocolStackName;
|
||||
android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback.NfwRequestor requestor;
|
||||
String requestorId;
|
||||
android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback.NfwResponseType responseType;
|
||||
boolean inEmergencyMode;
|
||||
boolean isCachedLocation;
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ interface IGnss {
|
||||
@nullable android.hardware.gnss.IGnssNavigationMessageInterface getExtensionGnssNavigationMessage();
|
||||
android.hardware.gnss.IAGnss getExtensionAGnss();
|
||||
android.hardware.gnss.IGnssDebug getExtensionGnssDebug();
|
||||
android.hardware.gnss.visibility_control.IGnssVisibilityControl getExtensionGnssVisibilityControl();
|
||||
const int ERROR_INVALID_ARGUMENT = 1;
|
||||
const int ERROR_ALREADY_INIT = 2;
|
||||
const int ERROR_GENERIC = 3;
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.hardware.gnss.IGnssMeasurementInterface;
|
||||
import android.hardware.gnss.IGnssNavigationMessageInterface;
|
||||
import android.hardware.gnss.IGnssPowerIndication;
|
||||
import android.hardware.gnss.IGnssPsds;
|
||||
import android.hardware.gnss.visibility_control.IGnssVisibilityControl;
|
||||
|
||||
/**
|
||||
* Represents the standard GNSS (Global Navigation Satellite System) interface.
|
||||
@@ -144,4 +145,11 @@ interface IGnss {
|
||||
* @return Handle to the IGnssDebug interface.
|
||||
*/
|
||||
IGnssDebug getExtensionGnssDebug();
|
||||
|
||||
/**
|
||||
* This method returns the IGnssVisibilityControl.
|
||||
*
|
||||
* @return Handle to the IGnssVisibilityControl.
|
||||
*/
|
||||
IGnssVisibilityControl getExtensionGnssVisibilityControl();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.visibility_control;
|
||||
|
||||
import android.hardware.gnss.visibility_control.IGnssVisibilityControlCallback;
|
||||
|
||||
/**
|
||||
* Represents the GNSS location reporting permissions and notification interface.
|
||||
*
|
||||
* This interface is used to tell the GNSS HAL implementation whether the framework user has
|
||||
* granted permission to the GNSS HAL implementation to provide GNSS location information for
|
||||
* non-framework (NFW), non-user initiated emergency use cases, and to notify the framework user
|
||||
* of these GNSS location information deliveries.
|
||||
*
|
||||
* For user initiated emergency cases (and for the configured extended emergency session duration),
|
||||
* the GNSS HAL implementation must serve the emergency location supporting network initiated
|
||||
* location requests immediately irrespective of this permission settings.
|
||||
*
|
||||
* There is no separate need for the GNSS HAL implementation to monitor the global device location
|
||||
* on/off setting. Permission to use GNSS for non-framework use cases is expressly controlled
|
||||
* by the method enableNfwLocationAccess(). The framework monitors the location permission settings
|
||||
* of the configured proxy applications(s), and device location settings, and calls the method
|
||||
* enableNfwLocationAccess() whenever the user control proxy applications have, or do not have,
|
||||
* location permission. The proxy applications are used to provide user visibility and control of
|
||||
* location access by the non-framework on/off device entities they are representing.
|
||||
*
|
||||
* For device user visibility, the GNSS HAL implementation must call the method
|
||||
* IGnssVisibilityControlCallback.nfwNotifyCb() whenever location request is rejected or
|
||||
* location information is provided to non-framework entities (on or off device). This includes
|
||||
* the network initiated location requests for user-initiated emergency use cases as well.
|
||||
*
|
||||
* The HAL implementations that support this interface must not report GNSS location, measurement,
|
||||
* status, or other information that can be used to derive user location to any entity when not
|
||||
* expressly authorized by this HAL. This includes all endpoints for location information
|
||||
* off the device, including carriers, vendors, OEM and others directly or indirectly.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IGnssVisibilityControl {
|
||||
/**
|
||||
* Enables/disables non-framework entity location access permission in the GNSS HAL.
|
||||
*
|
||||
* The framework will call this method to update GNSS HAL implementation every time the
|
||||
* framework user, through the given proxy application(s) and/or device location settings,
|
||||
* explicitly grants/revokes the location access permission for non-framework, non-user
|
||||
* initiated emergency use cases.
|
||||
*
|
||||
* Whenever the user location information is delivered to non-framework entities, the HAL
|
||||
* implementation must call the method IGnssVisibilityControlCallback.nfwNotifyCb() to notify
|
||||
* the framework for user visibility.
|
||||
*
|
||||
* @param proxyApps Full list of package names of proxy Android applications representing
|
||||
* the non-framework location access entities (on/off the device) for which the framework
|
||||
* user has granted non-framework location access permission. The GNSS HAL implementation
|
||||
* must provide location information only to non-framework entities represented by these
|
||||
* proxy applications.
|
||||
*
|
||||
* The package name of the proxy Android application follows the standard Java language
|
||||
* package naming format. For example, com.example.myapp.
|
||||
*/
|
||||
void enableNfwLocationAccess(in String[] proxyApps);
|
||||
|
||||
/**
|
||||
* Registers the callback for HAL implementation to use.
|
||||
*
|
||||
* @param callback Handle to IGnssVisibilityControlCallback interface.
|
||||
*/
|
||||
void setCallback(in IGnssVisibilityControlCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.visibility_control;
|
||||
|
||||
/**
|
||||
* GNSS location reporting permissions and notification callback interface.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IGnssVisibilityControlCallback {
|
||||
/**
|
||||
* Protocol stack that is requesting the non-framework location information.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum NfwProtocolStack {
|
||||
/** Cellular control plane requests */
|
||||
CTRL_PLANE = 0,
|
||||
|
||||
/** All types of SUPL requests */
|
||||
SUPL = 1,
|
||||
|
||||
/** All types of requests from IMS */
|
||||
IMS = 10,
|
||||
|
||||
/** All types of requests from SIM */
|
||||
SIM = 11,
|
||||
|
||||
/** Requests from other protocol stacks */
|
||||
OTHER_PROTOCOL_STACK = 100
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity that is requesting/receiving the location information.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum NfwRequestor {
|
||||
/** Wireless service provider */
|
||||
CARRIER = 0,
|
||||
|
||||
/** Device manufacturer */
|
||||
OEM = 10,
|
||||
|
||||
/** Modem chipset vendor */
|
||||
MODEM_CHIPSET_VENDOR = 11,
|
||||
|
||||
/** GNSS chipset vendor */
|
||||
GNSS_CHIPSET_VENDOR = 12,
|
||||
|
||||
/** Other chipset vendor */
|
||||
OTHER_CHIPSET_VENDOR = 13,
|
||||
|
||||
/** Automobile client */
|
||||
AUTOMOBILE_CLIENT = 20,
|
||||
|
||||
/** Other sources */
|
||||
OTHER_REQUESTOR = 100
|
||||
}
|
||||
|
||||
/**
|
||||
* GNSS response type for non-framework location requests.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum NfwResponseType {
|
||||
/** Request rejected because framework has not given permission for this use case */
|
||||
REJECTED = 0,
|
||||
|
||||
/** Request accepted but could not provide location because of a failure */
|
||||
ACCEPTED_NO_LOCATION_PROVIDED = 1,
|
||||
|
||||
/** Request accepted and location provided */
|
||||
ACCEPTED_LOCATION_PROVIDED = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a non-framework location information request/response notification.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable NfwNotification {
|
||||
/**
|
||||
* Package name of the Android proxy application representing the non-framework
|
||||
* entity that requested location. Set to empty string if unknown.
|
||||
*
|
||||
* For user-initiated emergency use cases, this field must be set to empty string
|
||||
* and the inEmergencyMode field must be set to true.
|
||||
*/
|
||||
String proxyAppPackageName;
|
||||
|
||||
/** Protocol stack that initiated the non-framework location request. */
|
||||
NfwProtocolStack protocolStack;
|
||||
|
||||
/**
|
||||
* Name of the protocol stack if protocolStack field is set to OTHER_PROTOCOL_STACK.
|
||||
* Otherwise, set to empty string.
|
||||
*
|
||||
* This field is opaque to the framework and used for logging purposes.
|
||||
*/
|
||||
String otherProtocolStackName;
|
||||
|
||||
/** Source initiating/receiving the location information. */
|
||||
NfwRequestor requestor;
|
||||
|
||||
/**
|
||||
* Identity of the endpoint receiving the location information. For example, carrier
|
||||
* name, OEM name, SUPL SLP/E-SLP FQDN, chipset vendor name, etc.
|
||||
*
|
||||
* This field is opaque to the framework and used for logging purposes.
|
||||
*/
|
||||
String requestorId;
|
||||
|
||||
/** Indicates whether location information was provided for this request. */
|
||||
NfwResponseType responseType;
|
||||
|
||||
/** Is the device in user initiated emergency session. */
|
||||
boolean inEmergencyMode;
|
||||
|
||||
/** Is cached location provided */
|
||||
boolean isCachedLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to report a non-framework delivered location.
|
||||
*
|
||||
* The GNSS HAL implementation must call this method to notify the framework whenever
|
||||
* a non-framework location request is made to the GNSS HAL.
|
||||
*
|
||||
* Non-framework entities like low power sensor hubs that request location from GNSS and
|
||||
* only pass location information through Android framework controls are exempt from this
|
||||
* power-spending reporting. However, low power sensor hubs or other chipsets which may send
|
||||
* the location information to anywhere other than Android framework (which provides user
|
||||
* visibility and control), must report location information use through this API whenever
|
||||
* location information (or events driven by that location such as "home" location detection)
|
||||
* leaves the domain of that low power chipset.
|
||||
*
|
||||
* To avoid overly spamming the framework, high speed location reporting of the exact same
|
||||
* type may be throttled to report location at a lower rate than the actual report rate, as
|
||||
* long as the location is reported with a latency of no more than the larger of 5 seconds,
|
||||
* or the next the Android processor awake time. For example, if an Automotive client is
|
||||
* getting location information from the GNSS location system at 20Hz, this method may be
|
||||
* called at 1Hz. As another example, if a low power processor is getting location from the
|
||||
* GNSS chipset, and the Android processor is asleep, the notification to the Android HAL may
|
||||
* be delayed until the next wake of the Android processor.
|
||||
*
|
||||
* @param notification Non-framework delivered location request/response description.
|
||||
*/
|
||||
void nfwNotifyCb(in NfwNotification notification);
|
||||
|
||||
/**
|
||||
* Tells if the device is currently in an emergency session.
|
||||
*
|
||||
* Emergency session is defined as the device being actively in a user initiated emergency
|
||||
* call or in post emergency call extension time period.
|
||||
*
|
||||
* If the GNSS HAL implementation cannot determine if the device is in emergency session
|
||||
* mode, it must call this method to confirm that the device is in emergency session before
|
||||
* serving network initiated emergency SUPL and Control Plane location requests.
|
||||
*
|
||||
* @return success True if the framework determines that the device is in emergency session.
|
||||
*/
|
||||
boolean isInEmergencySession();
|
||||
}
|
||||
@@ -52,6 +52,7 @@ cc_binary {
|
||||
"android.hardware.gnss.measurement_corrections@1.1",
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
"android.hardware.gnss.visibility_control@1.0",
|
||||
"android.hardware.gnss.visibility_control-V1-ndk",
|
||||
"android.hardware.gnss-V2-ndk",
|
||||
],
|
||||
srcs: [
|
||||
@@ -66,6 +67,7 @@ cc_binary {
|
||||
"GnssPsds.cpp",
|
||||
"GnssConfiguration.cpp",
|
||||
"GnssMeasurementInterface.cpp",
|
||||
"GnssVisibilityControl.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "GnssMeasurementInterface.h"
|
||||
#include "GnssNavigationMessageInterface.h"
|
||||
#include "GnssPsds.h"
|
||||
#include "GnssVisibilityControl.h"
|
||||
|
||||
namespace aidl::android::hardware::gnss {
|
||||
|
||||
@@ -128,4 +129,12 @@ ndk::ScopedAStatus Gnss::getExtensionGnssDebug(std::shared_ptr<IGnssDebug>* iGns
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Gnss::getExtensionGnssVisibilityControl(
|
||||
std::shared_ptr<visibility_control::IGnssVisibilityControl>* iGnssVisibilityControl) {
|
||||
ALOGD("Gnss::getExtensionGnssVisibilityControl");
|
||||
|
||||
*iGnssVisibilityControl = SharedRefBase::make<visibility_control::GnssVisibilityControl>();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::gnss
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
|
||||
#include <aidl/android/hardware/gnss/BnGnssPowerIndication.h>
|
||||
#include <aidl/android/hardware/gnss/BnGnssPsds.h>
|
||||
#include <aidl/android/hardware/gnss/visibility_control/BnGnssVisibilityControl.h>
|
||||
#include "GnssConfiguration.h"
|
||||
#include "GnssPowerIndication.h"
|
||||
|
||||
@@ -48,6 +49,9 @@ class Gnss : public BnGnss {
|
||||
std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) override;
|
||||
ndk::ScopedAStatus getExtensionAGnss(std::shared_ptr<IAGnss>* iAGnss) override;
|
||||
ndk::ScopedAStatus getExtensionGnssDebug(std::shared_ptr<IGnssDebug>* iGnssDebug) override;
|
||||
ndk::ScopedAStatus getExtensionGnssVisibilityControl(
|
||||
std::shared_ptr<android::hardware::gnss::visibility_control::IGnssVisibilityControl>*
|
||||
iGnssVisibilityControl) override;
|
||||
|
||||
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
|
||||
std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
|
||||
|
||||
51
gnss/aidl/default/GnssVisibilityControl.cpp
Normal file
51
gnss/aidl/default/GnssVisibilityControl.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 "GnssVisibilityControl"
|
||||
|
||||
#include "GnssVisibilityControl.h"
|
||||
#include <log/log.h>
|
||||
|
||||
namespace aidl::android::hardware::gnss::visibility_control {
|
||||
|
||||
std::shared_ptr<IGnssVisibilityControlCallback> GnssVisibilityControl::sCallback = nullptr;
|
||||
|
||||
ndk::ScopedAStatus GnssVisibilityControl::enableNfwLocationAccess(
|
||||
const std::vector<std::string>& proxyApps) {
|
||||
std::string os;
|
||||
bool first = true;
|
||||
for (const auto& proxyApp : proxyApps) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
os += " ";
|
||||
}
|
||||
os += proxyApp;
|
||||
}
|
||||
|
||||
ALOGD("GnssVisibilityControl::enableNfwLocationAccess proxyApps: %s", os.c_str());
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus GnssVisibilityControl::setCallback(
|
||||
const std::shared_ptr<IGnssVisibilityControlCallback>& callback) {
|
||||
ALOGD("GnssVisibilityControl::setCallback");
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
sCallback = callback;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::gnss::visibility_control
|
||||
36
gnss/aidl/default/GnssVisibilityControl.h
Normal file
36
gnss/aidl/default/GnssVisibilityControl.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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/visibility_control/BnGnssVisibilityControl.h>
|
||||
|
||||
namespace aidl::android::hardware::gnss::visibility_control {
|
||||
|
||||
struct GnssVisibilityControl : public BnGnssVisibilityControl {
|
||||
public:
|
||||
ndk::ScopedAStatus enableNfwLocationAccess(const std::vector<std::string>& hostname) override;
|
||||
ndk::ScopedAStatus setCallback(
|
||||
const std::shared_ptr<IGnssVisibilityControlCallback>& callback) override;
|
||||
|
||||
private:
|
||||
// Synchronization lock for sCallback
|
||||
mutable std::mutex mMutex;
|
||||
// Guarded by mMutex
|
||||
static std::shared_ptr<IGnssVisibilityControlCallback> sCallback;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::gnss::visibility_control
|
||||
@@ -37,6 +37,7 @@ cc_test {
|
||||
"GnssMeasurementCallbackAidl.cpp",
|
||||
"GnssNavigationMessageCallback.cpp",
|
||||
"GnssPowerIndicationCallback.cpp",
|
||||
"GnssVisibilityControlCallback.cpp",
|
||||
"VtsHalGnssTargetTest.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
@@ -49,6 +50,7 @@ cc_test {
|
||||
static_libs: [
|
||||
"android.hardware.gnss-V2-cpp",
|
||||
"android.hardware.gnss@common-vts-lib",
|
||||
"android.hardware.gnss.visibility_control-V1-cpp",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
|
||||
28
gnss/aidl/vts/GnssVisibilityControlCallback.cpp
Normal file
28
gnss/aidl/vts/GnssVisibilityControlCallback.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.
|
||||
*/
|
||||
|
||||
#include "GnssVisibilityControlCallback.h"
|
||||
#include <log/log.h>
|
||||
|
||||
android::binder::Status GnssVisibilityControlCallback::nfwNotifyCb(const NfwNotification&) {
|
||||
// To implement
|
||||
return android::binder::Status::ok();
|
||||
}
|
||||
|
||||
android::binder::Status GnssVisibilityControlCallback::isInEmergencySession(bool*) {
|
||||
// To implement
|
||||
return android::binder::Status::ok();
|
||||
}
|
||||
30
gnss/aidl/vts/GnssVisibilityControlCallback.h
Normal file
30
gnss/aidl/vts/GnssVisibilityControlCallback.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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/visibility_control/BnGnssVisibilityControlCallback.h>
|
||||
|
||||
class GnssVisibilityControlCallback
|
||||
: public android::hardware::gnss::visibility_control::BnGnssVisibilityControlCallback {
|
||||
public:
|
||||
GnssVisibilityControlCallback(){};
|
||||
~GnssVisibilityControlCallback(){};
|
||||
android::binder::Status nfwNotifyCb(
|
||||
const android::hardware::gnss::visibility_control::IGnssVisibilityControlCallback::
|
||||
NfwNotification& notification) override;
|
||||
android::binder::Status isInEmergencySession(bool* _aidl_return) override;
|
||||
};
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <android/hardware/gnss/IGnssMeasurementInterface.h>
|
||||
#include <android/hardware/gnss/IGnssPowerIndication.h>
|
||||
#include <android/hardware/gnss/IGnssPsds.h>
|
||||
#include <android/hardware/gnss/visibility_control/IGnssVisibilityControl.h>
|
||||
#include <cutils/properties.h>
|
||||
#include "AGnssCallbackAidl.h"
|
||||
#include "GnssBatchingCallback.h"
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "GnssMeasurementCallbackAidl.h"
|
||||
#include "GnssNavigationMessageCallback.h"
|
||||
#include "GnssPowerIndicationCallback.h"
|
||||
#include "GnssVisibilityControlCallback.h"
|
||||
#include "gnss_hal_test.h"
|
||||
|
||||
using android::sp;
|
||||
@@ -55,6 +57,7 @@ using android::hardware::gnss::IGnssPowerIndication;
|
||||
using android::hardware::gnss::IGnssPsds;
|
||||
using android::hardware::gnss::PsdsType;
|
||||
using android::hardware::gnss::SatellitePvt;
|
||||
using android::hardware::gnss::visibility_control::IGnssVisibilityControl;
|
||||
|
||||
using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
|
||||
|
||||
@@ -876,3 +879,27 @@ TEST_P(GnssHalTest, GnssDebugValuesSanityTest) {
|
||||
data.time.frequencyUncertaintyNsPerSec <= 2.0e5); // 200 ppm
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TestAGnssExtension:
|
||||
* TestGnssVisibilityControlExtension:
|
||||
* 1. Gets the IGnssVisibilityControl extension.
|
||||
* 2. Sets GnssVisibilityControlCallback
|
||||
* 3. Sets proxy apps
|
||||
*/
|
||||
TEST_P(GnssHalTest, TestGnssVisibilityControlExtension) {
|
||||
if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
|
||||
return;
|
||||
}
|
||||
sp<IGnssVisibilityControl> iGnssVisibilityControl;
|
||||
auto status = aidl_gnss_hal_->getExtensionGnssVisibilityControl(&iGnssVisibilityControl);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
ASSERT_TRUE(iGnssVisibilityControl != nullptr);
|
||||
auto gnssVisibilityControlCallback = sp<GnssVisibilityControlCallback>::make();
|
||||
status = iGnssVisibilityControl->setCallback(gnssVisibilityControlCallback);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
|
||||
std::vector<String16> proxyApps{String16("com.example.ims"), String16("com.example.mdt")};
|
||||
status = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user