aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/preferences_dialog.xml9
-rw-r--r--res/values/config.xml19
-rw-r--r--res/values/strings.xml5
-rw-r--r--res/values/symbols.xml19
-rw-r--r--src/org/lineageos/updater/UpdatesActivity.java39
-rw-r--r--src/org/lineageos/updater/misc/Constants.java6
-rw-r--r--src/org/lineageos/updater/misc/Utils.java6
7 files changed, 99 insertions, 4 deletions
diff --git a/res/layout/preferences_dialog.xml b/res/layout/preferences_dialog.xml
index ffc7348..864c8f7 100644
--- a/res/layout/preferences_dialog.xml
+++ b/res/layout/preferences_dialog.xml
@@ -49,4 +49,13 @@
android:layout_marginBottom="16dp"
android:text="@string/menu_mobile_data_warning"
android:textSize="16sp" />
+
+ <Switch
+ android:id="@+id/preferences_update_recovery"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:text="@string/menu_update_recovery"
+ android:textSize="16sp" />
+
</LinearLayout>
diff --git a/res/values/config.xml b/res/values/config.xml
new file mode 100644
index 0000000..76ab686
--- /dev/null
+++ b/res/values/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <bool name="config_hideRecoveryUpdate">false</bool>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8d4bfd2..c25b4aa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2017 The LineageOS Project
+ Copyright (C) 2017-2020 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -78,6 +78,9 @@
<string name="menu_show_changelog">Show changelog</string>
<string name="menu_local_update">Choose file ...</string>
+ <string name="menu_update_recovery">Update recovery</string>
+ <string name="toast_forced_update_recovery">You cannot disable the update of Lineage Recovery on this device.</string>
+
<string name="snack_updates_found">New updates found</string>
<string name="snack_no_updates_found">No new updates found</string>
<string name="snack_updates_check_failed">The update check failed. Please check your internet connection and try again later.</string>
diff --git a/res/values/symbols.xml b/res/values/symbols.xml
new file mode 100644
index 0000000..f3dc0ba
--- /dev/null
+++ b/res/values/symbols.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <java-symbol type="bool" name="config_hideRecoveryUpdate" />
+</resources>
diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java
index 284c718..e433f6c 100644
--- a/src/org/lineageos/updater/UpdatesActivity.java
+++ b/src/org/lineageos/updater/UpdatesActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
@@ -57,6 +58,7 @@ import android.view.animation.RotateAnimation;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
+import android.widget.Toast;
import com.aicp.updater3.R;
import androidx.appcompat.app.AlertDialog;
@@ -455,12 +457,40 @@ public class UpdatesActivity extends UpdatesListActivity {
view.findViewById(R.id.preferences_auto_updates_check_interval);
Switch autoDelete = view.findViewById(R.id.preferences_auto_delete_updates);
Switch dataWarning = view.findViewById(R.id.preferences_mobile_data_warning);
+ Switch updateRecovery = view.findViewById(R.id.preferences_update_recovery);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
autoCheckInterval.setSelection(Utils.getUpdateCheckSetting(this));
autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false));
dataWarning.setChecked(prefs.getBoolean(Constants.PREF_MOBILE_DATA_WARNING, true));
+ if (getResources().getBoolean(R.bool.config_hideRecoveryUpdate)) {
+ // Hide the update feature if explicitely requested.
+ // Might be the case of A-only devices using prebuilt vendor images.
+ updateRecovery.setVisibility(View.GONE);
+ } else if (Utils.isRecoveryUpdateExecPresent()) {
+ updateRecovery.setChecked(prefs.getBoolean(Constants.PREF_UPDATE_RECOVERY, false));
+ } else {
+ // There is no recovery updater script in the device, so the feature is considered
+ // forcefully enabled, just to avoid users to be confused and complain that
+ // recovery gets overwritten. That's the case of A/B and recovery-in-boot devices.
+ updateRecovery.setChecked(true);
+ updateRecovery.setOnTouchListener(new View.OnTouchListener() {
+ private Toast forcedUpdateToast = null;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (forcedUpdateToast != null) {
+ forcedUpdateToast.cancel();
+ }
+ forcedUpdateToast = Toast.makeText(getApplicationContext(),
+ getString(R.string.toast_forced_update_recovery), Toast.LENGTH_SHORT);
+ forcedUpdateToast.show();
+ return true;
+ }
+ });
+ }
+
new AlertDialog.Builder(this)
.setTitle(R.string.menu_preferences)
.setView(view)
@@ -472,6 +502,8 @@ public class UpdatesActivity extends UpdatesListActivity {
autoDelete.isChecked())
.putBoolean(Constants.PREF_MOBILE_DATA_WARNING,
dataWarning.isChecked())
+ .putBoolean(Constants.PREF_UPDATE_RECOVERY,
+ updateRecovery.isChecked())
.apply();
if (Utils.isUpdateCheckEnabled(this)) {
@@ -480,6 +512,11 @@ public class UpdatesActivity extends UpdatesListActivity {
UpdatesCheckReceiver.cancelRepeatingUpdatesCheck(this);
UpdatesCheckReceiver.cancelUpdatesCheck(this);
}
+ if (Utils.isRecoveryUpdateExecPresent()) {
+ boolean enableRecoveryUpdate = updateRecovery.isChecked();
+ SystemProperties.set(Constants.UPDATE_RECOVERY_PROPERTY,
+ String.valueOf(enableRecoveryUpdate));
+ }
})
.show();
}
diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java
index 42ea559..df9fce1 100644
--- a/src/org/lineageos/updater/misc/Constants.java
+++ b/src/org/lineageos/updater/misc/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ public final class Constants {
public static final String PREF_AUTO_DELETE_UPDATES = "auto_delete_updates";
public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning";
public static final String PREF_NEEDS_REBOOT_ID = "needs_reboot_id";
+ public static final String PREF_UPDATE_RECOVERY = "update_recovery";
public static final String UNCRYPT_FILE_EXT = ".uncrypt";
@@ -51,4 +52,7 @@ public final class Constants {
public static final String PREF_INSTALL_PACKAGE_PATH = "install_package_path";
public static final String PREF_INSTALL_AGAIN = "install_again";
public static final String PREF_INSTALL_NOTIFIED = "install_notified";
+
+ public static final String UPDATE_RECOVERY_EXEC = "/vendor/bin/install-recovery.sh";
+ public static final String UPDATE_RECOVERY_PROPERTY = "persist.vendor.recovery_update";
}
diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java
index 18b51dc..949df92 100644
--- a/src/org/lineageos/updater/misc/Utils.java
+++ b/src/org/lineageos/updater/misc/Utils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -418,4 +418,8 @@ public class Utils {
}
}
}
+
+ public static boolean isRecoveryUpdateExecPresent() {
+ return new File(Constants.UPDATE_RECOVERY_EXEC).exists();
+ }
}