闪屏分析

闪屏和不闪屏的区别

闪屏有两个 animation

而不闪屏的只有一个(设置同时设置lock screen和home screen的background image)

不闪屏的:

01-02 02:39:03.159   752  3074 I WindowManager:   SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.173 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,247.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.229 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,484.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.242 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,577.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.254 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,669.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.268 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,771.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.285 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,879.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:39:03.302 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.phone/com.android.phone.EmergencyDialer
android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$
android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$
android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$
android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$
android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$

闪屏的:

android@NSGWD180021:/data/workspace/issueAnalysis/systemui/0614$ grep -i 'SURFACE POS' main003_bad.log 
01-02 02:16:53.380 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.systemui.ImageWallpaper
01-02 02:16:53.388 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:16:53.400 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,322.0): com.android.systemui.ImageWallpaper
01-02 02:16:53.408 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,322.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:16:53.470 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,616.0): com.android.systemui.ImageWallpaper
01-02 02:16:53.475 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,616.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:16:53.539 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,777.0): com.android.systemui.ImageWallpaper
01-02 02:16:53.543 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,777.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:16:53.617 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.systemui.ImageWallpaper
01-02 02:16:53.622 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 02:16:53.727 752 3074 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,0.0): com.android.systemui.ImageWallpaper

这里调用动画

01-02 03:41:37.199   745  3054 W jackywei: 	at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:633)
01-02 03:41:37.199 745 3054 W jackywei: at com.android.server.wm.DisplayContent.prepareWindowSurfaces(DisplayContent.java:2637)
01-02 03:41:37.199 745 3054 W jackywei: at com.android.server.wm.WindowAnimator.animate(WindowAnimator.java:208)

差异LOG: 闪屏的 SURFACE POS 被执行了两次

01-02 08:12:43.067   932  3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.068 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.070 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.074 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.075 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:12:43.078 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 8255557
01-02 08:12:43.087 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.128 932 3088 W jackywei: mCurrentTime = 177639,hashCode = 210511779
01-02 08:12:43.131 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.132 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,369.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.135 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.137 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.139 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,369.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:12:43.141 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 8255557
01-02 08:12:43.145 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.164 932 3088 W jackywei: mCurrentTime = 177689,hashCode = 210511779
01-02 08:12:43.167 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.167 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,633.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.169 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.171 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.173 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,633.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:12:43.175 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 8255557
01-02 08:12:43.179 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.328 932 3088 W jackywei: mCurrentTime = 177722,hashCode = 210511779
01-02 08:12:43.332 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.332 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,834.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.334 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.336 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.337 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,834.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:12:43.340 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 8255557
01-02 08:12:43.345 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.360 932 3088 W jackywei: mCurrentTime = 177889,hashCode = 210511779
01-02 08:12:43.364 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.365 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.367 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.371 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.372 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:12:43.374 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 8255557
01-02 08:12:43.379 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.412 932 3088 W jackywei: mCurrentTime = 177922,hashCode = 210511779
01-02 08:12:43.415 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.420 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{9291c89 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 153689225
01-02 08:12:43.427 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.476 932 3088 W jackywei: mCurrentTime = 177972,hashCode = 210511779
01-02 08:12:43.521 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,0.0): com.android.systemui.ImageWallpaper
01-02 08:12:43.524 932 3088 W jackywei: this = Surface(name=com.android.systemui.ImageWallpaper),mSurfaceControl = Surface(name=com.android.systemui.ImageWallpaper),hashCode = 129717571
01-02 08:12:43.539 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.545 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.560 932 3088 W jackywei: mCurrentTime = 178089,hashCode = 210511779
01-02 08:12:43.563 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.570 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:12:43.631 932 3088 W jackywei: mCurrentTime = 178172,hashCode = 210511779
01-02 08:12:43.634 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:12:43.641 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701

差异LOG: 闪屏的 SURFACE POS只执行了一次

