Loading light/2.0/default/Light.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <log/log.h> #include <stdio.h> #include "Light.h" namespace android { Loading Loading @@ -107,6 +109,28 @@ const static std::map<Type, const char*> kLogicalLights = { {Type::WIFI, LIGHT_ID_WIFI} }; Return<void> Light::debug(const hidl_handle& handle, const hidl_vec<hidl_string>& /* options */) { if (handle == nullptr || handle->numFds < 1) { ALOGE("debug called with no handle\n"); return Void(); } int fd = handle->data[0]; if (fd < 0) { ALOGE("invalid FD: %d\n", handle->data[0]); return Void(); } dprintf(fd, "The following lights are registered: "); for (auto const& pair : mLights) { const Type type = pair.first; dprintf(fd, "%s,", kLogicalLights.at(type)); } dprintf(fd, ".\n"); fsync(fd); return Void(); } light_device_t* getLightDevice(const char* name) { light_device_t* lightDevice; const hw_module_t* hwModule = NULL; Loading light/2.0/default/Light.h +3 −2 Original line number Diff line number Diff line Loading @@ -42,10 +42,11 @@ using ::android::sp; struct Light : public ILight { Light(std::map<Type, light_device_t*> &&lights); // Methods from ::android::hardware::light::V2_0::ILight follow. Return<Status> setLight(Type type, const LightState& state) override; Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override; Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override; private: std::map<Type, light_device_t*> mLights; }; Loading Loading
light/2.0/default/Light.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <log/log.h> #include <stdio.h> #include "Light.h" namespace android { Loading Loading @@ -107,6 +109,28 @@ const static std::map<Type, const char*> kLogicalLights = { {Type::WIFI, LIGHT_ID_WIFI} }; Return<void> Light::debug(const hidl_handle& handle, const hidl_vec<hidl_string>& /* options */) { if (handle == nullptr || handle->numFds < 1) { ALOGE("debug called with no handle\n"); return Void(); } int fd = handle->data[0]; if (fd < 0) { ALOGE("invalid FD: %d\n", handle->data[0]); return Void(); } dprintf(fd, "The following lights are registered: "); for (auto const& pair : mLights) { const Type type = pair.first; dprintf(fd, "%s,", kLogicalLights.at(type)); } dprintf(fd, ".\n"); fsync(fd); return Void(); } light_device_t* getLightDevice(const char* name) { light_device_t* lightDevice; const hw_module_t* hwModule = NULL; Loading
light/2.0/default/Light.h +3 −2 Original line number Diff line number Diff line Loading @@ -42,10 +42,11 @@ using ::android::sp; struct Light : public ILight { Light(std::map<Type, light_device_t*> &&lights); // Methods from ::android::hardware::light::V2_0::ILight follow. Return<Status> setLight(Type type, const LightState& state) override; Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override; Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override; private: std::map<Type, light_device_t*> mLights; }; Loading