Skip to content

Commit 46cd9d9

Browse files
Android Build Coastguard Workerandroid-build-merge-worker-robot
authored andcommitted
Merge cherrypicks of ['googleplex-android-review.googlesource.com/22915959', 'googleplex-android-review.googlesource.com/22599577', 'googleplex-android-review.googlesource.com/23083138', 'googleplex-android-review.googlesource.com/23034056', 'googleplex-android-review.googlesource.com/23090199', 'googleplex-android-review.googlesource.com/23330385', 'googleplex-android-review.googlesource.com/23410117', 'googleplex-android-review.googlesource.com/23210299', 'googleplex-android-review.googlesource.com/23352460', 'googleplex-android-review.googlesource.com/23412216', 'googleplex-android-review.googlesource.com/23386456', 'googleplex-android-review.googlesource.com/23473144', 'googleplex-android-review.googlesource.com/23430378', 'googleplex-android-review.googlesource.com/23449211', 'googleplex-android-review.googlesource.com/23475497', 'googleplex-android-review.googlesource.com/23438365', 'googleplex-android-review.googlesource.com/23505029'] into tm-qpr3-release. am: 7c8d5d5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23682384 Change-Id: I7973c987958074fd6722ebd812217b4d11f45283 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 parents 066e11b + 7c8d5d5 commit 46cd9d9

21 files changed

Lines changed: 577 additions & 96 deletions

File tree

core/java/android/app/Notification.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,6 +2807,10 @@ private static void visitIconUri(@NonNull Consumer<Uri> visitor, @Nullable Icon
28072807
* @hide
28082808
*/
28092809
public void visitUris(@NonNull Consumer<Uri> visitor) {
2810+
if (publicVersion != null) {
2811+
publicVersion.visitUris(visitor);
2812+
}
2813+
28102814
visitor.accept(sound);
28112815

28122816
if (tickerView != null) tickerView.visitUris(visitor);
@@ -2892,6 +2896,8 @@ public void visitUris(@NonNull Consumer<Uri> visitor) {
28922896
}
28932897
}
28942898
}
2899+
2900+
visitIconUri(visitor, extras.getParcelable(EXTRA_CONVERSATION_ICON));
28952901
}
28962902

