android 延长开机动画显示时间

文章描述了一位技术专家分析并解决Android6.0设备在开机动画结束后到Launcher出现3秒黑屏的问题。问题源头被定位为客户提供的Launcher中的SplashActivity延迟跳转。通过延长开机动画时间并调整系统属性`persist.bootanim.exit`来解决黑屏现象,且该方案已得到客户验证。
摘要由CSDN通过智能技术生成

android 6.0 客户反馈:开机动画播完到Launcher有3秒左右黑屏

因为Launcher是客户提供的,首先把Launcher还原到原生Launcher3验证发现没有这个问题,怀疑这个问题是客户Launcher的原因,可能是theme配置问题或者启动界面做了什么耗时操作或延时导致的。

  • 用adb命令查看了开机动画后黑屏时的activity
C:\Users\Administrator>adb shell dumpsys window | findstr mCurrentFocus
  mCurrentFocus=Window{e4da3f9 u0 com.smona.btwriter/com.smona.btwriter.SplashActivity}
  • 然后试着反编译了一下客户的apk
    在这里插入图片描述
  • 又看了一下SplashActivity的布局,并且发现当界面由SplashActivity跳转到目标界面后不会出现黑屏现象,基本确定就是上面延时跳转导致的。
    在这里插入图片描述
  • 在客户对开机时长没啥要求的情况下,想通过延长开机动画时间到跳转目标界面解决
+++ b/frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
@@ -1039,6 +1039,14 @@ final class ActivityRecord {
     private void reportLaunchTimeLocked(final long curTime) {
         final ActivityStack stack = task.stack;
         if (stack == null) {
             return;
         }
         final long thisTime = curTime - displayStartTime;
         final long totalTime = stack.mLaunchStartTime != 0
                 ? (curTime - stack.mLaunchStartTime) : thisTime;
+        if(shortComponentName != null){
+            //android.util.Log.d("mh.log", "shortComponentName: " + shortComponentName);
+            if (!shortComponentName.contains("com.smona.btwriter/.SplashActivity")) {
+                SystemProperties.set("persist.bootanim.exit", "1");//结束
+            }else {
+                SystemProperties.set("persist.bootanim.exit", "0");//继续
+            }
+        }
         if (SHOW_ACTIVITY_START_TIME) {
             Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching: " + packageName, 0);
             EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME,
+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -6235,7 +6235,9 @@ public class WindowManagerService extends IWindowManager.Stub
     }
 
     private boolean checkBootAnimationCompleteLocked() {
-        if (SystemService.isRunning(BOOT_ANIMATION_SERVICE)) {
+        //if (SystemService.isRunning(BOOT_ANIMATION_SERVICE)) {
+        //android.util.Log.d("mh.log", "persist.bootanim.exit:::::" + SystemProperties.get("persist.bootanim.exit", "0"));
+        if(!SystemProperties.get("persist.bootanim.exit", "0").equals("1")) {
             mH.removeMessages(H.CHECK_IF_BOOT_ANIMATION_FINISHED);
             mH.sendEmptyMessageDelayed(H.CHECK_IF_BOOT_ANIMATION_FINISHED,
                     BOOT_ANIMATION_POLL_INTERVAL);
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -570,12 +570,20 @@ bool BootAnimation::android()
 }
 
 
+static const char PERSIST_BOOTANIM_EXIT[] = "persist.bootanim.exit";//mh.mmi

 void BootAnimation::checkExit() {
     // Allow surface flinger to gracefully request shutdown
     char value[PROPERTY_VALUE_MAX];
+    char value2[PROPERTY_VALUE_MAX];//mh.mmi
     property_get(EXIT_PROP_NAME, value, "0");
+    property_get(PERSIST_BOOTANIM_EXIT, value2, "0");///mh.mmi
     int exitnow = atoi(value);
+    int exitnow2 = atoi(value2);///mh.mmi
     if (exitnow) {
+       if(exitnow2 == 0) {
+               return;
+       }
         requestExit();
         if (mAudioPlayer != NULL) {
  • 客户验证通过
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值