use of org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity 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;
}
Aggregations