SetupWizard: update recovery after setup
* Instead of doing it when going to next page Change-Id: I65c5ca1bab1d79c8fd5906b36a02fd74547827ac
This commit is contained in:
@@ -110,6 +110,6 @@
|
|||||||
<!-- Update Recovery -->
|
<!-- Update Recovery -->
|
||||||
<string name="update_recovery_title">Update Lineage Recovery</string>
|
<string name="update_recovery_title">Update Lineage Recovery</string>
|
||||||
<string name="update_recovery_description">Updates Lineage Recovery on first boot subsequent to every update.</string>
|
<string name="update_recovery_description">Updates Lineage Recovery on first boot subsequent to every update.</string>
|
||||||
<string name="update_recovery_warning">Recovery will be updated as soon as you proceed to the next step. If you wish to keep it intact, disable this feature.</string>
|
<string name="update_recovery_warning">Recovery will be updated as soon as you finish the setup. If you wish to keep it intact, disable this feature.</string>
|
||||||
<string name="update_recovery_setting">Update Lineage Recovery alongside the OS</string>
|
<string name="update_recovery_setting">Update Lineage Recovery alongside the OS</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -19,8 +19,10 @@ package org.lineageos.setupwizard;
|
|||||||
|
|
||||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
|
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
|
||||||
import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
|
import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
|
||||||
|
import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE;
|
||||||
import static org.lineageos.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
|
import static org.lineageos.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
|
||||||
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
||||||
|
import static org.lineageos.setupwizard.SetupWizardApp.UPDATE_RECOVERY_PROP;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -34,6 +36,7 @@ import android.graphics.Point;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewAnimationUtils;
|
import android.view.ViewAnimationUtils;
|
||||||
@@ -174,6 +177,7 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
|||||||
}
|
}
|
||||||
handleEnableMetrics(mSetupWizardApp);
|
handleEnableMetrics(mSetupWizardApp);
|
||||||
handleNavKeys(mSetupWizardApp);
|
handleNavKeys(mSetupWizardApp);
|
||||||
|
handleRecoveryUpdate(mSetupWizardApp);
|
||||||
final WallpaperManager wallpaperManager =
|
final WallpaperManager wallpaperManager =
|
||||||
WallpaperManager.getInstance(mSetupWizardApp);
|
WallpaperManager.getInstance(mSetupWizardApp);
|
||||||
wallpaperManager.forgetLoadedWallpaper();
|
wallpaperManager.forgetLoadedWallpaper();
|
||||||
@@ -200,6 +204,15 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleRecoveryUpdate(SetupWizardApp setupWizardApp) {
|
||||||
|
if (setupWizardApp.getSettingsBundle().containsKey(ENABLE_RECOVERY_UPDATE)) {
|
||||||
|
boolean update = setupWizardApp.getSettingsBundle()
|
||||||
|
.getBoolean(ENABLE_RECOVERY_UPDATE);
|
||||||
|
|
||||||
|
SystemProperties.set(UPDATE_RECOVERY_PROP, String.valueOf(update));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
@@ -65,6 +65,8 @@ public class SetupWizardApp extends Application {
|
|||||||
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
|
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
|
||||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||||
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
||||||
|
public static final String ENABLE_RECOVERY_UPDATE = "enable_recovery_update";
|
||||||
|
public static final String UPDATE_RECOVERY_PROP = "persist.vendor.recovery_update";
|
||||||
|
|
||||||
public static final int REQUEST_CODE_SETUP_WIFI = 0;
|
public static final int REQUEST_CODE_SETUP_WIFI = 0;
|
||||||
public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4;
|
public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2019-2020 The Calyx Institute
|
* Copyright (C) 2020 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package org.lineageos.setupwizard;
|
package org.lineageos.setupwizard;
|
||||||
|
|
||||||
|
import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE;
|
||||||
|
import static org.lineageos.setupwizard.SetupWizardApp.UPDATE_RECOVERY_PROP;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -30,13 +33,14 @@ import org.lineageos.setupwizard.util.SetupWizardUtils;
|
|||||||
|
|
||||||
public class UpdateRecoveryActivity extends BaseSetupWizardActivity {
|
public class UpdateRecoveryActivity extends BaseSetupWizardActivity {
|
||||||
|
|
||||||
private static final String UPDATE_RECOVERY_PROP = "persist.vendor.recovery_update";
|
|
||||||
|
|
||||||
private CheckBox mRecoveryUpdateCheckbox;
|
private CheckBox mRecoveryUpdateCheckbox;
|
||||||
|
private SetupWizardApp mSetupWizardApp;
|
||||||
|
private static boolean sFirstTime = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
mSetupWizardApp = (SetupWizardApp) getApplication();
|
||||||
|
|
||||||
if (!SetupWizardUtils.hasRecoveryUpdater(this)) {
|
if (!SetupWizardUtils.hasRecoveryUpdater(this)) {
|
||||||
Log.v(TAG, "No recovery updater, skipping UpdateRecoveryActivity");
|
Log.v(TAG, "No recovery updater, skipping UpdateRecoveryActivity");
|
||||||
@@ -54,21 +58,29 @@ public class UpdateRecoveryActivity extends BaseSetupWizardActivity {
|
|||||||
cbView.setOnClickListener(v -> {
|
cbView.setOnClickListener(v -> {
|
||||||
mRecoveryUpdateCheckbox.setChecked(!mRecoveryUpdateCheckbox.isChecked());
|
mRecoveryUpdateCheckbox.setChecked(!mRecoveryUpdateCheckbox.isChecked());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Allow overriding the default checkbox state
|
||||||
|
if (sFirstTime) {
|
||||||
|
mSetupWizardApp.getSettingsBundle().putBoolean(ENABLE_RECOVERY_UPDATE,
|
||||||
|
SystemProperties.getBoolean(UPDATE_RECOVERY_PROP, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
sFirstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Default the checkbox to true, the effect will be reflected when going next
|
final Bundle myPageBundle = mSetupWizardApp.getSettingsBundle();
|
||||||
mRecoveryUpdateCheckbox.setChecked(
|
final boolean checked = myPageBundle.getBoolean(ENABLE_RECOVERY_UPDATE, true);
|
||||||
SystemProperties.getBoolean(UPDATE_RECOVERY_PROP, true));
|
mRecoveryUpdateCheckbox.setChecked(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNextPressed() {
|
protected void onNextPressed() {
|
||||||
SystemProperties.set(UPDATE_RECOVERY_PROP,
|
mSetupWizardApp.getSettingsBundle().putBoolean(ENABLE_RECOVERY_UPDATE,
|
||||||
String.valueOf(mRecoveryUpdateCheckbox.isChecked()));
|
mRecoveryUpdateCheckbox.isChecked());
|
||||||
|
|
||||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
||||||
nextAction(NEXT_REQUEST, intent);
|
nextAction(NEXT_REQUEST, intent);
|
||||||
|
Reference in New Issue
Block a user