В целях тестирования я хочу создать интерфейс HIDL + реализацию и запустить комбинацию как системный сервис. Для этого я определил интерфейс IGuotie.hal
:
package android.hardware.guotie@2.0;
interface IGuotie {
add(int32_t i, int32_t k) generates (int32_t result);
};
Следующие файлы используются для реализации интерфейса
Гот ie .h
#pragma once
#include <android/hardware/guotie/2.0/IGuotie.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace guotie {
namespace V2_0 {
namespace implementation {
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;
using ::android::sp;
struct Guotie : public IGuotie {
// Methods from ::android::hardware::guotie::V2_0::IGuotie follow.
Return<int32_t> add(int32_t i, int32_t k) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IGuotie* getInstance(void);
};
} // namespace implementation
} // namespace V2_0
} // namespace guotie
} // namespace hardware
}
Гот ie. cpp
#include "Guotie.h"
namespace android {
namespace hardware {
namespace guotie {
namespace V2_0 {
namespace implementation {
// Methods from ::android::hardware::guotie::V2_0::IGuotie follow.
Return<int32_t> Guotie::add(int32_t i, int32_t k) {
return i + k;
}
IGuotie *Guotie::getInstance(void) {
return new Guotie();
}
} // namespace implementation
} // namespace V2_0
} // namespace guotie
} // namespace hardware
}
сервис. cpp
#define LOG_TAG "android.hardware.graphics.allocator@2.0-service"
#include <android/hardware/guotie/2.0/IGuotie.h>
#include <hidl/LegacySupport.h>
#include "Guotie.h"
using android::hardware::guotie::V2_0::IGuotie;
using android::hardware::guotie::V2_0::implementation::Guotie;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;
int main() {
int res;
android::sp<IGuotie> ser = Guotie::getInstance();
ALOGE("simp main");
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (ser != nullptr) {
res = ser->registerAsService();
if(res != 0)
ALOGE("Can't register instance of GuotieHardware, nullptr");
} else {
ALOGE("Can't create instance of GuotieHardware, nullptr");
}
joinRpcThreadpool();
return 0; // should never get here
}
android .hardware. guotie@2.0-service.rc
service guotieserver /vendor/bin/hw/android.hardware.guotie@2.0-service
class hal
user root
group root
seclabel u:r:su:s0
Android .bp
hidl_interface {
name: "android.hardware.guotie@2.0",
root: "android.hardware",
vndk: {
enabled: true,
},
srcs: [
"IGuotie.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
gen_java: true,
}
Построение приводит к появлению следующего сообщения об ошибке
FAILED: out/target/product/generic/obj/PACKAGING/vndk_intermediates/check-list-timestamp
/bin/bash -c "(( diff --old-line-format=\"Removed %L\" --new-line-format=\"Added %L\" --unchanged-line-format=\"\" build/make/target/product/gsi/29.txt out/target/product/generic/obj/PACKAGING/vndk_intermediates/libs.txt || ( echo -e \" error: VNDK library list has been changed.\\n\" \" Changing the VNDK library list is not allowed in API locked branches.\"; exit 1 )) ) && (mkdir -p out/target/product/generic/obj/PACKAGING/vndk_intermediates/ ) && (touch out/target/product/generic/obj/PACKAGING/vndk_intermediates/check-list-timestamp )"
Removed VNDK-code: android.hardware.guotie@2.0.so
Added VNDK-core: android.hardware.guotie@2.0.so
error: VNDK library list has been changed.
Changing the VNDK library list is not allowed in API locked branches.
В некоторых статьях предлагается добавить (в моем случае) android.hardware.guotie@2.0.so
к build/make/target/product/vndk/28.txt
. Однако папка vndk не существует. Вместо этого я добавил его к build/make/target/product/gsi/29.txt
и current.txt
, но сборка все равно не удалась (я добавил его в алфавитном порядке). Есть предложения?