diff --git a/CHANGELOG.md b/CHANGELOG.md
index 26293fbf5..16c892e81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ Changelog
* Prevent accidental application name clicks ([issue](/../../issues/2109))
* Fixed restriction *USB.getSerialNumber*
+* Added restriction *Cast.getDeviceId* and *Cast.getIpAddress* ([issue](/../../issues/2108))
[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
diff --git a/res/values/functions.xml b/res/values/functions.xml
index 774515c85..60001bb89 100644
--- a/res/values/functions.xml
+++ b/res/values/functions.xml
@@ -99,6 +99,8 @@
Google documentation]]>
Google documentation]]>
Google documentation]]>
+ Google documentation]]>
+ Google documentation]]>
Google documentation]]>
diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java
index 9b8b76636..03d09ce83 100644
--- a/src/biz/bokhorst/xprivacy/Meta.java
+++ b/src/biz/bokhorst/xprivacy/Meta.java
@@ -150,6 +150,9 @@ public static List get() {
mListHook.add(new Hook("identification", "Srv_Android_ID", "", 19, "2.99", "getString").AOSP(19));
+ mListHook.add(new Hook("identification", "Cast.getDeviceId", "", 1, "3.5.11", null).unsafe());
+ mListHook.add(new Hook("identification", "Cast.getIpAddress", "", 1, "3.5.11", null).unsafe());
+
// java.net.NetworkInterface
mListHook.add(new Hook("internet", "NetworkInterface.getByIndex", "INTERNET", 19, "2.2.2", null).unsafe());
mListHook.add(new Hook("internet", "NetworkInterface.getByInetAddress", "INTERNET", 1, "2.2.2", "getByInetAddress").unsafe());
diff --git a/src/biz/bokhorst/xprivacy/PrivacyManager.java b/src/biz/bokhorst/xprivacy/PrivacyManager.java
index aa62dcbc0..c0d114ea1 100644
--- a/src/biz/bokhorst/xprivacy/PrivacyManager.java
+++ b/src/biz/bokhorst/xprivacy/PrivacyManager.java
@@ -1155,6 +1155,9 @@ public static Object getDefacedProp(int uid, String name) {
if (name.equals("BTName"))
return cDeface;
+ if (name.equals("CastID"))
+ return cDeface;
+
// Fallback
Util.log(null, Log.ERROR, "Fallback value name=" + name);
Util.logStack(null, Log.ERROR);
diff --git a/src/biz/bokhorst/xprivacy/XCastDevice.java b/src/biz/bokhorst/xprivacy/XCastDevice.java
new file mode 100644
index 000000000..7c1723dd4
--- /dev/null
+++ b/src/biz/bokhorst/xprivacy/XCastDevice.java
@@ -0,0 +1,56 @@
+package biz.bokhorst.xprivacy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.os.Binder;
+import biz.bokhorst.xprivacy.XHook;
+
+public class XCastDevice extends XHook {
+ private Methods mMethod;
+
+ private XCastDevice(Methods method, String restrictionName) {
+ super(restrictionName, method.name(), "Cast." + method.name());
+ mMethod = method;
+ }
+
+ public String getClassName() {
+ return "com.google.android.gms.cast.CastDevice";
+ }
+
+ // public static getDeviceId()
+ // public Inet4Address getIpAddress()
+ // http://developer.android.com/reference/com/google/android/gms/cast/CastDevice.html
+
+ private enum Methods {
+ getDeviceId, getIpAddress
+ };
+
+ public static List getInstances() {
+ List listHook = new ArrayList();
+ listHook.add(new XCastDevice(Methods.getDeviceId, PrivacyManager.cIdentification));
+ listHook.add(new XCastDevice(Methods.getIpAddress, PrivacyManager.cIdentification));
+ return listHook;
+ }
+
+ @Override
+ protected void before(XParam param) throws Throwable {
+ // Do nothing
+ }
+
+ @Override
+ protected void after(XParam param) throws Throwable {
+ // Do nothing
+ switch (mMethod) {
+ case getDeviceId:
+ if (param.getResult() != null && isRestricted(param))
+ param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "CastID"));
+ break;
+
+ case getIpAddress:
+ if (param.getResult() != null && isRestricted(param))
+ param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "InetAddress"));
+ break;
+ }
+ }
+}
diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java
index d53292068..f5c62e347 100644
--- a/src/biz/bokhorst/xprivacy/XPrivacy.java
+++ b/src/biz/bokhorst/xprivacy/XPrivacy.java
@@ -287,6 +287,13 @@ private static void handleLoadPackage(String packageName, ClassLoader classLoade
} catch (Throwable ignored) {
}
+ // Cast device
+ try {
+ Class.forName("com.google.android.gms.cast.CastDevice", false, classLoader);
+ hookAll(XCastDevice.getInstances(), classLoader, secret);
+ } catch (Throwable ignored) {
+ }
+
// Google auth
try {
Class.forName("com.google.android.gms.auth.GoogleAuthUtil", false, classLoader);