Merge "Fix a security issue in app widget service." into qt-dev am: 5a292b8bf4 am: f90c770087 am: af809557f8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20026360

Change-Id: I1dd4b4346229303d1e959ad06c98eb49a289e807
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Pinyao Ting
2022-09-23 21:15:00 +00:00
committed by Automerger Merge Worker
2 changed files with 7 additions and 4 deletions

View File

@@ -1109,7 +1109,9 @@ public class AppWidgetManager {
* @param intent The intent of the service which will be providing the data to the
* RemoteViewsAdapter.
* @param connection The callback interface to be notified when a connection is made or lost.
* @param flags Flags used for binding to the service
* @param flags Flags used for binding to the service. Currently only
* {@link Context#BIND_AUTO_CREATE} and
* {@link Context#BIND_FOREGROUND_SERVICE_WHILE_AWAKE} are supported.
*
* @see Context#getServiceDispatcher(ServiceConnection, Handler, int)
* @hide

View File

@@ -1315,11 +1315,12 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
try {
// Ask ActivityManager to bind it. Notice that we are binding the service with the
// caller app instead of DevicePolicyManagerService.
if(ActivityManager.getService().bindService(
if (ActivityManager.getService().bindService(
caller, activtiyToken, intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
connection, flags, mContext.getOpPackageName(),
widget.provider.getUserId()) != 0) {
connection, flags & (Context.BIND_AUTO_CREATE
| Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE),
mContext.getOpPackageName(), widget.provider.getUserId()) != 0) {
// Add it to the mapping of RemoteViewsService to appWidgetIds so that we
// can determine when we can call back to the RemoteViewsService later to