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

Commit

Permalink
Allow querying information about own package
Browse files Browse the repository at this point in the history
Closes #2079
  • Loading branch information
M66B committed Dec 13, 2014
1 parent ec7f55d commit 740f922
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ See for more information about XPrivacy 3 [this FAQ](https://github.com/M66B/XPr

* Broadcast *biz.bokhorst.xprivacy.action.EXCEPTION* if the database could not be read ([issue](/../../issues/2081))
* Fixed all problems reported through the debug info
* Allow querying information about own package in most cases ([issue](/../../issues/2079))
* Updated French translation
* Updated Indonesian translation
* Updated Polish translation
Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/XActivityThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private boolean checkIntent(int uid, Intent intent) throws Throwable {
else
packageNames = new String[] { intent.getData().getSchemeSpecificPart() };
for (String packageName : packageNames)
if (!XPackageManager.isPackageAllowed(packageName))
if (!XPackageManager.isPackageAllowed(0, packageName))
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/XContentResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private void handleUriAfter(XParam param) throws Throwable {
while (cursor.moveToNext()) {
int colPackage = cursor.getColumnIndex("package");
String packageName = (colPackage < 0 ? null : cursor.getString(colPackage));
if (packageName != null && XPackageManager.isPackageAllowed(packageName))
if (packageName != null && XPackageManager.isPackageAllowed(0, packageName))
copyColumns(cursor, result);
}
result.respond(cursor.getExtras());
Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/XIntentFirewall.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private boolean isIntentRestricted(int uid, Intent intent) throws Throwable {
else
packageNames = new String[] { intent.getData().getSchemeSpecificPart() };
for (String packageName : packageNames)
if (!XPackageManager.isPackageAllowed(packageName))
if (!XPackageManager.isPackageAllowed(0, packageName))
return true;
}

Expand Down
19 changes: 10 additions & 9 deletions src/biz/bokhorst/xprivacy/XPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ protected void after(XParam param) throws Throwable {
ApplicationInfo aInfo = (ApplicationInfo) param.getResult();
uid = aInfo.uid;
}
if (uid == Binder.getCallingUid())
return;

String packageName = (String) param.args[0];

// Prevent recursion
if (!XPackageManager.class.getPackage().getName().equals(packageName))
if (isRestrictedExtra(param, packageName))
if (!isPackageAllowed(packageName))
if (!isPackageAllowed(uid, packageName))
param.setResult(null);
}
break;
Expand Down Expand Up @@ -348,23 +346,24 @@ private void checkPermission(XParam param, int uid, String permName) throws Thro
private List<ApplicationInfo> filterApplicationInfo(List<ApplicationInfo> original) {
ArrayList<ApplicationInfo> result = new ArrayList<ApplicationInfo>();
for (ApplicationInfo appInfo : original)
if (isPackageAllowed(appInfo.packageName))
if (isPackageAllowed(appInfo.uid, appInfo.packageName))
result.add(appInfo);
return result;
}

private List<PackageInfo> filterPackageInfo(List<PackageInfo> original) {
ArrayList<PackageInfo> result = new ArrayList<PackageInfo>();
for (PackageInfo pkgInfo : original)
if (isPackageAllowed(pkgInfo.packageName))
if (isPackageAllowed(pkgInfo.applicationInfo == null ? 0 : pkgInfo.applicationInfo.uid, pkgInfo.packageName))
result.add(pkgInfo);
return result;
}

private List<ProviderInfo> filterProviderInfo(List<ProviderInfo> original) {
ArrayList<ProviderInfo> result = new ArrayList<ProviderInfo>();
for (ProviderInfo provInfo : original)
if (isPackageAllowed(provInfo.packageName))
if (isPackageAllowed(provInfo.applicationInfo == null ? 0 : provInfo.applicationInfo.uid,
provInfo.packageName))
result.add(provInfo);
return result;
}
Expand All @@ -373,13 +372,15 @@ private List<ResolveInfo> filterResolveInfo(List<ResolveInfo> original) {
ArrayList<ResolveInfo> result = new ArrayList<ResolveInfo>();
for (ResolveInfo resInfo : original)
if (resInfo.activityInfo != null && resInfo.activityInfo.applicationInfo != null)
if (isPackageAllowed(resInfo.activityInfo.applicationInfo.packageName))
if (isPackageAllowed(resInfo.activityInfo.applicationInfo.uid,
resInfo.activityInfo.applicationInfo.packageName))
result.add(resInfo);
return result;
}

public static boolean isPackageAllowed(String packageName) {
int uid = Binder.getCallingUid();
public static boolean isPackageAllowed(int uid, String packageName) {
if (uid == Binder.getCallingUid())
return true;

if (packageName == null) {
Util.log(null, Log.WARN, "isPackageAllowed uid=" + uid + " package=" + packageName);
Expand Down

0 comments on commit 740f922

Please sign in to comment.