summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Achim Thesmann <achim@google.com> 2024-07-23 00:06:51 +0000
committer Achim Thesmann <achim@google.com> 2024-07-29 20:20:08 +0000
commit048c91aa6a57667f061a6f2998a0438d8d06b1c9 (patch)
tree0f6a38edde5d3d319e226d92e859469097cb6447
parentbf13f5baca4d4be134517ed4a29542caa3f16b6d (diff)
Revert removal of hidden sendIntent method
While the method is not used in the system, one CTS test uses the method, and therefore it cannot be removed even so it is an internal API. Also updates PackageArchiverTest to use fixed types, as the reintroduced hidden and the public API have the same number of parameters and compilations fails passing in only generic types. Test: atest PackageManagerTest Bug: 354597253 Flag: EXEMPT bugfix Change-Id: I5c76136c159b2899e9f94e4587b38d07fbf6ca77
-rw-r--r--core/java/android/content/IntentSender.java48
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/PackageArchiverTest.java8
2 files changed, 52 insertions, 4 deletions
diff --git a/core/java/android/content/IntentSender.java b/core/java/android/content/IntentSender.java
index 32d1964dd4f0..ca6d86ae2dd8 100644
--- a/core/java/android/content/IntentSender.java
+++ b/core/java/android/content/IntentSender.java
@@ -16,6 +16,8 @@
package android.content;
+import static android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM;
+
import android.annotation.FlaggedApi;
import android.annotation.Nullable;
import android.app.ActivityManager;
@@ -23,6 +25,9 @@ import android.app.ActivityManager.PendingIntentInfo;
import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.IApplicationThread;
+import android.app.compat.CompatChanges;
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Bundle;
import android.os.Handler;
@@ -65,6 +70,11 @@ import java.util.concurrent.Executor;
* {@link android.app.PendingIntent#getIntentSender() PendingIntent.getIntentSender()}.
*/
public class IntentSender implements Parcelable {
+ /** If enabled consider the deprecated @hide method as removed. */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = VANILLA_ICE_CREAM)
+ private static final long REMOVE_HIDDEN_SEND_INTENT_METHOD = 356174596;
+
private static final Bundle SEND_INTENT_DEFAULT_OPTIONS =
ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT).toBundle();
@@ -220,6 +230,44 @@ public class IntentSender implements Parcelable {
* original Intent. Use {@code null} to not modify the original Intent.
* @param onFinished The object to call back on when the send has
* completed, or {@code null} for no callback.
+ * @param handler Handler identifying the thread on which the callback
+ * should happen. If {@code null}, the callback will happen from the thread
+ * pool of the process.
+ * @param options Additional options the caller would like to provide to modify the sending
+ * behavior. Typically built from using {@link ActivityOptions} to apply to an activity start.
+ *
+ * @throws SendIntentException Throws CanceledIntentException if the IntentSender
+ * is no longer allowing more intents to be sent through it.
+ *
+ * @deprecated use {@link #sendIntent(Context, int, Intent, String, Bundle, Executor,
+ * OnFinished)}
+ *
+ * @hide
+ */
+ @Deprecated public void sendIntent(Context context, int code, Intent intent,
+ OnFinished onFinished, Handler handler, String requiredPermission,
+ @Nullable Bundle options)
+ throws SendIntentException {
+ if (CompatChanges.isChangeEnabled(REMOVE_HIDDEN_SEND_INTENT_METHOD)) {
+ throw new NoSuchMethodError("This overload of sendIntent was removed.");
+ }
+ sendIntent(context, code, intent, requiredPermission, options,
+ handler == null ? null : handler::post, onFinished);
+ }
+
+ /**
+ * Perform the operation associated with this IntentSender, allowing the
+ * caller to specify information about the Intent to use and be notified
+ * when the send has completed.
+ *
+ * @param context The Context of the caller. This may be {@code null} if
+ * <var>intent</var> is also {@code null}.
+ * @param code Result code to supply back to the IntentSender's target.
+ * @param intent Additional Intent data. See {@link Intent#fillIn
+ * Intent.fillIn()} for information on how this is applied to the
+ * original Intent. Use {@code null} to not modify the original Intent.
+ * @param onFinished The object to call back on when the send has
+ * completed, or {@code null} for no callback.
* @param executor Executor identifying the thread on which the callback
* should happen. If {@code null}, the callback will happen from the thread
* pool of the process.
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/PackageArchiverTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/PackageArchiverTest.java
index 8d0b2797d200..fc28f9ef2a13 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/PackageArchiverTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/PackageArchiverTest.java
@@ -266,8 +266,8 @@ public class PackageArchiverTest {
rule.mocks().getHandler().flush();
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mIntentSender).sendIntent(any(), anyInt(), intentCaptor.capture(), any(), any(),
- any(), any());
+ verify(mIntentSender).sendIntent(any(), anyInt(), intentCaptor.capture(), any(),
+ (Bundle) any(), any(), any());
Intent value = intentCaptor.getValue();
assertThat(value.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)).isEqualTo(PACKAGE);
assertThat(value.getIntExtra(PackageInstaller.EXTRA_STATUS, 0)).isEqualTo(
@@ -336,8 +336,8 @@ public class PackageArchiverTest {
rule.mocks().getHandler().flush();
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mIntentSender).sendIntent(any(), anyInt(), intentCaptor.capture(), any(), any(),
- any(), any());
+ verify(mIntentSender).sendIntent(any(), anyInt(), intentCaptor.capture(), any(),
+ (Bundle) any(), any(), any());
Intent value = intentCaptor.getValue();
assertThat(value.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)).isEqualTo(PACKAGE);
assertThat(value.getIntExtra(PackageInstaller.EXTRA_STATUS, 0)).isEqualTo(