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

Commit 518d54e3 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Preventing launcher preload if user setup is not complete

Also fixing some leaks due to not destroying RecentsAnimationDeviceState

Bug: 155350432
Change-Id: I70f510c3db03515d5889f0bcde6a15a9456e9791
parent 2a4dce14
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -79,12 +79,13 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {

    @Override
    protected Activity getCurrentActivity() {
        OverviewComponentObserver observer = new OverviewComponentObserver(mContext,
                new RecentsAnimationDeviceState(mContext));
        RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(mContext);
        OverviewComponentObserver observer = new OverviewComponentObserver(mContext, rads);
        try {
            return observer.getActivityInterface().getCreatedActivity();
        } finally {
            observer.onDestroy();
            rads.destroy();
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -725,12 +725,13 @@ public class TouchInteractionService extends Service implements PluginListener<O
        if (!mDeviceState.isUserUnlocked()) {
            return;
        }

        if (mDeviceState.isButtonNavMode() && !mOverviewComponentObserver.isHomeAndOverviewSame()) {
            // Prevent the overview from being started before the real home on first boot.
            return;
        }

        if (RestoreDbTask.isPending(this)) {
        if (RestoreDbTask.isPending(this) || !mDeviceState.isUserSetupComplete()) {
            // Preloading while a restore is pending may cause launcher to start the restore
            // too early.
            return;
+22 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.content.res.Resources;
import android.graphics.Region;
import android.os.Process;
import android.os.UserManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.MotionEvent;

@@ -53,6 +54,7 @@ import androidx.annotation.BinderThread;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.DefaultDisplay;
import com.android.launcher3.util.SecureSettingsObserver;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.util.NavBarPosition;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -128,6 +130,8 @@ public class RecentsAnimationDeviceState implements
    private boolean mInOverview;
    private boolean mTaskListFrozen;

    private boolean mIsUserSetupComplete;

    public RecentsAnimationDeviceState(Context context) {
        mContext = context;
        mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
@@ -178,6 +182,17 @@ public class RecentsAnimationDeviceState implements
                        ComponentName.unflattenFromString(blockingActivity));
            }
        }

        SecureSettingsObserver userSetupObserver = new SecureSettingsObserver(
                context.getContentResolver(),
                e -> mIsUserSetupComplete = e,
                Settings.Secure.USER_SETUP_COMPLETE,
                0);
        mIsUserSetupComplete = userSetupObserver.getValue();
        if (!mIsUserSetupComplete) {
            userSetupObserver.register();
            runOnDestroy(userSetupObserver::unregister);
        }
    }

    private void setupOrientationSwipeHandler() {
@@ -318,6 +333,13 @@ public class RecentsAnimationDeviceState implements
        return mIsUserUnlocked;
    }

    /**
     * @return whether the user has completed setup wizard
     */
    public boolean isUserSetupComplete() {
        return mIsUserSetupComplete;
    }

    private void notifyUserUnlocked() {
        for (Runnable action : mUserUnlockedActions) {
            action.run();
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ final class HomeGestureTutorialController extends TutorialController {
        mViewSwipeUpAnimation = new ViewSwipeUpAnimation(mContext, deviceState,
                new GestureState(observer, -1));
        observer.onDestroy();
        deviceState.destroy();

        DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext)
                .getDeviceProfile(mContext)