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

Commit bedbaa9e authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Flesh out user locked/unlocked lifecycle.

When a user is first started, we assume that they're "locked" meaning
that credential-encrypted data is unavailable.  Once credentials have
been supplied, we can transition the user to a fully running state.

To facilitate this lifecycle, UserState now has two separate
RUNNING_LOCKED and RUNNING states.  To ensure consistent events are
sent on all devices, we always step through RUNNING_LOCKED before
arriving at RUNNING.  This consistency means that apps processing
data based on the new ACTION_LOCKED_BOOT_COMPLETED broadcast and
system services using the new onUnlockUser() event will be less
bug-prone over time.

If the user storage is unlocked (which is the case on the majority
of legacy devices), we immediately transition from the RUNNING_LOCKED
into the RUNNING state.

Add logging for all state transitions.

When we "recover" a user in the process of being shut down, return
to the last known state.

Bug: 25943941
Change-Id: I5fec980f10b0d0fb2c272a662d193dc15136f9b9
parent 10ad84a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8285,6 +8285,7 @@ package android.content {
    field public static final java.lang.String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
    field public static final java.lang.String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
    field public static final java.lang.String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
    field public static final java.lang.String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
    field public static final java.lang.String ACTION_MAIN = "android.intent.action.MAIN";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_ADDED = "android.intent.action.MANAGED_PROFILE_ADDED";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_REMOVED = "android.intent.action.MANAGED_PROFILE_REMOVED";
+1 −0
Original line number Diff line number Diff line
@@ -8542,6 +8542,7 @@ package android.content {
    field public static final java.lang.String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
    field public static final java.lang.String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
    field public static final java.lang.String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
    field public static final java.lang.String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
    field public static final java.lang.String ACTION_MAIN = "android.intent.action.MAIN";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_ADDED = "android.intent.action.MANAGED_PROFILE_ADDED";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_REMOVED = "android.intent.action.MANAGED_PROFILE_REMOVED";
+1 −0
Original line number Diff line number Diff line
@@ -8285,6 +8285,7 @@ package android.content {
    field public static final java.lang.String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
    field public static final java.lang.String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
    field public static final java.lang.String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
    field public static final java.lang.String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
    field public static final java.lang.String ACTION_MAIN = "android.intent.action.MAIN";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_ADDED = "android.intent.action.MANAGED_PROFILE_ADDED";
    field public static final java.lang.String ACTION_MANAGED_PROFILE_REMOVED = "android.intent.action.MANAGED_PROFILE_REMOVED";
+19 −0
Original line number Diff line number Diff line
@@ -1926,6 +1926,24 @@ public class Intent implements Parcelable, Cloneable {
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";

    /**
     * Broadcast Action: This is broadcast once, after the system has finished
     * booting and the user is in a "locked" state. A user is locked when their
     * credential-encrypted private app data storage is unavailable. Once the
     * user has entered their credentials (such as a lock pattern or PIN) for
     * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
     * sent.
     * <p>
     * You must hold the
     * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
     * order to receive this broadcast.
     * <p class="note">
     * This is a protected intent that can only be sent by the system.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";

    /**
     * Broadcast Action: This is broadcast once, after the system has finished
     * booting.  It can be used to perform application-specific initialization,
@@ -1938,6 +1956,7 @@ public class Intent implements Parcelable, Cloneable {
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";

    /**
     * Broadcast Action: This is broadcast when a user action should request a
     * temporary system dialog to dismiss.  Some examples of temporary system
+9 −0
Original line number Diff line number Diff line
@@ -132,6 +132,15 @@ public abstract class SystemService {
     */
    public void onStartUser(int userHandle) {}

    /**
     * Called when an existing user is unlocked. This means the
     * credential-encrypted storage for that user is now available, and
     * encryption-aware component filtering is no longer in effect.
     *
     * @param userHandle The identifier of the user.
     */
    public void onUnlockUser(int userHandle) {}

    /**
     * Called when switching to a different foreground user, for system services that have
     * special behavior for whichever user is currently in the foreground.  This is called
Loading