use Environment.getRootDirectory() instead of /system
Its officially possible to have the ROM's filesystem with any name. While I have never seen that in practice, Android does provide an easy method to get the real name. Plus this should help avoid typos and the like, and make it easy to track things that rely on that filesystem path.
This commit is contained in:
parent
f7c043b3fc
commit
014ab2d2b6
@ -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
|
||||
|
@ -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(),
|
||||
};
|
||||
|
@ -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<String> getInstallCommands(String apkPath) {
|
||||
final List<String> 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<String> 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/";
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user