01-02 08:11:36.840   932  3088 I WindowManager:   SURFACE POS (setPositionInTransaction) @ (0.0,9.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:11:36.843 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 29961845
01-02 08:11:36.847 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:11:36.852 932 3088 W jackywei: mCurrentTime = 111399,hashCode = 210511779
01-02 08:11:36.855 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:11:36.857 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{5886ab2 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 92826290
01-02 08:11:36.858 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,403.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:11:36.861 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 29961845
01-02 08:11:36.866 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:11:36.935 932 3088 W jackywei: mCurrentTime = 111432,hashCode = 210511779
01-02 08:11:36.938 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:11:36.940 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{5886ab2 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 92826290
01-02 08:11:36.941 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,577.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:11:36.943 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 29961845
01-02 08:11:36.946 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{68cbced StatusBar}, recoveringMemory = true,hashCode = 109886701
01-02 08:11:36.956 932 3088 W jackywei: mCurrentTime = 111499,hashCode = 210511779
01-02 08:11:36.959 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{8cb7a54 com.android.systemui.ImageWallpaper}, recoveringMemory = true,hashCode = 147552852
01-02 08:11:36.960 932 3088 W jackywei: setSurfaceBoundariesLocked this = WindowStateAnimator{5886ab2 com.android.phone/com.android.phone.EmergencyDialer}, recoveringMemory = true,hashCode = 92826290
01-02 08:11:36.961 932 3088 I WindowManager: SURFACE POS (setPositionInTransaction) @ (0.0,939.0): com.android.phone/com.android.phone.EmergencyDialer
01-02 08:11:36.963 932 3088 W jackywei: this = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),mSurfaceControl = Surface(name=com.android.phone/com.android.phone.EmergencyDialer),hashCode = 29961845

这一段很重要:

01-02 09:08:37.871   924  3080 W jackywei: 	at com.android.server.wm.WindowState.forAllWindows(WindowState.java:4035)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:623)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:623)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.DisplayContent.forAllWindows(DisplayContent.java:1546)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:636)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.DisplayContent.prepareWindowSurfaces(DisplayContent.java:2637)
01-02 09:08:37.871 924 3080 W jackywei: at com.android.server.wm.WindowAnimator.animate(WindowAnimator.java:208)

不闪屏时:

mTmpSize.set : w.mShownPosition.x = 0,w.mShownPosition.y = 9 这里的这个Y的值是不会变的mShownPosition.y 一直都是0

WP target app xform: 这个LOG和上面的mShownPosition 有关系

if (wpAppAnimator != null && wpAppAnimator.hasTransformation
&& wpAppAnimator.animation != null
&& !wpAppAnimator.animation.getDetachWallpaper()) {
appTransformation = wpAppAnimator.transformation;//jackywei
if (DEBUG_WALLPAPER && appTransformation != null) {
Slog.v(TAG, "WP target app xform: " + appTransformation);
} else {
android.util.Log.w("jackywei","this = "+this.hashCode()+",WP target app xform: = null");
}

WP target app xform 和这个wpAppAnimator变量有关系

可以Fix的代码

void computeShownFrameLocked() {
final boolean selfTransformation = mHasLocalTransformation;
Transformation attachedTransformation =
(mParentWinAnimator != null && mParentWinAnimator.mHasLocalTransformation)
? mParentWinAnimator.mTransformation : null;
Transformation appTransformation = (mAppAnimator != null && mAppAnimator.hasTransformation)
? mAppAnimator.transformation : null;
appTransformation = null; //jackywei is can fix the bug.这个代码可以解BUG,但是,不知道会引起其他什么问题.
// Wallpapers are animated based on the "real" window they
// are currently targeting.
final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget();
android.util.Log.w("jackywei","this = "+this.hashCode()+",wallpaperTarget= "+wallpaperTarget+",mIsWallpaper = "+mIsWallpaper);
android.util.Log.w("jackywei","this = "+this.hashCode()+",mService.mAnimateWallpaperWithTarget= "+mService.mAnimateWallpaperWithTarget);
wpAppAnimator.hasTransformation = false;//jackywei is can fix the bug.we must check where is the hasTransformation value from.这个代码可以解BUG,但是,不知道会引起其他什么问题.
if (wpAppAnimator != null && wpAppAnimator.hasTransformation
&& wpAppAnimator.animation != null
&& !wpAppAnimator.animation.getDetachWallpaper()) {
appTransformation = wpAppAnimator.transformation;//jackywei
if (DEBUG_WALLPAPER && appTransformation != null) {
Slog.v(TAG, "WP target app xform: " + appTransformation);
} else {
android.util.Log.w("jackywei","this = "+this.hashCode()+",WP target app xform: = null");
}
}
}