diff --git a/gnss/2.0/Android.bp b/gnss/2.0/Android.bp index 9b6b076f1b..9b04be0053 100644 --- a/gnss/2.0/Android.bp +++ b/gnss/2.0/Android.bp @@ -19,6 +19,7 @@ hidl_interface { ], interfaces: [ "android.hardware.gnss.measurement_corrections@1.0", + "android.hardware.gnss.visibility_control@1.0", "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", "android.hidl.base@1.0", diff --git a/gnss/2.0/IGnss.hal b/gnss/2.0/IGnss.hal index e1acd6d927..1f1858e940 100644 --- a/gnss/2.0/IGnss.hal +++ b/gnss/2.0/IGnss.hal @@ -17,6 +17,7 @@ package android.hardware.gnss@2.0; import android.hardware.gnss.measurement_corrections@1.0::IMeasurementCorrections; +import android.hardware.gnss.visibility_control@1.0::IGnssVisibilityControl; import @1.1::IGnss; import IGnssCallback; @@ -25,7 +26,15 @@ import IGnssMeasurement; import IAGnss; import IAGnssRil; -/** Represents the standard GNSS (Global Navigation Satellite System) interface. */ +/** + * Represents the standard GNSS (Global Navigation Satellite System) interface. + * + * Due to the introduction of new GNSS HAL package android.hardware.gnss.visibility_control@1.0 + * the interface @1.0::IGnssNi.hal and @1.0::IGnssNiCallback.hal are deprecated in this version + * and are not supported by the framework. The GNSS HAL implementation of this interface + * must return nullptr for the following @1.0::IGnss method. + * getExtensionGnssNi() generates (IGnssNi gnssNiIface); + */ interface IGnss extends @1.1::IGnss { /** * Opens the interface and provides the callback routines to the implementation of this @@ -76,6 +85,13 @@ interface IGnss extends @1.1::IGnss { * * @return measurementCorrectionsIface Handle to the IMeasurementCorrections interface. */ - getExtensionMeasurementCorrections() + getExtensionMeasurementCorrections() generates (IMeasurementCorrections measurementCorrectionsIface); -}; + + /** + * This method returns the IGnssVisibilityControl interface. + * + * @return visibilityControlIface Handle to the IGnssVisibilityControl interface. + */ + getExtensionVisibilityControl() generates (IGnssVisibilityControl visibilityControlIface); +}; \ No newline at end of file diff --git a/gnss/2.0/default/Android.bp b/gnss/2.0/default/Android.bp index 92d5c1f898..985aa2ba88 100644 --- a/gnss/2.0/default/Android.bp +++ b/gnss/2.0/default/Android.bp @@ -26,6 +26,7 @@ cc_binary { "AGnssRil.cpp", "Gnss.cpp", "GnssMeasurement.cpp", + "GnssVisibilityControl.cpp", "service.cpp" ], shared_libs: [ @@ -35,6 +36,7 @@ cc_binary { "liblog", "android.hardware.gnss@2.0", "android.hardware.gnss.measurement_corrections@1.0", + "android.hardware.gnss.visibility_control@1.0", "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", ], diff --git a/gnss/2.0/default/Gnss.cpp b/gnss/2.0/default/Gnss.cpp index 5c752d5d04..217f0f358b 100644 --- a/gnss/2.0/default/Gnss.cpp +++ b/gnss/2.0/default/Gnss.cpp @@ -22,8 +22,10 @@ #include "AGnssRil.h" #include "GnssConfiguration.h" #include "GnssMeasurement.h" +#include "GnssVisibilityControl.h" using ::android::hardware::Status; +using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; namespace android { namespace hardware { @@ -93,8 +95,8 @@ Return> Gnss::getExtensionAGnss() { } Return> Gnss::getExtensionGnssNi() { - // TODO implement - return sp{}; + // The IGnssNi.hal interface is deprecated in 2.0. + return nullptr; } Return> Gnss::getExtensionGnssMeasurement() { @@ -205,6 +207,11 @@ Gnss::getExtensionMeasurementCorrections() { return sp{}; } +Return> Gnss::getExtensionVisibilityControl() { + ALOGD("Gnss::getExtensionVisibilityControl"); + return new GnssVisibilityControl(); +} + Return Gnss::setCallback_2_0(const sp& callback) { ALOGD("Gnss::setCallback_2_0"); if (callback == nullptr) { diff --git a/gnss/2.0/default/Gnss.h b/gnss/2.0/default/Gnss.h index e86158f09f..890b026749 100644 --- a/gnss/2.0/default/Gnss.h +++ b/gnss/2.0/default/Gnss.h @@ -79,6 +79,8 @@ struct Gnss : public IGnss { Return setCallback_2_0(const sp& callback) override; Return> getExtensionMeasurementCorrections() override; + Return> getExtensionVisibilityControl() + override; private: static sp sGnssCallback_2_0; diff --git a/gnss/2.0/default/GnssVisibilityControl.cpp b/gnss/2.0/default/GnssVisibilityControl.cpp new file mode 100644 index 0000000000..99b8e34746 --- /dev/null +++ b/gnss/2.0/default/GnssVisibilityControl.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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 + +namespace android { +namespace hardware { +namespace gnss { +namespace visibility_control { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow. +Return GnssVisibilityControl::enableNfwLocationAccess( + const hidl_vec& proxyApps) { + std::string os; + bool first = true; + for (const auto& proxyApp : proxyApps) { + if (first) { + first = false; + } else { + os += " "; + } + + os += proxyApp; + } + + ALOGD("enableNfwLocationAccess proxyApps: %s", os.c_str()); + return true; +} + +Return GnssVisibilityControl::setCallback(const sp&) { + return true; +} + +} // namespace implementation +} // namespace V1_0 +} // namespace visibility_control +} // namespace gnss +} // namespace hardware +} // namespace android diff --git a/gnss/2.0/default/GnssVisibilityControl.h b/gnss/2.0/default/GnssVisibilityControl.h new file mode 100644 index 0000000000..45febfff9e --- /dev/null +++ b/gnss/2.0/default/GnssVisibilityControl.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef ANDROID_HARDWARE_GNSS_VISIBILITY_CONTROL_V1_0_GNSSVISIBILITYCONTROL_H +#define ANDROID_HARDWARE_GNSS_VISIBILITY_CONTROL_V1_0_GNSSVISIBILITYCONTROL_H + +#include +#include +#include + +namespace android { +namespace hardware { +namespace gnss { +namespace visibility_control { +namespace V1_0 { +namespace implementation { + +using ::android::sp; +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +struct GnssVisibilityControl : public IGnssVisibilityControl { + // Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl + // follow. + Return enableNfwLocationAccess(const hidl_vec& proxyApps) override; + Return setCallback(const sp& callback) override; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace visibility_control +} // namespace gnss +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_GNSS_VISIBILITY_CONTROL_V1_0_GNSSVISIBILITYCONTROL_H \ No newline at end of file diff --git a/gnss/2.0/vts/functional/Android.bp b/gnss/2.0/vts/functional/Android.bp index 894716dc85..684b381ae2 100644 --- a/gnss/2.0/vts/functional/Android.bp +++ b/gnss/2.0/vts/functional/Android.bp @@ -24,6 +24,7 @@ cc_test { ], static_libs: [ "android.hardware.gnss.measurement_corrections@1.0", + "android.hardware.gnss.visibility_control@1.0", "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", "android.hardware.gnss@2.0", diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp index cef06a2768..552cf1b5b1 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp @@ -19,6 +19,7 @@ #include #include +using android::hardware::hidl_string; using android::hardware::hidl_vec; using IGnssConfiguration_2_0 = android::hardware::gnss::V2_0::IGnssConfiguration; @@ -30,6 +31,8 @@ using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil; using IAGnss_2_0 = android::hardware::gnss::V2_0::IAGnss; using IAGnss_1_0 = android::hardware::gnss::V1_0::IAGnss; using IAGnssCallback_2_0 = android::hardware::gnss::V2_0::IAGnssCallback; +using android::hardware::gnss::V1_0::IGnssNi; +using android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl; /* * SetupTeardownCreateCleanup: @@ -117,7 +120,7 @@ TEST_F(GnssHalTest, TestGnssConfiguration_setGpsLock_Deprecation) { * The GNSS HAL 2.0 implementation must support @2.0::IAGnssRil interface due to the deprecation * of framework network API methods needed to support the @1.0::IAGnssRil interface. * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later. + * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later */ TEST_F(GnssHalTest, TestAGnssRilExtension) { auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0(); @@ -199,7 +202,7 @@ TEST_F(GnssHalTest, TestGnssMeasurementCodeType) { * The GNSS HAL 2.0 implementation must support @2.0::IAGnss interface due to the deprecation * of framework network API methods needed to support the @1.0::IAGnss interface. * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later. + * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later */ TEST_F(GnssHalTest, TestAGnssExtension) { // Verify IAGnss 2.0 is supported. @@ -218,10 +221,45 @@ TEST_F(GnssHalTest, TestAGnssExtension) { * TestAGnssExtension_1_0_Deprecation: * Gets the @1.0::IAGnss extension and verifies that it is a nullptr. * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later. + * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later */ TEST_F(GnssHalTest, TestAGnssExtension_1_0_Deprecation) { // Verify IAGnss 1.0 is not supported. auto agnss_1_0 = gnss_hal_->getExtensionAGnss(); ASSERT_TRUE(!agnss_1_0.isOk() || ((sp)agnss_1_0) == nullptr); } + +/* + * TestGnssNiExtension_Deprecation: + * Gets the @1.0::IGnssNi extension and verifies that it is a nullptr. + * + * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later + */ +TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) { + // Verify IGnssNi 1.0 is not supported. + auto gnssNi = gnss_hal_->getExtensionGnssNi(); + ASSERT_TRUE(!gnssNi.isOk() || ((sp)gnssNi) == nullptr); +} + +/* + * TestGnssVisibilityControlExtension: + * Gets the GnssVisibilityControlExtension and verifies that it supports the + * gnss.visibility_control@1.0::IGnssVisibilityControl interface by invoking a method. + * + * The GNSS HAL 2.0 implementation must support gnss.visibility_control@1.0::IGnssVisibilityControl. + * + * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later + */ +TEST_F(GnssHalTest, TestGnssVisibilityControlExtension) { + // Verify IGnssVisibilityControl is supported. + auto gnssVisibilityControl = gnss_hal_->getExtensionVisibilityControl(); + ASSERT_TRUE(gnssVisibilityControl.isOk()); + sp iGnssVisibilityControl = gnssVisibilityControl; + ASSERT_NE(iGnssVisibilityControl, nullptr); + + // Set non-framework proxy apps. + hidl_vec proxyApps{"ims.example.com", "mdt.example.com"}; + auto result = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps); + ASSERT_TRUE(result.isOk()); + EXPECT_TRUE(result); +} diff --git a/gnss/visibility_control/1.0/Android.bp b/gnss/visibility_control/1.0/Android.bp new file mode 100644 index 0000000000..40a28c90ab --- /dev/null +++ b/gnss/visibility_control/1.0/Android.bp @@ -0,0 +1,18 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "android.hardware.gnss.visibility_control@1.0", + root: "android.hardware", + vndk: { + enabled: true, + }, + srcs: [ + "IGnssVisibilityControl.hal", + "IGnssVisibilityControlCallback.hal", + ], + interfaces: [ + "android.hidl.base@1.0", + ], + gen_java: true, +} + diff --git a/gnss/visibility_control/1.0/IGnssVisibilityControl.hal b/gnss/visibility_control/1.0/IGnssVisibilityControl.hal new file mode 100644 index 0000000000..914812723d --- /dev/null +++ b/gnss/visibility_control/1.0/IGnssVisibilityControl.hal @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2018 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@1.0; + +import 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. + */ +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. + * + * @return success True if the operation was successful. + */ + enableNfwLocationAccess(vec proxyApps) generates (bool success); + + /** + * Registers the callback for HAL implementation to use. + * + * @param callback Handle to IGnssVisibilityControlCallback interface. + */ + setCallback(IGnssVisibilityControlCallback callback) generates (bool success); +}; \ No newline at end of file diff --git a/gnss/visibility_control/1.0/IGnssVisibilityControlCallback.hal b/gnss/visibility_control/1.0/IGnssVisibilityControlCallback.hal new file mode 100644 index 0000000000..5a582c23de --- /dev/null +++ b/gnss/visibility_control/1.0/IGnssVisibilityControlCallback.hal @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2018 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@1.0; + +/** + * GNSS location reporting permissions and notification callback interface. + */ +interface IGnssVisibilityControlCallback { + /** + * Protocol stack that is requesting the non-framework location information. + */ + enum NfwProtocolStack : uint8_t { + /** 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. + */ + enum NfwRequestor : uint8_t { + /** 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. + */ + enum NfwResponseType : uint8_t { + /** 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. + */ + struct NfwNotification { + /** + * Package name of the Android proxy application representing the non-framework + * entity that requested location. Set to empty string if unknown. + */ + 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. */ + bool inEmergencyMode; + + /** Is cached location provided */ + bool 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. + */ + nfwNotifyCb(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. + */ + isInEmergencySession() generates (bool success); +}; \ No newline at end of file