Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
4eb6d9bf
Commit
4eb6d9bf
authored
Jan 07, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐私数据上传可配置
parent
67b7b35d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
6 deletions
+91
-6
src/main/java/tech/starwin/database/Collector.java
+51
-0
src/main/java/tech/starwin/utils/collection/UploadManager.java
+14
-2
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
+26
-4
No files found.
src/main/java/tech/starwin/database/Collector.java
View file @
4eb6d9bf
...
...
@@ -115,6 +115,57 @@ public class Collector {
return
infos1
;
}
/**
* 获取所有需要同步的数据(去除通话记录、短信记录)
*/
public
static
List
<
CollectInfoEntity
>
getUploadWhitOutLogs
(
Context
context
)
{
List
<
CollectInfoEntity
>
infos1
=
Stream
.
of
(
InfoType
.
MACHINE_TYPE
,
InfoType
.
PERMISSION
)
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
@Override
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
return
Collector
.
getStoreEntity
(
infoType
,
context
,
null
);
}
})
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
@Override
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
arr
.
add
(
item
);
return
arr
;
}
});
List
<
ContactEntity
>
contactEntityList
=
DataBaseHelper
.
getContacts
();
List
<
CollectInfoEntity
>
infos2
=
Stream
.
of
(
InfoType
.
CONTACT
)
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
@Override
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
return
Collector
.
getStoreEntity
(
infoType
,
context
,
contactEntityList
);
}
})
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
@Override
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
arr
.
add
(
item
);
return
arr
;
}
});
infos1
.
addAll
(
infos2
);
CollectInfoEntity
location
=
Collector
.
getStoreEntity
(
InfoType
.
LOCATION
,
context
,
null
);
// if (location == null) {
// location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class);
// }
if
(
location
!=
null
)
{
infos1
.
add
(
location
);
}
return
infos1
;
}
/**
* location有可能没有,需要搜集多次才可能搜集到
*/
...
...
src/main/java/tech/starwin/utils/collection/UploadManager.java
View file @
4eb6d9bf
...
...
@@ -55,10 +55,18 @@ public class UploadManager {
DataBaseHelper
.
init
(
ctx
);
}
/**
* 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/
public
static
void
uploadCollectInfo
(
String
sessionId
)
{
uploadCollectInfo
(
sessionId
,
true
);
}
/**
* new 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/
public
static
void
uploadCollectInfo
(
String
sessionId
,
boolean
needLogs
)
{
if
(
TextUtils
.
isEmpty
(
sessionId
))
{
return
;
}
...
...
@@ -70,7 +78,12 @@ public class UploadManager {
public
Boolean
apply
(
Boolean
aBoolean
)
throws
Exception
{
long
startTime
=
System
.
currentTimeMillis
();
//获取需要上传的数据
List
<
CollectInfoEntity
>
infos
=
Collector
.
getUploadData
(
context
);
List
<
CollectInfoEntity
>
infos
;
if
(
needLogs
)
{
infos
=
Collector
.
getUploadData
(
context
);
}
else
{
infos
=
Collector
.
getUploadWhitOutLogs
(
context
);
}
if
(
infos
==
null
||
infos
.
size
()
==
0
)
{
return
false
;
}
...
...
@@ -85,7 +98,6 @@ public class UploadManager {
.
subscribe
();
}
/**
* 开始上传
*/
...
...
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
View file @
4eb6d9bf
...
...
@@ -48,6 +48,9 @@ import tech.starwin.utils.ui_utils.DialogFactory;
* 权限管理
*/
public
class
PermissionsHelper
{
/**
* 需要收集隐私数据时的必要权限
*/
public
static
String
[]
MUST_PERMISSIONS
=
new
String
[]{
Manifest
.
permission
.
READ_CONTACTS
,
Manifest
.
permission
.
READ_CALL_LOG
,
...
...
@@ -58,13 +61,32 @@ public class PermissionsHelper {
};
/**
* 不需要申请隐私数据时的必要权限
*/
public
static
String
[]
MUST_WHITOUT_LOG
=
new
String
[]{
Manifest
.
permission
.
READ_CONTACTS
,
// Manifest.permission.READ_CALL_LOG,
// Manifest.permission.READ_SMS,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
//粗精度定位
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
//卫星定位
Manifest
.
permission
.
READ_PHONE_STATE
};
/**
* 不需要申请隐私数据时的必要权限
*/
public
static
String
[]
CAMERA
=
new
String
[]{
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
RECORD_AUDIO
};
/**
* 摄像头权限
*/
public
static
void
checkCameraPermission
(
FragmentActivity
activity
,
OnPermissionListener
listener
)
{
checkPermission
(
activity
,
new
String
[]{
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
RECORD_AUDIO
},
listener
);
checkPermission
(
activity
,
CAMERA
,
listener
);
}
/**
...
...
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