Skip to content

Commit 2d148b5

Browse files
committed
Code cleanup
1 parent b2c2a6f commit 2d148b5

File tree

8 files changed

+39
-37
lines changed

8 files changed

+39
-37
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
android:installLocation="internalOnly">
55

66
<application
7+
android:icon="@mipmap/ic_launcher"
78
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
810
android:theme="@style/AppTheme"
9-
tools:ignore="AllowBackup"
10-
android:icon="@mipmap/ic_launcher"
11-
android:roundIcon="@mipmap/ic_launcher_round">
11+
tools:ignore="AllowBackup">
1212
<!-- Xposed -->
1313
<meta-data
1414
android:name="xposedmodule"
15-
android:value="true"/>
15+
android:value="true" />
1616
<meta-data
1717
android:name="xposeddescription"
1818
android:value="@string/xposed_description" />
@@ -21,8 +21,8 @@
2121
android:value="53" />
2222

2323
<activity
24-
android:label="@string/app_name"
25-
android:name="top.trumeet.mipush.settings.PreferenceActivity">
24+
android:name="top.trumeet.mipush.settings.PreferenceActivity"
25+
android:label="@string/app_name">
2626
<intent-filter>
2727
<action android:name="android.intent.action.MAIN" />
2828
<action android:name="android.intent.action.VIEW" />

app/src/main/java/org/meowcat/xposed/mipush/Constants.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ public final class Constants {
2222

2323
// Built-in package name Blacklists. The module will never
2424
// hook these packages due to known compatibility issues.
25-
// regExp required
2625
public static final String[] BUILT_IN_BLACKLIST = new String[]{ // TODO: more built-in blacklist packages
2726
"android", // Android system
28-
"com\\.android.*", // Android system components
29-
"com\\.google\\.android.*", // Google apps
30-
"de\\.robv\\.android\\.xposed\\.installer", // Xposed Installer
31-
"org\\.meowcat\\.edxposed\\.manager", // EdXposed Manager
32-
"com\\.xiaomi\\.xmsf", // MiPush Framework
33-
"com\\.tencent\\.mm", // WeChat
34-
"top\\.trumeet\\.mipush" // MiPush Manager
27+
"com.android.*", // Android system components
28+
"com.google.android.*", // Google apps
29+
"de.robv.android.xposed.installer", // Xposed Installer
30+
"org.meowcat.edxposed.manager", // EdXposed Manager
31+
"com.xiaomi.xmsf", // MiPush Framework
32+
"com.tencent.mm", // WeChat
33+
"top.trumeet.mipush" // MiPush Manager
3534
}; // UserHandle.isCore(uid) will auto pass
3635

3736
static {

app/src/main/java/org/meowcat/xposed/mipush/Enhancement.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import android.content.Context;
55
import android.os.Binder;
66
import android.os.UserHandle;
7-
import android.util.Log;
87

98
import java.io.IOException;
109
import java.util.Collections;
1110

1211
import de.robv.android.xposed.IXposedHookLoadPackage;
1312
import de.robv.android.xposed.XC_MethodHook;
1413
import de.robv.android.xposed.XC_MethodReplacement;
14+
import de.robv.android.xposed.XposedBridge;
1515
import de.robv.android.xposed.XposedHelpers;
1616
import de.robv.android.xposed.callbacks.XC_LoadPackage;
1717
import top.trumeet.mipush.settings.ini.IniConf;
@@ -23,7 +23,6 @@
2323
import static org.meowcat.xposed.mipush.Constants.MODE_BLACK;
2424
import static org.meowcat.xposed.mipush.Constants.MODE_WHITE;
2525
import static org.meowcat.xposed.mipush.Constants.PROPS;
26-
import static org.meowcat.xposed.mipush.Constants.TAG;
2726
import static top.trumeet.mipush.settings.ini.IniConstants.MODULE_BLACKLIST;
2827
import static top.trumeet.mipush.settings.ini.IniConstants.MODULE_WHITELIST;
2928
import static top.trumeet.mipush.settings.ini.IniConstants.MODULE_WORKING_MODE;
@@ -44,7 +43,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
4443
String packageName = lpparam.packageName;
4544

4645
if (Utils.inBuiltInBlackList(packageName)) {
47-
// is blacklisted package
46+
// is in built-in blacklisted package
4847
return;
4948
}
5049

@@ -59,7 +58,9 @@ protected void afterHookedMethod(MethodHookParam param) {
5958
final boolean availability = Utils.getParamAvailability(param, packagePid);
6059

6160
// hook myself
62-
XposedHelpers.findAndHookMethod(Utils.class.getName(), lpparam.classLoader, "isEnhancementEnabled", XC_MethodReplacement.returnConstant(true));
61+
if (packageName.equals(BuildConfig.APPLICATION_ID)) {
62+
XposedHelpers.findAndHookMethod(Utils.class.getName(), lpparam.classLoader, "isEnhancementEnabled", XC_MethodReplacement.returnConstant(true));
63+
}
6364

6465
if ((boolean) callStaticMethod(UserHandle.class, "isCore", packageUid) || !availability) {
6566
// is Android code package
@@ -81,7 +82,7 @@ protected void afterHookedMethod(MethodHookParam param) {
8182
}
8283
break;
8384
default:
84-
Log.e(TAG, "Unknown working mode.");
85+
// Log.e(TAG, "Unknown working mode.");
8586
return;
8687
}
8788

@@ -130,7 +131,7 @@ protected void afterHookedMethod(MethodHookParam param) {
130131
XposedHelpers.setStaticObjectField(android.os.Build.class, "MANUFACTURER", BRAND);
131132
XposedHelpers.setStaticObjectField(android.os.Build.class, "BRAND", BRAND);
132133
} catch (IOException e) {
133-
e.printStackTrace();
134+
XposedBridge.log(e);
134135
}
135136
}
136137
});

