Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27794e8f authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

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

parents 6180273e 05659a3d
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -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;
        }
        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