diff --git a/init/reboot.cpp b/init/reboot.cpp index 21086dcf9..a88a42d74 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -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(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() { @@ -316,8 +303,6 @@ static UmountStat TryUmountAndFsck(bool runFsck, std::chrono::milliseconds timeo std::vector block_devices; std::vector emulated_devices; - TurnOffBacklight(); // this part can take time. save power. - if (runFsck && !FindPartitionsToUmount(&block_devices, &emulated_devices, false)) { return UMOUNT_STAT_ERROR; } @@ -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()) {