summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPinyao Ting <pinyaoting@google.com>2022-07-14 11:25:54 -0700
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-10-19 16:39:16 +0000
commit1d3df96d8d20ef766672874760205335a7ffc052 (patch)
treeac56db2d1587da5d37c1e1f0a677908ea0376fce
parente9d1c08b7b0e110b6147c819659daa67b07d36eb (diff)
downloadbase-1d3df96d8d20ef766672874760205335a7ffc052.tar.gz
Fix a security issue in app widget service.
Bug: 234013191 Test: atest RemoteViewsAdapterTest Change-Id: Icd2eccb7a90124aca18a3dd463c3f79e3a595c20 Merged-In: Icd2eccb7a90124aca18a3dd463c3f79e3a595c20 (cherry picked from commit 263d7d0ba8818c471a27938c4e002bae33569f01) (cherry picked from commit 0ee21ef3e652c78c934d257632a4951bd6d38011) Merged-In: Icd2eccb7a90124aca18a3dd463c3f79e3a595c20
-rw-r--r--core/java/android/appwidget/AppWidgetManager.java4
-rw-r--r--services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java7
2 files changed, 7 insertions, 4 deletions
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 18c638112480..a432b8dec2cb 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -1130,7 +1130,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
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index c32543ae5c13..f5063ac4a023 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -1199,11 +1199,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