유희정

modify

......@@ -4,10 +4,8 @@
<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">
......@@ -17,7 +15,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings>
</option>
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -16,7 +16,7 @@ public class CallLogDataBase {
+TYPE+" integer not null , "
+NAME + " text not null,"
+NUMBER + " text not null,"
+DURATION + " inteter not null,"
+DURATION + " integer not null,"
+DATE + " text);";
}
}
......
......@@ -257,7 +257,8 @@ public class DBHelper {
values.put(Databases.CreateDB_PhoneInfo.SIMSTATE, simstate);
values.put(Databases.CreateDB_PhoneInfo.ISNETWORKROMING, isnetworkroming);
db.insert(Databases.CreateDB_PhoneInfo.TABLE_NAME, null, values);
Log.d("LogTest","addPhoneInfo");
Log.d("LogTest", "addPhoneInfo");
}
public long insertCallLogColumn(String type, String name, String number, String duration
, String date){
......
......@@ -67,7 +67,7 @@ public class MainActivity extends AppCompatActivity {
Manifest.permission.GET_ACCOUNTS,
Manifest.permission.READ_CONTACTS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.READ_PHONE_NUMBERS
Manifest.permission.READ_PHONE_NUMBERS,
Manifest.permission.READ_CONTACTS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.READ_SMS,
......@@ -92,54 +92,30 @@ public class MainActivity extends AppCompatActivity {
}
public void button1(View view){
ArrayList<photoItem> photos = getPhotoList();
ArrayList<videoItem> videos = getVideoList();
ArrayList<audioItem> audios = getAudioList();
ArrayList<calendarItem> calendars = getCalendarInfoList();
//getNetworkInfo();
dbHelper = new DBHelper(getApplicationContext());
dbHelper.open();
for(photoItem photo: photos){
dbHelper.insertPColumn(photo.getTitle(), photo.getId(), photo.getDate()
, photo.getDisplayName(), photo.getType(), photo.getPath()
, photo.getLatitude(), photo.getLongitude());
}
for(videoItem video : videos){
dbHelper.insertVColumn(video.getTitle(), video.getDate_added(), video.getDisplay_Name()
, video.getMIME_type(), video.getPath(), video.getLatitude(), video.getLongitude()
, video.getAlbum(), video.getArtist(), video.getBookmark(), video.getCategory()
, video.getDescription(), video.getLanguage(), video.getResolution(), video.getTags());
}
for(audioItem audio : audios){
dbHelper.insertAColumn(audio.getTitle(), audio.getDate_added(), audio.getMIME_TYPE()
, audio.getPath(), audio.getAlbum(), audio.getArtist(), audio.getComposer()
,audio.getYear(), audio.getSize());
}
getPhoto();
getVideo();
getAudio();
getCalendarInfo();;
getNetworkInfo();
for(calendarItem calendar : calendars){
dbHelper.insertCColumn(calendar.getTitle(), calendar.getCalID(), calendar.getLoc()
, calendar.getDesc(), calendar.getDtstart(), calendar.getDtend(), calendar.getDuration()
, calendar.getAllday(), calendar.getDisplayName(), calendar.getAccountName()
, calendar.getOwnerName(), calendar.getRrule(), calendar.getRdate());
}
getCallLog();
getContact();
getSMSMessage();
getWIFI();
getPhoneInfo();
getAccountInfo();
getAppInfo();
getUsageStats();
getCallLog();
getContact();
getSMSMessage();
getWIFI();
dbHelper.close();
}
public ArrayList<photoItem> getPhotoList() {
public void getPhoto() {
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{
......@@ -154,7 +130,6 @@ public class MainActivity extends AppCompatActivity {
};
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
ArrayList<photoItem> list = new ArrayList<>();
while (cursor.moveToNext()) {
photoItem photo = new photoItem();
......@@ -167,13 +142,14 @@ public class MainActivity extends AppCompatActivity {
photo.setLatitude(cursor.getString(6));
photo.setLongitude(cursor.getString(7));
list.add(photo);
dbHelper.insertPColumn(photo.getTitle(), photo.getId(), photo.getDate()
, photo.getDisplayName(), photo.getType(), photo.getPath()
, photo.getLatitude(), photo.getLongitude());
}
return list;
}
public ArrayList<videoItem> getVideoList() {
public void getVideo() {
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{
......@@ -196,8 +172,6 @@ public class MainActivity extends AppCompatActivity {
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
ArrayList<videoItem> videoList = new ArrayList<>();
while (cursor.moveToNext()) {
videoItem video = new videoItem();
......@@ -217,12 +191,14 @@ public class MainActivity extends AppCompatActivity {
video.setMIME_type(cursor.getString(13));
video.setTitle(cursor.getString(14));
videoList.add(video);
dbHelper.insertVColumn(video.getTitle(), video.getDate_added(), video.getDisplay_Name()
, video.getMIME_type(), video.getPath(), video.getLatitude(), video.getLongitude()
, video.getAlbum(), video.getArtist(), video.getBookmark(), video.getCategory()
, video.getDescription(), video.getLanguage(), video.getResolution(), video.getTags());
}
return videoList;
}
public ArrayList<audioItem> getAudioList() {
public void getAudio() {
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{
......@@ -239,8 +215,6 @@ public class MainActivity extends AppCompatActivity {
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
ArrayList<audioItem> audioList = new ArrayList<>();
while (cursor.moveToNext()) {
audioItem audio = new audioItem();
audio.setAlbum(cursor.getString(0));
......@@ -253,12 +227,14 @@ public class MainActivity extends AppCompatActivity {
audio.setSize(cursor.getString(7));
audio.setTitle(cursor.getString(8));
audioList.add(audio);
dbHelper.insertAColumn(audio.getTitle(), audio.getDate_added(), audio.getMIME_TYPE()
, audio.getPath(), audio.getAlbum(), audio.getArtist(), audio.getComposer()
,audio.getYear(), audio.getSize());
}
return audioList;
}
private ArrayList<calendarItem> getCalendarInfoList() {
private void getCalendarInfo() {
ArrayList<calendarItem> calendarList = new ArrayList<>();
Cursor cur = null;
......@@ -267,7 +243,7 @@ public class MainActivity extends AppCompatActivity {
if (checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show();
return null;
return;
}
String[] event_projection = new String[]{
......@@ -356,12 +332,14 @@ public class MainActivity extends AppCompatActivity {
calendar.setRrule(rrule);
calendar.setRdate(rdate);
calendarList.add(calendar);
dbHelper.insertCColumn(calendar.getTitle(), calendar.getCalID(), calendar.getLoc()
, calendar.getDesc(), calendar.getDtstart(), calendar.getDtend(), calendar.getDuration()
, calendar.getAllday(), calendar.getDisplayName(), calendar.getAccountName()
, calendar.getOwnerName(), calendar.getRrule(), calendar.getRdate());
}
}
}
return calendarList;
}
public void getNetworkInfo(){
......@@ -369,9 +347,9 @@ public class MainActivity extends AppCompatActivity {
LinkProperties linkProperties;
connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
Network[] networkList = connectivityManager.getAllNetworks();
networkDBHelper dbHelper = new networkDBHelper(getApplicationContext());
dbHelper.open();
dbHelper.deleteAllRows();
networkDBHelper dbNHelper = new networkDBHelper(getApplicationContext());
dbNHelper.open();
dbNHelper.deleteAllRows();
for(Network network : networkList){
NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
if(capabilities != null){
......@@ -379,26 +357,26 @@ public class MainActivity extends AppCompatActivity {
linkProperties = connectivityManager.getLinkProperties(network);
String domain = linkProperties.getDomains();
String interfacrName = linkProperties.getInterfaceName();
String DnsServerName = linkProperties.getPrivateDnsServerName();
dbHelper.insertColumn0(network.toString(), domain, interfacrName, DnsServerName);
//String DnsServerName = linkProperties.getPrivateDnsServerName();
dbNHelper.insertColumn0(network.toString(), domain, interfacrName, null);
List<InetAddress> inetAddresses = linkProperties.getDnsServers();
for(InetAddress address : inetAddresses){
dbHelper.insertColumn1(network.toString(), address.getHostAddress());
dbNHelper.insertColumn1(network.toString(), address.getHostAddress());
}
List<LinkAddress> linkAddresses = linkProperties.getLinkAddresses();
for(LinkAddress address : linkAddresses) {
dbHelper.insertColumn2(network.toString(), address.getAddress().getHostAddress(), address.getPrefixLength());
dbNHelper.insertColumn2(network.toString(), address.getAddress().getHostAddress(), address.getPrefixLength());
}
List<RouteInfo> routeInfos = linkProperties.getRoutes();
for(RouteInfo routeinfo : routeInfos){
dbHelper.insertColumn3(network.toString(), routeinfo.getDestination().toString()
dbNHelper.insertColumn3(network.toString(), routeinfo.getDestination().toString()
, routeinfo.getDestination().getPrefixLength(), routeinfo.getGateway().toString()
,routeinfo.getInterface());
}
}
}
}
dbHelper.close();
dbNHelper.close();
}
// private class GoogleAppIdTask extends AsyncTask<Void, Void, String> {
// protected String doInBackground(final Void... params) {
......@@ -434,8 +412,7 @@ public class MainActivity extends AppCompatActivity {
if (checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show();
}
DBHelper mDBhelper = new DBHelper(this);
mDBhelper.open();
String adid = "";
// try {
// MainActivity.GoogleAppIdTask asyncTask = new MainActivity.GoogleAppIdTask();
......@@ -444,33 +421,29 @@ public class MainActivity extends AppCompatActivity {
// e.printStackTrace();
// }
mDBhelper.addPhoneInfo(tm.getPhoneType(), tm.getDeviceSoftwareVersion(),
dbHelper.addPhoneInfo(tm.getPhoneType(), tm.getDeviceSoftwareVersion(),
tm.getLine1Number(), tm.getSubscriberId(), adid, tm.getCallState(),
tm.getDataState(),tm.getNetworkType(),tm.getNetworkCountryIso(),
tm.getSimCountryIso(),tm.getNetworkOperator(),tm.getSimOperator(),
tm.getNetworkOperatorName(),tm.getSimOperatorName() ,tm.getSimSerialNumber(),
tm.getSimState(),tm.isNetworkRoaming());
mDBhelper.close();
}
public void getAccountInfo(){
DBHelper mDBhelper = new DBHelper(this);
mDBhelper.open();
AccountManager am = AccountManager.get(this);
Account[] accounts = am.getAccounts();
for(Account account : accounts) {
mDBhelper.addAccountInfo(account.name,account.type);
dbHelper.addAccountInfo(account.name,account.type);
//String password=accountManager.getPassword(account);
}
mDBhelper.close();
}
public void getAppInfo() {
DBHelper mDBhelper = new DBHelper(this);
mDBhelper.open();
PackageManager pm = getPackageManager();
List<PackageInfo> packages = pm.getInstalledPackages(PackageManager.GET_META_DATA);
ApplicationInfo applicationInfo;
......@@ -520,10 +493,9 @@ public class MainActivity extends AppCompatActivity {
};
mobilenetworkStats.getNextBucket(cellularbucket);
mDBhelper.addAppInfo(packageInfo.packageName,packageInfo.versionName, applicationName,packageInfo.firstInstallTime, packageInfo.lastUpdateTime, wifirxbytes+wifitxbytes, cellrxbytes+celltxbytes);
dbHelper.addAppInfo(packageInfo.packageName,packageInfo.versionName, applicationName,packageInfo.firstInstallTime, packageInfo.lastUpdateTime, wifirxbytes+wifitxbytes, cellrxbytes+celltxbytes);
}
mDBhelper.close();
}
private String getSubscriberId(int networkType) {
......@@ -541,32 +513,29 @@ public class MainActivity extends AppCompatActivity {
}
public void getUsageStats() {
DBHelper mDBhelper = new DBHelper(this);
mDBhelper.open();
UsageStatsManager usageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
List<UsageStats> queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_YEARLY, 0, System.currentTimeMillis());
for (UsageStats usagestat : queryUsageStats) {
mDBhelper.addAppUsage_YEAR(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
dbHelper.addAppUsage_YEAR(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
}
queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_MONTHLY, 0, System.currentTimeMillis());
for (UsageStats usagestat : queryUsageStats) {
mDBhelper.addAppUsage_MONTH(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
dbHelper.addAppUsage_MONTH(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
}
queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_WEEKLY, 0, System.currentTimeMillis());
for (UsageStats usagestat : queryUsageStats) {
mDBhelper.addAppUsage_WEEK(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
dbHelper.addAppUsage_WEEK(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
}
queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, 0, System.currentTimeMillis());
for (UsageStats usagestat : queryUsageStats) {
mDBhelper.addAppUsage_DAY(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
dbHelper.addAppUsage_DAY(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground());
}
mDBhelper.close();
}
......@@ -575,6 +544,7 @@ public class MainActivity extends AppCompatActivity {
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);
......