Preventing launcher preload if user setup is not complete

Also fixing some leaks due to not destroying RecentsAnimationDeviceState

Bug: 155350432
Change-Id: I70f510c3db03515d5889f0bcde6a15a9456e9791
This commit is contained in:
Sunny Goyal
2020-06-01 16:18:36 -07:00
parent 2a4dce1402
commit 518d54e3f2
4 changed files with 28 additions and 3 deletions
@@ -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();
}
}
@@ -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;
@@ -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();
@@ -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)