diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java index 9d9c19eed..dd7aa9a15 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java @@ -34,6 +34,7 @@ import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.net.Uri; import android.os.Build; +import android.os.Environment; import android.os.StrictMode; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -78,6 +79,8 @@ public class FDroidApp extends Application { private static final String TAG = "FDroidApp"; + public static final String SYSTEM_DIR_NAME = Environment.getRootDirectory().getAbsolutePath(); + private static Locale locale; // for the local repo on this device, all static since there is only one diff --git a/app/src/main/java/org/fdroid/fdroid/compat/FileCompat.java b/app/src/main/java/org/fdroid/fdroid/compat/FileCompat.java index cb8726a53..663d7ba0a 100644 --- a/app/src/main/java/org/fdroid/fdroid/compat/FileCompat.java +++ b/app/src/main/java/org/fdroid/fdroid/compat/FileCompat.java @@ -5,6 +5,7 @@ import android.os.Build; import android.system.ErrnoException; import android.util.Log; +import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.SanitizedFile; @@ -59,7 +60,7 @@ public class FileCompat { protected static void symlinkRuntime(SanitizedFile source, SanitizedFile dest) { String[] commands = { - "/system/bin/ln", + FDroidApp.SYSTEM_DIR_NAME + "/bin/ln", source.getAbsolutePath(), dest.getAbsolutePath(), }; @@ -107,7 +108,7 @@ public class FileCompat { // The "file" must be a sanitized file, and hence only contain A-Za-z0-9.-_ already, // but it makes no assurances about the parent directory. final String[] args = { - "/system/bin/chmod", + FDroidApp.SYSTEM_DIR_NAME + "/bin/chmod", mode, file.getAbsolutePath(), }; diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtension.java b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtension.java index bfc3a99ec..3ea179fec 100644 --- a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtension.java +++ b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtension.java @@ -22,6 +22,7 @@ package org.fdroid.fdroid.privileged.install; import android.content.Context; import android.os.Build; +import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.R; import org.fdroid.fdroid.installer.PrivilegedInstaller; @@ -85,11 +86,11 @@ abstract class InstallExtension { private List getInstallCommands(String apkPath) { final List commands = new ArrayList<>(); - commands.add("mount -o rw,remount /system"); // remount as read-write + commands.add("mount -o rw,remount " + FDroidApp.SYSTEM_DIR_NAME); // remount as read-write commands.addAll(getCopyToSystemCommands(apkPath)); commands.add("mv " + getInstallPath() + ".tmp " + getInstallPath()); commands.add("sleep 5"); // wait until the app is really installed - commands.add("mount -o ro,remount /system"); // remount as read-only + commands.add("mount -o ro,remount " + FDroidApp.SYSTEM_DIR_NAME); // remount as read-only commands.add("am force-stop " + PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME); commands.addAll(getPostInstallCommands()); return commands; @@ -113,10 +114,10 @@ abstract class InstallExtension { final List commands = new ArrayList<>(); commands.add("am force-stop " + PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME); commands.add("pm clear " + PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME); - commands.add("mount -o rw,remount /system"); + commands.add("mount -o rw,remount " + FDroidApp.SYSTEM_DIR_NAME); commands.addAll(getCleanUninstallCommands()); commands.add("sleep 5"); - commands.add("mount -o ro,remount /system"); + commands.add("mount -o ro,remount " + FDroidApp.SYSTEM_DIR_NAME); commands.addAll(getPostUninstallCommands()); return commands; } @@ -139,7 +140,7 @@ abstract class InstallExtension { @Override protected String getSystemFolder() { - return "/system/app/"; + return FDroidApp.SYSTEM_DIR_NAME + "/app/"; } } @@ -156,7 +157,7 @@ abstract class InstallExtension { */ @Override protected String getSystemFolder() { - return "/system/priv-app/"; + return FDroidApp.SYSTEM_DIR_NAME + "/priv-app/"; } } @@ -190,7 +191,7 @@ abstract class InstallExtension { */ @Override protected String getSystemFolder() { - return "/system/priv-app/FDroidPrivileged/"; + return FDroidApp.SYSTEM_DIR_NAME + "/priv-app/FDroidPrivileged/"; } /**