forked from donjohanliebert/hardware_xiaomi
aidl: light: Initial stub service
* Made with aidl-gen Change-Id: I517ddd2222cb937c02298d0972b8abf0ffc24fd6
This commit is contained in:
parent
8fb3a9d722
commit
5b0631944d
22
aidl/light/Android.bp
Normal file
22
aidl/light/Android.bp
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright (C) 2021 The LineageOS Project
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.light-service",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.light-service.rc"],
|
||||
vintf_fragments: ["android.hardware.light-service.xml"],
|
||||
srcs: [
|
||||
"Lights.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"android.hardware.light-V1-ndk_platform",
|
||||
],
|
||||
vendor: true,
|
||||
}
|
25
aidl/light/Lights.cpp
Normal file
25
aidl/light/Lights.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "Lights.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace light {
|
||||
|
||||
ndk::ScopedAStatus Lights::setLightState(int32_t /*id*/, const HwLightState& /*state*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight> */*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
28
aidl/light/Lights.h
Normal file
28
aidl/light/Lights.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/android/hardware/light/BnLights.h>
|
||||
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
using ::aidl::android::hardware::light::HwLight;
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace light {
|
||||
|
||||
class Lights : public BnLights {
|
||||
public:
|
||||
ndk::ScopedAStatus setLightState(int32_t id, const HwLightState& state) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight> *_aidl_return) override;
|
||||
};
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
5
aidl/light/android.hardware.light-service.rc
Normal file
5
aidl/light/android.hardware.light-service.rc
Normal file
@ -0,0 +1,5 @@
|
||||
service vendor.light-default /vendor/bin/hw/android.hardware.light-service
|
||||
class hal
|
||||
user nobody
|
||||
group nobody
|
||||
shutdown critical
|
6
aidl/light/android.hardware.light-service.xml
Normal file
6
aidl/light/android.hardware.light-service.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.light</name>
|
||||
<fqname>ILights/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
25
aidl/light/service.cpp
Normal file
25
aidl/light/service.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "Lights.h"
|
||||
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::light::Lights;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<Lights> lights = ndk::SharedRefBase::make<Lights>();
|
||||
|
||||
const std::string instance = std::string() + Lights::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(lights->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
Loading…
Reference in New Issue
Block a user