From 6759b5297971e49e6d3c6f886649c6a2b06a4185 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 12 Feb 2015 10:36:59 +0100 Subject: [PATCH] Use application whitelist for (Srv_)getPackagesForUid Closes #2116 --- CHANGELOG.md | 2 +- .../bokhorst/xprivacy/XPackageManager.java | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a15e4ba2..e5c528104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ Changelog **Next release** -* ... +* Use application whitelist for *getPackagesForUid* and *Srv_getPackagesForUid* ([issue](/../../issues/2116)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/XPackageManager.java b/src/biz/bokhorst/xprivacy/XPackageManager.java index 02b13f94f..95cc84857 100644 --- a/src/biz/bokhorst/xprivacy/XPackageManager.java +++ b/src/biz/bokhorst/xprivacy/XPackageManager.java @@ -202,12 +202,22 @@ protected void after(XParam param) throws Throwable { } break; + case getPackagesForUid: case Srv_getPackagesForUid: if (param.args.length > 0 && param.args[0] instanceof Integer && param.getResult() != null) { int uid = (Integer) param.args[0]; if (uid != Binder.getCallingUid()) - if (isRestrictedExtra(param, Integer.toString(uid))) - param.setResult(null); + if (isRestrictedExtra(param, Integer.toString(uid))) { + List lstResult = new ArrayList(); + if (param.getResult() instanceof String[]) + for (String packageName : (String[]) param.getResult()) + if (isPackageAllowed(uid, packageName)) + lstResult.add(packageName); + if (lstResult.size() == 0) + param.setResult(null); + else + param.setResult(lstResult.toArray(new String[0])); + } } break; @@ -239,15 +249,6 @@ protected void after(XParam param) throws Throwable { param.setResult(filterApplicationInfo((List) param.getResult())); break; - case getPackagesForUid: - if (param.args.length > 0 && param.args[0] instanceof Integer && param.getResult() != null) { - int uid = (Integer) param.args[0]; - if (uid != Binder.getCallingUid()) - if (isRestrictedExtra(param, Integer.toString(uid))) - param.setResult(null); - } - break; - case getPreferredActivities: break;