summaryrefslogtreecommitdiff
path: root/core/java/android/appwidget/AppWidgetManager.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-10-18 00:17:20 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-10-20 16:43:23 -0700
commite1273ebbb7d0d208d0bb0304ccefc5659633068c (patch)
treeb8f01ddb513a118f819287b5e043cd10049b9cdd /core/java/android/appwidget/AppWidgetManager.java
parent2ea41b52d21db3ad60d734aae64202080b1dc772 (diff)
Binding to the RemoteViewsService directly from the host
The host passes an IServiceConnection to the AppWidgetManager which is used to bind to the RemoteViewsService. This allows the host to recieve the connection callbacks directly instead of proxying it via the AppWidgetManager. The host is also responsible for unbinding to the service. Bug: 26481160 Test: adb shell \ am instrument -w -e class android.widget.RemoteViewsAdapterTest \ com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Change-Id: Iac400095a319c3a43714c82fda7516be1ccc68af
Diffstat (limited to 'core/java/android/appwidget/AppWidgetManager.java')
-rw-r--r--core/java/android/appwidget/AppWidgetManager.java40
1 files changed, 11 insertions, 29 deletions
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 969b19ee48ac..37bb6b05c3e7 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -20,17 +20,19 @@ import android.annotation.BroadcastBehavior;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
-import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemService;
+import android.app.IServiceConnection;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.ServiceConnection;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
import android.os.Bundle;
-import android.os.IBinder;
+import android.os.Handler;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -1051,43 +1053,23 @@ public class AppWidgetManager {
* The appWidgetId specified must already be bound to the calling AppWidgetHost via
* {@link android.appwidget.AppWidgetManager#bindAppWidgetId AppWidgetManager.bindAppWidgetId()}.
*
- * @param packageName The package from which the binding is requested.
* @param appWidgetId The AppWidget instance for which to bind the RemoteViewsService.
* @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.
- * @hide
- */
- public void bindRemoteViewsService(String packageName, int appWidgetId, Intent intent,
- IBinder connection) {
- if (mService == null) {
- return;
- }
- try {
- mService.bindRemoteViewsService(packageName, appWidgetId, intent, connection);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Unbinds the RemoteViewsService for a given appWidgetId and intent.
- *
- * The appWidgetId specified muse already be bound to the calling AppWidgetHost via
- * {@link android.appwidget.AppWidgetManager#bindAppWidgetId AppWidgetManager.bindAppWidgetId()}.
+ * @param flags Flags used for binding to the service
*
- * @param packageName The package from which the binding is requested.
- * @param appWidgetId The AppWidget instance for which to bind the RemoteViewsService.
- * @param intent The intent of the service which will be providing the data to the
- * RemoteViewsAdapter.
+ * @see Context#getServiceDispatcher(ServiceConnection, Handler, int)
* @hide
*/
- public void unbindRemoteViewsService(String packageName, int appWidgetId, Intent intent) {
+ public boolean bindRemoteViewsService(Context context, int appWidgetId, Intent intent,
+ IServiceConnection connection, @Context.BindServiceFlags int flags) {
if (mService == null) {
- return;
+ return false;
}
try {
- mService.unbindRemoteViewsService(packageName, appWidgetId, intent);
+ return mService.bindRemoteViewsService(context.getOpPackageName(), appWidgetId, intent,
+ context.getIApplicationThread(), context.getActivityToken(), connection, flags);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}