diff --git a/src/biz/bokhorst/xprivacy/CRestriction.java b/src/biz/bokhorst/xprivacy/CRestriction.java index 72c8b65d1..ce031ace7 100644 --- a/src/biz/bokhorst/xprivacy/CRestriction.java +++ b/src/biz/bokhorst/xprivacy/CRestriction.java @@ -47,6 +47,10 @@ public void setMethodName(String methodName) { mMethodName = methodName; } + public void setExtra(String extra) { + mExtra = extra; + } + public boolean isSameMethod(PRestriction restriction) { // @formatter:off return (restriction.uid == mUid diff --git a/src/biz/bokhorst/xprivacy/PrivacyService.java b/src/biz/bokhorst/xprivacy/PrivacyService.java index 4e093d4fe..e4c226be0 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyService.java +++ b/src/biz/bokhorst/xprivacy/PrivacyService.java @@ -1389,21 +1389,32 @@ private boolean onDemandDialog(final Hook hook, final PRestriction restriction, Util.log(null, Log.WARN, "On demanding " + restriction); // Check if not asked before - CRestriction key = new CRestriction(restriction, restriction.extra); + CRestriction mkey = new CRestriction(restriction, restriction.extra); synchronized (mRestrictionCache) { - if (mRestrictionCache.containsKey(key)) - if (mRestrictionCache.get(key).asked) { + if (mRestrictionCache.containsKey(mkey)) + if (mRestrictionCache.get(mkey).asked) { Util.log(null, Log.WARN, "Already asked " + restriction); - result.restricted = mRestrictionCache.get(key).restricted; + result.restricted = mRestrictionCache.get(mkey).restricted; result.asked = true; return false; } } synchronized (mAskedOnceCache) { - if (mAskedOnceCache.containsKey(key) && !mAskedOnceCache.get(key).isExpired()) { + if (mAskedOnceCache.containsKey(mkey) && !mAskedOnceCache.get(mkey).isExpired()) { Util.log(null, Log.WARN, "Already asked once " + restriction); - result.restricted = mAskedOnceCache.get(key).restricted; + result.restricted = mAskedOnceCache.get(mkey).restricted; + result.asked = true; + return false; + } + } + + CRestriction ckey = new CRestriction(restriction, null); + ckey.setMethodName(null); + synchronized (mAskedOnceCache) { + if (mAskedOnceCache.containsKey(ckey) && !mAskedOnceCache.get(ckey).isExpired()) { + Util.log(null, Log.WARN, "Already asked once category " + restriction); + result.restricted = mAskedOnceCache.get(ckey).restricted; result.asked = true; return false; } @@ -1748,24 +1759,15 @@ private void onDemandOnce(final PRestriction restriction, boolean category, fina result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs; CRestriction key = new CRestriction(result, restriction.extra); + if (category) { + key.setMethodName(null); + key.setExtra(null); + } synchronized (mAskedOnceCache) { if (mAskedOnceCache.containsKey(key)) mAskedOnceCache.remove(key); mAskedOnceCache.put(key, key); } - - if (category) { - for (Hook hook : PrivacyManager.getHooks(restriction.restrictionName)) - if (!restriction.methodName.equals(hook.getName())) { - CRestriction mkey = new CRestriction(result, null); - mkey.setMethodName(hook.getName()); - synchronized (mAskedOnceCache) { - if (mAskedOnceCache.containsKey(mkey)) - mAskedOnceCache.remove(mkey); - mAskedOnceCache.put(mkey, mkey); - } - } - } } private void onDemandChoice(PRestriction restriction, boolean category, boolean restrict) {