From 48032682297d848754ded3b157044bbc4e22db71 Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Fri, 10 Apr 2020 14:18:51 -0700 Subject: Move noteAppWidgetTapped call into AppWidgetHostView. RemoteViews is public API used out of scope of widget. The correct place to call noteAppWidgetTapped is in AppWidgetHostView. Fix: 153676411 Test: manual test, tap a widget, "adb shell dumpsys usagestats | grep USER_INTERACTION" to oberserve USER_INTERACTION event sent to UsageStas, "adb shell dumpsys appops | grep appWidgetVisible" to observer appWidgetVisible flag. Change-Id: Ic473211b91fd952dbb81b09b1e1568d6f69a0dd8 --- core/java/android/widget/RemoteViews.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'core/java/android/widget/RemoteViews.java') diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 4a27d3a0e71d..7f6c0d2077f1 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -29,7 +29,6 @@ import android.app.Application; import android.app.PendingIntent; import android.app.RemoteInput; import android.appwidget.AppWidgetHostView; -import android.appwidget.AppWidgetManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.ContextWrapper; @@ -4131,18 +4130,8 @@ public class RemoteViews implements Parcelable, Filter { // The NEW_TASK flags are applied through the activity options and not as a part of // the call to startIntentSender() to ensure that they are consistently applied to // both mutable and immutable PendingIntents. - final IntentSender intentSender = pendingIntent.getIntentSender(); - final int uid = intentSender.getCreatorUid(); - final String packageName = intentSender.getCreatorPackage(); - if (uid != -1 && packageName != null) { - final AppWidgetManager appWidgetManager = - context.getSystemService(AppWidgetManager.class); - if (appWidgetManager != null) { - appWidgetManager.noteAppWidgetTapped(uid, packageName); - } - } context.startIntentSender( - intentSender, options.first, + pendingIntent.getIntentSender(), options.first, 0, 0, 0, options.second.toBundle()); } catch (IntentSender.SendIntentException e) { Log.e(LOG_TAG, "Cannot send pending intent: ", e); -- cgit v1.2.3