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

Commit 4a3053f9 authored by LuK1337's avatar LuK1337 Committed by Mohammed Althaf T
Browse files

Updater: Add /mnt/scratch detection

Change-Id: Ie4d408791c24ce0b592882a0e6c5af12bd16addb
parent 488b9161
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2017-2020 The LineageOS Project
     Copyright (C) 2017-2024 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.
@@ -61,6 +61,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>

+24 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017-2022 The LineageOS Project
 * Copyright (C) 2017-2024 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.
@@ -56,7 +56,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;
@@ -515,6 +517,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;
@@ -662,4 +670,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;
    }
}