Correct setting the RemoteView's provider id.

This seems to interfere with cross profile remote views otherwise. This
will also avoid changing the stored RemoteViews, or not providing an ID
if the RemoteViews is constructed by the host.

Fix: 187837525
Fix: 187867661
Test: atest ManagedProfileCrossProfileTest#testCrossProfileWidgets
Test: Manually with other apps, checking the colors do no flickr
Test: Check that uninstalling an app with a widget doesn't crash anymore
Change-Id: I7caa3f58d9b554e36f54e6b9d3b793c3ae5023ef
This commit is contained in:
Pierre Barbier de Reuille
2021-05-17 14:59:20 +01:00
parent 9b60ca5d02
commit f8960a0b31

View File

@@ -1839,8 +1839,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
// For a full update we replace the RemoteViews completely.
widget.views = views;
}
widget.views.setProviderInstanceId(UPDATE_COUNTER.get());
int memoryUsage;
if ((UserHandle.getAppId(Binder.getCallingUid()) != Process.SYSTEM_UID) &&
(widget.views != null) &&
@@ -1942,13 +1940,14 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
return;
}
if (updateViews != null) {
updateViews = new RemoteViews(updateViews);
updateViews.setProviderInstanceId(requestId);
}
SomeArgs args = SomeArgs.obtain();
args.arg1 = widget.host;
args.arg2 = widget.host.callbacks;
args.arg3 = (updateViews != null) ? updateViews.clone() : null;
args.arg3 = updateViews;
args.arg4 = requestId;
args.argi1 = widget.appWidgetId;