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

Commit f3054ea8 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fix SetupWizard crash when creating Guest or Restricted profile

Delay the launch of Home until after the USER_INITIALIZE broadcasts
are delivered, to make sure that any disabled HOME activities are
enabled.

Bug: 15709297
Change-Id: I796a40131f82989782cf5699bcc2e1da2cafbc6b
parent 1df3f99d
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
@@ -17519,7 +17519,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        d.show();
    }
    private boolean startUser(final int userId, boolean foreground) {
    private boolean startUser(final int userId, final boolean foreground) {
        if (checkCallingPermission(INTERACT_ACROSS_USERS_FULL)
                != PackageManager.PERMISSION_GRANTED) {
            String msg = "Permission Denial: switchUser() from pid="
@@ -17643,7 +17643,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                                    public void performReceive(Intent intent, int resultCode,
                                            String data, Bundle extras, boolean ordered,
                                            boolean sticky, int sendingUser) {
                                        userInitialized(uss, userId);
                                        onUserInitialized(uss, foreground, oldUserId, userId);
                                    }
                                }, 0, null, null, null, AppOpsManager.OP_NONE,
                                true, false, MY_PID, Process.SYSTEM_UID,
@@ -17655,15 +17655,9 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
                if (foreground) {
                    boolean homeInFront = mStackSupervisor.switchUserLocked(userId, uss);
                    if (homeInFront) {
                        startHomeActivityLocked(userId);
                    } else {
                        mStackSupervisor.resumeTopActivitiesLocked();
                    if (!uss.initializing) {
                        moveUserToForeground(uss, oldUserId, userId);
                    }
                    EventLogTags.writeAmSwitchUser(userId);
                    getUserManagerLocked().userForeground(userId);
                    sendUserSwitchBroadcastsLocked(oldUserId, userId);
                } else {
                    mStackSupervisor.startBackgroundUserLocked(userId, uss);
                }
@@ -17789,10 +17783,28 @@ public final class ActivityManagerService extends ActivityManagerNative
                oldUserId, newUserId, uss));
    }
    void userInitialized(UserStartedState uss, int newUserId) {
    void onUserInitialized(UserStartedState uss, boolean foreground, int oldUserId, int newUserId) {
        synchronized (this) {
            if (foreground) {
                moveUserToForeground(uss, oldUserId, newUserId);
            }
        }
        completeSwitchAndInitalize(uss, newUserId, true, false);
    }
    void moveUserToForeground(UserStartedState uss, int oldUserId, int newUserId) {
        boolean homeInFront = mStackSupervisor.switchUserLocked(newUserId, uss);
        if (homeInFront) {
            startHomeActivityLocked(newUserId);
        } else {
            mStackSupervisor.resumeTopActivitiesLocked();
        }
        EventLogTags.writeAmSwitchUser(newUserId);
        getUserManagerLocked().userForeground(newUserId);
        sendUserSwitchBroadcastsLocked(oldUserId, newUserId);
    }
    void continueUserSwitch(UserStartedState uss, int oldUserId, int newUserId) {
        completeSwitchAndInitalize(uss, newUserId, false, true);
    }