Init remove direct calls to light sys nodes.
These are halified. Instead launch blank_screen which
does the same task w/o init itself having binder
dependencies.
Bug: 70846424
Test: manual + reboot appears similar
Change-Id: If8b2a56cbc31077122ea81406721b06034e4498f
diff --git a/init/reboot.cpp b/init/reboot.cpp
index 21086dc..a88a42d 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -137,25 +137,12 @@
// 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() {
@@ -316,8 +303,6 @@
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;
}
@@ -397,6 +382,11 @@
}
}
+ // 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()) {