Commit ca909303 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Signin] Remove Android EDU support

This CL removes the Android EDU support.

Bug: 1044616
Change-Id: I4f63772cbb2c5f9da6c5b632a583572f6a85adec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072222
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746324}
parent 360d6e85
......@@ -1355,7 +1355,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfShareActivity.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/TargetDeviceInfo.java",
"java/src/org/chromium/chrome/browser/services/AccountsChangedReceiver.java",
"java/src/org/chromium/chrome/browser/services/AndroidEduAndChildAccountHelper.java",
"java/src/org/chromium/chrome/browser/services/AndroidChildAccountHelper.java",
"java/src/org/chromium/chrome/browser/services/AndroidEduOwnerCheckCallback.java",
"java/src/org/chromium/chrome/browser/services/GoogleServicesManager.java",
"java/src/org/chromium/chrome/browser/services/gcm/ChromeGcmListenerService.java",
......
......@@ -90,10 +90,13 @@ public abstract class AppHooks {
/**
* Initiate AndroidEdu device check.
* TODO(https://crbug.com/1044616) This method needs to be removed once we will remove the
* downstream overriden method
* @param callback Callback that should receive the results of the AndroidEdu device check.
*/
public void checkIsAndroidEduDevice(final AndroidEduOwnerCheckCallback callback) {
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> callback.onSchoolCheckDone(false));
assert false : "This method should not be called!";
}
/**
......
......@@ -24,7 +24,7 @@ import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.services.AndroidEduAndChildAccountHelper;
import org.chromium.chrome.browser.services.AndroidChildAccountHelper;
import org.chromium.chrome.browser.settings.privacy.PrivacyPreferencesManager;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.SigninManager;
......@@ -51,12 +51,8 @@ public abstract class FirstRunFlowSequencer {
private static final String TAG = "firstrun";
private final Activity mActivity;
// The following are initialized via initializeSharedState().
private boolean mIsAndroidEduDevice;
private @ChildAccountStatus.Status int mChildAccountStatus;
private List<Account> mGoogleAccounts;
private boolean mForceEduSignIn;
/**
* Callback that is called once the flow is determined.
......@@ -82,10 +78,10 @@ public abstract class FirstRunFlowSequencer {
return;
}
new AndroidEduAndChildAccountHelper() {
new AndroidChildAccountHelper() {
@Override
public void onParametersReady() {
initializeSharedState(isAndroidEduDevice(), getChildAccountStatus());
initializeSharedState(getChildAccountStatus());
processFreEnvironmentPreNative();
}
}.start();
......@@ -152,14 +148,9 @@ public abstract class FirstRunFlowSequencer {
FirstRunSignInProcessor.setFirstRunFlowSignInComplete(true);
}
void initializeSharedState(
boolean isAndroidEduDevice, @ChildAccountStatus.Status int childAccountStatus) {
mIsAndroidEduDevice = isAndroidEduDevice;
void initializeSharedState(@ChildAccountStatus.Status int childAccountStatus) {
mChildAccountStatus = childAccountStatus;
mGoogleAccounts = getGoogleAccounts();
// EDU devices should always have exactly 1 google account, which will be automatically
// signed-in. All FRE screens are skipped in this case.
mForceEduSignIn = mIsAndroidEduDevice && mGoogleAccounts.size() == 1 && !isSignedIn();
}
void processFreEnvironmentPreNative() {
......@@ -171,20 +162,16 @@ public abstract class FirstRunFlowSequencer {
}
Bundle freProperties = new Bundle();
// In the full FRE we always show the Welcome page, except on EDU devices.
boolean showWelcomePage = !mForceEduSignIn;
freProperties.putBoolean(FirstRunActivity.SHOW_WELCOME_PAGE, showWelcomePage);
// TODO(https://crbug.com/1056132): Remove the boolean FirstRunActivity.SHOW_WELCOME_PAGE
freProperties.putBoolean(FirstRunActivity.SHOW_WELCOME_PAGE, true);
freProperties.putInt(SigninFirstRunFragment.CHILD_ACCOUNT_STATUS, mChildAccountStatus);
// Initialize usage and crash reporting according to the default value.
// The user can explicitly enable or disable the reporting on the Welcome page.
// This is controlled by the administrator via a policy on EDU devices.
setDefaultMetricsAndCrashReporting();
onFlowIsKnown(freProperties);
if (ChildAccountStatus.isChild(mChildAccountStatus) || mForceEduSignIn) {
// Child and Edu forced signins are processed independently.
if (ChildAccountStatus.isChild(mChildAccountStatus)) {
setFirstRunFlowSignInComplete();
}
}
......@@ -194,15 +181,14 @@ public abstract class FirstRunFlowSequencer {
* @param freProperties Resulting FRE properties bundle.
*/
public void onNativeInitialized(Bundle freProperties) {
// We show the sign-in page if sync is allowed, and not signed in, and this is not
// an EDU device, and
// We show the sign-in page if sync is allowed, and not signed in, and
// - no "skip the first use hints" is set, or
// - "skip the first use hints" is set, but there is at least one account.
boolean offerSignInOk = isSyncAllowed() && !isSignedIn() && !mForceEduSignIn
boolean offerSignInOk = isSyncAllowed() && !isSignedIn()
&& (!shouldSkipFirstUseHints() || !mGoogleAccounts.isEmpty());
freProperties.putBoolean(FirstRunActivity.SHOW_SIGNIN_PAGE, offerSignInOk);
if (mForceEduSignIn || ChildAccountStatus.isChild(mChildAccountStatus)) {
// If the device is an Android EDU device or has a child account, there should be
if (ChildAccountStatus.isChild(mChildAccountStatus)) {
// If the device has a child account, there should be
// exactly account on the device. Force sign-in in to that account.
freProperties.putString(
SigninFirstRunFragment.FORCE_SIGNIN_ACCOUNT_TO, mGoogleAccounts.get(0).name);
......
......@@ -11,7 +11,7 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.SyncFirstSetupCompleteSource;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;
import org.chromium.chrome.browser.services.AndroidEduAndChildAccountHelper;
import org.chromium.chrome.browser.services.AndroidChildAccountHelper;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.sync.ProfileSyncService;
......@@ -23,8 +23,8 @@ import org.chromium.components.signin.metrics.SigninAccessPoint;
/**
* A helper to perform all necessary steps for forced sign in.
* The helper performs:
* - necessary Android EDU and child account checks;
* - automatic non-interactive forced sign in for Android EDU and child accounts; and
* - necessary child account checks;
* - automatic non-interactive forced sign in for child accounts; and
* The helper calls the observer's onSignInComplete() if
* - nothing needs to be done, or when
* - the sign in is complete.
......@@ -42,21 +42,16 @@ public final class ForcedSigninProcessor {
/**
* Check whether a forced automatic signin is required and process it if it is.
* This is triggered once per Chrome Application lifetime and everytime the Account state
* This is triggered once per Chrome Application lifetime and every time the Account state
* changes with early exit if an account has already been signed in.
*/
public static void start(@Nullable final Runnable onComplete) {
new AndroidEduAndChildAccountHelper() {
new AndroidChildAccountHelper() {
@Override
public void onParametersReady() {
boolean isAndroidEduDevice = isAndroidEduDevice();
boolean hasChildAccount = ChildAccountStatus.isChild(getChildAccountStatus());
// Child account and EDU device at the same time is not supported.
assert !(isAndroidEduDevice && hasChildAccount);
boolean forceSignin = isAndroidEduDevice || hasChildAccount;
AccountManagementFragment.setSignOutAllowedPreferenceValue(!forceSignin);
if (forceSignin) {
AccountManagementFragment.setSignOutAllowedPreferenceValue(!hasChildAccount);
if (hasChildAccount) {
processForcedSignIn(onComplete);
}
}
......@@ -114,7 +109,7 @@ public final class ForcedSigninProcessor {
* @param activity The activity for which to show the dialog.
*/
// TODO(bauerb): Once external dependencies reliably use policy to force sign-in,
// consider removing the child account / EDU checks.
// consider removing the child account.
public static void checkCanSignIn(final ChromeActivity activity) {
if (IdentityServicesProvider.get().getSigninManager().isForceSigninEnabled()) {
ExternalAuthUtils.getInstance().canUseGooglePlayServices(
......
......@@ -5,61 +5,39 @@
package org.chromium.chrome.browser.services;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.childaccounts.ChildAccountService;
import org.chromium.components.signin.ChildAccountStatus;
/**
* A helper for Android EDU and child account checks.
* A helper for child account checks.
* Usage:
* new AndroidEduAndChildAccountHelper() { override onParametersReady() }.start(appContext).
* new AndroidChildAccountHelper() { override onParametersReady() }.start(appContext).
*/
public abstract class AndroidEduAndChildAccountHelper
implements Callback<Integer>, AndroidEduOwnerCheckCallback {
private Boolean mIsAndroidEduDevice;
public abstract class AndroidChildAccountHelper implements Callback<Integer> {
private @ChildAccountStatus.Status Integer mChildAccountStatus;
// Abbreviated to < 20 chars.
private static final String TAG = "EduChildHelper";
/** The callback called when Android EDU and child account parameters are known. */
/** The callback called when child account parameters are known. */
public abstract void onParametersReady();
/** @return Whether the device is Android EDU device. */
public boolean isAndroidEduDevice() {
return mIsAndroidEduDevice;
}
/** @return The status of the device regarding child accounts. */
public @ChildAccountStatus.Status int getChildAccountStatus() {
protected @ChildAccountStatus.Status int getChildAccountStatus() {
return mChildAccountStatus;
}
/**
* Starts fetching the Android EDU and child accounts information.
* Starts fetching the child accounts information.
* Calls onParametersReady() once the information is fetched.
*/
public void start() {
ChildAccountService.checkChildAccountStatus(this);
AppHooks.get().checkIsAndroidEduDevice(this);
// TODO(aruslan): Should we start a watchdog to kill if Child/Edu stuff takes too long?
}
private void checkDone() {
if (mIsAndroidEduDevice == null || mChildAccountStatus == null) return;
onParametersReady();
}
// AndroidEdu.OwnerCheckCallback:
@Override
public void onSchoolCheckDone(boolean isAndroidEduDevice) {
mIsAndroidEduDevice = isAndroidEduDevice;
checkDone();
}
// Callback<Integer>:
@Override
public void onResult(@ChildAccountStatus.Status Integer status) {
mChildAccountStatus = status;
checkDone();
if (mChildAccountStatus != null) {
onParametersReady();
}
}
}
......@@ -165,8 +165,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.hasAnyUserSeenToS = true;
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.isFirstRunEulaAccepted = true;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.NOT_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD);
mSequencer.processFreEnvironmentPreNative();
assertTrue(mSequencer.calledOnFlowIsKnown);
......@@ -184,8 +183,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.hasAnyUserSeenToS = false;
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.shouldShowDataReductionPage = false;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.NOT_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD);
mSequencer.processFreEnvironmentPreNative();
assertTrue(mSequencer.calledOnFlowIsKnown);
......@@ -213,8 +211,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.hasAnyUserSeenToS = false;
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.shouldShowDataReductionPage = false;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.REGULAR_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.REGULAR_CHILD);
mSequencer.processFreEnvironmentPreNative();
assertTrue(mSequencer.calledOnFlowIsKnown);
......@@ -244,8 +241,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.shouldShowDataReductionPage = true;
mSequencer.shouldShowSearchEnginePage = false;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.NOT_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD);
mSequencer.processFreEnvironmentPreNative();
assertTrue(mSequencer.calledOnFlowIsKnown);
......@@ -273,8 +269,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.shouldShowDataReductionPage = true;
mSequencer.shouldShowSearchEnginePage = true;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.NOT_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD);
mSequencer.processFreEnvironmentPreNative();
assertTrue(mSequencer.calledOnFlowIsKnown);
......@@ -301,8 +296,7 @@ public class FirstRunFlowSequencerTest {
mSequencer.hasAnyUserSeenToS = false;
mSequencer.shouldSkipFirstUseHints = false;
mSequencer.shouldShowDataReductionPage = false;
mSequencer.initializeSharedState(
false /* androidEduDevice */, ChildAccountStatus.NOT_CHILD);
mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD);
mSequencer.processFreEnvironmentPreNative();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment