mirror of
https://github.com/ioacademy-jikim/android_framwork.git
synced 2026-08-11 08:22:53 +00:00
12
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.samples@1.0_hal",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IFoo.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.samples@1.0_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.samples@1.0",
|
||||
srcs: [
|
||||
":android.hardware.samples@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/samples/1.0/types.cpp",
|
||||
"android/hardware/samples/1.0/FooAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.samples@1.0_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.samples@1.0",
|
||||
srcs: [
|
||||
":android.hardware.samples@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/samples/1.0/types.h",
|
||||
"android/hardware/samples/1.0/hwtypes.h",
|
||||
"android/hardware/samples/1.0/IFoo.h",
|
||||
"android/hardware/samples/1.0/IHwFoo.h",
|
||||
"android/hardware/samples/1.0/BnHwFoo.h",
|
||||
"android/hardware/samples/1.0/BpHwFoo.h",
|
||||
"android/hardware/samples/1.0/BsFoo.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.samples@1.0",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.samples@1.0_genc++"],
|
||||
generated_headers: ["android.hardware.samples@1.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.samples@1.0_genc++_headers"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
cc_binary {
|
||||
name: "android.hardware.samples@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: [
|
||||
"Foo.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libutils",
|
||||
"android.hardware.samples@1.0",
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
#include "Foo.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace samples {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
// Methods from IFoo follow.
|
||||
Return<void> Foo::foo() {
|
||||
std::cout << "Foo::foo()" <<std::endl;
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
//IFoo* HIDL_FETCH_IFoo(const char* /* name */) {
|
||||
// return new Foo();
|
||||
//}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace samples
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef ANDROID_HARDWARE_SAMPLES_V1_0_FOO_H
|
||||
#define ANDROID_HARDWARE_SAMPLES_V1_0_FOO_H
|
||||
|
||||
#include <android/hardware/samples/1.0/IFoo.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace samples {
|
||||
namespace V1_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 Foo : public IFoo {
|
||||
// Methods from IFoo follow.
|
||||
Return<void> foo() override;
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
};
|
||||
|
||||
// FIXME: most likely delete, this is only for passthrough implementations
|
||||
// extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace samples
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_SAMPLES_V1_0_FOO_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "Foo.h"
|
||||
|
||||
using android::sp;
|
||||
using android::status_t;
|
||||
using android::OK;
|
||||
|
||||
// libhwbinder:
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::samples::V1_0::IFoo;
|
||||
using android::hardware::samples::V1_0::implementation::Foo;
|
||||
|
||||
int main() {
|
||||
status_t status;
|
||||
android::sp<Foo> service = nullptr;
|
||||
|
||||
service = new Foo();
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
service->registerAsService();
|
||||
std::cout << "Foo HAL Service is ready." << std::endl;
|
||||
joinRpcThreadpool();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user