Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design2
/
2016104137
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김예미
2020-04-21 16:36:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2fee1b23de71897e58124fb7ed2cf6fd6429f155
2fee1b23
1 parent
c0c5be2f
add Contact, CallLog, SMS, Wifi extraction
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
294 additions
and
5 deletions
source/DataExtraction/.idea/gradle.xml
source/DataExtraction/.idea/misc.xml
source/DataExtraction/.idea/vcs.xml
source/DataExtraction/app/build.gradle
source/DataExtraction/app/src/main/AndroidManifest.xml
source/DataExtraction/app/src/main/java/com/example/dataextraction/CallLogDataBase.java
source/DataExtraction/app/src/main/java/com/example/dataextraction/ContactDataBase.java
source/DataExtraction/app/src/main/java/com/example/dataextraction/DBHelper.java
source/DataExtraction/app/src/main/java/com/example/dataextraction/MainActivity.java
source/DataExtraction/app/src/main/java/com/example/dataextraction/SMSDataBase.java
source/DataExtraction/app/src/main/java/com/example/dataextraction/WifiDataBase.java
source/DataExtraction/.idea/gradle.xml
View file @
2fee1b2
...
...
@@ -4,8 +4,10 @@
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild
compositeDefinitionSource=
"SCRIPT"
/>
</compositeConfiguration>
<option
name=
"delegatedBuild"
value=
"false"
/>
<option
name=
"testRunner"
value=
"PLATFORM"
/>
<option
name=
"distributionType"
value=
"DEFAULT_WRAPPED"
/>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"modules"
>
...
...
@@ -15,6 +17,7 @@
</set>
</option>
<option
name=
"resolveModulePerSourceSet"
value=
"false"
/>
<option
name=
"testRunner"
value=
"PLATFORM"
/>
</GradleProjectSettings>
</option>
</component>
...
...
source/DataExtraction/.idea/misc.xml
View file @
2fee1b2
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
project-jdk-name=
"
JDK
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
project-jdk-name=
"
1.8
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
source/DataExtraction/.idea/vcs.xml
0 → 100644
View file @
2fee1b2
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/../.."
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
source/DataExtraction/app/build.gradle
View file @
2fee1b2
...
...
@@ -5,7 +5,7 @@ android {
buildToolsVersion
"29.0.2"
defaultConfig
{
applicationId
"com.example.dataextraction"
minSdkVersion
2
8
minSdkVersion
2
3
targetSdkVersion
29
versionCode
1
versionName
"1.0"
...
...
source/DataExtraction/app/src/main/AndroidManifest.xml
View file @
2fee1b2
...
...
@@ -7,6 +7,10 @@
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_CALENDAR"
/>
<uses-permission
android:name=
"android.permission.READ_CONTACTS"
/>
<uses-permission
android:name=
"android.permission.READ_CALL_LOG"
/>
<uses-permission
android:name=
"android.permission.READ_SMS"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<application
android:allowBackup=
"true"
...
...
source/DataExtraction/app/src/main/java/com/example/dataextraction/CallLogDataBase.java
0 → 100644
View file @
2fee1b2
package
com
.
example
.
dataextraction
;
import
android.provider.BaseColumns
;
public
class
CallLogDataBase
{
public
static
final
class
CreateDB
implements
BaseColumns
{
public
static
final
String
ID
=
"id"
;
public
static
final
String
TYPE
=
"type"
;
public
static
final
String
NAME
=
"name"
;
public
static
final
String
NUMBER
=
"number"
;
public
static
final
String
DURATION
=
"duration"
;
public
static
final
String
DATE
=
"date"
;
public
static
final
String
_TABLENAME0
=
"calllog"
;
public
static
final
String
_CREATE0
=
"create table if not exists "
+
_TABLENAME0
+
"("
+
ID
+
" INTEGER PRIMARY KEY autoincrement, "
+
TYPE
+
" integer not null , "
+
NAME
+
" text not null,"
+
NUMBER
+
" text not null,"
+
DURATION
+
" inteter not null,"
+
DATE
+
" text);"
;
}
}
source/DataExtraction/app/src/main/java/com/example/dataextraction/ContactDataBase.java
0 → 100644
View file @
2fee1b2
package
com
.
example
.
dataextraction
;
import
android.provider.BaseColumns
;
public
class
ContactDataBase
{
public
static
final
class
CreateDB
implements
BaseColumns
{
public
static
final
String
NUMBER
=
"number"
;
public
static
final
String
NAME
=
"name"
;
public
static
final
String
PHOTO_ID
=
"photo_id"
;
public
static
final
String
PERSON_ID
=
"person_id"
;
public
static
final
String
_TABLENAME0
=
"contact"
;
public
static
final
String
_CREATE0
=
"create table if not exists "
+
_TABLENAME0
+
"("
+
NUMBER
+
" text not null primary key, "
+
NAME
+
" text not null , "
+
PHOTO_ID
+
" integer,"
+
PERSON_ID
+
" integer);"
;
}
}
source/DataExtraction/app/src/main/java/com/example/dataextraction/DBHelper.java
View file @
2fee1b2
...
...
@@ -27,6 +27,10 @@ public class DBHelper {
db
.
execSQL
(
VideoDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
AudioDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
CalendarDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
CallLogDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
ContactDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
SMSDataBase
.
CreateDB
.
_CREATE0
);
db
.
execSQL
(
WifiDataBase
.
CreateDB
.
_CREATE0
);
}
@Override
...
...
@@ -35,6 +39,10 @@ public class DBHelper {
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
VideoDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
AudioDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
CalendarDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
CallLogDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
ContactDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
SMSDataBase
.
CreateDB
.
_TABLENAME0
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
WifiDataBase
.
CreateDB
.
_TABLENAME0
);
onCreate
(
db
);
}
}
...
...
@@ -122,4 +130,48 @@ public class DBHelper {
values
.
put
(
CalendarDataBase
.
CreateDB
.
RDATE
,
r_date
);
return
mDB
.
insert
(
CalendarDataBase
.
CreateDB
.
_TABLENAME0
,
null
,
values
);
}
public
long
insertCallLogColumn
(
String
type
,
String
name
,
String
number
,
String
duration
,
String
date
){
ContentValues
values
=
new
ContentValues
();
values
.
put
(
CallLogDataBase
.
CreateDB
.
TYPE
,
type
);
values
.
put
(
CallLogDataBase
.
CreateDB
.
NAME
,
name
);
values
.
put
(
CallLogDataBase
.
CreateDB
.
NUMBER
,
number
);
values
.
put
(
CallLogDataBase
.
CreateDB
.
DURATION
,
duration
);
values
.
put
(
CallLogDataBase
.
CreateDB
.
DATE
,
date
);
return
mDB
.
insert
(
CallLogDataBase
.
CreateDB
.
_TABLENAME0
,
null
,
values
);
}
public
long
insertContactColumn
(
String
number
,
String
name
,
String
photo_id
,
String
person_id
){
ContentValues
values
=
new
ContentValues
();
values
.
put
(
ContactDataBase
.
CreateDB
.
NUMBER
,
number
);
values
.
put
(
ContactDataBase
.
CreateDB
.
NAME
,
name
);
values
.
put
(
ContactDataBase
.
CreateDB
.
PHOTO_ID
,
photo_id
);
values
.
put
(
ContactDataBase
.
CreateDB
.
PERSON_ID
,
person_id
);
return
mDB
.
insert
(
ContactDataBase
.
CreateDB
.
_TABLENAME0
,
null
,
values
);
}
public
long
insertSMSColumn
(
String
mid
,
String
tid
,
String
type
,
String
address
,
String
person
,
String
creator
,
String
date
,
String
body
,
String
read
){
ContentValues
values
=
new
ContentValues
();
values
.
put
(
SMSDataBase
.
CreateDB
.
MID
,
mid
);
values
.
put
(
SMSDataBase
.
CreateDB
.
TID
,
tid
);
values
.
put
(
SMSDataBase
.
CreateDB
.
TYPE
,
type
);
values
.
put
(
SMSDataBase
.
CreateDB
.
ADDRESS
,
address
);
values
.
put
(
SMSDataBase
.
CreateDB
.
PERSON
,
person
);
values
.
put
(
SMSDataBase
.
CreateDB
.
CREATOR
,
creator
);
values
.
put
(
SMSDataBase
.
CreateDB
.
DATE
,
date
);
values
.
put
(
SMSDataBase
.
CreateDB
.
BODY
,
body
);
values
.
put
(
SMSDataBase
.
CreateDB
.
READ
,
read
);
return
mDB
.
insert
(
SMSDataBase
.
CreateDB
.
_TABLENAME0
,
null
,
values
);
}
public
long
insertWifiColumn
(
String
id
,
String
ssid
,
String
bssid
,
String
wepkeys
){
ContentValues
values
=
new
ContentValues
();
values
.
put
(
WifiDataBase
.
CreateDB
.
ID
,
id
);
values
.
put
(
WifiDataBase
.
CreateDB
.
SSID
,
ssid
);
values
.
put
(
WifiDataBase
.
CreateDB
.
BSSID
,
bssid
);
values
.
put
(
WifiDataBase
.
CreateDB
.
WEPKEYS
,
wepkeys
);
return
mDB
.
insert
(
WifiDataBase
.
CreateDB
.
_TABLENAME0
,
null
,
values
);
}
}
...
...
source/DataExtraction/app/src/main/java/com/example/dataextraction/MainActivity.java
View file @
2fee1b2
package
com
.
example
.
dataextraction
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.core.content.ContextCompat
;
import
android.Manifest
;
import
android.content.ContentResolver
;
...
...
@@ -16,10 +17,15 @@ import android.net.NetworkInfo;
import
android.net.ProxyInfo
;
import
android.net.RouteInfo
;
import
android.net.Uri
;
import
android.net.wifi.WifiConfiguration
;
import
android.net.wifi.WifiManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.provider.CalendarContract
;
import
android.provider.CallLog
;
import
android.provider.ContactsContract
;
import
android.provider.MediaStore
;
import
android.provider.Telephony
;
import
android.view.View
;
import
android.widget.Toast
;
...
...
@@ -29,15 +35,22 @@ import java.text.SimpleDateFormat;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
public
class
MainActivity
extends
AppCompatActivity
{
DBHelper
dbHelper
;
String
[]
permission_list
=
{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
READ_CALENDAR
,
Manifest
.
permission
.
ACCESS_NETWORK_STATE
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
Manifest
.
permission
.
READ_CONTACTS
,
Manifest
.
permission
.
READ_CALL_LOG
,
Manifest
.
permission
.
READ_SMS
,
Manifest
.
permission
.
ACCESS_WIFI_STATE
};
@Override
...
...
@@ -53,9 +66,9 @@ public class MainActivity extends AppCompatActivity {
ArrayList
<
videoItem
>
videos
=
getVideoList
();
ArrayList
<
audioItem
>
audios
=
getAudioList
();
ArrayList
<
calendarItem
>
calendars
=
getCalendarInfoList
();
getNetworkInfo
();
DBHelper
dbHelper
=
new
DBHelper
(
getApplicationContext
());
//getNetworkInfo();
dbHelper
=
new
DBHelper
(
getApplicationContext
());
dbHelper
.
open
();
for
(
photoItem
photo:
photos
){
dbHelper
.
insertPColumn
(
photo
.
getTitle
(),
photo
.
getId
(),
photo
.
getDate
()
...
...
@@ -82,6 +95,10 @@ public class MainActivity extends AppCompatActivity {
,
calendar
.
getAllday
(),
calendar
.
getDisplayName
(),
calendar
.
getAccountName
()
,
calendar
.
getOwnerName
(),
calendar
.
getRrule
(),
calendar
.
getRdate
());
}
getCallLog
();
getContact
();
getSMSMessage
();
getWIFI
();
dbHelper
.
close
();
}
...
...
@@ -347,6 +364,127 @@ public class MainActivity extends AppCompatActivity {
dbHelper
.
close
();
}
public
void
getCallLog
(){
int
permissionCheck
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
Manifest
.
permission
.
READ_CALL_LOG
);
Uri
uri
=
CallLog
.
Calls
.
CONTENT_URI
;
if
(
permissionCheck
==
PackageManager
.
PERMISSION_GRANTED
)
{
Cursor
cursor
=
getBaseContext
().
getContentResolver
().
query
(
uri
,
null
,
null
,
null
,
CallLog
.
Calls
.
DEFAULT_SORT_ORDER
);
if
(
cursor
.
getCount
()
>
0
){
while
(
cursor
.
moveToNext
()){
//1:수신, 2:발신, 3:부재중
String
type
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
CallLog
.
Calls
.
TYPE
));
//이름
String
name
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
CallLog
.
Calls
.
CACHED_NAME
));
//번호
String
number
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
CallLog
.
Calls
.
NUMBER
));
//통화시간
String
duration
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
CallLog
.
Calls
.
DURATION
));
//날짜
long
date_long
=
cursor
.
getLong
(
cursor
.
getColumnIndex
(
CallLog
.
Calls
.
DATE
));
DateFormat
timeFormat
=
new
SimpleDateFormat
(
"yyyy MMM dd HH:mm:ss"
);
Date
date
=
new
Date
(
date_long
);
//db에 추가
dbHelper
.
insertCallLogColumn
(
type
,
name
,
number
,
duration
,
timeFormat
.
format
(
date
));
}
}
}
}
public
void
getContact
(){
Uri
uri
=
ContactsContract
.
CommonDataKinds
.
Phone
.
CONTENT_URI
;
String
[]
projection
=
new
String
[]{
ContactsContract
.
CommonDataKinds
.
Phone
.
NUMBER
,
ContactsContract
.
CommonDataKinds
.
Phone
.
DISPLAY_NAME
,
ContactsContract
.
Contacts
.
PHOTO_ID
,
ContactsContract
.
Contacts
.
_ID
};
String
sortOrder
=
ContactsContract
.
CommonDataKinds
.
Phone
.
DISPLAY_NAME
+
" COLLATE LOCALIZED ASC"
;
Cursor
cursor
=
getContentResolver
().
query
(
uri
,
projection
,
null
,
null
,
sortOrder
);
if
(
cursor
.
moveToFirst
()){
do
{
//전화번호
String
number
=
cursor
.
getString
(
0
);
//이름
String
name
=
cursor
.
getString
(
1
);
String
photo_id
=
cursor
.
getString
(
2
);
String
person_id
=
cursor
.
getString
(
3
);
//name, number 중복하는거 거르기
//db에 추가
dbHelper
.
insertContactColumn
(
number
,
name
,
photo_id
,
person_id
);
}
while
(
cursor
.
moveToNext
());
}
}
public
void
getSMSMessage
(){
Uri
uri
=
Telephony
.
Sms
.
CONTENT_URI
;
String
[]
projection
=
new
String
[]{
"type"
,
"_id"
,
"thread_id"
,
"address"
,
"person"
,
"creator"
,
"date"
,
"body"
,
"read"
};
Cursor
cursor
=
getContentResolver
().
query
(
uri
,
projection
,
null
,
null
,
"date DESC"
);
while
(
cursor
.
moveToNext
()){
//Telephony.Sms.MESSAGE_TYPE_INBOX 받은 메시지/Telephony.Sms.MESSAGE_TYPE_SENT 보낸 메시지
String
type
=
cursor
.
getString
(
0
);
//메세지 id
String
mid
=
cursor
.
getString
(
1
);
//특정 사용자와 대화의 공통 id
String
tid
=
cursor
.
getString
(
2
);
//주소 번호
String
address
=
cursor
.
getString
(
3
);
//누가 보냈는지 contact
//Telephony.Sms.MESSAGE_TYPE_INBOX only
String
person
=
cursor
.
getString
(
4
);
//Telephony.Sms.MESSAGE_TYPE_SENT only
String
creator
=
cursor
.
getString
(
5
);
//시간 ms
Long
date_long
=
cursor
.
getLong
(
6
);
DateFormat
timeFormat
=
new
SimpleDateFormat
(
"yyyy MMM dd HH:mm:ss"
);
String
date
=
timeFormat
.
format
(
date_long
);
//내용
String
body
=
cursor
.
getString
(
7
);
//사용자가 메시지 읽었으면 1, 안 읽었으면 0
String
read
=
cursor
.
getString
(
8
);
//db에 추가
dbHelper
.
insertSMSColumn
(
mid
,
tid
,
type
,
address
,
person
,
creator
,
date
,
body
,
read
);
}
}
public
void
getWIFI
(){
WifiManager
wm
=
(
WifiManager
)
getApplicationContext
().
getSystemService
(
Context
.
WIFI_SERVICE
);
//네트워크 설정 목록 획득
List
<
WifiConfiguration
>
configurations
=
wm
.
getConfiguredNetworks
();
if
(
configurations
!=
null
){
for
(
final
WifiConfiguration
config
:
configurations
){
//network id
int
i_id
=
config
.
networkId
;
String
id
=
Integer
.
toString
(
i_id
);
//wifi 이름
String
ssid
=
config
.
SSID
;
//mac 주소
String
bssid
=
config
.
BSSID
;
//신호강도 (level)
//연결 password
String
[]
wepkeys
=
config
.
wepKeys
;
//db에 추가
dbHelper
.
insertWifiColumn
(
id
,
ssid
,
bssid
,
wepkeys
[
0
]);
}
}
}
public
void
checkPermission
(){
//현재 안드로이드 버전이 6.0미만이면 메서드를 종료한다.
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
...
...
source/DataExtraction/app/src/main/java/com/example/dataextraction/SMSDataBase.java
0 → 100644
View file @
2fee1b2
package
com
.
example
.
dataextraction
;
import
android.provider.BaseColumns
;
public
class
SMSDataBase
{
public
static
final
class
CreateDB
implements
BaseColumns
{
public
static
final
String
MID
=
"mid"
;
public
static
final
String
TID
=
"tid"
;
public
static
final
String
TYPE
=
"type"
;
public
static
final
String
ADDRESS
=
"address"
;
public
static
final
String
PERSON
=
"person"
;
public
static
final
String
CREATOR
=
"creator"
;
public
static
final
String
DATE
=
"date"
;
public
static
final
String
BODY
=
"body"
;
public
static
final
String
READ
=
"read"
;
public
static
final
String
_TABLENAME0
=
"sms"
;
public
static
final
String
_CREATE0
=
"create table if not exists "
+
_TABLENAME0
+
"("
+
MID
+
" integer not null primary key, "
+
TID
+
" integer not null , "
+
TYPE
+
" integer not null,"
+
ADDRESS
+
" text not null , "
+
PERSON
+
" text,"
+
CREATOR
+
" text , "
+
DATE
+
" text not null,"
+
BODY
+
" text not null,"
+
READ
+
" integer);"
;
}
}
source/DataExtraction/app/src/main/java/com/example/dataextraction/WifiDataBase.java
0 → 100644
View file @
2fee1b2
package
com
.
example
.
dataextraction
;
import
android.provider.BaseColumns
;
public
class
WifiDataBase
{
public
static
final
class
CreateDB
implements
BaseColumns
{
public
static
final
String
ID
=
"id"
;
public
static
final
String
SSID
=
"ssid"
;
public
static
final
String
BSSID
=
"bssid"
;
public
static
final
String
WEPKEYS
=
"wepkeys"
;
public
static
final
String
_TABLENAME0
=
"wifi"
;
public
static
final
String
_CREATE0
=
"create table if not exists "
+
_TABLENAME0
+
"("
+
ID
+
" integer not null primary key, "
+
SSID
+
" text not null , "
+
BSSID
+
" text not null,"
+
WEPKEYS
+
" text);"
;
}
}
Please
register
or
login
to post a comment