From cd42facfd8ef519a9ed130e1d7e502aab529e6bc Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 9 Jan 2015 10:26:21 +0100 Subject: [PATCH] Fixed restriction USB.getSerialNumber --- CHANGELOG.md | 1 + src/biz/bokhorst/xprivacy/XUsbDevice.java | 25 ++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5bde0bdf..26293fbf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Changelog **Next release** * Prevent accidental application name clicks ([issue](/../../issues/2109)) +* Fixed restriction *USB.getSerialNumber* [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/XUsbDevice.java b/src/biz/bokhorst/xprivacy/XUsbDevice.java index 87809d461..2bf44ebda 100644 --- a/src/biz/bokhorst/xprivacy/XUsbDevice.java +++ b/src/biz/bokhorst/xprivacy/XUsbDevice.java @@ -4,7 +4,6 @@ import java.util.List; import android.os.Binder; -import android.util.Log; import biz.bokhorst.xprivacy.XHook; public class XUsbDevice extends XHook { @@ -40,7 +39,13 @@ public static List getInstances() { @Override protected void before(XParam param) throws Throwable { - if (mMethod == Methods.getDeviceId) { + // Do nothing + } + + @Override + protected void after(XParam param) throws Throwable { + switch (mMethod) { + case getDeviceId: if (param.args.length > 0 && param.args[0] instanceof String) { if (isRestrictedExtra(param, (String) param.args[0])) param.setResult(0); @@ -48,17 +53,13 @@ protected void before(XParam param) throws Throwable { if (isRestricted(param)) param.setResult(0); } + break; - } else if (mMethod == Methods.getDeviceName) { - if (isRestricted(param)) + case getDeviceName: + case getSerialNumber: + if (param.getResult() != null && isRestricted(param)) param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "USB")); - - } else - Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); - } - - @Override - protected void after(XParam param) throws Throwable { - // Do nothing + break; + } } }