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

Commit 1eef5146 authored by LuK1337's avatar LuK1337 Committed by Mohammed Althaf T
Browse files

Updater: Add /mnt/scratch detection

Change-Id: Ie4d408791c24ce0b592882a0e6c5af12bd16addb
parent 69bcc38d
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
 * SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */
package org.lineageos.updater;
@@ -45,7 +45,9 @@ import org.lineageos.updater.misc.Utils;
import org.lineageos.updater.model.UpdateInfo;
import org.lineageos.updater.model.UpdateStatus;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.DateFormat;
import java.text.DecimalFormat;
@@ -513,6 +515,12 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
                    .setMessage(message)
                    .setPositiveButton(android.R.string.ok, null);
        }
        if (isScratchMounted()) {
            return new AlertDialog.Builder(mActivity)
                    .setTitle(R.string.dialog_scratch_mounted_title)
                    .setMessage(R.string.dialog_scratch_mounted_message)
                    .setPositiveButton(android.R.string.ok, null);
        }
        UpdateInfo update = mUpdaterController.getUpdate(downloadId);

        int title;
@@ -664,4 +672,19 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }

    private static boolean isScratchMounted() {
        File file = new File("/proc/mounts");
        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = br.readLine()) != null) {
                if (line.split(" ")[1].equals("/mnt/scratch")) {
                    return true;
                }
            }
        } catch (IOException e) {
            return false;
        }
        return false;
    }
}
+10 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
     SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
     SPDX-License-Identifier: Apache-2.0
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
@@ -50,6 +50,15 @@
    <string name="dialog_prepare_zip_message">Preliminary update preparation</string>
    <string name="dialog_battery_low_title">Low battery</string>
    <string name="dialog_battery_low_message_pct">The battery level is too low, you need at least <xliff:g id="percent_discharging">%1$d</xliff:g>%% of the battery to continue, <xliff:g id="percent_charging">%2$d</xliff:g>%% if charging.</string>
    <string name="dialog_scratch_mounted_message">
        <![CDATA[
        Please run the following commands and retry the update:\n
        • adb root\n
        • adb enable-verity\n
        • adb reboot
        ]]>
    </string>
    <string name="dialog_scratch_mounted_title">Cannot install update with OverlayFS mounted</string>

    <string name="reboot">Reboot</string>