/
hidden_api.h
57 lines (45 loc) · 1.86 KB
/
hidden_api.h
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
#pragma once
#include "base/object.h"
namespace art {
namespace hidden_api {
enum Action {
kAllow,
kAllowButWarn,
kAllowButWarnAndToast,
kDeny
};
CREATE_HOOK_STUB_ENTRIES(Action, GetMethodActionImpl) {
return Action::kAllow;
}
CREATE_HOOK_STUB_ENTRIES(Action, GetFieldActionImpl) {
return Action::kAllow;
}
CREATE_HOOK_STUB_ENTRIES(bool, ShouldDenyAccessToMethodImpl) {
return false;
}
CREATE_HOOK_STUB_ENTRIES(bool, ShouldDenyAccessToFieldImpl) {
return false;
}
static void DisableHiddenApi(void *handle, HookFunType hook_func) {
const int api_level = GetAndroidApiLevel();
if (api_level < __ANDROID_API_P__) {
return;
}
if (api_level == __ANDROID_API_P__) {
HOOK_FUNC(GetMethodActionImpl,
"_ZN3art9hiddenapi6detail19GetMemberActionImplINS_9ArtMethodEEENS0_"
"6ActionEPT_NS_20HiddenApiAccessFlags7ApiListES4_NS0_12AccessMethodE");
HOOK_FUNC(GetFieldActionImpl,
"_ZN3art9hiddenapi6detail19GetMemberActionImplINS_8ArtFieldEEENS0_"
"6ActionEPT_NS_20HiddenApiAccessFlags7ApiListES4_NS0_12AccessMethodE");
} else {
HOOK_FUNC(ShouldDenyAccessToMethodImpl,
"_ZN3art9hiddenapi6detail28ShouldDenyAccessToMemberImplINS_"
"9ArtMethodEEEbPT_NS0_7ApiListENS0_12AccessMethodE");
HOOK_FUNC(ShouldDenyAccessToFieldImpl,
"_ZN3art9hiddenapi6detail28ShouldDenyAccessToMemberImplINS_"
"8ArtFieldEEEbPT_NS0_7ApiListENS0_12AccessMethodE");
}
};
}
}