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

Commit 3ec2f73f authored by Nan Wu's avatar Nan Wu Committed by Android (Google) Code Review
Browse files

Merge "Fix AppWidget nested extra keys not collected issue" into main

parents f5419735 7976d884
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -9216,6 +9216,7 @@ public class RemoteViews implements Parcelable, Filter {
        public static RemoteResponse fromFillInIntent(@NonNull Intent fillIntent) {
            RemoteResponse response = new RemoteResponse();
            response.mFillIntent = fillIntent;
            fillIntent.collectExtraIntentKeys();
            return response;
        }

@@ -9224,6 +9225,7 @@ public class RemoteViews implements Parcelable, Filter {
            RemoteResponse response = new RemoteResponse();
            response.mPendingIntent = pendingIntent;
            response.mFillIntent = intent;
            intent.collectExtraIntentKeys();
            return response;
        }

+17 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.internal.R.id.pending_intent_tag;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
@@ -1065,6 +1066,22 @@ public class RemoteViewsTest {
        assertEquals(b1Memory + b2Memory, rv.estimateTotalBitmapMemoryUsage());
    }

    @Test
    public void remoteResponse_FillInIntentNestedIntentKeysCollected() {
        Intent fillInIntent = new Intent();
        fillInIntent.putExtra("extraIntent", new Intent());
        RemoteViews.RemoteResponse.fromFillInIntent(fillInIntent);
        assertNotEquals(0, fillInIntent.getExtendedFlags()
                & Intent.EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);

        fillInIntent = new Intent();
        fillInIntent.putExtra("extraIntent", new Intent());
        RemoteViews rv = new RemoteViews(mPackage, R.layout.remote_views_test);
        rv.setOnClickFillInIntent(R.id.view, fillInIntent);
        assertNotEquals(0, fillInIntent.getExtendedFlags()
                & Intent.EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);
    }

    private static LayoutInflater.Factory2 createLayoutInflaterFactory(String viewTypeToReplace,
            View replacementView) {
        return new LayoutInflater.Factory2() {