This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 527
/
XHook.java
123 lines (95 loc) · 4.24 KB
/
XHook.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package biz.bokhorst.xprivacy;
import android.annotation.SuppressLint;
import android.os.Binder;
public abstract class XHook {
private String mRestrictionName;
private String mMethodName;
private String mSpecifier;
private String mSecret;
protected XHook(String restrictionName, String methodName, String specifier) {
mRestrictionName = restrictionName;
mMethodName = methodName;
mSpecifier = specifier;
}
abstract public String getClassName();
public boolean isVisible() {
return true;
}
public String getRestrictionName() {
return mRestrictionName;
}
public String getMethodName() {
return mMethodName;
}
public String getSpecifier() {
return (mSpecifier == null ? mMethodName : mSpecifier);
}
public void setSecret(String secret) {
mSecret = secret;
}
protected String getSecret() {
return mSecret;
}
abstract protected void before(XParam param) throws Throwable;
abstract protected void after(XParam param) throws Throwable;
protected boolean isRestricted(XParam param) throws Throwable {
return isRestricted(param, getSpecifier());
}
protected boolean isRestrictedExtra(XParam param, String extra) throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, getSpecifier(), extra, mSecret);
}
protected boolean isRestrictedExtra(XParam param, String methodName, String extra) throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, methodName, extra, mSecret);
}
protected boolean isRestrictedExtra(XParam param, String restrictionName, String methodName, String extra)
throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestrictionExtra(this, uid, restrictionName, methodName, extra, mSecret);
}
protected boolean isRestrictedExtra(int uid, String restrictionName, String methodName, String extra)
throws Throwable {
return PrivacyManager.getRestrictionExtra(this, uid, restrictionName, methodName, extra, mSecret);
}
protected boolean isRestrictedValue(int uid, String value) throws Throwable {
return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, getSpecifier(), null, value, mSecret);
}
protected boolean isRestrictedValue(XParam param, String value) throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, getSpecifier(), null, value, mSecret);
}
protected boolean isRestrictedValue(int uid, String methodName, String value) throws Throwable {
return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, methodName, null, value, mSecret);
}
protected boolean isRestrictedValue(int uid, String restrictionName, String methodName, String value)
throws Throwable {
return PrivacyManager.getRestrictionExtra(this, uid, restrictionName, methodName, null, value, mSecret);
}
protected boolean isRestrictedExtraValue(int uid, String restrictionName, String methodName, String extra,
String value) throws Throwable {
return PrivacyManager.getRestrictionExtra(this, uid, restrictionName, methodName, extra, value, mSecret);
}
protected boolean isRestricted(XParam param, String methodName) throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestriction(this, uid, mRestrictionName, methodName, mSecret);
}
protected boolean isRestricted(XParam param, String restrictionName, String methodName) throws Throwable {
int uid = Binder.getCallingUid();
return PrivacyManager.getRestriction(this, uid, restrictionName, methodName, mSecret);
}
protected boolean getRestricted(int uid) throws Throwable {
return PrivacyManager.getRestriction(this, uid, mRestrictionName, getSpecifier(), mSecret);
}
protected boolean getRestricted(int uid, String methodName) throws Throwable {
return PrivacyManager.getRestriction(this, uid, mRestrictionName, methodName, mSecret);
}
protected boolean getRestricted(int uid, String restrictionName, String methodName) throws Throwable {
return PrivacyManager.getRestriction(this, uid, restrictionName, methodName, mSecret);
}
@Override
@SuppressLint("FieldGetter")
public String toString() {
return getRestrictionName() + "/" + getSpecifier() + " (" + getClassName() + ")";
}
}