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

Commit 51673bb4 authored by Nan Wu's avatar Nan Wu
Browse files

Fix null pointer exception rendering cubes widget

It turns out RemoteViews.fromFillinIntent(Intent) is incorrectly
marked as @Nonnull. Its caller RemoteViews.setOnClickFiilinIntent
does not require the intent to be non null. So guard the call to
collectExtraIntentKeys with a null check.

Bug: 402501535
Test: Manual
Flag: EXEMPT bugfix
Change-Id: I2c2d7a9a6c7b916aa988414db1f5e67997ee72ca
parent 1323ed89
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -9216,7 +9216,13 @@ public class RemoteViews implements Parcelable, Filter {
        public static RemoteResponse fromFillInIntent(@NonNull Intent fillIntent) {
            RemoteResponse response = new RemoteResponse();
            response.mFillIntent = fillIntent;
            if (fillIntent != null) {
                // Although the parameter is marked as @NonNull, it is nullable. The method that
                // calls it (RemoteReviews.setOnClickFillInIntent()) passes its fillInIntent
                // parameter to this method and it does not guarantee that the fillInIntent is
                // non-null.
                fillIntent.collectExtraIntentKeys();
            }
            return response;
        }

+3 −0
Original line number Diff line number Diff line
@@ -1080,6 +1080,9 @@ public class RemoteViewsTest {
        rv.setOnClickFillInIntent(R.id.view, fillInIntent);
        assertNotEquals(0, fillInIntent.getExtendedFlags()
                & Intent.EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);

        RemoteViews.RemoteResponse rr = RemoteViews.RemoteResponse.fromFillInIntent(null);
        assertNotNull(rr);
    }

    private static LayoutInflater.Factory2 createLayoutInflaterFactory(String viewTypeToReplace,