diff options
author | 2021-12-23 14:32:28 -0800 | |
---|---|---|
committer | 2021-12-23 14:35:34 -0800 | |
commit | f95b2007a3fb27fb7e42728e6822f78b8ae9bf7f (patch) | |
tree | efa433fe8d9ef6d46b6f0396e485f251ac85c712 | |
parent | 5fb75a47fce4a17b9dec8089df331bbc1f983728 (diff) |
Change the bootanim time file location.
This change moves the bootanim time file location from /data/system/time
to /data/bootanim/time. This change helps us remove the access to
system_data_file from bootanim.
Bug: 210757252
Test: Boot animation can show time. No SELinux violations.
Change-Id: Ie61155f8976f3b8c6ad5ceac1826140c1455ad54
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 28 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.h | 2 |
2 files changed, 15 insertions, 15 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 05a0661914dc..1f4a64f5c7f1 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -81,18 +81,18 @@ static constexpr const char* PRODUCT_USERSPACE_REBOOT_ANIMATION_FILE = "/product static constexpr const char* OEM_USERSPACE_REBOOT_ANIMATION_FILE = "/oem/media/userspace-reboot.zip"; static constexpr const char* SYSTEM_USERSPACE_REBOOT_ANIMATION_FILE = "/system/media/userspace-reboot.zip"; -static const char SYSTEM_DATA_DIR_PATH[] = "/data/system"; -static const char SYSTEM_TIME_DIR_NAME[] = "time"; -static const char SYSTEM_TIME_DIR_PATH[] = "/data/system/time"; +static const char BOOTANIM_DATA_DIR_PATH[] = "/data/bootanim"; +static const char BOOTANIM_TIME_DIR_NAME[] = "time"; +static const char BOOTANIM_TIME_DIR_PATH[] = "/data/bootanim/time"; static const char CLOCK_FONT_ASSET[] = "images/clock_font.png"; static const char CLOCK_FONT_ZIP_NAME[] = "clock_font.png"; static const char PROGRESS_FONT_ASSET[] = "images/progress_font.png"; static const char PROGRESS_FONT_ZIP_NAME[] = "progress_font.png"; static const char LAST_TIME_CHANGED_FILE_NAME[] = "last_time_change"; -static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/system/time/last_time_change"; +static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/bootanim/time/last_time_change"; static const char ACCURATE_TIME_FLAG_FILE_NAME[] = "time_is_accurate"; -static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/system/time/time_is_accurate"; -static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/system/time/time_format_12_hour"; +static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/bootanim/time/time_is_accurate"; +static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/bootanim/time/time_format_12_hour"; // Java timestamp format. Don't show the clock if the date is before 2000-01-01 00:00:00. static const long long ACCURATE_TIME_EPOCH = 946684800000; static constexpr char FONT_BEGIN_CHAR = ' '; @@ -1741,7 +1741,7 @@ bool BootAnimation::updateIsTimeAccurate() { } BootAnimation::TimeCheckThread::TimeCheckThread(BootAnimation* bootAnimation) : Thread(false), - mInotifyFd(-1), mSystemWd(-1), mTimeWd(-1), mBootAnimation(bootAnimation) {} + mInotifyFd(-1), mBootAnimWd(-1), mTimeWd(-1), mBootAnimation(bootAnimation) {} BootAnimation::TimeCheckThread::~TimeCheckThread() { // mInotifyFd may be -1 but that's ok since we're not at risk of attempting to close a valid FD. @@ -1784,7 +1784,7 @@ bool BootAnimation::TimeCheckThread::doThreadLoop() { const struct inotify_event *event; for (char* ptr = buff; ptr < buff + length; ptr += sizeof(struct inotify_event) + event->len) { event = (const struct inotify_event *) ptr; - if (event->wd == mSystemWd && strcmp(SYSTEM_TIME_DIR_NAME, event->name) == 0) { + if (event->wd == mBootAnimWd && strcmp(BOOTANIM_TIME_DIR_NAME, event->name) == 0) { addTimeDirWatch(); } else if (event->wd == mTimeWd && (strcmp(LAST_TIME_CHANGED_FILE_NAME, event->name) == 0 || strcmp(ACCURATE_TIME_FLAG_FILE_NAME, event->name) == 0)) { @@ -1796,12 +1796,12 @@ bool BootAnimation::TimeCheckThread::doThreadLoop() { } void BootAnimation::TimeCheckThread::addTimeDirWatch() { - mTimeWd = inotify_add_watch(mInotifyFd, SYSTEM_TIME_DIR_PATH, + mTimeWd = inotify_add_watch(mInotifyFd, BOOTANIM_TIME_DIR_PATH, IN_CLOSE_WRITE | IN_MOVED_TO | IN_ATTRIB); if (mTimeWd > 0) { // No need to watch for the time directory to be created if it already exists - inotify_rm_watch(mInotifyFd, mSystemWd); - mSystemWd = -1; + inotify_rm_watch(mInotifyFd, mBootAnimWd); + mBootAnimWd = -1; } } @@ -1812,11 +1812,11 @@ status_t BootAnimation::TimeCheckThread::readyToRun() { return NO_INIT; } - mSystemWd = inotify_add_watch(mInotifyFd, SYSTEM_DATA_DIR_PATH, IN_CREATE | IN_ATTRIB); - if (mSystemWd < 0) { + mBootAnimWd = inotify_add_watch(mInotifyFd, BOOTANIM_DATA_DIR_PATH, IN_CREATE | IN_ATTRIB); + if (mBootAnimWd < 0) { close(mInotifyFd); mInotifyFd = -1; - SLOGE("Could not add watch for %s: %s", SYSTEM_DATA_DIR_PATH, strerror(errno)); + SLOGE("Could not add watch for %s: %s", BOOTANIM_DATA_DIR_PATH, strerror(errno)); return NO_INIT; } diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 7a597da533ee..4c378cbc48bd 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -161,7 +161,7 @@ private: void addTimeDirWatch(); int mInotifyFd; - int mSystemWd; + int mBootAnimWd; int mTimeWd; BootAnimation* mBootAnimation; }; |