Commit 4eb6d9bf by sikang

隐私数据上传可配置

parent 67b7b35d
...@@ -115,6 +115,57 @@ public class Collector { ...@@ -115,6 +115,57 @@ public class Collector {
return infos1; 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有可能没有,需要搜集多次才可能搜集到 * location有可能没有,需要搜集多次才可能搜集到
*/ */
......
...@@ -55,10 +55,18 @@ public class UploadManager { ...@@ -55,10 +55,18 @@ public class UploadManager {
DataBaseHelper.init(ctx); DataBaseHelper.init(ctx);
} }
/** /**
* 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等) * 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/ */
public static void uploadCollectInfo(String sessionId) { public static void uploadCollectInfo(String sessionId) {
uploadCollectInfo(sessionId, true);
}
/**
* new 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/
public static void uploadCollectInfo(String sessionId, boolean needLogs) {
if (TextUtils.isEmpty(sessionId)) { if (TextUtils.isEmpty(sessionId)) {
return; return;
} }
...@@ -70,7 +78,12 @@ public class UploadManager { ...@@ -70,7 +78,12 @@ public class UploadManager {
public Boolean apply(Boolean aBoolean) throws Exception { public Boolean apply(Boolean aBoolean) throws Exception {
long startTime = System.currentTimeMillis(); 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) { if (infos == null || infos.size() == 0) {
return false; return false;
} }
...@@ -85,7 +98,6 @@ public class UploadManager { ...@@ -85,7 +98,6 @@ public class UploadManager {
.subscribe(); .subscribe();
} }
/** /**
* 开始上传 * 开始上传
*/ */
......
...@@ -48,6 +48,9 @@ import tech.starwin.utils.ui_utils.DialogFactory; ...@@ -48,6 +48,9 @@ import tech.starwin.utils.ui_utils.DialogFactory;
* 权限管理 * 权限管理
*/ */
public class PermissionsHelper { public class PermissionsHelper {
/**
* 需要收集隐私数据时的必要权限
*/
public static String[] MUST_PERMISSIONS = new String[]{ public static String[] MUST_PERMISSIONS = new String[]{
Manifest.permission.READ_CONTACTS, Manifest.permission.READ_CONTACTS,
Manifest.permission.READ_CALL_LOG, Manifest.permission.READ_CALL_LOG,
...@@ -58,13 +61,32 @@ public class PermissionsHelper { ...@@ -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) { public static void checkCameraPermission(FragmentActivity activity, OnPermissionListener listener) {
checkPermission(activity, new String[]{Manifest.permission.CAMERA, checkPermission(activity, CAMERA, listener);
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO}, listener);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment