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

Commit

Permalink
Added restrictions for SIP calling
Browse files Browse the repository at this point in the history
Fixes #1739
  • Loading branch information
M66B committed Jun 19, 2014
1 parent 09a1ad6 commit 4e09934
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Changelog

**Next release**

* Added restrictions for [SIP](http://en.wikipedia.org/wiki/Session_Initiation_Protocol) calling ([issue](/../../issues/1739))

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

**Version 2.1.4 STABLE**
Expand Down
4 changes: 4 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public static List<Hook> get() {
mListHook.add(new Hook("calling", "android.intent.action.RESPOND_VIA_MESSAGE", "SEND_RESPOND_VIA_MESSAGE", 18, null, null).doNotify());
mListHook.add(new Hook("calling", "android.intent.action.CALL", "CALL_PHONE", 10, null, null).doNotify());

mListHook.add(new Hook("calling", "SIP.isApiSupported", "USE_SIP", 9, null, null).doNotify());
mListHook.add(new Hook("calling", "SIP.isVoipSupported", "USE_SIP", 9, null, null).doNotify());
mListHook.add(new Hook("calling", "SIP.newInstance", "USE_SIP", 9, null, null).doNotify());

mListHook.add(new Hook("clipboard", "addPrimaryClipChangedListener", "", 11, null, null));
mListHook.add(new Hook("clipboard", "getPrimaryClip", "", 11, null, null).doNotify());
mListHook.add(new Hook("clipboard", "getPrimaryClipDescription", "", 11, null, null).doNotify());
Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// Settings secure
hookAll(XSettingsSecure.getInstances(), mSecret);

// SIP manager
hookAll(XSipManager.getInstances(), mSecret);

// SMS manager
hookAll(XSmsManager.getInstances(), mSecret);

Expand Down
64 changes: 64 additions & 0 deletions src/biz/bokhorst/xprivacy/XSipManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package biz.bokhorst.xprivacy;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class XSipManager extends XHook {
private Methods mMethod;

private XSipManager(Methods method, String restrictionName) {
super(restrictionName, method.name(), "SIP." + method.name());
mMethod = method;
}

private XSipManager(Methods method, String restrictionName, int sdk) {
super(restrictionName, method.name(), "SIP." + method.name(), sdk);
mMethod = method;
}

public String getClassName() {
return "android.net.sip.SipManager";
}

// @formatter:off

// static boolean isApiSupported(Context context)
// static boolean isVoipSupported(Context context)
// public static SipManager newInstance (Context context)
// http://developer.android.com/reference/android/net/sip/SipManager.html

// @formatter:on

private enum Methods {
isApiSupported, isVoipSupported, newInstance
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XSipManager(Methods.isApiSupported, PrivacyManager.cCalling));
listHook.add(new XSipManager(Methods.isVoipSupported, PrivacyManager.cCalling));
listHook.add(new XSipManager(Methods.newInstance, PrivacyManager.cCalling));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
if (mMethod == Methods.isApiSupported || mMethod == Methods.isVoipSupported) {
if (isRestricted(param))
param.setResult(false);

} else if (mMethod == Methods.newInstance) {
if (isRestricted(param))
param.setResult(null);

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

@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}

0 comments on commit 4e09934

Please sign in to comment.