Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9180a4ac authored by Pinyao Ting's avatar Pinyao Ting
Browse files

Fix the on click popup when clicking on unavailable widgets in HSUM

Bug: 345415843
Change-Id: Ie9b2f9cd3a47e3671e34c70c939f1ea8a6978107
Flag: EXEMPT bugfix
Test: manual
parent a42d5f4a
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -898,18 +898,30 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
            for (int j = 0; j < widgetCount; j++) {
                Widget widget = provider.widgets.get(j);
                if (targetWidget != null && targetWidget != widget) continue;
                // Identify the user in the host process since the intent will be invoked by
                // the host app.
                final Host host = widget.host;
                final UserHandle hostUser;
                if (host != null && host.id != null) {
                    hostUser = UserHandle.getUserHandleForUid(host.id.uid);
                } else {
                    // Fallback to the parent profile if the host is null.
                    Slog.w(TAG, "Host is null when masking widget: " + widget.appWidgetId);
                    hostUser = mUserManager.getProfileParent(appUserId).getUserHandle();
                }
                if (provider.maskedByStoppedPackage) {
                    Intent intent = createUpdateIntentLocked(provider,
                            new int[] { widget.appWidgetId });
                    views.setOnClickPendingIntent(android.R.id.background,
                            PendingIntent.getBroadcast(mContext, widget.appWidgetId,
                            PendingIntent.getBroadcastAsUser(mContext, widget.appWidgetId,
                                    intent, PendingIntent.FLAG_UPDATE_CURRENT
                                            | PendingIntent.FLAG_IMMUTABLE));
                                            | PendingIntent.FLAG_IMMUTABLE, hostUser));
                } else if (onClickIntent != null) {
                    views.setOnClickPendingIntent(android.R.id.background,
                            PendingIntent.getActivity(mContext, widget.appWidgetId, onClickIntent,
                                    PendingIntent.FLAG_UPDATE_CURRENT
                                       | PendingIntent.FLAG_IMMUTABLE));
                            PendingIntent.getActivityAsUser(mContext, widget.appWidgetId,
                            onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT
                                    | PendingIntent.FLAG_IMMUTABLE, null /* options */,
                            hostUser));
                }
                if (widget.replaceWithMaskedViewsLocked(views)) {
                    scheduleNotifyUpdateAppWidgetLocked(widget, widget.getEffectiveViewsLocked());