Non-framework location access visibility and control (HAL)

Define IGnssVisibilityControl(Callback).hal interfaces to tell
the GNSS HAL implementation for which non-framework non-user
initiated emergency use cases, the framework user has granted
permission to the HAL implementation to provide GNSS location
information and to notify the framework user of these GNSS location
information deliveries.

Bug: 119560261
Test: Partial testing with cuttlefish
Change-Id: Ife704eb9fa4e6113196729b002bc9dc08bb47bc3
This commit is contained in:
Anil Admal 2018-11-14 12:38:57 -08:00
parent 9bed22a4b5
commit 4d739e7201
12 changed files with 446 additions and 8 deletions

View file

@ -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",

View file

@ -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);
};

View file

@ -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",
],

View file

@ -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<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss() {
}
Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi() {
// TODO implement
return sp<V1_0::IGnssNi>{};
// The IGnssNi.hal interface is deprecated in 2.0.
return nullptr;
}
Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
@ -205,6 +207,11 @@ Gnss::getExtensionMeasurementCorrections() {
return sp<measurement_corrections::V1_0::IMeasurementCorrections>{};
}
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> Gnss::getExtensionVisibilityControl() {
ALOGD("Gnss::getExtensionVisibilityControl");
return new GnssVisibilityControl();
}
Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
ALOGD("Gnss::setCallback_2_0");
if (callback == nullptr) {

View file

@ -79,6 +79,8 @@ struct Gnss : public IGnss {
Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
getExtensionMeasurementCorrections() override;
Return<sp<visibility_control::V1_0::IGnssVisibilityControl>> getExtensionVisibilityControl()
override;
private:
static sp<V2_0::IGnssCallback> sGnssCallback_2_0;

View file

@ -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 <log/log.h>
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<bool> GnssVisibilityControl::enableNfwLocationAccess(
const hidl_vec<hidl_string>& 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<bool> GnssVisibilityControl::setCallback(const sp<V1_0::IGnssVisibilityControlCallback>&) {
return true;
}
} // namespace implementation
} // namespace V1_0
} // namespace visibility_control
} // namespace gnss
} // namespace hardware
} // namespace android

View file

@ -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 <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
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<bool> enableNfwLocationAccess(const hidl_vec<hidl_string>& proxyApps) override;
Return<bool> setCallback(const sp<V1_0::IGnssVisibilityControlCallback>& 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

View file

@ -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",

View file

@ -19,6 +19,7 @@
#include <VtsHalHidlTargetTestBase.h>
#include <gnss_hal_test.h>
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<IAGnss_1_0>)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<IGnssNi>)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> iGnssVisibilityControl = gnssVisibilityControl;
ASSERT_NE(iGnssVisibilityControl, nullptr);
// Set non-framework proxy apps.
hidl_vec<hidl_string> proxyApps{"ims.example.com", "mdt.example.com"};
auto result = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps);
ASSERT_TRUE(result.isOk());
EXPECT_TRUE(result);
}

View file

@ -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,
}

View file

@ -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<string> proxyApps) generates (bool success);
/**
* Registers the callback for HAL implementation to use.
*
* @param callback Handle to IGnssVisibilityControlCallback interface.
*/
setCallback(IGnssVisibilityControlCallback callback) generates (bool success);
};

View file

@ -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);
};