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

Commit 0a77f979 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Send EXTRA_TIME with PACKAGE_RESTARTED broadcast

The time can be used to understand relative ordering
of stopped state changes with other API calls into a service.

Bug: 300349952
Test: atest ForceStopTest
Change-Id: I13195bec32742b40abd4a9d6067974419fbbc36c
parent 281c3994
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import android.os.Process;
import android.os.ResultReceiver;
import android.os.ShellCommand;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.ContactsContract.QuickContact;
@@ -2796,6 +2797,8 @@ public class Intent implements Parcelable, Cloneable {
     * started and is no longer considered stopped.
     * <ul>
     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
     * <li> {@link #EXTRA_TIME} containing the {@link SystemClock#elapsedRealtime()
     *          elapsed realtime} of when the package was unstopped.
     * </ul>
     *
     * <p class="note">This is a protected intent that can only be sent by the system.
@@ -2869,9 +2872,15 @@ public class Intent implements Parcelable, Cloneable {
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
     * <p>
     * Starting in {@link Build.VERSION_CODES#VANILLA_ICE_CREAM Android V}, an extra timestamp
     * {@link #EXTRA_TIME} is included with this broadcast to indicate the exact time the package
     * was restarted, in {@link SystemClock#elapsedRealtime() elapsed realtime}.
     * </p>
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
    /**
     * Broadcast Action: The user has cleared the data of a package.  This should
     * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
@@ -6576,8 +6585,8 @@ public class Intent implements Parcelable, Cloneable {
            = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
    /**
     * Optional extra specifying a time in milliseconds since the Epoch. The value must be
     * non-negative.
     * Optional extra specifying a time in milliseconds. The timebase depends on the Intent
     * including this extra. The value must be non-negative.
     * <p>
     * Type: long
     * </p>
+2 −0
Original line number Diff line number Diff line
@@ -4564,6 +4564,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                final Bundle extras = new Bundle();
                extras.putInt(Intent.EXTRA_UID, pmi.getPackageUid(packageName, 0, userId));
                extras.putInt(Intent.EXTRA_USER_HANDLE, userId);
                extras.putLong(Intent.EXTRA_TIME, SystemClock.elapsedRealtime());
                mHandler.post(() -> {
                    mBroadcastHelper.sendPackageBroadcast(Intent.ACTION_PACKAGE_UNSTOPPED,
                            packageName, extras,
@@ -6959,6 +6960,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            final Bundle extras = new Bundle();
            extras.putInt(Intent.EXTRA_UID, uid);
            extras.putInt(Intent.EXTRA_USER_HANDLE, userId);
            extras.putLong(Intent.EXTRA_TIME, SystemClock.elapsedRealtime());
            mHandler.post(() -> {
                mBroadcastHelper.sendPackageBroadcast(Intent.ACTION_PACKAGE_RESTARTED,
                        packageName, extras,