SetupWizard: don't allow skipping FRP

Change-Id: I7532c0c68418458b921a98e556ee3172b2cf1af3
Signed-off-by: Roman Birg <roman@cyngn.com>
This commit is contained in:
Roman Birg 2015-08-07 12:13:32 -07:00 committed by Gerrit Code Review
parent 48115dde4c
commit d587f56e2e
2 changed files with 28 additions and 14 deletions

View File

@ -64,7 +64,7 @@ public class CMSetupWizardData extends AbstractSetupData {
.setHidden(!isSimInserted() || mMobileDataEnabled));
}
if (SetupWizardUtils.hasGMS(mContext)) {
pages.add(new GmsAccountPage(mContext, this).setHidden(true));
pages.add(new GmsAccountPage(mContext, this));
}
if (!SetupWizardUtils.hasLeanback(mContext)) {
pages.add(new CyanogenServicesPage(mContext, this).setHidden(true));
@ -109,11 +109,7 @@ public class CMSetupWizardData extends AbstractSetupData {
private void showHideAccountPages() {
boolean isConnected = SetupWizardUtils.isNetworkConnected(mContext);
GmsAccountPage gmsAccountPage =
(GmsAccountPage) getPage(GmsAccountPage.TAG);
if (gmsAccountPage != null) {
gmsAccountPage.setHidden(!isConnected);
}
CyanogenServicesPage cyanogenServicesPage =
(CyanogenServicesPage) getPage(CyanogenServicesPage.TAG);
if (cyanogenServicesPage != null) {

View File

@ -32,6 +32,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Settings;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Log;
import com.cyanogenmod.setupwizard.R;
@ -160,16 +161,21 @@ public class GmsAccountPage extends SetupPage {
SetupStats.Action.EXTERNAL_PAGE_RESULT,
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "success");
getCallbacks().onNextPage();
} else {
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_RESULT,
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "skipped");
if (canSkip()) {
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_RESULT,
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "skipped");
getCallbacks().onNextPage();
} else {
getCallbacks().onPreviousPage();
}
}
if (SetupWizardUtils.accountExists(mContext, SetupWizardApp.ACCOUNT_TYPE_GMS)) {
setHidden(true);
}
getCallbacks().onNextPage();
}
}
@ -201,14 +207,22 @@ public class GmsAccountPage extends SetupPage {
e.printStackTrace();
// XXX: In open source, we don't know what gms version a user has.
// Bail if the restore activity is not found.
getCallbacks().onNextPage();
}
getCallbacks().onNextPage();
}
private boolean canSkip() {
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
return pdbManager == null
|| pdbManager.getDataBlockSize() == 0
|| pdbManager.getOemUnlockEnabled();
}
private void launchGmsAccountSetup() {
Bundle bundle = new Bundle();
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, canSkip());
bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
AccountManager
.get(mContext).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null,
@ -239,7 +253,11 @@ public class GmsAccountPage extends SetupPage {
} finally {
if (error && getCallbacks().
isCurrentPage(GmsAccountPage.this)) {
getCallbacks().onNextPage();
if (canSkip()) {
getCallbacks().onNextPage();
} else {
getCallbacks().onPreviousPage();
}
}
}
}