1
0
mirror of https://github.com/ioacademy-jikim/android_framwork synced 2025-06-06 15:36:30 +00:00
This commit is contained in:
ioacademy-jikim 2018-06-15 17:07:15 +09:00
parent 931b702e82
commit b313330e0f
17 changed files with 296 additions and 0 deletions

Binary file not shown.

BIN
04_day/hal/a.out Normal file

Binary file not shown.

19
04_day/hal/led.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
typedef struct module
{
void (*on)();
void (*off)();
} module_t;
void ledOn()
{
printf("ledOn()\n");
}
void ledOff()
{
printf("ledOff()\n");
}
module_t HMI = { ledOn, ledOff };

BIN
04_day/hal/led.o Normal file

Binary file not shown.

BIN
04_day/hal/libled.a Normal file

Binary file not shown.

BIN
04_day/hal/libled.so Normal file

Binary file not shown.

19
04_day/hal/main.c Normal file
View File

@ -0,0 +1,19 @@
#include <dlfcn.h>
typedef struct module
{
void (*on)();
void (*off)();
} module_t;
int main()
{
void *handle;
module_t *module;
handle = dlopen("libled.so", RTLD_NOW);
module = dlsym( handle, "HMI" );
module->on();
module->off();
dlclose(handle);
return 0;
}

7
04_day/hidl/Android.bp Normal file
View File

@ -0,0 +1,7 @@
subdirs = [
"server",
]

View File

@ -0,0 +1,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES = liblog libutils libhidlbase android.hardware.samples@1.0
LOCAL_SRC_FILES := client.cpp
LOCAL_MODULE := my_client
include $(BUILD_EXECUTABLE)

View File

@ -0,0 +1,20 @@
#include <android-base/logging.h>
#include <android/hardware/samples/1.0/IFoo.h>
#include <set>
#include <unistd.h>
#include <stdio.h>
using ::android::hardware::samples::V1_0::IFoo;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
int main()
{
sp<IFoo> foo;
foo = IFoo::getService();
foo->foo();
return 0;
}

View File

@ -0,0 +1,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES = liblog libutils libhidlbase android.hardware.light@2.0
LOCAL_SRC_FILES := light_client.cpp
LOCAL_MODULE := light_client
include $(BUILD_EXECUTABLE)

View File

@ -0,0 +1,38 @@
#include <android-base/logging.h>
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
#include <set>
#include <unistd.h>
#include <stdio.h>
using ::android::hardware::light::V2_0::Brightness;
using ::android::hardware::light::V2_0::Flash;
using ::android::hardware::light::V2_0::ILight;
using ::android::hardware::light::V2_0::LightState;
using ::android::hardware::light::V2_0::Status;
using ::android::hardware::light::V2_0::Type;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
const static LightState kWhite = {
.color = 0xFFFFFFFF,
.flashMode = Flash::TIMED,
.flashOnMs = 100,
.flashOffMs = 50,
.brightnessMode = Brightness::USER,
};
int main()
{
sp<ILight> light;
light = ILight::getService();
Return<Status> ret = light->setLight( Type::BACKLIGHT, kWhite);
//if( ret.isOk() == false )
// return -1;
//if( Status::SUCCESS == static_cast<Status>(ret) )
// return 0;
return 0;
}

View File

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

View File

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

View File

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

39
04_day/hidl/server/Foo.h Normal file
View File

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

View File

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