Suppress Boot sound for non-standard scenarios.
am: 290c4350ed
Change-Id: I819489be834dd262de530b0ff24a2e20aafcad2d
This commit is contained in:
@@ -77,12 +77,23 @@ static const long long ACCURATE_TIME_EPOCH = 946684800000;
|
|||||||
static const char EXIT_PROP_NAME[] = "service.bootanim.exit";
|
static const char EXIT_PROP_NAME[] = "service.bootanim.exit";
|
||||||
static const char PLAY_SOUND_PROP_NAME[] = "persist.sys.bootanim.play_sound";
|
static const char PLAY_SOUND_PROP_NAME[] = "persist.sys.bootanim.play_sound";
|
||||||
static const int ANIM_ENTRY_NAME_MAX = 256;
|
static const int ANIM_ENTRY_NAME_MAX = 256;
|
||||||
|
static const char BOOT_COMPLETED_PROP_NAME[] = "sys.boot_completed";
|
||||||
|
static const char BOOTREASON_PROP_NAME[] = "ro.boot.bootreason";
|
||||||
|
// bootreasons list in "system/core/bootstat/bootstat.cpp".
|
||||||
|
static const std::vector<std::string> PLAY_SOUND_BOOTREASON_BLACKLIST {
|
||||||
|
"kernel_panic",
|
||||||
|
"Panic",
|
||||||
|
"Watchdog",
|
||||||
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false),
|
BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false),
|
||||||
mTimeCheckThread(NULL) {
|
mTimeCheckThread(NULL) {
|
||||||
mSession = new SurfaceComposerClient();
|
mSession = new SurfaceComposerClient();
|
||||||
|
|
||||||
|
// If the system has already booted, the animation is not being used for a boot.
|
||||||
|
mSystemBoot = !property_get_bool(BOOT_COMPLETED_PROP_NAME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BootAnimation::~BootAnimation() {}
|
BootAnimation::~BootAnimation() {}
|
||||||
@@ -778,13 +789,9 @@ bool BootAnimation::playAnimation(const Animation& animation)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// only play audio file the first time we animate the part
|
// only play audio file the first time we animate the part
|
||||||
if (r == 0 && part.audioData) {
|
if (r == 0 && part.audioData && playSoundsAllowed()) {
|
||||||
// Read the system property to see if we should play the sound.
|
ALOGD("playing clip for part%d, size=%d", (int) i, part.audioLength);
|
||||||
// If not present, default to playing it.
|
audioplay::playClip(part.audioData, part.audioLength);
|
||||||
if (property_get_bool(PLAY_SOUND_PROP_NAME, 1)) {
|
|
||||||
ALOGD("playing clip for part%d, size=%d", (int) i, part.audioLength);
|
|
||||||
audioplay::playClip(part.audioData, part.audioLength);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glClearColor(
|
glClearColor(
|
||||||
@@ -920,6 +927,30 @@ BootAnimation::Animation* BootAnimation::loadAnimation(const String8& fn)
|
|||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BootAnimation::playSoundsAllowed() const {
|
||||||
|
// Only play sounds for system boots, not runtime restarts.
|
||||||
|
if (!mSystemBoot) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the system property to see if we should play the sound.
|
||||||
|
// If it's not present, default to allowed.
|
||||||
|
if (!property_get_bool(PLAY_SOUND_PROP_NAME, 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't play sounds if this is a reboot due to an error.
|
||||||
|
char bootreason[PROPERTY_VALUE_MAX];
|
||||||
|
if (property_get(BOOTREASON_PROP_NAME, bootreason, nullptr) > 0) {
|
||||||
|
for (const auto& str : PLAY_SOUND_BOOTREASON_BLACKLIST) {
|
||||||
|
if (strcasecmp(str.c_str(), bootreason) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool BootAnimation::updateIsTimeAccurate() {
|
bool BootAnimation::updateIsTimeAccurate() {
|
||||||
static constexpr long long MAX_TIME_IN_PAST = 60000LL * 60LL * 24LL * 30LL; // 30 days
|
static constexpr long long MAX_TIME_IN_PAST = 60000LL * 60LL * 24LL * 30LL; // 30 days
|
||||||
static constexpr long long MAX_TIME_IN_FUTURE = 60000LL * 90LL; // 90 minutes
|
static constexpr long long MAX_TIME_IN_FUTURE = 60000LL * 90LL; // 90 minutes
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ private:
|
|||||||
void releaseAnimation(Animation*) const;
|
void releaseAnimation(Animation*) const;
|
||||||
bool parseAnimationDesc(Animation&);
|
bool parseAnimationDesc(Animation&);
|
||||||
bool preloadZip(Animation &animation);
|
bool preloadZip(Animation &animation);
|
||||||
|
bool playSoundsAllowed() const;
|
||||||
|
|
||||||
void checkExit();
|
void checkExit();
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ private:
|
|||||||
sp<Surface> mFlingerSurface;
|
sp<Surface> mFlingerSurface;
|
||||||
bool mClockEnabled;
|
bool mClockEnabled;
|
||||||
bool mTimeIsAccurate;
|
bool mTimeIsAccurate;
|
||||||
|
bool mSystemBoot;
|
||||||
String8 mZipFileName;
|
String8 mZipFileName;
|
||||||
SortedVector<String8> mLoadedFiles;
|
SortedVector<String8> mLoadedFiles;
|
||||||
sp<TimeCheckThread> mTimeCheckThread;
|
sp<TimeCheckThread> mTimeCheckThread;
|
||||||
|
|||||||
Reference in New Issue
Block a user