Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc9e3664 authored by Sahil Sonar's avatar Sahil Sonar 💬
Browse files

Updater: Kill recovery update option

   - Enabled by default.
parent 198cb3aa
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -597,7 +597,6 @@ public class UpdatesActivity extends UpdatesListActivity implements UpdateImport
        SwitchCompat meteredNetworkWarning = view.findViewById(
                R.id.preferences_metered_network_warning);
        SwitchCompat abPerfMode = view.findViewById(R.id.preferences_ab_perf_mode);
        SwitchCompat updateRecovery = view.findViewById(R.id.preferences_update_recovery);

        if (!Utils.isABDevice()) {
            abPerfMode.setVisibility(View.GONE);
@@ -630,34 +629,6 @@ public class UpdatesActivity extends UpdatesListActivity implements UpdateImport
        abPerfMode.setChecked(prefs.getBoolean(Constants.PREF_AB_PERF_MODE,
                getResources().getBoolean(R.bool.config_prioritizeUpdateProcess)));

        if (getResources().getBoolean(R.bool.config_hideRecoveryUpdate)) {
            // Hide the update feature if explicitly requested.
            // Might be the case of A-only devices using prebuilt vendor images.
            updateRecovery.setVisibility(View.GONE);
        } else if (Utils.isRecoveryUpdateExecPresent()) {
            updateRecovery.setChecked(
                    SystemProperties.getBoolean(Constants.UPDATE_RECOVERY_PROPERTY, 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)
@@ -683,11 +654,6 @@ public class UpdatesActivity extends UpdatesListActivity implements UpdateImport
                        boolean enableABPerfMode = abPerfMode.isChecked();
                        mUpdaterService.getUpdaterController().setPerformanceMode(enableABPerfMode);
                    }
                    if (Utils.isRecoveryUpdateExecPresent()) {
                        boolean enableRecoveryUpdate = updateRecovery.isChecked();
                        SystemProperties.set(Constants.UPDATE_RECOVERY_PROPERTY,
                                String.valueOf(enableRecoveryUpdate));
                    }
                })
                .show();
    }
+0 −3
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ public final class Constants {
    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";

    public static final String RESUME_DOWNLOAD_ID = "resume_download_id";
    public static final String AUTO_UPDATE_CHECK_FAILED = "auto_update_check_failed";
}
+0 −4
Original line number Diff line number Diff line
@@ -594,10 +594,6 @@ public class Utils {
        }
    }

    public static boolean isRecoveryUpdateExecPresent() {
        return new File(Constants.UPDATE_RECOVERY_EXEC).exists();
    }

    public static boolean isBatteryLevelOk(Context context) {
        Intent intent = context.registerReceiver(null,
                new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+0 −7
Original line number Diff line number Diff line
@@ -60,11 +60,4 @@
        android:text="@string/menu_ab_perf_mode"
        android:textSize="16sp" />

    <androidx.appcompat.widget.SwitchCompat
        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>
+0 −20
Original line number Diff line number Diff line
<?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>
    <bool name="config_prioritizeUpdateProcess">false</bool>
</resources>
Loading