From ddbb843309b932283da9c2e26f58c3365d7ee695 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Thu, 2 May 2024 15:17:26 +0200 Subject: [PATCH] Updater: Add /mnt/scratch detection Change-Id: Ie4d408791c24ce0b592882a0e6c5af12bd16addb --- .../lineageos/updater/UpdatesListAdapter.java | 19 ++++++++++++++++++- app/src/main/res/values/strings.xml | 11 ++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java b/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java index 2a62b63..3014470 100644 --- a/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java +++ b/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java @@ -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 { @@ -475,6 +478,12 @@ public class UpdatesListAdapter extends RecyclerView.Adapter= required; } + + private static boolean isScratchMounted() { + try (Stream lines = Files.lines(Path.of("/proc/mounts"))) { + return lines.anyMatch(x -> x.split(" ")[1].equals("/mnt/scratch")); + } catch (IOException e) { + return false; + } + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 02dda7f..b59cea4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,6 @@