diff --git a/services/ui/driver/fbdev_driver.cpp b/services/ui/driver/fbdev_driver.cpp index 69efb293cb5507262a1bc05aec188686907a2363..f89dd7c5a5314e25e4db89a32c80d34b56431392 100644 --- a/services/ui/driver/fbdev_driver.cpp +++ b/services/ui/driver/fbdev_driver.cpp @@ -152,6 +152,11 @@ void FbdevDriver::RegisterBlankHook(FbBlankHook blankHook) blankHook_ = blankHook; } +void FbdevDriver::RegisterBrightnessHook(FbBrightnessHook brightness) +{ + brightnessHook_ = brightness; +} + void FbdevDriver::ReleaseFb(const struct FbBufferObject *fbo) { /* @@ -175,6 +180,9 @@ bool FbdevDriver::FbPowerContrl(int fd, bool powerOn) LOG(ERROR) << "failed to set fb0 power " << powerOn; return false; } + if (brightnessHook_ != nullptr) { + brightnessHook_(devPath_, powerOn); + } return true; } } // namespace Updater diff --git a/services/ui/driver/fbdev_driver.h b/services/ui/driver/fbdev_driver.h index fdcf6e2f78ad03a4a920e8a18e212734c5409856..fce0231e962d7a4cb9ad7a845735dc91cf4698e9 100644 --- a/services/ui/driver/fbdev_driver.h +++ b/services/ui/driver/fbdev_driver.h @@ -34,6 +34,7 @@ struct FbBufferObject { class FbdevDriver : public GraphicDrv { DISALLOW_COPY_MOVE(FbdevDriver); using FbBlankHook = std::function; + using FbBrightnessHook = std::function; public: FbdevDriver() = default; ~FbdevDriver() override; @@ -44,6 +45,7 @@ public: void Exit(void) override; static void SetDevPath(const std::string &devPath); static void RegisterBlankHook(FbBlankHook blankHook); + static void RegisterBrightnessHook(FbBrightnessHook brightness); private: void FBLog() const; void ReleaseFb(const struct FbBufferObject *fbo); @@ -53,6 +55,7 @@ private: bool FbPowerContrl(int fd, bool powerOn); static inline std::string devPath_ = FB_DEV_PATH; static inline FbBlankHook blankHook_ {}; + static inline FbBrightnessHook brightnessHook_ {}; }; } // namespace Updater #endif