Loading init/reboot.cpp +9 −19 Original line number Diff line number Diff line Loading @@ -137,25 +137,12 @@ class MountEntry { // Turn off backlight while we are performing power down cleanup activities. static void TurnOffBacklight() { static constexpr char OFF[] = "0"; android::base::WriteStringToFile(OFF, "/sys/class/leds/lcd-backlight/brightness"); static const char backlightDir[] = "/sys/class/backlight"; std::unique_ptr<DIR, int (*)(DIR*)> dir(opendir(backlightDir), closedir); if (!dir) { Service* service = ServiceList::GetInstance().FindService("blank_screen"); if (service == nullptr) { LOG(WARNING) << "cannot find blank_screen in TurnOffBacklight"; return; } struct dirent* dp; while ((dp = readdir(dir.get())) != nullptr) { if (((dp->d_type != DT_DIR) && (dp->d_type != DT_LNK)) || (dp->d_name[0] == '.')) { continue; } std::string fileName = StringPrintf("%s/%s/brightness", backlightDir, dp->d_name); android::base::WriteStringToFile(OFF, fileName); } service->Start(); } static void ShutdownVold() { Loading Loading @@ -316,8 +303,6 @@ static UmountStat TryUmountAndFsck(bool runFsck, std::chrono::milliseconds timeo std::vector<MountEntry> block_devices; std::vector<MountEntry> emulated_devices; TurnOffBacklight(); // this part can take time. save power. if (runFsck && !FindPartitionsToUmount(&block_devices, &emulated_devices, false)) { return UMOUNT_STAT_ERROR; } Loading Loading @@ -397,6 +382,11 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re } } // remaining operations (specifically fsck) may take a substantial duration if (cmd == ANDROID_RB_POWEROFF || is_thermal_shutdown) { TurnOffBacklight(); } Service* bootAnim = ServiceList::GetInstance().FindService("bootanim"); Service* surfaceFlinger = ServiceList::GetInstance().FindService("surfaceflinger"); if (bootAnim != nullptr && surfaceFlinger != nullptr && surfaceFlinger->IsRunning()) { Loading Loading
init/reboot.cpp +9 −19 Original line number Diff line number Diff line Loading @@ -137,25 +137,12 @@ class MountEntry { // Turn off backlight while we are performing power down cleanup activities. static void TurnOffBacklight() { static constexpr char OFF[] = "0"; android::base::WriteStringToFile(OFF, "/sys/class/leds/lcd-backlight/brightness"); static const char backlightDir[] = "/sys/class/backlight"; std::unique_ptr<DIR, int (*)(DIR*)> dir(opendir(backlightDir), closedir); if (!dir) { Service* service = ServiceList::GetInstance().FindService("blank_screen"); if (service == nullptr) { LOG(WARNING) << "cannot find blank_screen in TurnOffBacklight"; return; } struct dirent* dp; while ((dp = readdir(dir.get())) != nullptr) { if (((dp->d_type != DT_DIR) && (dp->d_type != DT_LNK)) || (dp->d_name[0] == '.')) { continue; } std::string fileName = StringPrintf("%s/%s/brightness", backlightDir, dp->d_name); android::base::WriteStringToFile(OFF, fileName); } service->Start(); } static void ShutdownVold() { Loading Loading @@ -316,8 +303,6 @@ static UmountStat TryUmountAndFsck(bool runFsck, std::chrono::milliseconds timeo std::vector<MountEntry> block_devices; std::vector<MountEntry> emulated_devices; TurnOffBacklight(); // this part can take time. save power. if (runFsck && !FindPartitionsToUmount(&block_devices, &emulated_devices, false)) { return UMOUNT_STAT_ERROR; } Loading Loading @@ -397,6 +382,11 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re } } // remaining operations (specifically fsck) may take a substantial duration if (cmd == ANDROID_RB_POWEROFF || is_thermal_shutdown) { TurnOffBacklight(); } Service* bootAnim = ServiceList::GetInstance().FindService("bootanim"); Service* surfaceFlinger = ServiceList::GetInstance().FindService("surfaceflinger"); if (bootAnim != nullptr && surfaceFlinger != nullptr && surfaceFlinger->IsRunning()) { Loading