app/src/main/java/org/meowcat/xposed/mipush/Utils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import de.robv.android.xposed.XposedHelpers;
1919

2020
public class Utils {
21+
2122
/**
2223
* Check package name in built-in blacklist
24+
*
2325
* @param pkgName package name to check
2426
* @return is in built-in blacklist
2527
*/
@@ -38,7 +40,7 @@ static boolean inBuiltInBlackList(String pkgName) {
3840
* call this method after got any MethodHookParam
3941
*
4042
* @param methodHookParam Xposed hook param
41-
* @param callingPid Process Pid
43+
* @param callingPid Process Pid
4244
* @return true
4345
*/
4446
public static boolean getParamAvailability(final XC_MethodHook.MethodHookParam methodHookParam, int callingPid) {
@@ -68,6 +70,7 @@ public static boolean getParamAvailability(final XC_MethodHook.MethodHookParam m
6870

6971
/**
7072
* Check Xposed module status
73+
*
7174
* @return true if hooked
7275
*/
7376
public static boolean isEnhancementEnabled() {
@@ -76,9 +79,10 @@ public static boolean isEnhancementEnabled() {
7679

7780
/**
7881
* Hide or show app icon
82+
*
7983
* @param packageManager packageNamager
80-
* @param componentName compoentName
81-
* @param hide hide or show icon
84+
* @param componentName compoentName
85+
* @param hide hide or show icon
8286
*/
8387
public static void hideIcon(PackageManager packageManager, ComponentName componentName, boolean hide) {
8488
packageManager.getComponentEnabledSetting(componentName);

app/src/main/java/top/trumeet/mipush/settings/PreferenceFragment.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import android.os.Bundle;
88
import android.os.SystemProperties;
99
import android.text.Html;
10-
import android.util.Log;
1110
import android.util.Pair;
1211
import android.view.Menu;
1312
import android.view.MenuInflater;
@@ -16,7 +15,6 @@
1615
import androidx.annotation.NonNull;
1716
import androidx.annotation.Nullable;
1817

19-
import org.meowcat.xposed.mipush.BuildConfig;
2018
import org.meowcat.xposed.mipush.R;
2119
import org.meowcat.xposed.mipush.Utils;
2220

@@ -38,7 +36,6 @@
3836
import top.trumeet.mipush.settings.ini.IniConstants;
3937
import top.trumeet.mipush.settings.ini.IniUtils;
4038

41-
import static org.meowcat.xposed.mipush.Constants.TAG;
4239
import static org.meowcat.xposed.mipush.Utils.hideIcon;
4340

4441
public class PreferenceFragment extends moe.shizuku.preference.PreferenceFragment implements
@@ -116,7 +113,7 @@ public void onResume() {
116113

117114
@Override
118115
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
119-
Log.d(TAG, "onSharedPreferenceChanged(): " + key);
116+
// Log.d(TAG, "onSharedPreferenceChanged(): " + key);
120117
if (key.equals("module_blacklist") || key.equals("module_whitelist")) {
121118
mConf.putAll(IniUtils.convertKeyToIni(key), new ArrayList<>(Objects.requireNonNull(sharedPreferences.getStringSet(key, Collections.emptySet()))));
122119
} else if (key.equals("hide_icon")) {

app/src/main/java/top/trumeet/mipush/settings/ini/IniConf.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ private Ini createDefaultConfig(@Nullable final File file) throws IOException {
103103
private void compare(@NonNull Ini parent, @NonNull Ini child) {
104104
for (final String section : parent.keySet()) {
105105
if (!child.containsKey(section)) {
106-
Log.i(TAG, "Adding section " + section);
106+
// Log.i(TAG, "Adding section " + section);
107107
child.put(section, parent.get(section));
108108
child.putComment(section, parent.getComment(section));
109109
} else {
110110
final Profile.Section parentSection = parent.get(section);
111111
final Profile.Section childSection = child.get(section);
112112
for (final String option : Objects.requireNonNull(parentSection).keySet()) {
113113
if (!Objects.requireNonNull(childSection).containsKey(option)) {
114-
Log.i(TAG, "Adding option " + option);
114+
// Log.i(TAG, "Adding option " + option);
115115
childSection.put(option, Objects.requireNonNull(parentSection.get(option)));
116116
childSection.putComment(option, parentSection.getComment(option));
117117
}
@@ -141,7 +141,7 @@ public Map<IniKey, Object> getAll() {
141141
*/
142142
@SuppressWarnings("ResultOfMethodCallIgnored")
143143
public void write() throws IOException {
144-
Log.d(TAG, "Saving configuration");
144+
// Log.d(TAG, "Saving configuration");
145145
if (mIni.getFile() != null) {
146146
// Create the parent if needed.
147147
final File parent = mIni.getFile().getParentFile();
@@ -197,7 +197,7 @@ public List<String> getAll(@NonNull IniKey key, List<String> defaultValue) {
197197
* Put a value
198198
*/
199199
public void put(@NonNull IniKey key, @Nullable Object value) {
200-
Log.d(TAG, "put() " + key + ", " + value);
200+
// Log.d(TAG, "put() " + key + ", " + value);
201201
mIni.put(key.section, key.option, value);
202202
}
203203

app/src/main/java/top/trumeet/mipush/settings/ini/IniUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static String convertKeyToSP(@NonNull final IniKey key) {
3030

3131
/**
3232
* Change file permission with given permission mode
33+
*
3334
* @param file file to change permissions
3435
* @param mode file permission
3536
*/

app/src/main/res/xml/preferences.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
33

44
<PreferenceCategory
5-
android:title="@string/pref_cat_module"
6-
android:key="pref_category">
5+
android:key="pref_category"
6+
android:title="@string/pref_cat_module">
77

88
<Preference
99
android:key="device_status"
10-
android:title="@string/pref_enhancement_status"
11-
android:summary="@string/pref_enhancement_status_failed" />
10+
android:summary="@string/pref_enhancement_status_failed"
11+
android:title="@string/pref_enhancement_status" />
1212

1313
<SimpleMenuPreference
1414
android:defaultValue="blacklist"
@@ -29,10 +29,10 @@
2929
android:title="@string/pref_whitelist" />
3030

3131
<SwitchPreference
32-
android:key="hide_icon"
3332
android:defaultValue="false"
33+
android:key="hide_icon"
3434
android:summary="@string/pref_hide_icon_summary"
35-
android:title="@string/pref_hide_icon"/>
35+
android:title="@string/pref_hide_icon" />
3636

3737
</PreferenceCategory>
3838

0 commit comments

Comments
 (0)