Skip to content

Commit 777198b

Browse files
committed
Fixes debug logging in debug builds, etc.
1 parent 845a098 commit 777198b

3 files changed

Lines changed: 11 additions & 18 deletions

File tree

app/src/main/java/com/devadvance/rootcloak2/Common.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313
public class Common {
1414
public static final String PREFS_SETTINGS = "CustomizeSettings";
15-
public static final String PACKAGE_NAME = "com.devadvance.rootcloak2";
16-
public static final String FIRST_RUN_KEY = Common.PACKAGE_NAME + "IS_FIRST_RUN";
17-
public static final String DEBUG_KEY = Common.PACKAGE_NAME + "DEBUGGERPREF";
15+
public static final String FIRST_RUN_KEY = Common.class.getPackage().getName() + "IS_FIRST_RUN";
16+
public static final String DEBUG_KEY = "debug_logs";
1817
public static final String SHOW_WARNING = "SHOW_WARNING";
1918

2019
public static final PrefSet APPS = new AppsSet();
@@ -50,7 +49,7 @@ public SharedPreferences getSharedPreferences(PreferenceActivity activity) {
5049

5150
public static class AppsSet extends PrefSet {
5251
public static final String PREFS_APPS = "CustomizeApps";
53-
public static final String APP_SET_KEY = PACKAGE_NAME + "APPS_LIST"; // Uses the name LIST for legacy purposes
52+
public static final String APP_SET_KEY = Common.class.getPackage().getName() + "APPS_LIST"; // Uses the name LIST for legacy purposes
5453
public static final Set<String> DEFAULT_APPS_SET = new HashSet<>(Arrays.asList(DefaultLists.DEFAULT_APPS_LIST));
5554

5655
@Override
@@ -71,7 +70,7 @@ public Set<String> getDefaultSet() {
7170

7271
public static class KeywordSet extends PrefSet {
7372
public static final String PREFS_KEYWORDS = "CustomizeKeywords";
74-
public static final String KEYWORD_SET_KEY = PACKAGE_NAME + "KEYWORD_SET";
73+
public static final String KEYWORD_SET_KEY = Common.class.getPackage().getName() + "KEYWORD_SET";
7574
public static final Set<String> DEFAULT_KEYWORD_SET = new HashSet<>(Arrays.asList(DefaultLists.DEFAULT_KEYWORD_LIST));
7675

7776
@Override
@@ -92,7 +91,7 @@ public Set<String> getDefaultSet() {
9291

9392
public static class CommandSet extends PrefSet {
9493
public static final String PREFS_COMMANDS = "CustomizeCommands";
95-
public static final String COMMAND_SET_KEY = PACKAGE_NAME + "APPS_SET";
94+
public static final String COMMAND_SET_KEY = Common.class.getPackage().getName() + "APPS_SET";
9695
public static final Set<String> DEFAULT_COMMAND_SET = new HashSet<>(Arrays.asList(DefaultLists.DEFAULT_COMMAND_LIST));
9796

9897
@Override

app/src/main/java/com/devadvance/rootcloak2/RootCloak.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
3131
import de.robv.android.xposed.callbacks.XCallback;
3232

33-
3433
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
3534
import static de.robv.android.xposed.XposedHelpers.findConstructorExact;
3635

@@ -49,10 +48,6 @@ public class RootCloak implements IXposedHookLoadPackage {
4948
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
5049
isRootCloakLoadingPref = true;
5150
Set<String> tmpAppSet = loadSetFromPrefs(Common.APPS); // Load prefs for any app. This way we can determine if it matches the list of apps to hide root from.
52-
// if (debugPref) {
53-
// XposedBridge.log("Found app: " + lpparam.packageName);
54-
// }
55-
5651
if (!(tmpAppSet.contains(lpparam.packageName))) { // If the app doesn't match, don't hook into anything, and just return.
5752
isRootCloakLoadingPref = false;
5853
} else {
@@ -248,7 +243,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { // Ho
248243
}
249244

250245
List<ApplicationInfo> packages = (List<ApplicationInfo>) param.getResult(); // Get the results from the method call
251-
Iterator<ApplicationInfo> iter = packages.iterator();
246+
Iterator<ApplicationInfo> iter = packages.iterator();
252247
ApplicationInfo tempAppInfo;
253248
String tempPackageName;
254249

@@ -540,7 +535,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
540535
}
541536
}
542537
});
543-
538+
544539
/**
545540
* Hooks loadLibrary() within java.lang.Runtime.
546541
* There are libraries specifically built to check for root. This helps us block those and others.
@@ -613,7 +608,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
613608
XposedBridge.log("Hooked ADB debugging info, adb status is off");
614609
}
615610
}
616-
611+
617612
if (Settings.Global.DEVELOPMENT_SETTINGS_ENABLED.equals(setting)) { // Hide development options being on from an app
618613
param.setResult(0);
619614
if (debugPref) {
@@ -625,7 +620,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
625620
}
626621

627622
private void initSettings() {
628-
final XSharedPreferences prefSettings = new XSharedPreferences(Common.PACKAGE_NAME, Common.PREFS_SETTINGS);
623+
final XSharedPreferences prefSettings = new XSharedPreferences(BuildConfig.APPLICATION_ID, Common.PREFS_SETTINGS);
629624
prefSettings.makeWorldReadable();
630625
debugPref = prefSettings.getBoolean(Common.DEBUG_KEY, false);
631626
}
@@ -642,7 +637,7 @@ private static Set<String> loadSetFromPrefs(Common.PrefSet type) {
642637

643638
final Set<String> newSet = new HashSet<>();
644639
try {
645-
final XSharedPreferences loadedPrefs = new XSharedPreferences(Common.PACKAGE_NAME, type.getPrefKey());
640+
final XSharedPreferences loadedPrefs = new XSharedPreferences(BuildConfig.APPLICATION_ID, type.getPrefKey());
646641
loadedPrefs.makeWorldReadable();
647642

648643
final boolean isFirstRun = loadedPrefs.getBoolean(Common.FIRST_RUN_KEY, true); // Load boolean that determines if this is the first run since being installed.

app/src/main/java/com/devadvance/rootcloak2/SettingsActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.preference.Preference;
1212
import android.preference.PreferenceActivity;
1313

14-
1514
@SuppressWarnings("deprecation")
1615
public class SettingsActivity extends PreferenceActivity {
1716

@@ -101,7 +100,7 @@ public boolean onPreferenceChange(Preference preference,
101100
PackageManager packageManager = getPackageManager();
102101
int state = (boolean) newValue ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
103102
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
104-
String settings = Common.PACKAGE_NAME + ".Settings";
103+
String settings = SettingsActivity.class.getPackage().getName() + ".Settings";
105104
ComponentName alias = new ComponentName(SettingsActivity.this, settings);
106105
packageManager.setComponentEnabledSetting(alias, state,
107106
PackageManager.DONT_KILL_APP);

0 commit comments

Comments
 (0)