Explicitly set PendingIntent.FLAG_IMMUTABLE

Fixes: 178079297

Test: atest
frameworks/base/core/tests/coretests/src/android/view/textclassifier

Change-Id: I80702b948ea1ea228147859dc10fe5b507eadb7d
This commit is contained in:
Tony Mak
2021-01-21 20:37:17 +00:00
parent 29779f5658
commit cd740df769
3 changed files with 13 additions and 6 deletions

View File

@@ -39,7 +39,8 @@ public final class ConversationActionTest {
@Test
public void toBuilder() {
final Context context = InstrumentationRegistry.getTargetContext();
final PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_MUTABLE_UNAUDITED);
final PendingIntent intent = PendingIntent.getActivity(
context, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE);
final Icon icon = Icon.createWithData(new byte[]{0}, 0, 1);
final Bundle extras = new Bundle();
extras.putInt("key", 5);

View File

@@ -16,6 +16,8 @@
package android.view.textclassifier;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -79,7 +81,7 @@ public class TextClassificationTest {
final String primaryDescription = "primaryDescription";
final Intent primaryIntent = new Intent("primaryIntentAction");
final PendingIntent primaryPendingIntent = PendingIntent.getActivity(context, 0,
primaryIntent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
primaryIntent, FLAG_IMMUTABLE);
final RemoteAction remoteAction0 = new RemoteAction(primaryIcon, primaryLabel,
primaryDescription, primaryPendingIntent);
@@ -88,7 +90,7 @@ public class TextClassificationTest {
final String secondaryDescription = "secondaryDescription";
final Intent secondaryIntent = new Intent("secondaryIntentAction");
final PendingIntent secondaryPendingIntent = PendingIntent.getActivity(context, 0,
secondaryIntent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
secondaryIntent, FLAG_IMMUTABLE);
final RemoteAction remoteAction1 = new RemoteAction(secondaryIcon, secondaryLabel,
secondaryDescription, secondaryPendingIntent);
@@ -156,7 +158,7 @@ public class TextClassificationTest {
final int iconColor = Color.RED;
final String label = "label";
final PendingIntent pendingIntent = PendingIntent.getActivity(
context, 0, new Intent("ACTION_0"), PendingIntent.FLAG_MUTABLE_UNAUDITED);
context, 0, new Intent("ACTION_0"), FLAG_IMMUTABLE);
final RemoteAction remoteAction = new RemoteAction(
generateTestIcon(width, height, iconColor),
label,
@@ -239,7 +241,8 @@ public class TextClassificationTest {
.setIntent(new Intent("action"))
.setOnClickListener(view -> { })
.addAction(new RemoteAction(icon1, "title1", "desc1",
PendingIntent.getActivity(context, 0, new Intent("action1"), PendingIntent.FLAG_MUTABLE_UNAUDITED)))
PendingIntent.getActivity(
context, 0, new Intent("action1"), FLAG_IMMUTABLE)))
.addAction(new RemoteAction(icon1, "title2", "desc2",
PendingIntent.getActivity(context, 0, new Intent("action2"), 0)))
.setEntityType(TextClassifier.TYPE_EMAIL, 0.5f)

View File

@@ -16,6 +16,8 @@
package android.view.textclassifier;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
@@ -128,7 +130,8 @@ public class TextSelectionTest {
final TextClassification classification = new TextClassification.Builder()
.addAction(new RemoteAction(icon1, "title1", "desc1",
PendingIntent.getActivity(context, 0, new Intent("action1"), 0)))
PendingIntent.getActivity(
context, 0, new Intent("action1"), FLAG_IMMUTABLE)))
.setEntityType(TextClassifier.TYPE_ADDRESS, 1.0f)
.build();
final TextSelection textSelection = new TextSelection.Builder(startIndex, endIndex)