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

Commit

Permalink
Added restrictions Srv_getPackageInfo and Srv_getApplicationInfo
Browse files Browse the repository at this point in the history
Fixed #1834
  • Loading branch information
M66B committed Aug 16, 2014
1 parent 841e78c commit 9ee4507
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Version 2.99.x and version 3.x will be available with a [pro license](http://www
**Next release**

* Added help items to template ([issue](/../../issues/1827))
* Added restrictions *Srv_getPackageInfo* and *Srv_getApplicationInfo* ([issue](/../../issues/1834))

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

Expand Down
2 changes: 2 additions & 0 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@
<string name="system_queryIntentActivityOptions" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivityOptions(android.content.ComponentName,%20android.content.Intent[],%20android.content.Intent,%20int)">Google documentation</a>]]></string>
<string name="system_queryIntentContentProviders" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentContentProviders(android.content.Intent,%20int)">Google documentation</a>]]></string>
<string name="system_queryIntentServices" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentServices(android.content.Intent,%20int)">Google documentation</a>]]></string>
<string name="system_Srv_getPackageInfo" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String,%20int)">Google documentation</a>]]></string>
<string name="system_Srv_getApplicationInfo" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#getApplicationInfo(java.lang.String,%20int)">Google documentation</a>]]></string>
<string name="system_Srv_getInstalledApplications" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledApplications(int)">Google documentation</a>]]></string>
<string name="system_Srv_getInstalledPackages" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledPackages(int)">Google documentation</a>]]></string>
<string name="system_Srv_getPackagesForUid" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/pm/PackageManager.html#getPackagesForUid(int)">Google documentation</a>]]></string>
Expand Down
2 changes: 2 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ public static List<Hook> get() {
mListHook.add(new Hook("system", "queryIntentContentProviders", "", 19, "1.99.1", null).notAOSP(19).dangerous());
mListHook.add(new Hook("system", "queryIntentServices", "", 1, null, null).notAOSP(19).dangerous());

mListHook.add(new Hook("system", "Srv_getPackageInfo", "", 19, "2.99.30", null).AOSP(19).dangerous());
mListHook.add(new Hook("system", "Srv_getApplicationInfo", "", 19, "2.99.30", null).AOSP(19).dangerous());
mListHook.add(new Hook("system", "Srv_getInstalledApplications", "", 19, "2.99", "getInstalledApplications").AOSP(19).dangerous());
mListHook.add(new Hook("system", "Srv_getInstalledPackages", "", 19, "2.99", "getInstalledPackages").AOSP(19).dangerous());
mListHook.add(new Hook("system", "Srv_getPackagesForUid", "", 19, "2.99", "getPackagesForUid").AOSP(19).dangerous());
Expand Down
19 changes: 19 additions & 0 deletions src/biz/bokhorst/xprivacy/XPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public String getClassName() {
// public android.content.pm.ParceledListSlice getInstalledPackages(int flags, int userId)
// public android.content.pm.ParceledListSlice getPackagesHoldingPermissions(java.lang.String[] permissions, int flags, int userId)
// public android.content.pm.ParceledListSlice getInstalledApplications(int flags, int userId)

// public PackageInfo getPackageInfo(String packageName, int flags, int userId)
// public ApplicationInfo getApplicationInfo(String packageName, int flags, int userId)

// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/com/android/server/pm/PackageManagerService.java

// @formatter:on
Expand All @@ -83,6 +87,7 @@ private enum Methods {

checkPermission, checkUidPermission,

Srv_getPackageInfo, Srv_getApplicationInfo,
Srv_getInstalledApplications, Srv_getInstalledPackages,
Srv_getPackagesForUid,
Srv_getPackagesHoldingPermissions,
Expand All @@ -102,6 +107,8 @@ public static List<XHook> getInstances(String className) {
if (className == null)
className = cClassName;

listHook.add(new XPackageManager(Methods.Srv_getPackageInfo, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getApplicationInfo, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getInstalledApplications, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getInstalledPackages, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getPackagesForUid, PrivacyManager.cSystem));
Expand Down Expand Up @@ -149,6 +156,18 @@ protected void before(XParam param) throws Throwable {
@SuppressWarnings("unchecked")
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case Srv_getPackageInfo:
case Srv_getApplicationInfo:
if (param.args.length > 0 && param.args[0] instanceof String && param.getResult() != null) {
String packageName = (String) param.args[0];
// Prevent recursion
if (!XPackageManager.class.getPackage().getName().equals(packageName))
if (isRestricted(param))
if (!isPackageAllowed(packageName))
param.setResult(null);
}
break;

case Srv_getInstalledApplications:
if (param.getResult() != null)
if (isRestricted(param)) {
Expand Down

0 comments on commit 9ee4507

Please sign in to comment.