sm6250-common: Pull in AOSP lights AIDL

* From ee34a8ce6e

Change-Id: Id83b242a850119c83f1b7b2d9b7a74928a7d5e67
This commit is contained in:
Sebastiano Barezzi 2021-05-08 16:32:07 +02:00 committed by Alexander Winkowski
parent 3ccb8d04dd
commit c755af1f0d
No known key found for this signature in database
GPG Key ID: 72762A66704CDE44
7 changed files with 140 additions and 0 deletions

View File

@ -188,6 +188,10 @@ PRODUCT_PACKAGES += \
android.hardware.ir@1.0-impl \ android.hardware.ir@1.0-impl \
android.hardware.ir@1.0-service android.hardware.ir@1.0-service
# Lights
PRODUCT_PACKAGES += \
android.hardware.lights-service.example
# Rootdir # Rootdir
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
init.qcom.early_boot.sh \ init.qcom.early_boot.sh \

16
lights/Android.bp Normal file
View File

@ -0,0 +1,16 @@
cc_binary {
name: "android.hardware.lights-service.example",
relative_install_path: "hw",
init_rc: ["lights-default.rc"],
vintf_fragments: ["lights-default.xml"],
vendor: true,
shared_libs: [
"libbase",
"libbinder_ndk",
"android.hardware.light-ndk_platform",
],
srcs: [
"Lights.cpp",
"main.cpp",
],
}

39
lights/Lights.cpp Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Lights.h"
#include <android-base/logging.h>
namespace aidl {
namespace android {
namespace hardware {
namespace light {
ndk::ScopedAStatus Lights::setLightState(int id, const HwLightState& state) {
LOG(INFO) << "Lights setting state for id=" << id << " to color " << std::hex << state.color;
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight>* /*lights*/) {
LOG(INFO) << "Lights reporting supported lights";
return ndk::ScopedAStatus::ok();
}
} // namespace light
} // namespace hardware
} // namespace android
} // namespace aidl

35
lights/Lights.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/hardware/light/BnLights.h>
namespace aidl {
namespace android {
namespace hardware {
namespace light {
// Default implementation that reports no supported lights.
class Lights : public BnLights {
ndk::ScopedAStatus setLightState(int id, const HwLightState& state) override;
ndk::ScopedAStatus getLights(std::vector<HwLight>* types) override;
};
} // namespace light
} // namespace hardware
} // namespace android
} // namespace aidl

5
lights/lights-default.rc Normal file
View File

@ -0,0 +1,5 @@
service vendor.light-default /vendor/bin/hw/android.hardware.lights-service.example
class hal
user nobody
group nobody
shutdown critical

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

35
lights/main.cpp Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Lights.h"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.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 reached
}