Skip to content

Commit 44cd96a

Browse files
committed
Remove useless field to fix NPE
1 parent bf773f2 commit 44cd96a

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Application;
44
import android.content.Context;
5+
import android.content.pm.ApplicationInfo;
56
import android.os.Binder;
67
import android.os.UserHandle;
78

@@ -52,17 +53,14 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
5253
@Override
5354
protected void afterHookedMethod(MethodHookParam param) {
5455
final Context context = (Context) param.args[0];
55-
final int userId = UserHandle.getUserHandleForUid(context.getApplicationInfo().uid).hashCode();
56-
final int packageUid = Binder.getCallingUid();
57-
final int packagePid = Binder.getCallingPid();
58-
final boolean availability = Utils.getParamAvailability(param, packagePid);
56+
final boolean availability = Utils.getParamAvailability(param, Binder.getCallingPid());
5957

60-
// hook myself
6158
if (packageName.equals(BuildConfig.APPLICATION_ID)) {
59+
// hook myself
6260
XposedHelpers.findAndHookMethod(Utils.class.getName(), lpparam.classLoader, "isEnhancementEnabled", XC_MethodReplacement.returnConstant(true));
6361
}
6462

65-
if ((boolean) callStaticMethod(UserHandle.class, "isCore", packageUid) || !availability) {
63+
if ((boolean) callStaticMethod(UserHandle.class, "isCore", Binder.getCallingUid()) || !availability) {
6664
// is Android code package
6765
return;
6866
}
@@ -90,8 +88,6 @@ protected void afterHookedMethod(MethodHookParam param) {
9088
findAndHookMethod(XposedHelpers.findClass("android.os.SystemProperties", lpparam.classLoader), "native_get", String.class, String.class, new XC_MethodHook() {
9189
@Override
9290
protected void afterHookedMethod(MethodHookParam param) {
93-
final int packagePid = Binder.getCallingPid();
94-
final boolean availability = Utils.getParamAvailability(param, packagePid);
9591
final String key = param.args[0].toString();
9692

9793
if (PROPS.containsKey(key)) {
@@ -104,8 +100,6 @@ protected void afterHookedMethod(MethodHookParam param) {
104100
findAndHookMethod(XposedHelpers.findClass("android.os.SystemProperties", lpparam.classLoader), "native_get_int", String.class, int.class, new XC_MethodHook() {
105101
@Override
106102
protected void afterHookedMethod(MethodHookParam param) {
107-
final int packagePid = Binder.getCallingPid();
108-
final boolean availability = Utils.getParamAvailability(param, packagePid);
109103
final String key = param.args[0].toString();
110104

111105
if (PROPS.containsKey(key)) {
@@ -118,8 +112,6 @@ protected void afterHookedMethod(MethodHookParam param) {
118112
findAndHookMethod(XposedHelpers.findClass("android.os.SystemProperties", lpparam.classLoader), "native_get_long", String.class, long.class, new XC_MethodHook() {
119113
@Override
120114
protected void afterHookedMethod(MethodHookParam param) {
121-
final int packagePid = Binder.getCallingPid();
122-
final boolean availability = Utils.getParamAvailability(param, packagePid);
123115
final String key = param.args[0].toString();
124116

125117
if (PROPS.containsKey(key)) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ static boolean inBuiltInBlackList(String pkgName) {
4545
*/
4646
public static boolean getParamAvailability(final XC_MethodHook.MethodHookParam methodHookParam, int callingPid) {
4747
new Thread(() -> {
48-
ClassLoader classLoader = XposedBridge.class.getClassLoader();
49-
Object[] dexElements = (Object[]) XposedHelpers.getObjectField(XposedHelpers.getObjectField(classLoader, "pathList"), "dexElements");
48+
Object[] dexElements = (Object[]) XposedHelpers.getObjectField(XposedHelpers.getObjectField(XposedBridge.class.getClassLoader(), "pathList"), "dexElements");
5049
for (Object entry : dexElements) {
5150
Enumeration<String> entries = ((DexFile) XposedHelpers.getObjectField(entry, "dexFile")).entries();
5251
while (entries.hasMoreElements()) {
53-
String className = entries.nextElement();
54-
if (className.matches(".+?(epic|weishu).+")) {
52+
if (entries.nextElement().matches(".+?(epic|weishu).+")) {
5553
try {
5654
String message = new String(Base64.decode("RG8gTk9UIHVzZSBUYWlDaGkgYW55d2F5XG7or7fkuI3opoHkvb/nlKjlpKrmnoHmiJbml6DmnoE=".getBytes(StandardCharsets.UTF_8), Base64.DEFAULT));
5755
if (methodHookParam.args[0] instanceof Application) {

0 commit comments

Comments
 (0)