summaryrefslogtreecommitdiff
path: root/neuralnetworks
diff options
context:
space:
mode:
authorMichael Butler <butlermichael@google.com>2022-02-11 17:53:49 -0800
committerMichael Butler <butlermichael@google.com>2022-02-14 19:21:38 -0800
commit73e470235d6430ee6eeadc43014e535e288e2a5a (patch)
tree9234181e6f11807ffb8c7448602b0db8d0ac6fbd /neuralnetworks
parent6f497d1833dca4412a9f75846ad0ab318e92a565 (diff)
Remove isUpdatable query from NNAPI -- hal
The NNAPI originally planned to have updated platform drivers delivered through GMSCore. These updatable drivers would be retrieved through the NN sAIDL utility code, and were known to be updatable through Manager.cpp's Device::isUpdatable query. However, the NNAPI ultimately did not move forward with its updatability plans. This CL removes the updatability check in the NN AIDL utility code. Bug: N/A Test: mma Test: CtsNNAPITestCases Test: NeuralNetworksTest_static Change-Id: I6f9c1eac3af8cb54565bfaaeab7ddd382a85e3bd
Diffstat (limited to 'neuralnetworks')
-rw-r--r--neuralnetworks/utils/service/include/nnapi/hal/Service.h9
-rw-r--r--neuralnetworks/utils/service/src/Service.cpp26
2 files changed, 9 insertions, 26 deletions
diff --git a/neuralnetworks/utils/service/include/nnapi/hal/Service.h b/neuralnetworks/utils/service/include/nnapi/hal/Service.h
index e8b9c10d77..38d2a54a95 100644
--- a/neuralnetworks/utils/service/include/nnapi/hal/Service.h
+++ b/neuralnetworks/utils/service/include/nnapi/hal/Service.h
@@ -24,23 +24,16 @@
namespace android::hardware::neuralnetworks::service {
-struct SharedDeviceAndUpdatability {
- nn::SharedDevice device;
- bool isDeviceUpdatable = false;
-};
-
/**
* @brief Get the NNAPI sAIDL and HIDL services declared in the VINTF.
*
* @pre maxFeatureLevelAllowed >= Version::Level::FEATURE_LEVEL_5
*
- * @param includeUpdatableDrivers Allow updatable drivers to be used.
* @param maxFeatureLevelAllowed Maximum version of driver allowed to be used. Any driver version
* exceeding this must be clamped to `maxFeatureLevelAllowed`.
* @return A list of devices and whether each device is updatable or not.
*/
-std::vector<SharedDeviceAndUpdatability> getDevices(bool includeUpdatableDrivers,
- nn::Version::Level maxFeatureLevelAllowed);
+std::vector<nn::SharedDevice> getDevices(nn::Version::Level maxFeatureLevelAllowed);
} // namespace android::hardware::neuralnetworks::service
diff --git a/neuralnetworks/utils/service/src/Service.cpp b/neuralnetworks/utils/service/src/Service.cpp
index e0d5f8240c..dd37dae526 100644
--- a/neuralnetworks/utils/service/src/Service.cpp
+++ b/neuralnetworks/utils/service/src/Service.cpp
@@ -51,7 +51,7 @@ namespace aidl_hal = ::aidl::android::hardware::neuralnetworks;
using getDeviceFn = std::add_pointer_t<nn::GeneralResult<nn::SharedDevice>(const std::string&)>;
void getHidlDevicesForVersion(const std::string& descriptor, getDeviceFn getDevice,
- std::vector<SharedDeviceAndUpdatability>* devices,
+ std::vector<nn::SharedDevice>* devices,
std::unordered_set<std::string>* registeredDevices) {
CHECK(devices != nullptr);
CHECK(registeredDevices != nullptr);
@@ -63,7 +63,7 @@ void getHidlDevicesForVersion(const std::string& descriptor, getDeviceFn getDevi
if (maybeDevice.has_value()) {
auto device = std::move(maybeDevice).value();
CHECK(device != nullptr);
- devices->push_back({.device = std::move(device)});
+ devices->push_back(std::move(device));
} else {
LOG(ERROR) << "getDevice(" << name << ") failed with " << maybeDevice.error().code
<< ": " << maybeDevice.error().message;
@@ -72,9 +72,9 @@ void getHidlDevicesForVersion(const std::string& descriptor, getDeviceFn getDevi
}
}
-void getAidlDevices(std::vector<SharedDeviceAndUpdatability>* devices,
+void getAidlDevices(std::vector<nn::SharedDevice>* devices,
std::unordered_set<std::string>* registeredDevices,
- bool includeUpdatableDrivers, nn::Version::Level maxFeatureLevelAllowed) {
+ nn::Version::Level maxFeatureLevelAllowed) {
CHECK(devices != nullptr);
CHECK(registeredDevices != nullptr);
@@ -91,21 +91,12 @@ void getAidlDevices(std::vector<SharedDeviceAndUpdatability>* devices,
}
for (const auto& name : names) {
- bool isDeviceUpdatable = false;
- if (__builtin_available(android __NNAPI_AIDL_MIN_ANDROID_API__, *)) {
- const auto instance = std::string(aidl_hal::IDevice::descriptor) + '/' + name;
- isDeviceUpdatable = AServiceManager_isUpdatableViaApex(instance.c_str());
- }
- if (isDeviceUpdatable && !includeUpdatableDrivers) {
- continue;
- }
if (const auto [it, unregistered] = registeredDevices->insert(name); unregistered) {
auto maybeDevice = aidl_hal::utils::getDevice(name, maxFeatureLevelAllowed);
if (maybeDevice.has_value()) {
auto device = std::move(maybeDevice).value();
CHECK(device != nullptr);
- devices->push_back(
- {.device = std::move(device), .isDeviceUpdatable = isDeviceUpdatable});
+ devices->push_back(std::move(device));
} else {
LOG(ERROR) << "getDevice(" << name << ") failed with " << maybeDevice.error().code
<< ": " << maybeDevice.error().message;
@@ -116,14 +107,13 @@ void getAidlDevices(std::vector<SharedDeviceAndUpdatability>* devices,
} // namespace
-std::vector<SharedDeviceAndUpdatability> getDevices(bool includeUpdatableDrivers,
- nn::Version::Level maxFeatureLevelAllowed) {
- std::vector<SharedDeviceAndUpdatability> devices;
+std::vector<nn::SharedDevice> getDevices(nn::Version::Level maxFeatureLevelAllowed) {
+ std::vector<nn::SharedDevice> devices;
std::unordered_set<std::string> registeredDevices;
CHECK_GE(maxFeatureLevelAllowed, nn::Version::Level::FEATURE_LEVEL_5);
- getAidlDevices(&devices, &registeredDevices, includeUpdatableDrivers, maxFeatureLevelAllowed);
+ getAidlDevices(&devices, &registeredDevices, maxFeatureLevelAllowed);
getHidlDevicesForVersion(V1_3::IDevice::descriptor, &V1_3::utils::getDevice, &devices,
&registeredDevices);