2017-11-05 20:41:23 +00:00
|
|
|
package com.topjohnwu.magisk.utils;
|
|
|
|
|
2017-11-17 16:04:31 +00:00
|
|
|
import android.os.Environment;
|
2017-12-11 18:35:00 +00:00
|
|
|
import android.os.Process;
|
2017-11-17 16:04:31 +00:00
|
|
|
|
2018-04-29 06:40:42 +00:00
|
|
|
import com.topjohnwu.magisk.BuildConfig;
|
2017-12-20 07:46:04 +00:00
|
|
|
import com.topjohnwu.magisk.MagiskManager;
|
2018-02-12 15:07:35 +00:00
|
|
|
import com.topjohnwu.superuser.io.SuFile;
|
2017-12-20 07:46:04 +00:00
|
|
|
|
2017-11-17 16:04:31 +00:00
|
|
|
import java.io.File;
|
2017-11-05 20:41:23 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Const {
|
|
|
|
|
|
|
|
public static final String DEBUG_TAG = "MagiskManager";
|
2018-04-29 06:40:42 +00:00
|
|
|
public static final String ORIG_PKG_NAME = BuildConfig.APPLICATION_ID;
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String SNET_PKG = "com.topjohnwu.snet";
|
|
|
|
public static final String MAGISKHIDE_PROP = "persist.magisk.hide";
|
|
|
|
|
|
|
|
// APK content
|
|
|
|
public static final String UNINSTALLER = "magisk_uninstaller.sh";
|
|
|
|
public static final String UTIL_FUNCTIONS= "util_functions.sh";
|
|
|
|
public static final String ANDROID_MANIFEST = "AndroidManifest.xml";
|
|
|
|
|
2018-01-11 17:53:49 +00:00
|
|
|
public static final String SU_KEYSTORE_KEY = "su_key";
|
|
|
|
|
2017-11-05 20:41:23 +00:00
|
|
|
// Paths
|
2018-02-12 15:07:35 +00:00
|
|
|
private static SuFile MAGISK_PATH = null;
|
|
|
|
public static final SuFile MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk", true);
|
2018-01-20 22:07:24 +00:00
|
|
|
public static final String BUSYBOX_PATH = "/sbin/.core/busybox";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String TMP_FOLDER_PATH = "/dev/tmp";
|
|
|
|
public static final String MAGISK_LOG = "/cache/magisk.log";
|
2017-11-17 16:04:31 +00:00
|
|
|
public static final File EXTERNAL_PATH = new File(Environment.getExternalStorageDirectory(), "MagiskManager");
|
2017-12-08 15:38:03 +00:00
|
|
|
public static final String MANAGER_CONFIGS = ".tmp.magisk.config";
|
2017-11-05 20:41:23 +00:00
|
|
|
|
2017-12-26 10:24:43 +00:00
|
|
|
// Versions
|
|
|
|
public static final int UPDATE_SERVICE_VER = 1;
|
|
|
|
public static final int SNET_VER = 7;
|
2018-04-07 17:05:01 +00:00
|
|
|
|
|
|
|
public static int MIN_MODULE_VER() {
|
|
|
|
return MagiskManager.get().magiskVersionCode >= 1630 ? 1500 : 1400;
|
|
|
|
}
|
2017-12-26 10:24:43 +00:00
|
|
|
|
2018-02-12 15:07:35 +00:00
|
|
|
public synchronized static SuFile MAGISK_PATH() {
|
|
|
|
SuFile file;
|
2018-01-25 10:43:30 +00:00
|
|
|
if (MAGISK_PATH == null) {
|
2018-02-12 15:07:35 +00:00
|
|
|
file = new SuFile("/sbin/.core/img", true);
|
|
|
|
if (file.exists()) {
|
|
|
|
MAGISK_PATH = file;
|
|
|
|
} else if ((file = new SuFile("/dev/magisk/img", true)).exists()) {
|
|
|
|
MAGISK_PATH = file;
|
2018-01-25 10:43:30 +00:00
|
|
|
} else {
|
2018-02-12 15:07:35 +00:00
|
|
|
MAGISK_PATH = new SuFile("/magisk", true);
|
2018-01-25 10:43:30 +00:00
|
|
|
}
|
2017-11-08 16:03:37 +00:00
|
|
|
}
|
2018-01-25 10:43:30 +00:00
|
|
|
return MAGISK_PATH;
|
2017-11-08 16:03:37 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 15:07:35 +00:00
|
|
|
public static SuFile MAGISK_HOST_FILE() {
|
|
|
|
return new SuFile(MAGISK_PATH() + "/.core/hosts");
|
2017-11-08 16:03:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 20:41:23 +00:00
|
|
|
/* A list of apps that should not be shown as hide-able */
|
2017-12-20 07:46:04 +00:00
|
|
|
public static final List<String> HIDE_BLACKLIST = Arrays.asList(
|
2017-11-05 20:41:23 +00:00
|
|
|
"android",
|
2017-12-20 07:46:04 +00:00
|
|
|
MagiskManager.get().getPackageName(),
|
2017-11-05 20:41:23 +00:00
|
|
|
"com.google.android.gms"
|
|
|
|
);
|
|
|
|
|
2017-12-11 18:35:00 +00:00
|
|
|
public static final int USER_ID = Process.myUid() / 100000;
|
|
|
|
|
2018-04-14 07:32:37 +00:00
|
|
|
public static final class MAGISK_VER {
|
|
|
|
public static final int UNIFIED = 1300;
|
|
|
|
public static final int FBE_AWARE = 1410;
|
|
|
|
public static final int RESETPROP_PERSIST = 1436;
|
|
|
|
public static final int MANAGER_HIDE = 1440;
|
|
|
|
public static final int DTBO_SUPPORT = 1446;
|
|
|
|
public static final int LEGACY_GLOBAL_DB = 1450;
|
|
|
|
public static final int HIDDEN_PATH = 1460;
|
2018-04-14 10:08:53 +00:00
|
|
|
public static final int SEPOL_REFACTOR = 1640;
|
2018-04-14 07:32:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 20:41:23 +00:00
|
|
|
public static class ID {
|
|
|
|
public static final int UPDATE_SERVICE_ID = 1;
|
|
|
|
public static final int FETCH_ZIP = 2;
|
|
|
|
public static final int SELECT_BOOT = 3;
|
|
|
|
|
|
|
|
// notifications
|
|
|
|
public static final int MAGISK_UPDATE_NOTIFICATION_ID = 4;
|
|
|
|
public static final int APK_UPDATE_NOTIFICATION_ID = 5;
|
|
|
|
public static final int ONBOOT_NOTIFICATION_ID = 6;
|
2017-11-14 20:39:05 +00:00
|
|
|
public static final int DTBO_NOTIFICATION_ID = 7;
|
|
|
|
public static final String NOTIFICATION_CHANNEL = "magisk_notification";
|
2017-11-05 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class Url {
|
|
|
|
public static final String STABLE_URL = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/stable.json";
|
2017-11-19 19:09:08 +00:00
|
|
|
public static final String BETA_URL = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/update/beta.json";
|
2017-12-25 19:59:14 +00:00
|
|
|
public static final String SNET_URL = "https://github.com/topjohnwu/MagiskManager/raw/a82a5e5a49285df65da91d2e8b24f4783841b515/snet.apk";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String REPO_URL = "https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&page=%d";
|
|
|
|
public static final String FILE_URL = "https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s";
|
|
|
|
public static final String ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip";
|
|
|
|
public static final String DONATION_URL = "https://www.paypal.me/topjohnwu";
|
2017-12-25 19:00:07 +00:00
|
|
|
public static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3473445";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class Key {
|
|
|
|
// su
|
|
|
|
public static final String ROOT_ACCESS = "root_access";
|
|
|
|
public static final String SU_MULTIUSER_MODE = "multiuser_mode";
|
|
|
|
public static final String SU_MNT_NS = "mnt_ns";
|
|
|
|
public static final String SU_REQUESTER = "requester";
|
|
|
|
public static final String SU_REQUEST_TIMEOUT = "su_request_timeout";
|
|
|
|
public static final String SU_AUTO_RESPONSE = "su_auto_response";
|
|
|
|
public static final String SU_NOTIFICATION = "su_notification";
|
|
|
|
public static final String SU_REAUTH = "su_reauth";
|
2018-01-11 17:53:49 +00:00
|
|
|
public static final String SU_FINGERPRINT = "su_fingerprint";
|
2017-11-05 20:41:23 +00:00
|
|
|
|
|
|
|
// intents
|
|
|
|
public static final String OPEN_SECTION = "section";
|
2018-02-12 17:22:43 +00:00
|
|
|
public static final String INTENT_SET_FILENAME = "filename";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String INTENT_SET_LINK = "link";
|
2017-11-05 21:36:20 +00:00
|
|
|
public static final String INTENT_PERM = "perm_dialog";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String FLASH_ACTION = "action";
|
|
|
|
public static final String FLASH_SET_BOOT = "boot";
|
2017-11-05 21:36:20 +00:00
|
|
|
|
2017-11-05 20:41:23 +00:00
|
|
|
// others
|
2018-02-19 16:39:17 +00:00
|
|
|
public static final String CHECK_UPDATES = "check_update";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String UPDATE_CHANNEL = "update_channel";
|
2017-11-19 19:09:08 +00:00
|
|
|
public static final String CUSTOM_CHANNEL = "custom_channel";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String BOOT_FORMAT = "boot_format";
|
|
|
|
public static final String UPDATE_SERVICE_VER = "update_service_version";
|
2017-12-02 18:48:21 +00:00
|
|
|
public static final String APP_VER = "app_version";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String MAGISKHIDE = "magiskhide";
|
|
|
|
public static final String HOSTS = "hosts";
|
2017-12-02 20:15:17 +00:00
|
|
|
public static final String COREONLY = "disable";
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final String LOCALE = "locale";
|
|
|
|
public static final String DARK_THEME = "dark_theme";
|
|
|
|
public static final String ETAG_KEY = "ETag";
|
|
|
|
public static final String LINK_KEY = "Link";
|
|
|
|
public static final String IF_NONE_MATCH = "If-None-Match";
|
2017-12-26 17:07:33 +00:00
|
|
|
public static final String REPO_ORDER = "repo_order";
|
2017-11-05 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class Value {
|
|
|
|
public static final int STABLE_CHANNEL = 0;
|
|
|
|
public static final int BETA_CHANNEL = 1;
|
2017-11-19 19:09:08 +00:00
|
|
|
public static final int CUSTOM_CHANNEL = 2;
|
2017-11-05 20:41:23 +00:00
|
|
|
public static final int ROOT_ACCESS_DISABLED = 0;
|
|
|
|
public static final int ROOT_ACCESS_APPS_ONLY = 1;
|
|
|
|
public static final int ROOT_ACCESS_ADB_ONLY = 2;
|
|
|
|
public static final int ROOT_ACCESS_APPS_AND_ADB = 3;
|
|
|
|
public static final int MULTIUSER_MODE_OWNER_ONLY = 0;
|
|
|
|
public static final int MULTIUSER_MODE_OWNER_MANAGED = 1;
|
|
|
|
public static final int MULTIUSER_MODE_USER = 2;
|
|
|
|
public static final int NAMESPACE_MODE_GLOBAL = 0;
|
|
|
|
public static final int NAMESPACE_MODE_REQUESTER = 1;
|
|
|
|
public static final int NAMESPACE_MODE_ISOLATE = 2;
|
|
|
|
public static final int NO_NOTIFICATION = 0;
|
|
|
|
public static final int NOTIFICATION_TOAST = 1;
|
|
|
|
public static final int NOTIFY_NORMAL_LOG = 0;
|
|
|
|
public static final int NOTIFY_USER_TOASTS = 1;
|
|
|
|
public static final int NOTIFY_USER_TO_OWNER = 2;
|
|
|
|
public static final int SU_PROMPT = 0;
|
|
|
|
public static final int SU_AUTO_DENY = 1;
|
|
|
|
public static final int SU_AUTO_ALLOW = 2;
|
|
|
|
public static final String FLASH_ZIP = "flash";
|
|
|
|
public static final String PATCH_BOOT = "patch";
|
|
|
|
public static final String FLASH_MAGISK = "magisk";
|
|
|
|
public static final int[] timeoutList = {0, -1, 10, 20, 30, 60};
|
2017-12-26 17:07:33 +00:00
|
|
|
public static final int ORDER_NAME = 0;
|
|
|
|
public static final int ORDER_DATE = 1;
|
2017-11-05 20:41:23 +00:00
|
|
|
}
|
|
|
|
}
|