欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 旅游 > android11为开机动画添加铃声(语音)

android11为开机动画添加铃声(语音)

2024/11/30 10:46:56 来源:https://blog.csdn.net/weixin_71997855/article/details/140374507  浏览:    关键词:android11为开机动画添加铃声(语音)

一、碰到的问题

1、第一次开机无铃声

2、开机时铃声和动画不同步,开头的铃声会丢失

3、开机时铃声/动画不能完全播放完

二、解决

以下为添加的patch

/开机铃声不同步,语音第一段无声
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index b816042b75..2605df5afb 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -2811,7 +2811,7 @@ MediaPlayerService::BatteryTracker::BatteryTracker() {// reset battery stats// if the mediaserver has crashed, battery stats could be left// in bad state, reset the state upon service start.
-    BatteryNotifier::getInstance().noteResetVideo();
+//    BatteryNotifier::getInstance().noteResetVideo();}void MediaPlayerService::BatteryTracker::addBatteryData(uint32_t params)
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 764fdc33c0..66729b88f6 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -186,7 +186,8 @@ AudioFlinger::AudioFlinger()mGlobalEffectEnableTime(0),mPatchPanel(this),mDeviceEffectManager(this),
-      mSystemReady(false)
+//      mSystemReady(false)
+      mSystemReady(true){// unsigned instead of audio_unique_id_use_t, because ++ operator is unavailable for enumfor (unsigned use = AUDIO_UNIQUE_ID_USE_UNSPECIFIED; use < AUDIO_UNIQUE_ID_USE_MAX; use++) {
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 10404285a9..6ab56e0fd5 100755
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -580,11 +580,11 @@ status_t AudioFlinger::ThreadBase::sendConfigEvent_l(sp<ConfigEvent>& event){status_t status = NO_ERROR;-    if (event->mRequiresSystemReady && !mSystemReady) {
+/*    if (event->mRequiresSystemReady && !mSystemReady) {event->mWaitStatus = false;mPendingConfigEvents.add(event);return status;
-    }
+    }	*/mConfigEvents.add(event);ALOGV("sendConfigEvent_l() num events %zu event %d", mConfigEvents.size(), event->mType);mWaitWorkCV.signal();
@@ -1021,7 +1021,8 @@ void AudioFlinger::ThreadBase::releaseWakeLock_l()}void AudioFlinger::ThreadBase::getPowerManager_l() {
-    if (mSystemReady && mPowerManager == 0) {
+//    if (mSystemReady && mPowerManager == 0) {
+    if (mSystemReady == 0) {// use checkService() to avoid blocking if power service is not up yetsp<IBinder> binder =defaultServiceManager()->checkService(String16("power"));
@@ -3090,6 +3091,9 @@ ssize_t AudioFlinger::PlaybackThread::threadLoop_write()ssize_t bytesWritten;const size_t offset = mCurrentWriteLength - mBytesRemaining;+    if (mPowerManager == 0)
+	    acquireWakeLock();
+// If an NBAIO sink is present, use it to write the normal mixer's submixif (mNormalSink != 0) {
//初次开机无铃声
@@ -5241,6 +5245,15 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTractrack->mHasVolumeController = false;}+	    /*wmc modify start */
+            char mvalue[PROPERTY_VALUE_MAX] = { 1 };
+            property_get("service.bootanim.exit", mvalue, "");
+            if (strcmp(mvalue,"0") == 0){
+                vlf = 0.25f;
+                vrf = 0.25f;
+            }
+            /*wmc modify end */
+// XXX: these things DON'T need to be done each timemAudioMixer->setBufferProvider(trackId, track);mAudioMixer->enable(trackId);
//加了开机铃声,开机动画不能播放完
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 6ee60273264c..1aac6251061d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3455,8 +3455,10 @@ public class WindowManagerService extends IWindowManager.Stub// stop boot animation// formerly we would just kill the process, but we now ask it to exit so it// can choose where to stop the animation.
-                SystemProperties.set("service.bootanim.exit", "1");
-                mBootAnimationStopped = true;
+//                SystemProperties.set("service.bootanim.exit", "1");
+//                mBootAnimationStopped = true;
+                SystemProperties.set("service.bootanim.exit", "0");
+                mBootAnimationStopped = false;}if (!mForceDisplayEnabled && !checkBootAnimationCompleteLocked()) {

还有,我将bootanimation.zip文件的desc.txt进行了修改,这里添加了延时100ms,如下:

1280 800 20        //宽          高          帧数
p 1 0 part0        //标志性符  循环次数(0表示无限循环)  阶段切换间隔时间  对应目录名
p 0 100 part1

注意,这里的铃声/语音的格式需要为wav,这个音频文件需要和part0的文件一起打包,或者单独建一个part文件,和所需要的图片打包成bootanimation.zip,格式为存储。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com