summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-03-17 19:22:58 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-03-17 19:22:58 -0700
commit6baab03bd81d36e60774ac2b9a2dcfbdc731c2a2 (patch)
tree3cbf019e10299bb3bcc016e5a12d63e8b2f35e48 /src
parent57080c360c7dc36fd6094f143b31f3cad36f4998 (diff)
downloadpackages_apps_SetupWizard-6baab03bd81d36e60774ac2b9a2dcfbdc731c2a2.zip
packages_apps_SetupWizard-6baab03bd81d36e60774ac2b9a2dcfbdc731c2a2.tar.gz
packages_apps_SetupWizard-6baab03bd81d36e60774ac2b9a2dcfbdc731c2a2.tar.bz2
SetupWizard: Handle both restore scenarios.
If a user logs into Google's SetupWizard with their gmail account, they need to be prompted with a restoration picker -- otherwise, if they have a valid restoreToken and restoreAccount, we can assume that they came from a Tap & Go scenario and begin restoring as needed. Change-Id: Ifa9ce978822f365996a509edeb3023001a07be84 TICKET: CYNGNOS-2233
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java66
1 files changed, 31 insertions, 35 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
index 7c33328..2285a4c 100644
--- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
@@ -25,14 +25,9 @@ import android.app.Activity;
import android.app.ActivityOptions;
import android.app.Fragment;
import android.app.FragmentManager;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.database.ContentObserver;
import android.os.Bundle;
-import android.os.Handler;
-import android.provider.Settings;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Log;
@@ -48,41 +43,26 @@ public class GmsAccountPage extends SetupPage {
public static final String TAG = "GmsAccountPage";
+ public static final String ACTION_RESTORE = "com.google.android.setupwizard.RESTORE";
public static final String ACTION_PROGRESS = "com.google.android.setupwizard.PROGRESS";
public static final String RESTORE_ACTION_ID = "mfm_restore_start";
+ public static final String RESTORE_CHECK_ID = "restore_check";
public static final String FRAGMENT_START_RESTORE =
"com.google.android.setupwizard.account.StartRestoreFragment";
+ public static final String FRAGMENT_CHECK_RESTORE =
+ "com.google.android.setupwizard.account.CheckRestoreTokenFragment";
+
+ public static final String EXTRA_AUTH_ACCOUNT = "authAccount";
+ public static final String EXTRA_RESTORE_ACCOUNT = "restoreAccount";
+ public static final String EXTRA_RESTORE_TOKEN = "restoreToken";
private static final String RESTORE_WIZARD_SCRIPT =
"android.resource://com.google.android.setupwizard/xml/wizard_script";
- private boolean mBackupEnabled = false;
-
private Fragment mFragment;
- private ContentResolver mContentResolver;
public GmsAccountPage(final Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
- mContentResolver = context.getContentResolver();
- mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
- Settings.Secure.BACKUP_AUTO_RESTORE), false, mSettingsObserver);
- mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
- Settings.Secure.BACKUP_ENABLED), false, mSettingsObserver);
- }
-
- private ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
- @Override
- public void onChange(boolean selfChange) {
- super.onChange(selfChange);
- onBackupEnabledChanged();
- }
- };
-
- private void onBackupEnabledChanged() {
- mBackupEnabled = (Settings.Secure.getInt(mContentResolver,
- Settings.Secure.BACKUP_AUTO_RESTORE, 0) == 1) ||
- (Settings.Secure.getInt(mContentResolver,
- Settings.Secure.BACKUP_ENABLED, 0) == 1);
}
@Override
@@ -125,12 +105,21 @@ public class GmsAccountPage extends SetupPage {
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS) {
- if (!mBackupEnabled && SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {
+ if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) {
+ if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {
+
+ // If we don't have a restore token and a restore account, then we need to
+ // prompt with the restore picker from googles setup wizard so the user
+ // can select what device they would like to restore from. Otherwise,
+ // we're coming from a Tap&Go scenario and we should just restore.
+ boolean restorePicker = !data.hasExtra(EXTRA_RESTORE_TOKEN)
+ && !data.hasExtra(EXTRA_RESTORE_ACCOUNT) &&
+ data.hasExtra(EXTRA_AUTH_ACCOUNT);
+
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_RESULT,
SetupStats.Label.GMS_ACCOUNT, "success");
- launchGmsRestorePage();
+ launchGmsRestorePage(restorePicker);
} else {
handleResult(requestCode, resultCode);
}
@@ -143,7 +132,7 @@ public class GmsAccountPage extends SetupPage {
@Override
public void onFinishSetup() {
- mContentResolver.unregisterContentObserver(mSettingsObserver);
+
}
private void handleResult(int requestCode, int resultCode) {
@@ -177,13 +166,20 @@ public class GmsAccountPage extends SetupPage {
}
}
- private void launchGmsRestorePage() {
+ private void launchGmsRestorePage(boolean restorePicker) {
try {
// GMS can disable this after logging in sometimes
if (SetupWizardUtils.enableGMSSetupWizard(mContext)) {
Intent intent = new Intent(ACTION_PROGRESS);
- intent.putExtra(SetupWizardApp.EXTRA_FRAGMENT, FRAGMENT_START_RESTORE);
- intent.putExtra(SetupWizardApp.EXTRA_ACTION_ID, RESTORE_ACTION_ID);
+ if (!restorePicker) {
+ intent.setAction(ACTION_PROGRESS);
+ intent.putExtra(SetupWizardApp.EXTRA_FRAGMENT, FRAGMENT_START_RESTORE);
+ intent.putExtra(SetupWizardApp.EXTRA_ACTION_ID, RESTORE_ACTION_ID);
+ } else {
+ intent.setAction(ACTION_PROGRESS);
+ intent.putExtra(SetupWizardApp.EXTRA_ACTION_ID, RESTORE_CHECK_ID);
+ intent.putExtra(SetupWizardApp.EXTRA_FRAGMENT, FRAGMENT_CHECK_RESTORE);
+ }
intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);