Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ReyunSecureSdk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
daiwenjie
ReyunSecureSdk
Commits
63e0f769
Commit
63e0f769
authored
Apr 06, 2021
by
leiguo1029
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4/1
parent
00db59d1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
19 deletions
+41
-19
collect.c
wandun/src/main/cpp/collect.c
+32
-19
collect.h
wandun/src/main/cpp/include/collect.h
+9
-0
No files found.
wandun/src/main/cpp/collect.c
View file @
63e0f769
...
...
@@ -39,6 +39,7 @@ void do_collect(JNIEnv* env) {
start_time
=
ts
.
tv_nsec
/
1000000
+
ts
.
tv_sec
*
1000ULL
;
}
collect_app_info
(
env
,
json
);
int
permissions
=
collect_permissions
(
env
,
json
);
collect_imei
(
env
,
json
);
collect_android_id
(
env
,
json
);
collect_mac_addr
(
env
,
json
);
...
...
@@ -56,7 +57,10 @@ void do_collect(JNIEnv* env) {
collect_mem_info
(
env
,
json
);
collect_network_info
(
env
,
json
);
collect_user_agent
(
env
,
json
);
if
((
permissions
&
PERMISSION_ACCESS_FINE_LOCATION
)
&&
(
permissions
&
PERMISSION_ACCESS_COARSE_LOCATION
))
{
collect_location_info
(
env
,
json
);
}
if
(
WDSYSCALL
(
SYS_clock_gettime
,
CLOCK_MONOTONIC
,
&
ts
)
==
0
)
{
end_time
=
(
double
)
ts
.
tv_nsec
/
1000000
+
(
double
)
ts
.
tv_sec
*
1000ULL
;
...
...
@@ -127,6 +131,29 @@ void collect_app_info(JNIEnv* env, cJSON *json) {
(
*
env
)
->
PopLocalFrame
(
env
,
NULL
);
}
int
collect_permissions
(
JNIEnv
*
env
,
cJSON
*
json
)
{
int
value
=
0
;
const
char
*
permissions
[]
=
{
"android.permission.READ_EXTERNAL_STORAGE"
,
"android.permission.WRITE_EXTERNAL_STORAGE"
,
"android.permission.READ_PHONE_STATE"
,
"android.permission.ACCESS_NETWORK_STATE"
,
"android.permission.ACCESS_WIFI_STATE"
,
"android.permission.ACCESS_COARSE_LOCATION"
,
"android.permission.ACCESS_FINE_LOCATION"
};
for
(
int
i
=
0
;
i
<
sizeof
(
permissions
)
/
sizeof
(
const
char
*
);
++
i
)
{
jstring
str
=
(
*
env
)
->
NewStringUTF
(
env
,
permissions
[
i
]);
if
(
wdCallIntMethod
(
env
,
g_app_context
,
"checkSelfPermission"
,
"(Ljava/lang/String;)I"
,
str
)
==
0
)
{
value
|=
(
2
<<
i
);
}
(
*
env
)
->
DeleteLocalRef
(
env
,
str
);
}
return
value
;
}
void
collect_imei
(
JNIEnv
*
env
,
cJSON
*
json
)
{
//get imei from telephonymanager
jstring
phone_str
=
(
*
env
)
->
NewStringUTF
(
env
,
"phone"
);
...
...
@@ -515,26 +542,12 @@ void collect_user_agent(JNIEnv *env, cJSON *json) {
void
collect_location_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
//get location info need ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION permission.
cJSON
*
item
=
cJSON_CreateObject
();
const
char
*
permissions
[]
=
{
"android.permission.ACCESS_COARSE_LOCATION"
,
"android.permission.ACCESS_FINE_LOCATION"
};
int
get_permissions
=
1
;
for
(
int
i
=
0
;
i
<
sizeof
(
permissions
)
/
sizeof
(
const
char
*
);
++
i
)
{
jstring
str
=
(
*
env
)
->
NewStringUTF
(
env
,
permissions
[
i
]);
if
(
wdCallIntMethod
(
env
,
g_app_context
,
"checkSelfPermission"
,
"(Ljava/lang/String;)I"
,
str
)
!=
0
)
{
get_permissions
=
0
;
(
*
env
)
->
DeleteLocalRef
(
env
,
str
);
break
;
}
(
*
env
)
->
DeleteLocalRef
(
env
,
str
);
}
if
(
!
get_permissions
)
goto
return_label
;
jstring
loc_jstr
=
(
*
env
)
->
NewStringUTF
(
env
,
"location"
);
jobject
lm
=
wdCallObjectMethod
(
env
,
g_app_context
,
"getSystemService"
,
"(Ljava/lang/String;)Ljava/lang/Object;"
,
loc_jstr
);
jobject
providers
=
wdCallObjectMethod
(
env
,
lm
,
"getAllProviders"
,
"()Ljava/util/List;"
);
if
(
providers
==
NULL
)
goto
return_label
2
;
if
(
providers
==
NULL
)
goto
return_label
;
jint
size
=
wdCallIntMethod
(
env
,
providers
,
"size"
,
"()I"
);
int
get_loc
=
0
;
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
...
...
@@ -556,15 +569,15 @@ void collect_location_info(JNIEnv *env, cJSON *json) {
if
(
get_loc
)
break
;
}
(
*
env
)
->
DeleteLocalRef
(
env
,
providers
);
return_label
2
:
return_label:
(
*
env
)
->
DeleteLocalRef
(
env
,
lm
);
(
*
env
)
->
DeleteLocalRef
(
env
,
loc_jstr
);
return_label:
cJSON_AddItemToObject
(
json
,
"location"
,
item
);
logd
(
WD_COLLECT
,
"%s"
,
"collect location info finished..."
);
}
void
collect_cell_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
//cell info need ACCESSS_COARSE_LOCATION permission
cJSON
*
item
=
cJSON_CreateObject
();
}
wandun/src/main/cpp/include/collect.h
View file @
63e0f769
...
...
@@ -11,6 +11,7 @@
void
do_collect
(
JNIEnv
*
env
);
cJSON
*
collect_init
();
void
collect_app_info
(
JNIEnv
*
env
,
cJSON
*
json
);
int
collect_permissions
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_imei
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_android_id
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_mac_addr
(
JNIEnv
*
env
,
cJSON
*
json
);
...
...
@@ -74,5 +75,13 @@ void collect_cell_info(JNIEnv* env, cJSON* json);
/** Current network is NR(New Radio) 5G. */
#define NETWORK_TYPE_NR 20
#define PERMISSION_READ_EXTERNAL_STORAGE 0x1
#define PERMISSION_WRITE_EXTERNAL_STORAGE 0x2
#define PERMISSION_READ_PHONE_STATE 0x4
#define PERMISSION_ACCESS_NETWORK_STATE 0x8
#define PERMISSION_ACCESS_WIFI_STATE 0x10
#define PERMISSION_ACCESS_COARSE_LOCATION 0x20
#define PERMISSION_ACCESS_FINE_LOCATION 0x40
#endif //REYUNSDK_COLLECT_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment