Loading core/java/android/widget/RemoteViews.java +19 −11 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import com.android.internal.R; import com.android.internal.util.Preconditions; import com.android.internal.widget.IRemoteViewsFactory; import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.player.RemoteComposeDocument; import com.android.internal.widget.remotecompose.player.RemoteComposePlayer; Loading Loading @@ -3902,7 +3903,6 @@ public class RemoteViews implements Parcelable, Filter { throws ActionException { if (drawDataParcel() && mInstructions != null && root instanceof RemoteComposePlayer player) { player.setTag(mInstructions); final List<byte[]> bytes = mInstructions.mInstructions; if (bytes.isEmpty()) { return; Loading Loading @@ -6082,10 +6082,13 @@ public class RemoteViews implements Parcelable, Filter { if (applyThemeResId != 0) { inflationContext = new ContextThemeWrapper(inflationContext, applyThemeResId); } View v; // If the RemoteViews contains draw instructions, just use it instead. if (rv.hasDrawInstructions()) { return new RemoteComposePlayer(inflationContext); } final RemoteComposePlayer player = new RemoteComposePlayer(inflationContext); player.setDebug(Build.IS_USERDEBUG || Build.IS_ENG ? 1 : 0); v = player; } else { LayoutInflater inflater = LayoutInflater.from(context); // Clone inflater so we load resources from correct context and Loading @@ -6095,7 +6098,8 @@ public class RemoteViews implements Parcelable, Filter { if (mLayoutInflaterFactory2 != null) { inflater.setFactory2(mLayoutInflaterFactory2); } View v = inflater.inflate(rv.getLayoutId(), parent, false); v = inflater.inflate(rv.getLayoutId(), parent, false); } if (mViewId != View.NO_ID) { v.setId(mViewId); v.setTagInternal(R.id.remote_views_override_id, mViewId); Loading Loading @@ -6441,6 +6445,10 @@ public class RemoteViews implements Parcelable, Filter { if (params.handler == null) { params.handler = DEFAULT_INTERACTION_HANDLER; } if (v instanceof RemoteComposePlayer player) { player.setTheme(v.getResources().getConfiguration().isNightModeActive() ? Theme.DARK : Theme.LIGHT); } if (mActions != null) { final int count = mActions.size(); for (int i = 0; i < count; i++) { Loading core/tests/coretests/src/android/widget/RemoteViewsTest.java +0 −22 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.widget; import static android.appwidget.flags.Flags.drawDataParcel; import static com.android.internal.R.id.pending_intent_tag; import static org.junit.Assert.assertArrayEquals; Loading Loading @@ -65,7 +63,6 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDownLatch; Loading Loading @@ -417,25 +414,6 @@ public class RemoteViewsTest { assertNotNull(view.findViewById(R.id.light_background_text)); } @Test public void remoteCanvasCanAccessDrawInstructions() { if (!drawDataParcel()) { return; } final byte[] bytes = new byte[] {'h', 'e', 'l', 'l', 'o'}; final RemoteViews.DrawInstructions drawInstructions = new RemoteViews.DrawInstructions.Builder(Collections.singletonList(bytes)).build(); final RemoteViews rv = new RemoteViews(drawInstructions); final PendingIntent pi = PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_VIEW), PendingIntent.FLAG_IMMUTABLE); final Intent i = new Intent().putExtra("TEST", "Success"); final int viewId = 1; rv.setPendingIntentTemplate(viewId, pi); rv.setOnClickFillInIntent(viewId, i); final View view = rv.apply(mContext, mContainer); assertEquals(drawInstructions, view.getTag()); } private RemoteViews createViewChained(int depth, String... texts) { RemoteViews result = new RemoteViews(mPackage, R.layout.remote_view_host); Loading Loading
core/java/android/widget/RemoteViews.java +19 −11 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import com.android.internal.R; import com.android.internal.util.Preconditions; import com.android.internal.widget.IRemoteViewsFactory; import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.player.RemoteComposeDocument; import com.android.internal.widget.remotecompose.player.RemoteComposePlayer; Loading Loading @@ -3902,7 +3903,6 @@ public class RemoteViews implements Parcelable, Filter { throws ActionException { if (drawDataParcel() && mInstructions != null && root instanceof RemoteComposePlayer player) { player.setTag(mInstructions); final List<byte[]> bytes = mInstructions.mInstructions; if (bytes.isEmpty()) { return; Loading Loading @@ -6082,10 +6082,13 @@ public class RemoteViews implements Parcelable, Filter { if (applyThemeResId != 0) { inflationContext = new ContextThemeWrapper(inflationContext, applyThemeResId); } View v; // If the RemoteViews contains draw instructions, just use it instead. if (rv.hasDrawInstructions()) { return new RemoteComposePlayer(inflationContext); } final RemoteComposePlayer player = new RemoteComposePlayer(inflationContext); player.setDebug(Build.IS_USERDEBUG || Build.IS_ENG ? 1 : 0); v = player; } else { LayoutInflater inflater = LayoutInflater.from(context); // Clone inflater so we load resources from correct context and Loading @@ -6095,7 +6098,8 @@ public class RemoteViews implements Parcelable, Filter { if (mLayoutInflaterFactory2 != null) { inflater.setFactory2(mLayoutInflaterFactory2); } View v = inflater.inflate(rv.getLayoutId(), parent, false); v = inflater.inflate(rv.getLayoutId(), parent, false); } if (mViewId != View.NO_ID) { v.setId(mViewId); v.setTagInternal(R.id.remote_views_override_id, mViewId); Loading Loading @@ -6441,6 +6445,10 @@ public class RemoteViews implements Parcelable, Filter { if (params.handler == null) { params.handler = DEFAULT_INTERACTION_HANDLER; } if (v instanceof RemoteComposePlayer player) { player.setTheme(v.getResources().getConfiguration().isNightModeActive() ? Theme.DARK : Theme.LIGHT); } if (mActions != null) { final int count = mActions.size(); for (int i = 0; i < count; i++) { Loading
core/tests/coretests/src/android/widget/RemoteViewsTest.java +0 −22 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.widget; import static android.appwidget.flags.Flags.drawDataParcel; import static com.android.internal.R.id.pending_intent_tag; import static org.junit.Assert.assertArrayEquals; Loading Loading @@ -65,7 +63,6 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDownLatch; Loading Loading @@ -417,25 +414,6 @@ public class RemoteViewsTest { assertNotNull(view.findViewById(R.id.light_background_text)); } @Test public void remoteCanvasCanAccessDrawInstructions() { if (!drawDataParcel()) { return; } final byte[] bytes = new byte[] {'h', 'e', 'l', 'l', 'o'}; final RemoteViews.DrawInstructions drawInstructions = new RemoteViews.DrawInstructions.Builder(Collections.singletonList(bytes)).build(); final RemoteViews rv = new RemoteViews(drawInstructions); final PendingIntent pi = PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_VIEW), PendingIntent.FLAG_IMMUTABLE); final Intent i = new Intent().putExtra("TEST", "Success"); final int viewId = 1; rv.setPendingIntentTemplate(viewId, pi); rv.setOnClickFillInIntent(viewId, i); final View view = rv.apply(mContext, mContainer); assertEquals(drawInstructions, view.getTag()); } private RemoteViews createViewChained(int depth, String... texts) { RemoteViews result = new RemoteViews(mPackage, R.layout.remote_view_host); Loading