summaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorSteven Moreland2017-12-22 16:02:12 -0600
committerandroid-build-merger2017-12-22 16:02:12 -0600
commit7de4288e6d5bf4f82c325d1945b59735fc3e5f79 (patch)
tree035532f90c26b95cf3846be2d5c032710aea678c /light
parenteb2b87ba3ee16f245b9367ead0ce24471313e4da (diff)
parent711ea3501ab2a1c3f692a565dc06bbdacfed739d (diff)
downloadplatform-hardware-interfaces-7de4288e6d5bf4f82c325d1945b59735fc3e5f79.tar.gz
platform-hardware-interfaces-7de4288e6d5bf4f82c325d1945b59735fc3e5f79.tar.xz
platform-hardware-interfaces-7de4288e6d5bf4f82c325d1945b59735fc3e5f79.zip
Merge "Add debug output for lights." am: 25ccf20c8c am: ba7d14198b
am: 711ea3501a Change-Id: Ib37c58aeb9aa13542ae730426cc7c4e2ae39e19c
Diffstat (limited to 'light')
-rw-r--r--light/2.0/default/Light.cpp24
-rw-r--r--light/2.0/default/Light.h5
2 files changed, 27 insertions, 2 deletions
diff --git a/light/2.0/default/Light.cpp b/light/2.0/default/Light.cpp
index cde15366..5484d2db 100644
--- a/light/2.0/default/Light.cpp
+++ b/light/2.0/default/Light.cpp
@@ -18,6 +18,8 @@
18 18
19#include <log/log.h> 19#include <log/log.h>
20 20
21#include <stdio.h>
22
21#include "Light.h" 23#include "Light.h"
22 24
23namespace android { 25namespace android {
@@ -107,6 +109,28 @@ const static std::map<Type, const char*> kLogicalLights = {
107 {Type::WIFI, LIGHT_ID_WIFI} 109 {Type::WIFI, LIGHT_ID_WIFI}
108}; 110};
109 111
112Return<void> Light::debug(const hidl_handle& handle, const hidl_vec<hidl_string>& /* options */) {
113 if (handle == nullptr || handle->numFds < 1) {
114 ALOGE("debug called with no handle\n");
115 return Void();
116 }
117
118 int fd = handle->data[0];
119 if (fd < 0) {
120 ALOGE("invalid FD: %d\n", handle->data[0]);
121 return Void();
122 }
123
124 dprintf(fd, "The following lights are registered: ");
125 for (auto const& pair : mLights) {
126 const Type type = pair.first;
127 dprintf(fd, "%s,", kLogicalLights.at(type));
128 }
129 dprintf(fd, ".\n");
130 fsync(fd);
131 return Void();
132}
133
110light_device_t* getLightDevice(const char* name) { 134light_device_t* getLightDevice(const char* name) {
111 light_device_t* lightDevice; 135 light_device_t* lightDevice;
112 const hw_module_t* hwModule = NULL; 136 const hw_module_t* hwModule = NULL;
diff --git a/light/2.0/default/Light.h b/light/2.0/default/Light.h
index 8987036f..8851461d 100644
--- a/light/2.0/default/Light.h
+++ b/light/2.0/default/Light.h
@@ -42,11 +42,12 @@ using ::android::sp;
42struct Light : public ILight { 42struct Light : public ILight {
43 Light(std::map<Type, light_device_t*> &&lights); 43 Light(std::map<Type, light_device_t*> &&lights);
44 44
45 // Methods from ::android::hardware::light::V2_0::ILight follow.
46 Return<Status> setLight(Type type, const LightState& state) override; 45 Return<Status> setLight(Type type, const LightState& state) override;
47 Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override; 46 Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
48 47
49private: 48 Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override;
49
50 private:
50 std::map<Type, light_device_t*> mLights; 51 std::map<Type, light_device_t*> mLights;
51}; 52};
52 53