Add special backup action for adaptive brightness data #839
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Searching through the code in frameworks/base/services/core/java/com/android/server/display/, these two files are the relevant ones.
Adaptive brightness in its current form was introduced for Android 9, and as per https://cs.android.com/android/_/android/platform/frameworks/base/+/3d9c19f2fd34cccac6fe09877ae9a6b4563a063e the storage directory moved from /data/system_de to /data/system for Android 14.
Restoring this data will likely be a bit tricky, because it seems the files are only read on startup, and afterwards the BrightnessTracker will always write back its in-memory values, overwriting any other data that might be present on disk.
Since the BrightnessTracker also writes its state during a regular reboot, it seems the only thing that could possibly work (other than an offline-restore through recovery or whatever) would be an immediate abrupt reboot through the
reboot
command (or possibly a "warm" reboot by only restarting zygote). I haven't tested this, though, because I didn't want to mess with my phone's adaptive brightness data (which currently works very nicely). Plus how to then fit the reboot into the UX flow would also be a good question.At least it seems that other than on shutdown, the BrightnessTracker only writes via an Idle job that is executed once daily when the phone is charging, so the abrupt rebooting after restoration isn't super time-critical.