Search in sources :

Example 1 with FirstRunActivity

use of org.chromium.chrome.browser.firstrun.FirstRunActivity in project AndroidChromium by JackyAndroid.

the class ChromeLauncherActivity method launchFirstRunExperience.

/**
     * Tries to launch the First Run Experience.  If ChromeLauncherActivity is running with the
     * wrong Intent flags, we instead relaunch ChromeLauncherActivity to make sure it runs in its
     * own task, which then triggers First Run.
     * @return Whether or not the First Run Experience needed to be shown.
     * @param forTabbedMode Whether the First Run Experience is launched for tabbed mode.
     */
private boolean launchFirstRunExperience(boolean forTabbedMode) {
    // Tries to launch the Generic First Run Experience for intent from GSA.
    boolean showLightweightFre = IntentHandler.determineExternalIntentSource(this.getPackageName(), getIntent()) != ExternalAppId.GSA;
    Intent freIntent = FirstRunFlowSequencer.checkIfFirstRunIsNecessary(this, getIntent(), showLightweightFre);
    if (freIntent == null)
        return false;
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
            boolean isTabbedModeActive = false;
            boolean isLightweightFreActive = false;
            boolean isGenericFreActive = false;
            List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities();
            for (WeakReference<Activity> weakActivity : activities) {
                Activity activity = weakActivity.get();
                if (activity == null) {
                    continue;
                }
                if (activity instanceof ChromeTabbedActivity) {
                    isTabbedModeActive = true;
                    continue;
                }
                if (activity instanceof LightweightFirstRunActivity) {
                    isLightweightFreActive = true;
                    // A Generic or a new Lightweight First Run Experience will be launched
                    // below, so finish the old Lightweight First Run Experience.
                    activity.setResult(Activity.RESULT_CANCELED);
                    activity.finish();
                    continue;
                }
                if (activity instanceof FirstRunActivity) {
                    isGenericFreActive = true;
                    continue;
                }
            }
            if (forTabbedMode) {
                if (isTabbedModeActive || isLightweightFreActive || !showLightweightFre) {
                    // Lets ChromeTabbedActivity checks and launches the Generic First Run
                    // Experience.
                    launchTabbedMode(false);
                    finish();
                    return true;
                }
            } else if (isGenericFreActive) {
                // Launch the Generic First Run Experience if it is active previously.
                freIntent = FirstRunFlowSequencer.createGenericFirstRunIntent(this, TextUtils.equals(getIntent().getAction(), Intent.ACTION_MAIN));
            }
        }
        // Add a PendingIntent so that the intent used to launch Chrome will be resent when
        // first run is completed or canceled.
        FirstRunFlowSequencer.addPendingIntent(this, freIntent, getIntent());
        startActivity(freIntent);
    } else {
        Intent newIntent = new Intent(getIntent());
        newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(newIntent);
    }
    finish();
    return true;
}
Also used : LightweightFirstRunActivity(org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity) ChromeTabbedActivity(org.chromium.chrome.browser.ChromeTabbedActivity) LightweightFirstRunActivity(org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity) FirstRunActivity(org.chromium.chrome.browser.firstrun.FirstRunActivity) WeakReference(java.lang.ref.WeakReference) WebappLauncherActivity(org.chromium.chrome.browser.webapps.WebappLauncherActivity) LightweightFirstRunActivity(org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity) ChromeTabbedActivity(org.chromium.chrome.browser.ChromeTabbedActivity) CustomTabActivity(org.chromium.chrome.browser.customtabs.CustomTabActivity) SeparateTaskCustomTabActivity(org.chromium.chrome.browser.customtabs.SeparateTaskCustomTabActivity) UpgradeActivity(org.chromium.chrome.browser.upgrade.UpgradeActivity) FirstRunActivity(org.chromium.chrome.browser.firstrun.FirstRunActivity) Activity(android.app.Activity) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent)

Aggregations

Activity (android.app.Activity)1 Intent (android.content.Intent)1 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)1 WeakReference (java.lang.ref.WeakReference)1 ChromeTabbedActivity (org.chromium.chrome.browser.ChromeTabbedActivity)1 CustomTabActivity (org.chromium.chrome.browser.customtabs.CustomTabActivity)1 SeparateTaskCustomTabActivity (org.chromium.chrome.browser.customtabs.SeparateTaskCustomTabActivity)1 FirstRunActivity (org.chromium.chrome.browser.firstrun.FirstRunActivity)1 LightweightFirstRunActivity (org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity)1 UpgradeActivity (org.chromium.chrome.browser.upgrade.UpgradeActivity)1 WebappLauncherActivity (org.chromium.chrome.browser.webapps.WebappLauncherActivity)1