Updater: Add /mnt/scratch detection
Change-Id: Ie4d408791c24ce0b592882a0e6c5af12bd16addb
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2023 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.
|
||||
@@ -63,10 +63,13 @@ import org.lineageos.updater.model.UpdateInfo;
|
||||
import org.lineageos.updater.model.UpdateStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.ViewHolder> {
|
||||
|
||||
@@ -475,6 +478,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 resId;
|
||||
try {
|
||||
@@ -609,4 +618,12 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
mActivity.getResources().getInteger(R.integer.battery_ok_percentage_discharging);
|
||||
return percent >= required;
|
||||
}
|
||||
|
||||
private static boolean isScratchMounted() {
|
||||
try (Stream<String> lines = Files.lines(Path.of("/proc/mounts"))) {
|
||||
return lines.anyMatch(x -> x.split(" ")[1].equals("/mnt/scratch"));
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017-2023 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.
|
||||
@@ -60,6 +60,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>
|
||||
|
||||
|
Reference in New Issue
Block a user