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) {
- 客户验证通过