SetupWizard: Adjust FRP-enforcing logic

* Always pass ALLOW_SKIP to GMS, it's smart enough to know when it
   can't be applied.
 * Don't bring up the authentication screen if no-network and canSkip

Still CYNGNOS-707

Change-Id: Ia1a81c4443cfd5bc3c3e5fd84758ff0ba2a2a140
This commit is contained in:
Ricardo Cerqueira 2015-08-10 13:07:37 +01:00
parent d587f56e2e
commit 649a5ec162
2 changed files with 9 additions and 4 deletions

View File

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

View File

@ -211,9 +211,10 @@ public class GmsAccountPage extends SetupPage {
} }
} }
private boolean canSkip() { public boolean canSkip() {
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager) final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE); mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
Log.d(TAG,"GMS skip: OEM unlock is enabled: " + pdbManager.getOemUnlockEnabled() + " and amount of PST blocks is " + pdbManager.getDataBlockSize());
return pdbManager == null return pdbManager == null
|| pdbManager.getDataBlockSize() == 0 || pdbManager.getDataBlockSize() == 0
|| pdbManager.getOemUnlockEnabled(); || pdbManager.getOemUnlockEnabled();
@ -222,7 +223,7 @@ public class GmsAccountPage extends SetupPage {
private void launchGmsAccountSetup() { private void launchGmsAccountSetup() {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true); bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, canSkip()); bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true); bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
AccountManager AccountManager
.get(mContext).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null, .get(mContext).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null,