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

Commit fb2df700 authored by Stevie Kideckel's avatar Stevie Kideckel
Browse files

Ensure that the root view is an AppWidgetHostView in setRemoteAdapter

Bug: 185367016
Test: atest RemoteViewsFixedCollectionAdapterTest

Change-Id: I77d866157e97c4507243dbc2cd5411384f885458
parent bcc5b4c1
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -928,6 +928,13 @@ public class RemoteViews implements Parcelable, Filter {
            View target = root.findViewById(viewId);
            if (target == null) return;

            // Ensure that we are applying to an AppWidget root
            if (!(rootParent instanceof AppWidgetHostView)) {
                Log.e(LOG_TAG, "setRemoteAdapter can only be used for "
                        + "AppWidgets (root id: " + viewId + ")");
                return;
            }

            if (!(target instanceof AdapterView)) {
                Log.e(LOG_TAG, "Cannot call setRemoteAdapter on a view which is not "
                        + "an AdapterView (id: " + viewId + ")");
@@ -993,14 +1000,15 @@ public class RemoteViews implements Parcelable, Filter {

            // Ensure that we are applying to an AppWidget root
            if (!(rootParent instanceof AppWidgetHostView)) {
                Log.e(LOG_TAG, "SetRemoteViewsAdapterIntent action can only be used for " +
                        "AppWidgets (root id: " + viewId + ")");
                Log.e(LOG_TAG, "setRemoteAdapter can only be used for "
                        + "AppWidgets (root id: " + viewId + ")");
                return;
            }

            // Ensure that we are calling setRemoteAdapter on an AdapterView that supports it
            if (!(target instanceof AbsListView) && !(target instanceof AdapterViewAnimator)) {
                Log.e(LOG_TAG, "Cannot setRemoteViewsAdapter on a view which is not " +
                        "an AbsListView or AdapterViewAnimator (id: " + viewId + ")");
                Log.e(LOG_TAG, "Cannot setRemoteAdapter on a view which is not "
                        + "an AbsListView or AdapterViewAnimator (id: " + viewId + ")");
                return;
            }