Loading core/java/android/content/IntentSender.java +8 −0 Original line number Diff line number Diff line Loading @@ -417,4 +417,12 @@ public class IntentSender implements Parcelable { return mCachedInfo; } /** * Check if the PendingIntent is marked with {@link android.app.PendingIntent#FLAG_IMMUTABLE}. * @hide */ public boolean isImmutable() { return getCachedInfo().isImmutable(); } } core/java/android/content/pm/PackageInstaller.java +9 −0 Original line number Diff line number Diff line Loading @@ -1062,6 +1062,9 @@ public class PackageInstaller { * @param timeoutMillis The maximum time to wait, in milliseconds until the * constraints are satisfied. The caller will be notified via * {@code statusReceiver} if timeout happens before commit. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. */ public void commitSessionAfterInstallConstraintsAreMet(int sessionId, @NonNull IntentSender statusReceiver, @NonNull InstallConstraints constraints, Loading Loading @@ -1736,6 +1739,9 @@ public class PackageInstaller { * * @throws SecurityException if streams opened through * {@link #openWrite(String, long, long)} are still open. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. * * @see android.app.admin.DevicePolicyManager * @see #requestUserPreapproval Loading Loading @@ -1764,6 +1770,9 @@ public class PackageInstaller { * @param statusReceiver Called when the state of the session changes. Intents * sent to this receiver contain {@link #EXTRA_STATUS}. Refer to the * individual status codes on how to handle them. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. * * @hide */ Loading services/core/java/com/android/server/pm/PackageInstallerSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.app.NotificationManager; import android.app.admin.DevicePolicyEventLogger; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManagerInternal; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.ComponentName; Loading Loading @@ -333,6 +334,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private static final int APP_METADATA_FILE_ACCESS_MODE = 0640; /** * Throws IllegalArgumentException if the {@link IntentSender} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. */ @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) private static final long THROW_EXCEPTION_COMMIT_WITH_IMMUTABLE_PENDING_INTENT = 240618202L; // TODO: enforce INSTALL_ALLOW_TEST // TODO: enforce INSTALL_ALLOW_DOWNGRADE Loading Loading @@ -1864,6 +1874,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @Override public void commit(@NonNull IntentSender statusReceiver, boolean forTransfer) { assertNotChild("commit"); boolean throwsExceptionCommitImmutableCheck = CompatChanges.isChangeEnabled( THROW_EXCEPTION_COMMIT_WITH_IMMUTABLE_PENDING_INTENT, Binder.getCallingUid()); if (throwsExceptionCommitImmutableCheck && statusReceiver.isImmutable()) { throw new IllegalArgumentException( "The commit() status receiver should come from a mutable PendingIntent"); } if (!markAsSealed(statusReceiver, forTransfer)) { return; Loading Loading
core/java/android/content/IntentSender.java +8 −0 Original line number Diff line number Diff line Loading @@ -417,4 +417,12 @@ public class IntentSender implements Parcelable { return mCachedInfo; } /** * Check if the PendingIntent is marked with {@link android.app.PendingIntent#FLAG_IMMUTABLE}. * @hide */ public boolean isImmutable() { return getCachedInfo().isImmutable(); } }
core/java/android/content/pm/PackageInstaller.java +9 −0 Original line number Diff line number Diff line Loading @@ -1062,6 +1062,9 @@ public class PackageInstaller { * @param timeoutMillis The maximum time to wait, in milliseconds until the * constraints are satisfied. The caller will be notified via * {@code statusReceiver} if timeout happens before commit. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. */ public void commitSessionAfterInstallConstraintsAreMet(int sessionId, @NonNull IntentSender statusReceiver, @NonNull InstallConstraints constraints, Loading Loading @@ -1736,6 +1739,9 @@ public class PackageInstaller { * * @throws SecurityException if streams opened through * {@link #openWrite(String, long, long)} are still open. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. * * @see android.app.admin.DevicePolicyManager * @see #requestUserPreapproval Loading Loading @@ -1764,6 +1770,9 @@ public class PackageInstaller { * @param statusReceiver Called when the state of the session changes. Intents * sent to this receiver contain {@link #EXTRA_STATUS}. Refer to the * individual status codes on how to handle them. * @throws IllegalArgumentException if the {@code statusReceiver} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. * * @hide */ Loading
services/core/java/com/android/server/pm/PackageInstallerSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.app.NotificationManager; import android.app.admin.DevicePolicyEventLogger; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManagerInternal; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.ComponentName; Loading Loading @@ -333,6 +334,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private static final int APP_METADATA_FILE_ACCESS_MODE = 0640; /** * Throws IllegalArgumentException if the {@link IntentSender} from an immutable * {@link android.app.PendingIntent} when caller has a target SDK of API * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or above. */ @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) private static final long THROW_EXCEPTION_COMMIT_WITH_IMMUTABLE_PENDING_INTENT = 240618202L; // TODO: enforce INSTALL_ALLOW_TEST // TODO: enforce INSTALL_ALLOW_DOWNGRADE Loading Loading @@ -1864,6 +1874,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @Override public void commit(@NonNull IntentSender statusReceiver, boolean forTransfer) { assertNotChild("commit"); boolean throwsExceptionCommitImmutableCheck = CompatChanges.isChangeEnabled( THROW_EXCEPTION_COMMIT_WITH_IMMUTABLE_PENDING_INTENT, Binder.getCallingUid()); if (throwsExceptionCommitImmutableCheck && statusReceiver.isImmutable()) { throw new IllegalArgumentException( "The commit() status receiver should come from a mutable PendingIntent"); } if (!markAsSealed(statusReceiver, forTransfer)) { return; Loading