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

Commit 12ebb293 authored by Roman Birg's avatar Roman Birg Committed by Ricardo Cerqueira
Browse files

SetupWizard: don't allow skipping FRP



Fixes CYNGNOS-707
Change-Id: I7532c0c68418458b921a98e556ee3172b2cf1af3
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
(cherry picked from commit d587f56e)
parent f38055d3
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -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) {
+26 −8
Original line number Diff line number Diff line
@@ -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 {
                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();
        }
    }

    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)) {
                                if (canSkip()) {
                                    getCallbacks().onNextPage();
                                } else {
                                    getCallbacks().onPreviousPage();
                                }
                            }
                        }
                    }