From a8d89bc41284cf4787bfd856553cebc870f8fac1 Mon Sep 17 00:00:00 2001 From: pylerCM Date: Thu, 3 Mar 2016 19:25:49 +0100 Subject: [PATCH 1/2] Added new API to get Package Info --- .../java/de/robv/android/xposed/XposedHelpers.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/de/robv/android/xposed/XposedHelpers.java b/app/src/main/java/de/robv/android/xposed/XposedHelpers.java index f53a26ac..db3b3b61 100644 --- a/app/src/main/java/de/robv/android/xposed/XposedHelpers.java +++ b/app/src/main/java/de/robv/android/xposed/XposedHelpers.java @@ -1,5 +1,7 @@ package de.robv.android.xposed; +import android.content.Context; +import android.content.pm.PackageInfo; import android.content.res.Resources; import java.io.ByteArrayOutputStream; @@ -1161,6 +1163,14 @@ public static String getMD5Sum(String file) throws IOException { return ""; } } + + public static PackageInfo getPackageInfo(String packageName) { + Object activityThread = callStaticMethod(("android.app.ActivityThread", null), "currentActivityThread"); + Context context = (Context) callMethod(activityThread, "getSystemContext"); + if (context == NULL) return NULL; + return context.getPackageManager().getPackageInfo(packageName, 0); + + } //################################################################################################# /** From 428b72a917c6fe271471f7b98aba94e2f349f9f1 Mon Sep 17 00:00:00 2001 From: pylerCM Date: Thu, 3 Mar 2016 19:30:01 +0100 Subject: [PATCH 2/2] Fixed forgotten findClass --- app/src/main/java/de/robv/android/xposed/XposedHelpers.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/robv/android/xposed/XposedHelpers.java b/app/src/main/java/de/robv/android/xposed/XposedHelpers.java index db3b3b61..0d195e79 100644 --- a/app/src/main/java/de/robv/android/xposed/XposedHelpers.java +++ b/app/src/main/java/de/robv/android/xposed/XposedHelpers.java @@ -1165,9 +1165,10 @@ public static String getMD5Sum(String file) throws IOException { } public static PackageInfo getPackageInfo(String packageName) { - Object activityThread = callStaticMethod(("android.app.ActivityThread", null), "currentActivityThread"); + Object activityThread = callStaticMethod(findClass("android.app.ActivityThread", null), "currentActivityThread"); + if (activityThread == null) return null; Context context = (Context) callMethod(activityThread, "getSystemContext"); - if (context == NULL) return NULL; + if (context == null) return null; return context.getPackageManager().getPackageInfo(packageName, 0); }