Merge "Add logging of draw / DeviceProfile params for a crash" into sc-v2-dev

This commit is contained in:
Alex Chau 2021-11-02 18:26:58 +00:00 committed by Android (Google) Code Review
commit 27794e8fa3
1 changed files with 20 additions and 2 deletions

View File

@ -16,6 +16,7 @@
package com.android.launcher3.widget;
import android.annotation.SuppressLint;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.graphics.Canvas;
@ -30,6 +31,9 @@ import android.widget.RemoteViews;
import com.android.launcher3.R;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* A widget host views created while the host has not bind to the system service.
*/
@ -75,8 +79,22 @@ public class DeferredAppWidgetHostView extends LauncherAppWidgetHostView {
&& mSetupTextLayout.getWidth() == availableWidth) {
return;
}
mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth,
Layout.Alignment.ALIGN_CENTER, 1, 0, true);
try {
mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth,
Layout.Alignment.ALIGN_CENTER, 1, 0, true);
} catch (IllegalArgumentException e) {
@SuppressLint("DrawAllocation") StringWriter stringWriter = new StringWriter();
@SuppressLint("DrawAllocation") PrintWriter printWriter = new PrintWriter(stringWriter);
mActivity.getDeviceProfile().dump(/*prefix=*/"", printWriter);
printWriter.flush();
String message = "b/203530620 "
+ "- availableWidth: " + availableWidth
+ ", getMeasuredWidth: " + getMeasuredWidth()
+ ", getPaddingLeft: " + getPaddingLeft()
+ ", getPaddingRight: " + getPaddingRight()
+ ", deviceProfile: " + stringWriter.toString();
throw new IllegalArgumentException(message, e);
}
}
@Override