From d5455378ac7b576c7ec3084417ce299471274814 Mon Sep 17 00:00:00 2001 From: zhanghaidong Date: Sat, 26 Sep 2020 09:42:14 +0800 Subject: [PATCH 1/2] ANR: show anr dialog show anr dialog of background app process. --- services/core/java/com/android/server/am/AppErrors.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java index 0c67c75d..f8e31a53 100644 --- a/services/core/java/com/android/server/am/AppErrors.java +++ b/services/core/java/com/android/server/am/AppErrors.java @@ -572,6 +572,7 @@ class AppErrors { long now = SystemClock.uptimeMillis(); boolean showBackground = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0; + showBackground = true; Long crashTime; Long crashTimePersistent; @@ -679,6 +680,7 @@ class AppErrors { AppErrorDialog.Data data = (AppErrorDialog.Data) msg.obj; boolean showBackground = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0; + showBackground = true; synchronized (mService) { ProcessRecord proc = data.proc; AppErrorResult res = data.result; @@ -702,8 +704,9 @@ class AppErrors { } return; } - final boolean crashSilenced = mAppsNotReportingCrashes != null && + boolean crashSilenced = mAppsNotReportingCrashes != null && mAppsNotReportingCrashes.contains(proc.info.packageName); + crashSilenced = false; if ((mService.canShowErrorDialogs() || showBackground) && !crashSilenced) { proc.crashDialog = new AppErrorDialog(mContext, mService, data); } else { @@ -943,6 +946,7 @@ class AppErrors { boolean showBackground = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0; + showBackground = true; if (mService.canShowErrorDialogs() || showBackground) { d = new AppNotRespondingDialog(mService, mContext, proc, (ActivityRecord)data.get("activity"), -- Gitee From 13356d2a0061d1c51453b4924808f8ff885c40e9 Mon Sep 17 00:00:00 2001 From: zhanghaidong Date: Sun, 27 Sep 2020 00:12:10 +0800 Subject: [PATCH 2/2] anr: fix anr dialog size fix anr and crash dialog view size. --- core/java/android/view/View.java | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index fc2a2d03..e9b65c80 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -17661,6 +17661,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, int oldT = mTop; int oldB = mBottom; int oldR = mRight; + /* + Log.d("zhdl", "layout=" + this.getClass().getName() + " - (" + l + "," + t + "," + r + "," + b + "), old=" + + "(" + oldL + "," + oldT + "," + oldR + "," + oldB + ")"); + if (this.mParent != null) { + Log.d("zhdl", " --mParent=" + this.mParent.getClass().getName() + ", id=" + mID); + } + */ boolean changed = isLayoutModeOptical(mParent) ? setOpticalFrame(l, t, r, b) : setFrame(l, t, r, b); @@ -19862,7 +19869,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int widthSize = MeasureSpec.getSize(widthMeasureSpec); final int heightSize = MeasureSpec.getSize(heightMeasureSpec); final int widthMode = MeasureSpec.getMode(widthMeasureSpec); - final int heighMode = MeasureSpec.getMode(heightMeasureSpec); + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + + if (this.getClass().getName().startsWith("com.android.internal.policy.DecorView")) { + if (widthMode == MeasureSpec.AT_MOST && heightMode == MeasureSpec.AT_MOST && + widthSize == 320 && heightSize == 1079) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(320, MeasureSpec.EXACTLY); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(220, MeasureSpec.AT_MOST); + } + } if (this.getClass().getName().startsWith("com.tencent.mm.ui.LayoutListenerView")) { if (heightSize > 960) { @@ -19910,6 +19925,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, heightMeasureSpec = MeasureSpec.makeMeasureSpec(303, MeasureSpec.EXACTLY); } } + + if (this.mParent != null) { + String whiteView = "com.ss.android.video.impl.detail.widget.MotionFrameLayout"; + if (this.mParent.getClass().getName().startsWith(whiteView) && + this.getClass().getName().startsWith("android.widget.RelativeLayout")) { + if (widthSize == 1080) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(540, MeasureSpec.EXACTLY); + } + } + } + + if (this.getClass().getName().startsWith("com.ixigua.commonui.view.AutoScrollViewPager")) { + if (widthSize == 540 && heightSize == 156) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(539, MeasureSpec.EXACTLY); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(228, MeasureSpec.EXACTLY); + } + } /* ******************************************************************** */ boolean optical = isLayoutModeOptical(this); -- Gitee