Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Fixed on demand restricting for some custom ROMs
Browse files Browse the repository at this point in the history
Closes #2203
  • Loading branch information
M66B committed May 25, 2015
1 parent b71f2cd commit 2d11daa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Changelog

**Next release**

* Fixed on demand restricting on some Android Lollipop ROMs (OPPO)
* Fixed on demand restricting for some custom ROMs (OPPO)

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)

Expand Down
15 changes: 12 additions & 3 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,18 @@ public static void register(List<String> listError, ClassLoader classLoader, Str
XActivityManagerService.setSemaphore(mOndemandSemaphore);

// Get context
Field fContext = am.getClass().getField("mContext");
fContext.setAccessible(true);
mContext = (Context) fContext.get(am);
Field fContext = null;
Class<?> cam = am.getClass();
while (cam != null && fContext == null)
try {
fContext = cam.getDeclaredField("mContext");
fContext.setAccessible(true);
mContext = (Context) fContext.get(am);
} catch (NoSuchFieldException ignored) {
cam = cam.getSuperclass();
}
if (mContext == null)
Util.log(null, Log.ERROR, "No am context found");

// Start a worker thread
mWorker = new Thread(new Runnable() {
Expand Down
4 changes: 2 additions & 2 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public void initZygote(StartupParam startupParam) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Class<?> ams = Class.forName("com.android.server.am.ActivityManagerService", false, loader);
XposedBridge.hookAllConstructors(ams, new XC_MethodHook() {
Class<?> am = Class.forName("com.android.server.am.ActivityManagerService", false, loader);
XposedBridge.hookAllConstructors(am, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
PrivacyService.register(mListHookError, loader, mSecret, param.thisObject);
Expand Down

0 comments on commit 2d11daa

Please sign in to comment.