Java Code Examples for org.chromium.base.ApiCompatibilityUtils#isDemoUser()

The following examples show how to use org.chromium.base.ApiCompatibilityUtils#isDemoUser() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirstRunFlowSequencer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Starts determining parameters for the First Run.
 * Once finished, calls onFlowIsKnown().
 */
public void start() {
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(mActivity)) {
        onFlowIsKnown(null);
        return;
    }

    if (!mLaunchProperties.getBoolean(FirstRunActivity.EXTRA_USE_FRE_FLOW_SEQUENCER)) {
        onFlowIsKnown(mLaunchProperties);
        return;
    }

    new AndroidEduAndChildAccountHelper() {
        @Override
        public void onParametersReady() {
            processFreEnvironment(isAndroidEduDevice(), hasChildAccount());
        }
    }.start(mActivity.getApplicationContext());
}
 
Example 2
Source File: FirstRunFlowSequencer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Starts determining parameters for the First Run.
 * Once finished, calls onFlowIsKnown().
 */
public void start() {
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(mActivity)) {
        onFlowIsKnown(null);
        return;
    }

    new AndroidEduAndChildAccountHelper() {
        @Override
        public void onParametersReady() {
            initializeSharedState(isAndroidEduDevice(), hasChildAccount());
            processFreEnvironmentPreNative();
        }
    }.start(mActivity.getApplicationContext());
}
 
Example 3
Source File: FirstRunFlowSequencer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the First Run needs to be launched.
 * @return The intent to launch the First Run Experience if necessary, or null.
 * @param context The context.
 * @param fromIntent The intent that was used to launch Chrome.
 * @param forLightweightFre Whether this is a check for the Lightweight First Run Experience.
 */
public static Intent checkIfFirstRunIsNecessary(
        Context context, Intent fromIntent, boolean forLightweightFre) {
    // If FRE is disabled (e.g. in tests), proceed directly to the intent handling.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(context)) {
        return null;
    }

    if (fromIntent != null && fromIntent.getBooleanExtra(SKIP_FIRST_RUN_EXPERIENCE, false)) {
        return null;
    }

    // If Chrome isn't opened via the Chrome icon, and the user accepted the ToS
    // in the Setup Wizard, skip any First Run Experience screens and proceed directly
    // to the intent handling.
    final boolean fromChromeIcon =
            fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN);
    if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null;

    final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete();
    if (!baseFreComplete) {
        if (forLightweightFre
                && CommandLine.getInstance().hasSwitch(
                           ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
            if (!FirstRunStatus.shouldSkipWelcomePage()
                    && !FirstRunStatus.getLightweightFirstRunFlowComplete()) {
                return createLightweightFirstRunIntent(context, fromChromeIcon);
            }
        } else {
            return createGenericFirstRunIntent(context, fromChromeIcon);
        }
    }

    // Promo pages are removed, so there is nothing else to show in FRE.
    return null;
}
 
Example 4
Source File: FirstRunFlowSequencer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the First Run needs to be launched.
 * @param context The context.
 * @param fromIntent The intent that was used to launch Chrome.
 * @param forLightweightFre Whether this is a check for the Lightweight First Run Experience.
 * @return The intent to launch the First Run Experience if necessary, or null.
 */
@Nullable
public static Intent checkIfFirstRunIsNecessary(
        Context context, Intent fromIntent, boolean forLightweightFre) {
    // If FRE is disabled (e.g. in tests), proceed directly to the intent handling.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(context)) {
        return null;
    }

    if (fromIntent != null && fromIntent.getBooleanExtra(SKIP_FIRST_RUN_EXPERIENCE, false)) {
        return null;
    }

    // If Chrome isn't opened via the Chrome icon, and the user accepted the ToS
    // in the Setup Wizard, skip any First Run Experience screens and proceed directly
    // to the intent handling.
    final boolean fromChromeIcon =
            fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN);
    if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null;

    final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete();
    if (!baseFreComplete) {
        if (forLightweightFre
                && CommandLine.getInstance().hasSwitch(
                           ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
            if (!FirstRunStatus.shouldSkipWelcomePage()
                    && !FirstRunStatus.getLightweightFirstRunFlowComplete()) {
                return createLightweightFirstRunIntent(context, fromChromeIcon);
            }
        } else {
            return createGenericFirstRunIntent(context, fromChromeIcon);
        }
    }

    // Promo pages are removed, so there is nothing else to show in FRE.
    return null;
}
 
Example 5
Source File: SigninManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether true if the current user is not demo user and the user has a reasonable
 *         Google Play Services installed.
 */
public boolean isSigninSupported() {
    return !ApiCompatibilityUtils.isDemoUser(mContext)
            && !ExternalAuthUtils.getInstance().isGooglePlayServicesMissing(mContext);
}
 