28972903
if (isStyle(CallStyle.class) & extras != null) {

core/java/android/app/admin/DevicePolicyManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12402,7 +12402,8 @@ public CharSequence getShortSupportMessage(@NonNull ComponentName admin) {
1240212402

1240312403
/**
1240412404
* Called by a device admin to set the long support message. This will be displayed to the user
12405-
* in the device administators settings screen.
12405+
* in the device administrators settings screen. If the message is longer than 20000 characters
12406+
* it may be truncated.
1240612407
* <p>
1240712408
* If the long support message needs to be localized, it is the responsibility of the
1240812409
* {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast

core/java/android/widget/RemoteViews.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ public void visitUris(@NonNull Consumer<Uri> visitor) {
726726
mActions.get(i).visitUris(visitor);
727727
}
728728
}
729+
if (mSizedRemoteViews != null) {
730+
for (int i = 0; i < mSizedRemoteViews.size(); i++) {
731+
mSizedRemoteViews.get(i).visitUris(visitor);
732+
}
733+
}
729734
if (mLandscape != null) {
730735
mLandscape.visitUris(visitor);
731736
}
@@ -1830,7 +1835,7 @@ public final boolean prefersAsyncApply() {
18301835
}
18311836

18321837
@Override
1833-
public final void visitUris(@NonNull Consumer<Uri> visitor) {
1838+
public void visitUris(@NonNull Consumer<Uri> visitor) {
18341839
switch (this.type) {
18351840
case URI:
18361841
final Uri uri = (Uri) getParameterValue(null);
@@ -2293,6 +2298,14 @@ protected Object getParameterValue(@Nullable View view) throws ActionException {
22932298
public int getActionTag() {
22942299
return NIGHT_MODE_REFLECTION_ACTION_TAG;
22952300
}
2301+
2302+
@Override
2303+
public void visitUris(@NonNull Consumer<Uri> visitor) {
2304+
if (this.type == ICON) {
2305+
visitIconUri((Icon) mDarkValue, visitor);
2306+
visitIconUri((Icon) mLightValue, visitor);
2307+
}
2308+
}
22962309
}
22972310

22982311
/**
@@ -2583,6 +2596,11 @@ public boolean prefersAsyncApply() {
25832596
public int getActionTag() {
25842597
return VIEW_GROUP_ACTION_ADD_TAG;
25852598
}
2599+
2600+
@Override
2601+
public final void visitUris(@NonNull Consumer<Uri> visitor) {
2602+
mNestedViews.visitUris(visitor);
2603+
}
25862604
}
25872605

25882606
/**

core/tests/coretests/src/android/widget/RemoteViewsTest.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.ArrayList;
6464
import java.util.Arrays;
6565
import java.util.Map;
66+
import java.util.HashMap;
6667
import java.util.concurrent.CountDownLatch;
6768
import java.util.function.Consumer;
6869

@@ -719,6 +720,43 @@ public void visitUris() {
719720
verify(visitor, times(1)).accept(eq(icon4.getUri()));
720721
}
721722

723+
@Test
724+
public void visitUris_themedIcons() {
725+
RemoteViews views = new RemoteViews(mPackage, R.layout.remote_views_test);
726+
final Icon iconLight = Icon.createWithContentUri("content://light/icon");
727+
final Icon iconDark = Icon.createWithContentUri("content://dark/icon");
728+
views.setIcon(R.id.layout, "setLargeIcon", iconLight, iconDark);
729+
730+
Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
731+
views.visitUris(visitor);
732+
verify(visitor, times(1)).accept(eq(iconLight.getUri()));
733+
verify(visitor, times(1)).accept(eq(iconDark.getUri()));
734+
}
735+
736+
@Test
737+
public void visitUris_nestedViews() {
738+
final RemoteViews outer = new RemoteViews(mPackage, R.layout.remote_views_test);
739+
740+
final RemoteViews inner = new RemoteViews(mPackage, 33);
741+
final Uri imageUriI = Uri.parse("content://inner/image");
742+
final Icon icon1 = Icon.createWithContentUri("content://inner/icon1");
743+
final Icon icon2 = Icon.createWithContentUri("content://inner/icon2");
744+
final Icon icon3 = Icon.createWithContentUri("content://inner/icon3");
745+
final Icon icon4 = Icon.createWithContentUri("content://inner/icon4");
746+
inner.setImageViewUri(R.id.image, imageUriI);
747+
inner.setTextViewCompoundDrawables(R.id.text, icon1, icon2, icon3, icon4);
748+
749+
outer.addView(R.id.layout, inner);
750+
751+
Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
752+
outer.visitUris(visitor);
753+
verify(visitor, times(1)).accept(eq(imageUriI));
754+
verify(visitor, times(1)).accept(eq(icon1.getUri()));
755+
verify(visitor, times(1)).accept(eq(icon2.getUri()));
756+
verify(visitor, times(1)).accept(eq(icon3.getUri()));
757+
verify(visitor, times(1)).accept(eq(icon4.getUri()));
758+
}
759+
722760
@Test
723761
public void visitUris_separateOrientation() {
724762
final RemoteViews landscape = new RemoteViews(mPackage, R.layout.remote_views_test);
@@ -754,4 +792,43 @@ public void visitUris_separateOrientation() {
754792
verify(visitor, times(1)).accept(eq(icon3P.getUri()));
755793
verify(visitor, times(1)).accept(eq(icon4P.getUri()));
756794
}
795+
796+
@Test
797+
public void visitUris_sizedViews() {
798+
final RemoteViews large = new RemoteViews(mPackage, R.layout.remote_views_test);
799+
final Uri imageUriL = Uri.parse("content://large/image");
800+
final Icon icon1L = Icon.createWithContentUri("content://large/icon1");
801+
final Icon icon2L = Icon.createWithContentUri("content://large/icon2");
802+
final Icon icon3L = Icon.createWithContentUri("content://large/icon3");
803+
final Icon icon4L = Icon.createWithContentUri("content://large/icon4");
804+
large.setImageViewUri(R.id.image, imageUriL);
805+
large.setTextViewCompoundDrawables(R.id.text, icon1L, icon2L, icon3L, icon4L);
806+
807+
final RemoteViews small = new RemoteViews(mPackage, 33);
808+
final Uri imageUriS = Uri.parse("content://small/image");
809+
final Icon icon1S = Icon.createWithContentUri("content://small/icon1");
810+
final Icon icon2S = Icon.createWithContentUri("content://small/icon2");
811+
final Icon icon3S = Icon.createWithContentUri("content://small/icon3");
812+
final Icon icon4S = Icon.createWithContentUri("content://small/icon4");
813+
small.setImageViewUri(R.id.image, imageUriS);
814+
small.setTextViewCompoundDrawables(R.id.text, icon1S, icon2S, icon3S, icon4S);
815+
816+
HashMap<SizeF, RemoteViews> sizedViews = new HashMap<>();
817+
sizedViews.put(new SizeF(300, 300), large);
818+
sizedViews.put(new SizeF(100, 100), small);
819+
RemoteViews views = new RemoteViews(sizedViews);
820+
821+
Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
822+
views.visitUris(visitor);
823+
verify(visitor, times(1)).accept(eq(imageUriL));
824+
verify(visitor, times(1)).accept(eq(icon1L.getUri()));
825+
verify(visitor, times(1)).accept(eq(icon2L.getUri()));
826+
verify(visitor, times(1)).accept(eq(icon3L.getUri()));
827+
verify(visitor, times(1)).accept(eq(icon4L.getUri()));
828+
verify(visitor, times(1)).accept(eq(imageUriS));
829+
verify(visitor, times(1)).accept(eq(icon1S.getUri()));
830+
verify(visitor, times(1)).accept(eq(icon2S.getUri()));
831+
verify(visitor, times(1)).accept(eq(icon3S.getUri()));
832+
verify(visitor, times(1)).accept(eq(icon4S.getUri()));
833+
}
757834
}

libs/androidfw/CursorWindow.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ status_t CursorWindow::maybeInflate() {
108108

109109
{
110110
// Migrate existing contents into new ashmem region
111-
uint32_t slotsSize = mSize - mSlotsOffset;
111+
uint32_t slotsSize = sizeOfSlots();
112112
uint32_t newSlotsOffset = mInflatedSize - slotsSize;
113113
memcpy(static_cast<uint8_t*>(newData),
114114
static_cast<uint8_t*>(mData), mAllocOffset);
@@ -216,11 +216,9 @@ status_t CursorWindow::writeToParcel(Parcel* parcel) {
216216
if (parcel->writeDupFileDescriptor(mAshmemFd)) goto fail;
217217
} else {
218218
// Since we know we're going to be read-only on the remote side,
219-
// we can compact ourselves on the wire, with just enough padding
220-
// to ensure our slots stay aligned
221-
size_t slotsSize = mSize - mSlotsOffset;
222-
size_t compactedSize = mAllocOffset + slotsSize;
223-
compactedSize = (compactedSize + 3) & ~3;
219+
// we can compact ourselves on the wire.
220+
size_t slotsSize = sizeOfSlots();
221+
size_t compactedSize = sizeInUse();
224222
if (parcel->writeUint32(compactedSize)) goto fail;
225223
if (parcel->writeBool(false)) goto fail;
226224
void* dest = parcel->writeInplace(compactedSize);

libs/androidfw/include/androidfw/CursorWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class CursorWindow {
9090
inline uint32_t getNumRows() { return mNumRows; }
9191
inline uint32_t getNumColumns() { return mNumColumns; }
9292

93+
inline size_t sizeOfSlots() const { return mSize - mSlotsOffset; }
94+
inline size_t sizeInUse() const { return mAllocOffset + sizeOfSlots(); }
95+
9396
status_t clear();
9497
status_t setNumColumns(uint32_t numColumns);
9598

libs/androidfw/tests/CursorWindow_test.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@
2020

2121
#include "TestHelpers.h"
2222

23+
// Verify that the memory in use is a multiple of 4 bytes
24+
#define ASSERT_ALIGNED(w) \
25+
ASSERT_EQ(((w)->sizeInUse() & 3), 0); \
26+
ASSERT_EQ(((w)->freeSpace() & 3), 0); \
27+
ASSERT_EQ(((w)->sizeOfSlots() & 3), 0)
28+
2329
#define CREATE_WINDOW_1K \
2430
CursorWindow* w; \
25-
CursorWindow::create(String8("test"), 1 << 10, &w);
31+
CursorWindow::create(String8("test"), 1 << 10, &w); \
32+
ASSERT_ALIGNED(w);
2633

2734
#define CREATE_WINDOW_1K_3X3 \
2835
CursorWindow* w; \
2936
CursorWindow::create(String8("test"), 1 << 10, &w); \
3037
ASSERT_EQ(w->setNumColumns(3), OK); \
3138
ASSERT_EQ(w->allocRow(), OK); \
3239
ASSERT_EQ(w->allocRow(), OK); \
33-
ASSERT_EQ(w->allocRow(), OK);
40+
ASSERT_EQ(w->allocRow(), OK); \
41+
ASSERT_ALIGNED(w);
3442

3543
#define CREATE_WINDOW_2M \
3644
CursorWindow* w; \
37-
CursorWindow::create(String8("test"), 1 << 21, &w);
45+
CursorWindow::create(String8("test"), 1 << 21, &w); \
46+
ASSERT_ALIGNED(w);
3847

3948
static constexpr const size_t kHalfInlineSize = 8192;
4049
static constexpr const size_t kGiantSize = 1048576;
@@ -48,6 +57,7 @@ TEST(CursorWindowTest, Empty) {
4857
ASSERT_EQ(w->getNumColumns(), 0);
4958
ASSERT_EQ(w->size(), 1 << 10);
5059
ASSERT_EQ(w->freeSpace(), 1 << 10);
60+
ASSERT_ALIGNED(w);
5161
}
5262

5363
TEST(CursorWindowTest, SetNumColumns) {
@@ -59,6 +69,7 @@ TEST(CursorWindowTest, SetNumColumns) {
5969
ASSERT_NE(w->setNumColumns(5), OK);
6070
ASSERT_NE(w->setNumColumns(3), OK);
6171
ASSERT_EQ(w->getNumColumns(), 4);
72+
ASSERT_ALIGNED(w);
6273
}
6374

6475
TEST(CursorWindowTest, SetNumColumnsAfterRow) {
@@ -69,6 +80,7 @@ TEST(CursorWindowTest, SetNumColumnsAfterRow) {
6980
ASSERT_EQ(w->allocRow(), OK);
7081
ASSERT_NE(w->setNumColumns(4), OK);
7182
ASSERT_EQ(w->getNumColumns(), 0);
83+
ASSERT_ALIGNED(w);
7284
}
7385

7486
TEST(CursorWindowTest, AllocRow) {
@@ -82,14 +94,17 @@ TEST(CursorWindowTest, AllocRow) {
8294
ASSERT_EQ(w->allocRow(), OK);
8395
ASSERT_LT(w->freeSpace(), before);
8496
ASSERT_EQ(w->getNumRows(), 1);
97+
ASSERT_ALIGNED(w);
8598

8699
// Verify we can unwind
87100
ASSERT_EQ(w->freeLastRow(), OK);
88101
ASSERT_EQ(w->freeSpace(), before);
89102
ASSERT_EQ(w->getNumRows(), 0);
103+
ASSERT_ALIGNED(w);
90104

91105
// Can't unwind when no rows left
92106
ASSERT_NE(w->freeLastRow(), OK);
107+
ASSERT_ALIGNED(w);
93108
}
94109

95110
TEST(CursorWindowTest, AllocRowBounds) {
@@ -99,6 +114,7 @@ TEST(CursorWindowTest, AllocRowBounds) {
99114
ASSERT_EQ(w->setNumColumns(60), OK);
100115
ASSERT_EQ(w->allocRow(), OK);
101116
ASSERT_NE(w->allocRow(), OK);
117+
ASSERT_ALIGNED(w);
102118
}
103119

104120
TEST(CursorWindowTest, StoreNull) {
@@ -115,6 +131,7 @@ TEST(CursorWindowTest, StoreNull) {
115131
auto field = w->getFieldSlot(0, 0);
116132
ASSERT_EQ(w->getFieldSlotType(field), CursorWindow::FIELD_TYPE_NULL);
117133
}
134+
ASSERT_ALIGNED(w);
118135
}
119136

120137
TEST(CursorWindowTest, StoreLong) {
@@ -133,6 +150,7 @@ TEST(CursorWindowTest, StoreLong) {
133150
ASSERT_EQ(w->getFieldSlotType(field), CursorWindow::FIELD_TYPE_INTEGER);
134151
ASSERT_EQ(w->getFieldSlotValueLong(field), 0xcafe);
135152
}
153+
ASSERT_ALIGNED(w);
136154
}
137155

138156
TEST(CursorWindowTest, StoreString) {
@@ -154,6 +172,7 @@ TEST(CursorWindowTest, StoreString) {
154172
auto actual = w->getFieldSlotValueString(field, &size);
155173
ASSERT_EQ(std::string(actual), "cafe");
156174
}
175+
ASSERT_ALIGNED(w);
157176
}
158177

159178
TEST(CursorWindowTest, StoreBounds) {
@@ -174,6 +193,7 @@ TEST(CursorWindowTest, StoreBounds) {
174193
ASSERT_EQ(w->getFieldSlot(-1, 0), nullptr);
175194
ASSERT_EQ(w->getFieldSlot(0, -1), nullptr);
176195
ASSERT_EQ(w->getFieldSlot(-1, -1), nullptr);
196+
ASSERT_ALIGNED(w);
177197
}
178198

179199
TEST(CursorWindowTest, Inflate) {
@@ -233,6 +253,7 @@ TEST(CursorWindowTest, Inflate) {
233253
ASSERT_NE(actual, buf);
234254
ASSERT_EQ(memcmp(buf, actual, kHalfInlineSize), 0);
235255
}
256+
ASSERT_ALIGNED(w);
236257
}
237258

238259
TEST(CursorWindowTest, ParcelEmpty) {
@@ -248,10 +269,12 @@ TEST(CursorWindowTest, ParcelEmpty) {
248269
ASSERT_EQ(w->getNumColumns(), 0);
249270
ASSERT_EQ(w->size(), 0);
250271
ASSERT_EQ(w->freeSpace(), 0);
272+
ASSERT_ALIGNED(w);
251273

252274
// We can't mutate the window after parceling
253275
ASSERT_NE(w->setNumColumns(4), OK);
254276
ASSERT_NE(w->allocRow(), OK);
277+
ASSERT_ALIGNED(w);
255278
}
256279

257280
TEST(CursorWindowTest, ParcelSmall) {
@@ -310,6 +333,7 @@ TEST(CursorWindowTest, ParcelSmall) {
310333
ASSERT_EQ(actualSize, 0);
311334
ASSERT_NE(actual, nullptr);
312335
}
336+
ASSERT_ALIGNED(w);
313337
}
314338

315339
TEST(CursorWindowTest, ParcelLarge) {
@@ -362,6 +386,7 @@ TEST(CursorWindowTest, ParcelLarge) {
362386
ASSERT_EQ(actualSize, 0);
363387
ASSERT_NE(actual, nullptr);
364388
}
389+
ASSERT_ALIGNED(w);
365390
}
366391

367392
} // android

media/java/android/media/session/MediaSession.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,11 @@ public void setMediaButtonReceiver(@Nullable PendingIntent mbr) {
297297
* class that should receive media buttons. This allows restarting playback after the session
298298
* has been stopped. If your app is started in this way an {@link Intent#ACTION_MEDIA_BUTTON}
299299
* intent will be sent to the broadcast receiver.
300-
* <p>
301-
* Note: The given {@link android.content.BroadcastReceiver} should belong to the same package
302-
* as the context that was given when creating {@link MediaSession}.
300+
*
301+
* <p>Note: The given {@link android.content.BroadcastReceiver} should belong to the same
302+
* package as the context that was given when creating {@link MediaSession}.
303+
*
304+
* <p>Calls with invalid or non-existent receivers will be ignored.
303305
*
304306
* @param broadcastReceiver the component name of the BroadcastReceiver class
305307
*/

0 commit comments

Comments
 (0)