From 66de1d9909560742735baaa5d02cf489c0b5847f Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 31 Jan 2014 13:57:15 +0100 Subject: [PATCH] Fixed accessing Google services Closes #1206 Closes #1209 --- CHANGELOG.md | 1 + .../bokhorst/xprivacy/XAccountManager.java | 44 +++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fea7b8d..2a3e6b3f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Test and beta releases will have experimental functions enabled by default. **Next release** +* Fixed accessing Google services ([issue](https://github.com/M66B/XPrivacy/issues/1206)) ([issue](https://github.com/M66B/XPrivacy/issues/1209)) * Compatibility with LBE Security Master ([issue](https://github.com/M66B/XPrivacy/issues/1167)) * Display message for *media* restrictions * Added *deny once* (this will be cached for 15 seconds) diff --git a/src/biz/bokhorst/xprivacy/XAccountManager.java b/src/biz/bokhorst/xprivacy/XAccountManager.java index f3dc2d185..4694c5f8d 100644 --- a/src/biz/bokhorst/xprivacy/XAccountManager.java +++ b/src/biz/bokhorst/xprivacy/XAccountManager.java @@ -107,6 +107,7 @@ protected void before(MethodHookParam param) throws Throwable { } param.args[0] = xlistener; } + } else if (mMethod == Methods.removeOnAccountsUpdatedListener) { if (param.args.length > 0 && param.args[0] != null) if (isRestricted(param)) { @@ -121,17 +122,29 @@ protected void before(MethodHookParam param) throws Throwable { } } } + } else if (mMethod == Methods.getAccountsByTypeAndFeatures) { - if (param.args.length > 2 && param.args[2] != null) { - AccountManagerCallback callback = (AccountManagerCallback) param.args[2]; - param.args[2] = new XAccountManagerCallbackAccount(callback, Binder.getCallingUid()); - } - } else if (mMethod == Methods.getAuthToken) { - for (int i = 0; i < param.args.length; i++) - if (param.args[i] instanceof AccountManagerCallback) { - AccountManagerCallback callback = (AccountManagerCallback) param.args[i]; - param.args[i] = new XAccountManagerCallbackBundle(callback, Binder.getCallingUid()); + if (param.args.length > 2 && param.args[2] != null) + if (isRestricted(param)) { + AccountManagerCallback callback = (AccountManagerCallback) param.args[2]; + param.args[2] = new XAccountManagerCallbackAccount(callback, Binder.getCallingUid()); } + + } else if (mMethod == Methods.getAuthToken || mMethod == Methods.getAuthTokenByFeatures) { + for (int i = 0; i < param.args.length; i++) + if (param.args[i] instanceof AccountManagerCallback) + if (isRestricted(param)) { + AccountManagerCallback callback = (AccountManagerCallback) param.args[i]; + param.args[i] = new XAccountManagerCallbackBundle(callback, Binder.getCallingUid()); + } + + } else if (mMethod == Methods.hasFeatures) { + for (int i = 0; i < param.args.length; i++) + if (param.args[i] instanceof AccountManagerCallback) + if (isRestricted(param)) { + AccountManagerCallback callback = (AccountManagerCallback) param.args[i]; + param.args[i] = new XAccountManagerCallbackBoolean(callback); + } } } @@ -367,4 +380,17 @@ public void run(AccountManagerFuture future) { mCallback.run(new XAccountManager.XFutureBundle(future, mUid)); } } + + private class XAccountManagerCallbackBoolean implements AccountManagerCallback { + private AccountManagerCallback mCallback; + + public XAccountManagerCallbackBoolean(AccountManagerCallback callback) { + mCallback = callback; + } + + @Override + public void run(AccountManagerFuture future) { + mCallback.run(new XAccountManager.XFutureBoolean()); + } + } }