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

Commit 7350e218 authored by Jackeagle's avatar Jackeagle
Browse files

Updater: Add check if Adoptable Storage is enabled or not.



- Block OTA Upgrades for herolte/hero2lte devices that have Adoptable storage enabled.

Signed-off-by: default avatarJackeagle <jackeagle102@gmail.com>
parent ae3d2688
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -163,8 +163,8 @@
    <string name="menu_mobile_data_warning">Mobile data warning</string>

    <string name="blocked_update_dialog_title">Update blocked</string>
    <string name="blocked_update_dialog_message">This update cannot be installed using the updater app.  Please read <xliff:g id="info_url">%1$s</xliff:g> for more information.</string>
    <string name="blocked_update_info_url" translatable="false">http://wiki.lineageos.org/devices/<xliff:g id="device_name">%1$s</xliff:g>/upgrade</string>
    <string name="blocked_update_dialog_message">This upgrade cannot be installed because Adoptable Storage is not supported on Android 11. Upgrading will result in data loss and SD card corruption for users with Adoptable Storage enabled.</string>
    <string name="blocked_update_info_url" translatable="false">https://doc.e.foundation/devices/<xliff:g id="device_name">%1$s</xliff:g></string>

    <string name="export_channel_title">Export completion</string>
    <string name="new_updates_channel_title">New updates</string>
+22 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.os.SystemProperties;
@@ -180,7 +181,27 @@ public class Utils {

    public static boolean canInstall(UpdateBaseInfo update) {
        return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) ||
                update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0));
                update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)) &&
		isAdoptableStorageEnabled();
    }

    private static boolean isAdoptableStorageEnabled() {
        String selinuxProp = SystemProperties.get("selinux.restorecon_recursive", "");

        // Prefix of prop output
        String expectedPrefix = "/mnt/expand/";

        if (selinuxProp.startsWith(expectedPrefix)) {

            // Extract the content after "/mnt/expand/"
            String pathContent = selinuxProp.substring(expectedPrefix.length());

            Log.d("Updater", "Adoptable storage is enabled. Blocking OTA Updates");
            return false;
        } else {
            Log.d("Updater", "Adoptable storage is not enabled or invalid property format");
            return true;
        }
    }

    public static List<UpdateInfo> parseJson(File file, boolean compatibleOnly)