Example 6
Source File: FirstRunSignInProcessor.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Initiates the automatic sign-in process in background.
 *
 * @param activity The context for the FRE parameters processor.
 */
public static void start(final Activity activity) {
    SigninManager signinManager = SigninManager.get(activity.getApplicationContext());
    signinManager.onFirstRunCheckDone();

    boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete();
    // We skip signin and the FRE if
    // - FRE is disabled, or
    // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(activity)
            || (!firstRunFlowComplete && ToSAckedReceiver.checkAnyUserHasSeenToS(activity))) {
        return;
    }

    // Force trigger the FRE if the Lightweight FRE is disabled or Chrome is started via Chrome
    // icon or via intent from GSA. Otherwise, skip signin.
    if (!firstRunFlowComplete) {
        if (!CommandLine.getInstance().hasSwitch(
                    ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)
                || TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN)
                || IntentHandler.determineExternalIntentSource(
                           activity.getPackageName(), activity.getIntent())
                        == ExternalAppId.GSA) {
            requestToFireIntentAndFinish(activity);
        }
        return;
    }

    // We are only processing signin from the FRE.
    if (getFirstRunFlowSignInComplete(activity)) {
        return;
    }
    final String accountName = getFirstRunFlowSignInAccountName(activity);
    if (!FeatureUtilities.canAllowSync(activity) || !signinManager.isSignInAllowed()
            || TextUtils.isEmpty(accountName)) {
        setFirstRunFlowSignInComplete(activity, true);
        return;
    }

    final boolean setUp = getFirstRunFlowSignInSetup(activity);
    signinManager.signIn(accountName, activity, new SignInCallback() {
        @Override
        public void onSignInComplete() {
            // Show sync settings if user pressed the "Settings" button.
            if (setUp) {
                openSignInSettings(activity);
            }
            setFirstRunFlowSignInComplete(activity, true);
        }

        @Override
        public void onSignInAborted() {
            // Set FRE as complete even if signin fails because the user has already seen and
            // accepted the terms of service.
            setFirstRunFlowSignInComplete(activity, true);
        }
    });
}
 
Example 7
Source File: SigninManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether true if the current user is not demo user and the user has a reasonable
 *         Google Play Services installed.
 */
public boolean isSigninSupported() {
    return !ApiCompatibilityUtils.isDemoUser(mContext)
            && !ExternalAuthUtils.getInstance().isGooglePlayServicesMissing(mContext);
}
 
Example 8
Source File: FirstRunSignInProcessor.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Initiates the automatic sign-in process in background.
 *
 * @param activity The context for the FRE parameters processor.
 */
public static void start(final Activity activity) {
    SigninManager signinManager = SigninManager.get(activity.getApplicationContext());
    signinManager.onFirstRunCheckDone();

    boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete();
    // We skip signin and the FRE if
    // - FRE is disabled, or
    // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(activity)
            || (!firstRunFlowComplete && ToSAckedReceiver.checkAnyUserHasSeenToS(activity))) {
        return;
    }

    // Force trigger the FRE if the Lightweight FRE is disabled or Chrome is started via Chrome
    // icon or via intent from GSA. Otherwise, skip signin.
    if (!firstRunFlowComplete) {
        if (!CommandLine.getInstance().hasSwitch(
                    ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)
                || TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN)
                || IntentHandler.determineExternalIntentSource(
                           activity.getPackageName(), activity.getIntent())
                        == ExternalAppId.GSA) {
            requestToFireIntentAndFinish(activity);
        }
        return;
    }

    // We are only processing signin from the FRE.
    if (getFirstRunFlowSignInComplete(activity)) {
        return;
    }
    final String accountName = getFirstRunFlowSignInAccountName(activity);
    if (!FeatureUtilities.canAllowSync(activity) || !signinManager.isSignInAllowed()
            || TextUtils.isEmpty(accountName)) {
        setFirstRunFlowSignInComplete(activity, true);
        return;
    }

    final boolean setUp = getFirstRunFlowSignInSetup(activity);
    signinManager.signIn(accountName, activity, new SignInCallback() {
        @Override
        public void onSignInComplete() {
            // Show sync settings if user pressed the "Settings" button.
            if (setUp) {
                openSignInSettings(activity);
            }
            setFirstRunFlowSignInComplete(activity, true);
        }

        @Override
        public void onSignInAborted() {
            // Set FRE as complete even if signin fails because the user has already seen and
            // accepted the terms of service.
            setFirstRunFlowSignInComplete(activity, true);
        }
    });
}
 
Example 9
Source File: MostVisitedSites.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@CalledByNative
private static boolean isPopularSitesForceEnabled() {
    return ApiCompatibilityUtils.isDemoUser(ContextUtils.getApplicationContext());
}