For test purposes I want to create a HIDL interface + implementation and run the combination as a system service. For that I defined the IGuotie.hal
interface:
package [email protected];
interface IGuotie {
add(int32_t i, int32_t k) generates (int32_t result);
};
The following files are used to implement the interface
Guotie.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
}
Guotie.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
}
service.cpp
#define LOG_TAG "[email protected]"
#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
}
service guotieserver /vendor/bin/hw/[email protected]
class hal
user root
group root
seclabel u:r:su:s0
Android.bp
hidl_interface {
name: "[email protected]",
root: "android.hardware",
vndk: {
enabled: true,
},
srcs: [
"IGuotie.hal",
],
interfaces: [
"[email protected]",
],
gen_java: true,
}
Building results in following error message
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: [email protected]
Added VNDK-core: [email protected]
error: VNDK library list has been changed.
Changing the VNDK library list is not allowed in API locked branches.
Some articles suggested to add (in my case) [email protected]
to build/make/target/product/vndk/28.txt
. However, the vndk folder does not exist. Instead I added it to build/make/target/product/gsi/29.txt
and current.txt
but the build still fails (I added it in alphabetical order). Any suggestions?
I solved this build error when I was trying to make Khadas vim3 Android P.
Firstly please check if out/target/product/product_name/obj/PACKAGING/vndk_intermediates/libs.txt is same with build\make\target\product\vndk\28.txt and \current.txt.
Secondly please run make update-api.
This works for me and hope my sharing could help you.
You can see more detail and my console screenshot on my GitHub :)