mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
59bf3b75c7
https://review.lineageos.org/c/LineageOS/android_frameworks_base/+/353117 https://review.lineageos.org/q/topic:Q_asb_2023-03 https://review.lineageos.org/q/topic:Q_asb_2023-04 https://review.lineageos.org/q/topic:Q_asb_2023-05 https://review.lineageos.org/q/topic:Q_asb_2023-06 https://review.lineageos.org/q/topic:Q_asb_2023-07 https://review.lineageos.org/q/topic:Q_asb_2023-08 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376560 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376561 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376562 https://review.lineageos.org/q/topic:Q_asb_2023-09 https://review.lineageos.org/q/topic:Q_asb_2023-10 https://review.lineageos.org/q/topic:Q_asb_2023-11 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376563 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_webp/+/376568 https://review.lineageos.org/q/topic:Q_asb_2023-12 https://review.lineageos.org/q/topic:Q_asb_2024-01 https://review.lineageos.org/q/topic:Q_asb_2024-02 https://review.lineageos.org/q/topic:Q_asb_2024-03 Signed-off-by: Tavi <tavi@divested.dev>
128 lines
6.0 KiB
Diff
128 lines
6.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ioana Alexandru <aioana@google.com>
|
|
Date: Thu, 27 Apr 2023 12:36:05 +0000
|
|
Subject: [PATCH] Visit URIs in landscape/portrait custom remote views.
|
|
|
|
Bug: 277740848
|
|
Test: atest RemoteViewsTest NotificationManagerServiceTest & tested with POC from bug
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e8acb2f660bdb03616989852f9dbbf1726f8237e)
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:43e1ae4e0d408604b9e3c18ac0e9bf87529b92a8)
|
|
Merged-In: I7d3d35df0ec38945019f71755bed8797b7af4517
|
|
Change-Id: I7d3d35df0ec38945019f71755bed8797b7af4517
|
|
---
|
|
core/java/android/widget/RemoteViews.java | 6 ++
|
|
.../src/android/widget/RemoteViewsTest.java | 64 +++++++++++++++++++
|
|
2 files changed, 70 insertions(+)
|
|
|
|
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
|
|
index 86cec5e0f0a2..21d38b559736 100644
|
|
--- a/core/java/android/widget/RemoteViews.java
|
|
+++ b/core/java/android/widget/RemoteViews.java
|
|
@@ -554,6 +554,12 @@ public class RemoteViews implements Parcelable, Filter {
|
|
mActions.get(i).visitUris(visitor);
|
|
}
|
|
}
|
|
+ if (mLandscape != null) {
|
|
+ mLandscape.visitUris(visitor);
|
|
+ }
|
|
+ if (mPortrait != null) {
|
|
+ mPortrait.visitUris(visitor);
|
|
+ }
|
|
}
|
|
|
|
private static void visitIconUri(Icon icon, @NonNull Consumer<Uri> visitor) {
|
|
diff --git a/core/tests/coretests/src/android/widget/RemoteViewsTest.java b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
|
|
index 8cb7e1b95245..46f2c0928fc3 100644
|
|
--- a/core/tests/coretests/src/android/widget/RemoteViewsTest.java
|
|
+++ b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
|
|
@@ -20,6 +20,10 @@ import static org.junit.Assert.assertArrayEquals;
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertSame;
|
|
import static org.junit.Assert.assertTrue;
|
|
+import static org.mockito.ArgumentMatchers.eq;
|
|
+import static org.mockito.Mockito.spy;
|
|
+import static org.mockito.Mockito.times;
|
|
+import static org.mockito.Mockito.verify;
|
|
|
|
import android.app.ActivityOptions;
|
|
import android.app.PendingIntent;
|
|
@@ -29,6 +33,8 @@ import android.content.Intent;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.Drawable;
|
|
+import android.graphics.drawable.Icon;
|
|
+import android.net.Uri;
|
|
import android.os.AsyncTask;
|
|
import android.os.Binder;
|
|
import android.os.Parcel;
|
|
@@ -50,6 +56,7 @@ import org.junit.runner.RunWith;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.concurrent.CountDownLatch;
|
|
+import java.util.function.Consumer;
|
|
|
|
/**
|
|
* Tests for RemoteViews.
|
|
@@ -499,4 +506,61 @@ public class RemoteViewsTest {
|
|
return null;
|
|
}
|
|
}
|
|
+
|
|
+ @Test
|
|
+ public void visitUris() {
|
|
+ RemoteViews views = new RemoteViews(mPackage, R.layout.remote_views_test);
|
|
+
|
|
+ final Uri imageUri = Uri.parse("content://media/image");
|
|
+ final Icon icon1 = Icon.createWithContentUri("content://media/icon1");
|
|
+ final Icon icon2 = Icon.createWithContentUri("content://media/icon2");
|
|
+ final Icon icon3 = Icon.createWithContentUri("content://media/icon3");
|
|
+ final Icon icon4 = Icon.createWithContentUri("content://media/icon4");
|
|
+ views.setImageViewUri(R.id.image, imageUri);
|
|
+ views.setTextViewCompoundDrawables(R.id.text, icon1, icon2, icon3, icon4);
|
|
+
|
|
+ Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
|
|
+ views.visitUris(visitor);
|
|
+ verify(visitor, times(1)).accept(eq(imageUri));
|
|
+ verify(visitor, times(1)).accept(eq(icon1.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon2.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon3.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon4.getUri()));
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void visitUris_separateOrientation() {
|
|
+ final RemoteViews landscape = new RemoteViews(mPackage, R.layout.remote_views_test);
|
|
+ final Uri imageUriL = Uri.parse("content://landscape/image");
|
|
+ final Icon icon1L = Icon.createWithContentUri("content://landscape/icon1");
|
|
+ final Icon icon2L = Icon.createWithContentUri("content://landscape/icon2");
|
|
+ final Icon icon3L = Icon.createWithContentUri("content://landscape/icon3");
|
|
+ final Icon icon4L = Icon.createWithContentUri("content://landscape/icon4");
|
|
+ landscape.setImageViewUri(R.id.image, imageUriL);
|
|
+ landscape.setTextViewCompoundDrawables(R.id.text, icon1L, icon2L, icon3L, icon4L);
|
|
+
|
|
+ final RemoteViews portrait = new RemoteViews(mPackage, 33);
|
|
+ final Uri imageUriP = Uri.parse("content://portrait/image");
|
|
+ final Icon icon1P = Icon.createWithContentUri("content://portrait/icon1");
|
|
+ final Icon icon2P = Icon.createWithContentUri("content://portrait/icon2");
|
|
+ final Icon icon3P = Icon.createWithContentUri("content://portrait/icon3");
|
|
+ final Icon icon4P = Icon.createWithContentUri("content://portrait/icon4");
|
|
+ portrait.setImageViewUri(R.id.image, imageUriP);
|
|
+ portrait.setTextViewCompoundDrawables(R.id.text, icon1P, icon2P, icon3P, icon4P);
|
|
+
|
|
+ RemoteViews views = new RemoteViews(landscape, portrait);
|
|
+
|
|
+ Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
|
|
+ views.visitUris(visitor);
|
|
+ verify(visitor, times(1)).accept(eq(imageUriL));
|
|
+ verify(visitor, times(1)).accept(eq(icon1L.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon2L.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon3L.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon4L.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(imageUriP));
|
|
+ verify(visitor, times(1)).accept(eq(icon1P.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon2P.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon3P.getUri()));
|
|
+ verify(visitor, times(1)).accept(eq(icon4P.getUri()));
|
|
+ }
|
|
}
|