Fix crash java.lang.IllegalArgumentException
There is the java.lang.IllegalArgumentException: width and height must
be > 0, so to avoid this case.
Bug: 323290864
Test: verify the UI. Using the Scan QR code
Change-Id: I85f5f73c09ee27e79c2a47a42fc4921074cef06e
diff --git a/packages/SettingsLib/src/com/android/settingslib/qrcode/QrDecorateView.java b/packages/SettingsLib/src/com/android/settingslib/qrcode/QrDecorateView.java
index e034254..eb57b40 100644
--- a/packages/SettingsLib/src/com/android/settingslib/qrcode/QrDecorateView.java
+++ b/packages/SettingsLib/src/com/android/settingslib/qrcode/QrDecorateView.java
@@ -24,6 +24,7 @@
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.View;
@@ -33,6 +34,7 @@
private static final float CORNER_STROKE_WIDTH = 4f; // 4dp
private static final float CORNER_LINE_LENGTH = 264f; // 264dp
private static final float CORNER_RADIUS = 16f; // 16dp
+ private static final String TAG = "QrDecorateView";
private final int mCornerColor;
private final int mFocusedCornerColor;
@@ -94,6 +96,10 @@
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
+ if (getWidth() <= 0 || getHeight() <= 0) {
+ Log.e(TAG, "width and height must be > 0");
+ return;
+ }
if (mMaskBitmap == null) {
mMaskBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);