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

Commit

Permalink
Allow white listing of getExternalStorageState
Browse files Browse the repository at this point in the history
Refs #1757
  • Loading branch information
M66B committed Dec 15, 2014
1 parent c821385 commit 5532b74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Changelog
* Added account type parameter for *Srv_getAccounts* and *Srv_getAccountsAsUser*
* Check external storage directory for *open* restriction ([issue](/../../issues/1757))
* Added restriction *getInstalledProvidersForProfile* ([issue](/../../issues/1757))
* Allow white listing / show parameter of *getExternalStorageState* ([issue](/../../issues/1757))

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

Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public static List<Hook> get() {
mListHook.add(new Hook("storage", "media", "WRITE_MEDIA_STORAGE", 10, null, null).dangerous().restart().noUsageData());
mListHook.add(new Hook("storage", "sdcard", "READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE,ACCESS_ALL_EXTERNAL_STORAGE", 10, null, null).dangerous().restart().noUsageData());
mListHook.add(new Hook("storage", "mtp", "ACCESS_MTP", 10, "2.1.1", null).dangerous().restart().noUsageData());
mListHook.add(new Hook("storage", "getExternalStorageState", null, 10, null, null).unsafe());
mListHook.add(new Hook("storage", "getExternalStorageState", null, 10, null, null).unsafe().whitelist(cTypeFilename));
mListHook.add(new Hook("storage", "open", null, 1, "1.99.46", null).unsafe().dangerous().whitelist(cTypeFilename));

mListHook.add(new Hook("storage", "openAssetFileDescriptor", null, 3, "2.1.17", null).unsafe().dangerous().whitelist(cTypeFilename));
Expand Down
13 changes: 11 additions & 2 deletions src/biz/bokhorst/xprivacy/XEnvironment.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package biz.bokhorst.xprivacy;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import android.os.Build;
import android.os.Environment;
import android.util.Log;

Expand Down Expand Up @@ -42,8 +44,15 @@ protected void before(XParam param) throws Throwable {
@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getExternalStorageState) {
if (param.getResult() != null && isRestricted(param))
param.setResult(Environment.MEDIA_UNMOUNTED);
if (param.getResult() != null) {
String extra = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
if (param.args.length > 0 && param.args[0] instanceof File)
extra = ((File) param.args[0]).getAbsolutePath();

if (isRestrictedExtra(param, extra))
param.setResult(Environment.MEDIA_UNMOUNTED);
}

} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
Expand Down

0 comments on commit 5532b74

Please sign in to comment.