Add interface to disable modules log
New method: XposedBridge.log(String name, String text) XposedBridge.log(String name, Throwable t)
This commit is contained in:
parent
96185011cd
commit
2c5c5f8cc8
|
|
@ -23,6 +23,10 @@ public class BaseEdxpConfig implements EdxpConfig {
|
||||||
public boolean isResourcesHookEnabled() {
|
public boolean isResourcesHookEnabled() {
|
||||||
return ConfigManager.isResourcesHookEnabled();
|
return ConfigManager.isResourcesHookEnabled();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isNoModuleLogEnabled() {
|
||||||
|
return ConfigManager.isNoModuleLogEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBlackWhiteListMode() {
|
public boolean isBlackWhiteListMode() {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ public class ConfigManager {
|
||||||
|
|
||||||
public static native boolean isDynamicModulesEnabled();
|
public static native boolean isDynamicModulesEnabled();
|
||||||
|
|
||||||
|
public static native boolean isNoModuleLogEnabled();
|
||||||
|
|
||||||
public static native boolean isResourcesHookEnabled();
|
public static native boolean isResourcesHookEnabled();
|
||||||
|
|
||||||
public static native boolean isDeoptBootImageEnabled();
|
public static native boolean isDeoptBootImageEnabled();
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ public class InstallerChooser {
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? "/data/user_de/0/" : "/data/user/0/";
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? "/data/user_de/0/" : "/data/user/0/";
|
||||||
|
|
||||||
|
|
||||||
public static final String PRIMARY_INSTALLER_PACKAGE_NAME = "com.solohsu.android.edxp.manager";
|
public static final String PRIMARY_INSTALLER_PACKAGE_NAME = "org.meowcat.edxposed.manager";
|
||||||
public static final String SECONDARY_INSTALLER_PACKAGE_NAME = "org.meowcat.edxposed.manager";
|
|
||||||
public static final String LEGACY_INSTALLER_PACKAGE_NAME = "de.robv.android.xposed.installer";
|
public static final String LEGACY_INSTALLER_PACKAGE_NAME = "de.robv.android.xposed.installer";
|
||||||
|
|
||||||
public static String INSTALLER_PACKAGE_NAME;
|
public static String INSTALLER_PACKAGE_NAME;
|
||||||
|
|
@ -42,12 +41,6 @@ public class InstallerChooser {
|
||||||
Utils.logI("using " + PRIMARY_INSTALLER_PACKAGE_NAME + "as installer app");
|
Utils.logI("using " + PRIMARY_INSTALLER_PACKAGE_NAME + "as installer app");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkDataDirValid(dataBaseDir = DATA_DIR_PATH_PREFIX + SECONDARY_INSTALLER_PACKAGE_NAME + "/")) {
|
|
||||||
INSTALLER_PACKAGE_NAME = SECONDARY_INSTALLER_PACKAGE_NAME;
|
|
||||||
INSTALLER_DATA_BASE_DIR = dataBaseDir;
|
|
||||||
Utils.logI("using " + SECONDARY_INSTALLER_PACKAGE_NAME + "as installer app");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checkDataDirValid(dataBaseDir = DATA_DIR_PATH_PREFIX + LEGACY_INSTALLER_PACKAGE_NAME + "/")) {
|
if (checkDataDirValid(dataBaseDir = DATA_DIR_PATH_PREFIX + LEGACY_INSTALLER_PACKAGE_NAME + "/")) {
|
||||||
INSTALLER_PACKAGE_NAME = LEGACY_INSTALLER_PACKAGE_NAME;
|
INSTALLER_PACKAGE_NAME = LEGACY_INSTALLER_PACKAGE_NAME;
|
||||||
INSTALLER_DATA_BASE_DIR = dataBaseDir;
|
INSTALLER_DATA_BASE_DIR = dataBaseDir;
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ public abstract class BaseRouter implements Router {
|
||||||
XposedHelpers.findAndHookMethod(OnePlusWorkAroundHooker.className,
|
XposedHelpers.findAndHookMethod(OnePlusWorkAroundHooker.className,
|
||||||
classLoader, OnePlusWorkAroundHooker.methodName,
|
classLoader, OnePlusWorkAroundHooker.methodName,
|
||||||
int.class, String.class, new OneplusWorkaround());
|
int.class, String.class, new OneplusWorkaround());
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HookMain.doHookDefault(
|
HookMain.doHookDefault(
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,6 @@ namespace edxp {
|
||||||
LOGI("using installer %s", kPrimaryInstallerPkgName);
|
LOGI("using installer %s", kPrimaryInstallerPkgName);
|
||||||
return kPrimaryInstallerPkgName;
|
return kPrimaryInstallerPkgName;
|
||||||
}
|
}
|
||||||
data_test_path = data_path_prefix_ + kSecondaryInstallerPkgName;
|
|
||||||
if (access(data_test_path.c_str(), F_OK) == 0) {
|
|
||||||
LOGI("using installer %s", kSecondaryInstallerPkgName);
|
|
||||||
return kSecondaryInstallerPkgName;
|
|
||||||
}
|
|
||||||
data_test_path = data_path_prefix_ + kLegacyInstallerPkgName;
|
data_test_path = data_path_prefix_ + kLegacyInstallerPkgName;
|
||||||
if (access(data_test_path.c_str(), F_OK) == 0) {
|
if (access(data_test_path.c_str(), F_OK) == 0) {
|
||||||
LOGI("using installer %s", kLegacyInstallerPkgName);
|
LOGI("using installer %s", kLegacyInstallerPkgName);
|
||||||
|
|
@ -87,14 +82,16 @@ namespace edxp {
|
||||||
black_white_list_enabled_ = access(GetConfigPath("blackwhitelist").c_str(), F_OK) == 0;
|
black_white_list_enabled_ = access(GetConfigPath("blackwhitelist").c_str(), F_OK) == 0;
|
||||||
deopt_boot_image_enabled_ = access(GetConfigPath("deoptbootimage").c_str(), F_OK) == 0;
|
deopt_boot_image_enabled_ = access(GetConfigPath("deoptbootimage").c_str(), F_OK) == 0;
|
||||||
resources_hook_enabled_ = access(GetConfigPath("disable_resources").c_str(), F_OK) != 0;
|
resources_hook_enabled_ = access(GetConfigPath("disable_resources").c_str(), F_OK) != 0;
|
||||||
|
no_module_log_enabled_ = access(GetConfigPath("disable_modules_log").c_str(), F_OK) == 0;
|
||||||
|
|
||||||
// use_white_list snapshot
|
// use_white_list snapshot
|
||||||
use_white_list_snapshot_ = access(use_whitelist_path_.c_str(), F_OK) == 0;
|
use_white_list_snapshot_ = access(use_whitelist_path_.c_str(), F_OK) == 0;
|
||||||
LOGI("black/white list mode: %s, using whitelist: %s",
|
LOGI("application list mode: %s, using whitelist: %s",
|
||||||
BoolToString(black_white_list_enabled_), BoolToString(use_white_list_snapshot_));
|
BoolToString(black_white_list_enabled_), BoolToString(use_white_list_snapshot_));
|
||||||
LOGI("dynamic modules mode: %s", BoolToString(dynamic_modules_enabled_));
|
LOGI("dynamic modules mode: %s", BoolToString(dynamic_modules_enabled_));
|
||||||
LOGI("resources hook: %s", BoolToString(resources_hook_enabled_));
|
LOGI("resources hook: %s", BoolToString(resources_hook_enabled_));
|
||||||
LOGI("deopt boot image: %s", BoolToString(deopt_boot_image_enabled_));
|
LOGI("deopt boot image: %s", BoolToString(deopt_boot_image_enabled_));
|
||||||
|
LOGI("no module log: %s", BoolToString(no_module_log_enabled_));
|
||||||
if (black_white_list_enabled_) {
|
if (black_white_list_enabled_) {
|
||||||
SnapshotBlackWhiteList();
|
SnapshotBlackWhiteList();
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +122,6 @@ namespace edxp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strcmp(package_name, kPrimaryInstallerPkgName) == 0
|
if (strcmp(package_name, kPrimaryInstallerPkgName) == 0
|
||||||
|| strcmp(package_name, kSecondaryInstallerPkgName) == 0
|
|
||||||
|| strcmp(package_name, kLegacyInstallerPkgName) == 0) {
|
|| strcmp(package_name, kLegacyInstallerPkgName) == 0) {
|
||||||
// always hook installer apps
|
// always hook installer apps
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -164,6 +160,10 @@ namespace edxp {
|
||||||
return dynamic_modules_enabled_;
|
return dynamic_modules_enabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE bool ConfigManager::IsNoModuleLogEnabled() const {
|
||||||
|
return no_module_log_enabled_;
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE bool ConfigManager::IsResourcesHookEnabled() const {
|
ALWAYS_INLINE bool ConfigManager::IsResourcesHookEnabled() const {
|
||||||
return resources_hook_enabled_;
|
return resources_hook_enabled_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
namespace edxp {
|
namespace edxp {
|
||||||
|
|
||||||
static constexpr const char *kPrimaryInstallerPkgName = "com.solohsu.android.edxp.manager";
|
static constexpr const char *kPrimaryInstallerPkgName = "org.meowcat.edxposed.manager";
|
||||||
static constexpr const char *kSecondaryInstallerPkgName = "org.meowcat.edxposed.manager";
|
|
||||||
static constexpr const char *kLegacyInstallerPkgName = "de.robv.android.xposed.installer";
|
static constexpr const char *kLegacyInstallerPkgName = "de.robv.android.xposed.installer";
|
||||||
|
|
||||||
class ConfigManager {
|
class ConfigManager {
|
||||||
|
|
@ -30,6 +29,8 @@ namespace edxp {
|
||||||
|
|
||||||
bool IsDeoptBootImageEnabled() const;
|
bool IsDeoptBootImageEnabled() const;
|
||||||
|
|
||||||
|
bool IsNoModuleLogEnabled() const;
|
||||||
|
|
||||||
std::string GetInstallerPkgName() const;
|
std::string GetInstallerPkgName() const;
|
||||||
|
|
||||||
bool IsAppNeedHook(const std::string &app_data_dir) const;
|
bool IsAppNeedHook(const std::string &app_data_dir) const;
|
||||||
|
|
@ -47,6 +48,7 @@ namespace edxp {
|
||||||
bool black_white_list_enabled_ = false;
|
bool black_white_list_enabled_ = false;
|
||||||
bool dynamic_modules_enabled_ = false;
|
bool dynamic_modules_enabled_ = false;
|
||||||
bool deopt_boot_image_enabled_ = false;
|
bool deopt_boot_image_enabled_ = false;
|
||||||
|
bool no_module_log_enabled_ = false;
|
||||||
bool resources_hook_enabled_ = true;
|
bool resources_hook_enabled_ = true;
|
||||||
// snapshot at boot
|
// snapshot at boot
|
||||||
bool use_white_list_snapshot_ = false;
|
bool use_white_list_snapshot_ = false;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ namespace edxp {
|
||||||
return (jboolean) ConfigManager::GetInstance()->IsDeoptBootImageEnabled();
|
return (jboolean) ConfigManager::GetInstance()->IsDeoptBootImageEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jboolean ConfigManager_isNoModuleLogEnabled(JNI_START) {
|
||||||
|
return (jboolean) ConfigManager::GetInstance()->IsNoModuleLogEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
static jstring ConfigManager_getInstallerPackageName(JNI_START) {
|
static jstring ConfigManager_getInstallerPackageName(JNI_START) {
|
||||||
return env->NewStringUTF(ConfigManager::GetInstance()->GetInstallerPkgName().c_str());
|
return env->NewStringUTF(ConfigManager::GetInstance()->GetInstallerPkgName().c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +42,7 @@ namespace edxp {
|
||||||
NATIVE_METHOD(ConfigManager, isDynamicModulesEnabled, "()Z"),
|
NATIVE_METHOD(ConfigManager, isDynamicModulesEnabled, "()Z"),
|
||||||
NATIVE_METHOD(ConfigManager, isResourcesHookEnabled, "()Z"),
|
NATIVE_METHOD(ConfigManager, isResourcesHookEnabled, "()Z"),
|
||||||
NATIVE_METHOD(ConfigManager, isDeoptBootImageEnabled, "()Z"),
|
NATIVE_METHOD(ConfigManager, isDeoptBootImageEnabled, "()Z"),
|
||||||
|
NATIVE_METHOD(ConfigManager, isNoModuleLogEnabled, "()Z"),
|
||||||
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
|
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
|
||||||
NATIVE_METHOD(ConfigManager, isAppNeedHook, "(Ljava/lang/String;)Z"),
|
NATIVE_METHOD(ConfigManager, isAppNeedHook, "(Ljava/lang/String;)Z"),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ public interface EdxpConfig {
|
||||||
|
|
||||||
boolean isDynamicModulesMode();
|
boolean isDynamicModulesMode();
|
||||||
|
|
||||||
|
boolean isNoModuleLogEnabled();
|
||||||
|
|
||||||
boolean isResourcesHookEnabled();
|
boolean isResourcesHookEnabled();
|
||||||
|
|
||||||
boolean isBlackWhiteListMode();
|
boolean isBlackWhiteListMode();
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ public final class XposedBridge {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a message to the Xposed error log.
|
* Writes a message to the Xposed modules log.
|
||||||
*
|
*
|
||||||
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
||||||
* If you want to write information/debug messages, use logcat.
|
* If you want to write information/debug messages, use logcat.
|
||||||
|
|
@ -155,11 +155,14 @@ public final class XposedBridge {
|
||||||
* @param text The log message.
|
* @param text The log message.
|
||||||
*/
|
*/
|
||||||
public synchronized static void log(String text) {
|
public synchronized static void log(String text) {
|
||||||
Log.i(TAG, text);
|
if (EdXpConfigGlobal.getConfig().isNoModuleLogEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.i(TAG, "Module: " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a stack trace to the Xposed error log.
|
* Logs a stack trace to the Xposed modules log.
|
||||||
*
|
*
|
||||||
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
||||||
* If you want to write information/debug messages, use logcat.
|
* If you want to write information/debug messages, use logcat.
|
||||||
|
|
@ -167,7 +170,36 @@ public final class XposedBridge {
|
||||||
* @param t The Throwable object for the stack trace.
|
* @param t The Throwable object for the stack trace.
|
||||||
*/
|
*/
|
||||||
public synchronized static void log(Throwable t) {
|
public synchronized static void log(Throwable t) {
|
||||||
Log.e(TAG, Log.getStackTraceString(t));
|
Log.e(TAG, "Module: " + Log.getStackTraceString(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a message to the Xposed modules log with module's name.
|
||||||
|
*
|
||||||
|
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
||||||
|
* If you want to write information/debug messages, use logcat.
|
||||||
|
*
|
||||||
|
* @param name The module's name..
|
||||||
|
* @param text The log message.
|
||||||
|
*/
|
||||||
|
public synchronized static void log(String name, String text) {
|
||||||
|
if (EdXpConfigGlobal.getConfig().isNoModuleLogEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.i(TAG, "Module: " + name + ": " + text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a stack trace to the Xposed modules log with module's name.
|
||||||
|
*
|
||||||
|
* <p class="warning"><b>DON'T FLOOD THE LOG!!!</b> This is only meant for error logging.
|
||||||
|
* If you want to write information/debug messages, use logcat.
|
||||||
|
*
|
||||||
|
* @param name The module's name..
|
||||||
|
* @param t The Throwable object for the stack trace.
|
||||||
|
*/
|
||||||
|
public synchronized static void log(String name, Throwable t) {
|
||||||
|
Log.e(TAG, "Module: " + name + ": " + Log.getStackTraceString(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue