mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-11 00:44:23 -05:00
082bc48c32
https://review.lineageos.org/q/topic:P_asb_2022-05 https://review.lineageos.org/q/topic:P_asb_2022-06 https://review.lineageos.org/q/topic:P_asb_2022-07 https://review.lineageos.org/q/topic:P_asb_2022-08 https://review.lineageos.org/q/topic:P_asb_2022-09 https://review.lineageos.org/q/topic:P_asb_2022-10 https://review.lineageos.org/q/topic:P_asb_2022-11 https://review.lineageos.org/q/topic:P_asb_2022-12 https://review.lineageos.org/q/topic:P_asb_2023-01 https://review.lineageos.org/q/topic:P_asb_2023-02 https://review.lineageos.org/q/topic:P_asb_2023-03 https://review.lineageos.org/q/topic:P_asb_2023-04 https://review.lineageos.org/q/topic:P_asb_2023-05 https://review.lineageos.org/q/topic:P_asb_2023-06 https://review.lineageos.org/q/topic:P_asb_2023-07 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_freetype/+/361250 https://review.lineageos.org/q/topic:P_asb_2023-08 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_freetype/+/364606 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/365328 https://review.lineageos.org/q/topic:P_asb_2023-09 https://review.lineageos.org/q/topic:P_asb_2023-10 https://review.lineageos.org/q/topic:P_asb_2023-11 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/374916 https://review.lineageos.org/q/topic:P_asb_2023-12 https://review.lineageos.org/q/topic:P_asb_2024-01 https://review.lineageos.org/q/topic:P_asb_2024-02 https://review.lineageos.org/q/topic:P_asb_2024-03 https://review.lineageos.org/q/topic:P_asb_2024-04 Signed-off-by: Tavi <tavi@divested.dev>
86 lines
3.8 KiB
Diff
86 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Valentin Iftime <valiiftime@google.com>
|
|
Date: Wed, 22 Feb 2023 09:38:55 +0100
|
|
Subject: [PATCH] Prevent RemoteViews crashing SystemUi
|
|
|
|
Catch canvas drawing exceptions caused by unsuported image sizes.
|
|
|
|
Test: 1. Post a custom view notification with a layout
|
|
containing an ImageView that references a 5k x 5k image
|
|
2. Add an App Widget to the home screen with that has the
|
|
layout mentioned above as preview/initial layout.
|
|
|
|
Bug: 268193777
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:cfc0b34432ab54e3fa472db5c43e620293f64a5d)
|
|
Merged-In: Ib3bda769c499b4069b49c566b1b227f98f707a8a
|
|
Change-Id: Ib3bda769c499b4069b49c566b1b227f98f707a8a
|
|
---
|
|
.../android/appwidget/AppWidgetHostView.java | 39 ++++++++++++++-----
|
|
1 file changed, 29 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
|
|
index ab0eb92e1726..02b244bdd9a6 100644
|
|
--- a/core/java/android/appwidget/AppWidgetHostView.java
|
|
+++ b/core/java/android/appwidget/AppWidgetHostView.java
|
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageManager.NameNotFoundException;
|
|
import android.content.res.Resources;
|
|
+import android.graphics.Canvas;
|
|
import android.graphics.Color;
|
|
import android.graphics.Rect;
|
|
import android.os.Build;
|
|
@@ -248,19 +249,26 @@ public class AppWidgetHostView extends FrameLayout {
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
} catch (final RuntimeException e) {
|
|
Log.e(TAG, "Remote provider threw runtime exception, using error view instead.", e);
|
|
- removeViewInLayout(mView);
|
|
- View child = getErrorView();
|
|
- prepareView(child);
|
|
- addViewInLayout(child, 0, child.getLayoutParams());
|
|
- measureChild(child, MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
|
|
- MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
|
- child.layout(0, 0, child.getMeasuredWidth() + mPaddingLeft + mPaddingRight,
|
|
- child.getMeasuredHeight() + mPaddingTop + mPaddingBottom);
|
|
- mView = child;
|
|
- mViewMode = VIEW_MODE_ERROR;
|
|
+ handleViewError();
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
+ * Remove bad view and replace with error message view
|
|
+ */
|
|
+ private void handleViewError() {
|
|
+ removeViewInLayout(mView);
|
|
+ View child = getErrorView();
|
|
+ prepareView(child);
|
|
+ addViewInLayout(child, 0, child.getLayoutParams());
|
|
+ measureChild(child, MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
|
|
+ MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
|
+ child.layout(0, 0, child.getMeasuredWidth() + mPaddingLeft + mPaddingRight,
|
|
+ child.getMeasuredHeight() + mPaddingTop + mPaddingBottom);
|
|
+ mView = child;
|
|
+ mViewMode = VIEW_MODE_ERROR;
|
|
+ }
|
|
+
|
|
/**
|
|
* Provide guidance about the size of this widget to the AppWidgetManager. The widths and
|
|
* heights should correspond to the full area the AppWidgetHostView is given. Padding added by
|
|
@@ -646,4 +654,15 @@ public class AppWidgetHostView extends FrameLayout {
|
|
super.onInitializeAccessibilityNodeInfoInternal(info);
|
|
info.setClassName(AppWidgetHostView.class.getName());
|
|
}
|
|
+
|
|
+ @Override
|
|
+ protected void dispatchDraw(Canvas canvas) {
|
|
+ try {
|
|
+ super.dispatchDraw(canvas);
|
|
+ } catch (Exception e) {
|
|
+ // Catch draw exceptions that may be caused by RemoteViews
|
|
+ Log.e(TAG, "Drawing view failed: " + e);
|
|
+ post(this::handleViewError);
|
|
+ }
|
|
+ }
|
|
}
|