Showing
5 changed files
with
55 additions
and
87 deletions
... | @@ -4,10 +4,8 @@ | ... | @@ -4,10 +4,8 @@ |
4 | <component name="GradleSettings"> | 4 | <component name="GradleSettings"> |
5 | <option name="linkedExternalProjectsSettings"> | 5 | <option name="linkedExternalProjectsSettings"> |
6 | <GradleProjectSettings> | 6 | <GradleProjectSettings> |
7 | - <compositeConfiguration> | ||
8 | - <compositeBuild compositeDefinitionSource="SCRIPT" /> | ||
9 | - </compositeConfiguration> | ||
10 | <option name="delegatedBuild" value="false" /> | 7 | <option name="delegatedBuild" value="false" /> |
8 | + <option name="testRunner" value="PLATFORM" /> | ||
11 | <option name="distributionType" value="DEFAULT_WRAPPED" /> | 9 | <option name="distributionType" value="DEFAULT_WRAPPED" /> |
12 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | 10 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
13 | <option name="modules"> | 11 | <option name="modules"> |
... | @@ -17,7 +15,6 @@ | ... | @@ -17,7 +15,6 @@ |
17 | </set> | 15 | </set> |
18 | </option> | 16 | </option> |
19 | <option name="resolveModulePerSourceSet" value="false" /> | 17 | <option name="resolveModulePerSourceSet" value="false" /> |
20 | - <option name="testRunner" value="PLATFORM" /> | ||
21 | </GradleProjectSettings> | 18 | </GradleProjectSettings> |
22 | </option> | 19 | </option> |
23 | </component> | 20 | </component> | ... | ... |
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | 3 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK"> |
4 | <output url="file://$PROJECT_DIR$/build/classes" /> | 4 | <output url="file://$PROJECT_DIR$/build/classes" /> |
5 | </component> | 5 | </component> |
6 | <component name="ProjectType"> | 6 | <component name="ProjectType"> | ... | ... |
... | @@ -16,7 +16,7 @@ public class CallLogDataBase { | ... | @@ -16,7 +16,7 @@ public class CallLogDataBase { |
16 | +TYPE+" integer not null , " | 16 | +TYPE+" integer not null , " |
17 | +NAME + " text not null," | 17 | +NAME + " text not null," |
18 | +NUMBER + " text not null," | 18 | +NUMBER + " text not null," |
19 | - +DURATION + " inteter not null," | 19 | + +DURATION + " integer not null," |
20 | +DATE + " text);"; | 20 | +DATE + " text);"; |
21 | } | 21 | } |
22 | } | 22 | } | ... | ... |
... | @@ -257,7 +257,8 @@ public class DBHelper { | ... | @@ -257,7 +257,8 @@ public class DBHelper { |
257 | values.put(Databases.CreateDB_PhoneInfo.SIMSTATE, simstate); | 257 | values.put(Databases.CreateDB_PhoneInfo.SIMSTATE, simstate); |
258 | values.put(Databases.CreateDB_PhoneInfo.ISNETWORKROMING, isnetworkroming); | 258 | values.put(Databases.CreateDB_PhoneInfo.ISNETWORKROMING, isnetworkroming); |
259 | db.insert(Databases.CreateDB_PhoneInfo.TABLE_NAME, null, values); | 259 | db.insert(Databases.CreateDB_PhoneInfo.TABLE_NAME, null, values); |
260 | - Log.d("LogTest","addPhoneInfo"); | 260 | + Log.d("LogTest", "addPhoneInfo"); |
261 | + } | ||
261 | 262 | ||
262 | public long insertCallLogColumn(String type, String name, String number, String duration | 263 | public long insertCallLogColumn(String type, String name, String number, String duration |
263 | , String date){ | 264 | , String date){ | ... | ... |
... | @@ -67,7 +67,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -67,7 +67,7 @@ public class MainActivity extends AppCompatActivity { |
67 | Manifest.permission.GET_ACCOUNTS, | 67 | Manifest.permission.GET_ACCOUNTS, |
68 | Manifest.permission.READ_CONTACTS, | 68 | Manifest.permission.READ_CONTACTS, |
69 | Manifest.permission.READ_CALL_LOG, | 69 | Manifest.permission.READ_CALL_LOG, |
70 | - Manifest.permission.READ_PHONE_NUMBERS | 70 | + Manifest.permission.READ_PHONE_NUMBERS, |
71 | Manifest.permission.READ_CONTACTS, | 71 | Manifest.permission.READ_CONTACTS, |
72 | Manifest.permission.READ_CALL_LOG, | 72 | Manifest.permission.READ_CALL_LOG, |
73 | Manifest.permission.READ_SMS, | 73 | Manifest.permission.READ_SMS, |
... | @@ -92,54 +92,30 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -92,54 +92,30 @@ public class MainActivity extends AppCompatActivity { |
92 | } | 92 | } |
93 | 93 | ||
94 | public void button1(View view){ | 94 | public void button1(View view){ |
95 | - ArrayList<photoItem> photos = getPhotoList(); | ||
96 | - ArrayList<videoItem> videos = getVideoList(); | ||
97 | - ArrayList<audioItem> audios = getAudioList(); | ||
98 | - ArrayList<calendarItem> calendars = getCalendarInfoList(); | ||
99 | - //getNetworkInfo(); | ||
100 | 95 | ||
101 | dbHelper = new DBHelper(getApplicationContext()); | 96 | dbHelper = new DBHelper(getApplicationContext()); |
102 | dbHelper.open(); | 97 | dbHelper.open(); |
103 | - for(photoItem photo: photos){ | ||
104 | - dbHelper.insertPColumn(photo.getTitle(), photo.getId(), photo.getDate() | ||
105 | - , photo.getDisplayName(), photo.getType(), photo.getPath() | ||
106 | - , photo.getLatitude(), photo.getLongitude()); | ||
107 | - } | ||
108 | - | ||
109 | - for(videoItem video : videos){ | ||
110 | - dbHelper.insertVColumn(video.getTitle(), video.getDate_added(), video.getDisplay_Name() | ||
111 | - , video.getMIME_type(), video.getPath(), video.getLatitude(), video.getLongitude() | ||
112 | - , video.getAlbum(), video.getArtist(), video.getBookmark(), video.getCategory() | ||
113 | - , video.getDescription(), video.getLanguage(), video.getResolution(), video.getTags()); | ||
114 | - } | ||
115 | 98 | ||
116 | - for(audioItem audio : audios){ | 99 | + getPhoto(); |
117 | - dbHelper.insertAColumn(audio.getTitle(), audio.getDate_added(), audio.getMIME_TYPE() | 100 | + getVideo(); |
118 | - , audio.getPath(), audio.getAlbum(), audio.getArtist(), audio.getComposer() | 101 | + getAudio(); |
119 | - ,audio.getYear(), audio.getSize()); | 102 | + getCalendarInfo();; |
120 | - } | 103 | + getNetworkInfo(); |
121 | 104 | ||
122 | - for(calendarItem calendar : calendars){ | 105 | + getCallLog(); |
123 | - dbHelper.insertCColumn(calendar.getTitle(), calendar.getCalID(), calendar.getLoc() | 106 | + getContact(); |
124 | - , calendar.getDesc(), calendar.getDtstart(), calendar.getDtend(), calendar.getDuration() | 107 | + getSMSMessage(); |
125 | - , calendar.getAllday(), calendar.getDisplayName(), calendar.getAccountName() | 108 | + getWIFI(); |
126 | - , calendar.getOwnerName(), calendar.getRrule(), calendar.getRdate()); | ||
127 | - } | ||
128 | 109 | ||
129 | getPhoneInfo(); | 110 | getPhoneInfo(); |
130 | getAccountInfo(); | 111 | getAccountInfo(); |
131 | getAppInfo(); | 112 | getAppInfo(); |
132 | getUsageStats(); | 113 | getUsageStats(); |
133 | 114 | ||
134 | - getCallLog(); | ||
135 | - getContact(); | ||
136 | - getSMSMessage(); | ||
137 | - getWIFI(); | ||
138 | - | ||
139 | dbHelper.close(); | 115 | dbHelper.close(); |
140 | } | 116 | } |
141 | 117 | ||
142 | - public ArrayList<photoItem> getPhotoList() { | 118 | + public void getPhoto() { |
143 | Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; | 119 | Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; |
144 | 120 | ||
145 | String[] projection = new String[]{ | 121 | String[] projection = new String[]{ |
... | @@ -154,7 +130,6 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -154,7 +130,6 @@ public class MainActivity extends AppCompatActivity { |
154 | }; | 130 | }; |
155 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); | 131 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); |
156 | 132 | ||
157 | - ArrayList<photoItem> list = new ArrayList<>(); | ||
158 | 133 | ||
159 | while (cursor.moveToNext()) { | 134 | while (cursor.moveToNext()) { |
160 | photoItem photo = new photoItem(); | 135 | photoItem photo = new photoItem(); |
... | @@ -167,13 +142,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -167,13 +142,14 @@ public class MainActivity extends AppCompatActivity { |
167 | photo.setLatitude(cursor.getString(6)); | 142 | photo.setLatitude(cursor.getString(6)); |
168 | photo.setLongitude(cursor.getString(7)); | 143 | photo.setLongitude(cursor.getString(7)); |
169 | 144 | ||
170 | - list.add(photo); | 145 | + dbHelper.insertPColumn(photo.getTitle(), photo.getId(), photo.getDate() |
146 | + , photo.getDisplayName(), photo.getType(), photo.getPath() | ||
147 | + , photo.getLatitude(), photo.getLongitude()); | ||
171 | } | 148 | } |
172 | 149 | ||
173 | - return list; | ||
174 | } | 150 | } |
175 | 151 | ||
176 | - public ArrayList<videoItem> getVideoList() { | 152 | + public void getVideo() { |
177 | Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; | 153 | Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; |
178 | 154 | ||
179 | String[] projection = new String[]{ | 155 | String[] projection = new String[]{ |
... | @@ -196,8 +172,6 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -196,8 +172,6 @@ public class MainActivity extends AppCompatActivity { |
196 | 172 | ||
197 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); | 173 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); |
198 | 174 | ||
199 | - ArrayList<videoItem> videoList = new ArrayList<>(); | ||
200 | - | ||
201 | while (cursor.moveToNext()) { | 175 | while (cursor.moveToNext()) { |
202 | videoItem video = new videoItem(); | 176 | videoItem video = new videoItem(); |
203 | 177 | ||
... | @@ -217,12 +191,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -217,12 +191,14 @@ public class MainActivity extends AppCompatActivity { |
217 | video.setMIME_type(cursor.getString(13)); | 191 | video.setMIME_type(cursor.getString(13)); |
218 | video.setTitle(cursor.getString(14)); | 192 | video.setTitle(cursor.getString(14)); |
219 | 193 | ||
220 | - videoList.add(video); | 194 | + dbHelper.insertVColumn(video.getTitle(), video.getDate_added(), video.getDisplay_Name() |
195 | + , video.getMIME_type(), video.getPath(), video.getLatitude(), video.getLongitude() | ||
196 | + , video.getAlbum(), video.getArtist(), video.getBookmark(), video.getCategory() | ||
197 | + , video.getDescription(), video.getLanguage(), video.getResolution(), video.getTags()); | ||
221 | } | 198 | } |
222 | - return videoList; | ||
223 | } | 199 | } |
224 | 200 | ||
225 | - public ArrayList<audioItem> getAudioList() { | 201 | + public void getAudio() { |
226 | Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; | 202 | Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; |
227 | 203 | ||
228 | String[] projection = new String[]{ | 204 | String[] projection = new String[]{ |
... | @@ -239,8 +215,6 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -239,8 +215,6 @@ public class MainActivity extends AppCompatActivity { |
239 | 215 | ||
240 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); | 216 | Cursor cursor = getContentResolver().query(uri, projection, null, null, null); |
241 | 217 | ||
242 | - ArrayList<audioItem> audioList = new ArrayList<>(); | ||
243 | - | ||
244 | while (cursor.moveToNext()) { | 218 | while (cursor.moveToNext()) { |
245 | audioItem audio = new audioItem(); | 219 | audioItem audio = new audioItem(); |
246 | audio.setAlbum(cursor.getString(0)); | 220 | audio.setAlbum(cursor.getString(0)); |
... | @@ -253,12 +227,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -253,12 +227,14 @@ public class MainActivity extends AppCompatActivity { |
253 | audio.setSize(cursor.getString(7)); | 227 | audio.setSize(cursor.getString(7)); |
254 | audio.setTitle(cursor.getString(8)); | 228 | audio.setTitle(cursor.getString(8)); |
255 | 229 | ||
256 | - audioList.add(audio); | 230 | + dbHelper.insertAColumn(audio.getTitle(), audio.getDate_added(), audio.getMIME_TYPE() |
231 | + , audio.getPath(), audio.getAlbum(), audio.getArtist(), audio.getComposer() | ||
232 | + ,audio.getYear(), audio.getSize()); | ||
257 | } | 233 | } |
258 | - return audioList; | 234 | + |
259 | } | 235 | } |
260 | 236 | ||
261 | - private ArrayList<calendarItem> getCalendarInfoList() { | 237 | + private void getCalendarInfo() { |
262 | ArrayList<calendarItem> calendarList = new ArrayList<>(); | 238 | ArrayList<calendarItem> calendarList = new ArrayList<>(); |
263 | 239 | ||
264 | Cursor cur = null; | 240 | Cursor cur = null; |
... | @@ -267,7 +243,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -267,7 +243,7 @@ public class MainActivity extends AppCompatActivity { |
267 | 243 | ||
268 | if (checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) { | 244 | if (checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) { |
269 | Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show(); | 245 | Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show(); |
270 | - return null; | 246 | + return; |
271 | } | 247 | } |
272 | 248 | ||
273 | String[] event_projection = new String[]{ | 249 | String[] event_projection = new String[]{ |
... | @@ -356,12 +332,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -356,12 +332,14 @@ public class MainActivity extends AppCompatActivity { |
356 | calendar.setRrule(rrule); | 332 | calendar.setRrule(rrule); |
357 | calendar.setRdate(rdate); | 333 | calendar.setRdate(rdate); |
358 | 334 | ||
359 | - calendarList.add(calendar); | 335 | + dbHelper.insertCColumn(calendar.getTitle(), calendar.getCalID(), calendar.getLoc() |
336 | + , calendar.getDesc(), calendar.getDtstart(), calendar.getDtend(), calendar.getDuration() | ||
337 | + , calendar.getAllday(), calendar.getDisplayName(), calendar.getAccountName() | ||
338 | + , calendar.getOwnerName(), calendar.getRrule(), calendar.getRdate()); | ||
360 | } | 339 | } |
361 | } | 340 | } |
362 | } | 341 | } |
363 | 342 | ||
364 | - return calendarList; | ||
365 | } | 343 | } |
366 | 344 | ||
367 | public void getNetworkInfo(){ | 345 | public void getNetworkInfo(){ |
... | @@ -369,9 +347,9 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -369,9 +347,9 @@ public class MainActivity extends AppCompatActivity { |
369 | LinkProperties linkProperties; | 347 | LinkProperties linkProperties; |
370 | connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); | 348 | connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); |
371 | Network[] networkList = connectivityManager.getAllNetworks(); | 349 | Network[] networkList = connectivityManager.getAllNetworks(); |
372 | - networkDBHelper dbHelper = new networkDBHelper(getApplicationContext()); | 350 | + networkDBHelper dbNHelper = new networkDBHelper(getApplicationContext()); |
373 | - dbHelper.open(); | 351 | + dbNHelper.open(); |
374 | - dbHelper.deleteAllRows(); | 352 | + dbNHelper.deleteAllRows(); |
375 | for(Network network : networkList){ | 353 | for(Network network : networkList){ |
376 | NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network); | 354 | NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network); |
377 | if(capabilities != null){ | 355 | if(capabilities != null){ |
... | @@ -379,26 +357,26 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -379,26 +357,26 @@ public class MainActivity extends AppCompatActivity { |
379 | linkProperties = connectivityManager.getLinkProperties(network); | 357 | linkProperties = connectivityManager.getLinkProperties(network); |
380 | String domain = linkProperties.getDomains(); | 358 | String domain = linkProperties.getDomains(); |
381 | String interfacrName = linkProperties.getInterfaceName(); | 359 | String interfacrName = linkProperties.getInterfaceName(); |
382 | - String DnsServerName = linkProperties.getPrivateDnsServerName(); | 360 | + //String DnsServerName = linkProperties.getPrivateDnsServerName(); |
383 | - dbHelper.insertColumn0(network.toString(), domain, interfacrName, DnsServerName); | 361 | + dbNHelper.insertColumn0(network.toString(), domain, interfacrName, null); |
384 | List<InetAddress> inetAddresses = linkProperties.getDnsServers(); | 362 | List<InetAddress> inetAddresses = linkProperties.getDnsServers(); |
385 | for(InetAddress address : inetAddresses){ | 363 | for(InetAddress address : inetAddresses){ |
386 | - dbHelper.insertColumn1(network.toString(), address.getHostAddress()); | 364 | + dbNHelper.insertColumn1(network.toString(), address.getHostAddress()); |
387 | } | 365 | } |
388 | List<LinkAddress> linkAddresses = linkProperties.getLinkAddresses(); | 366 | List<LinkAddress> linkAddresses = linkProperties.getLinkAddresses(); |
389 | for(LinkAddress address : linkAddresses) { | 367 | for(LinkAddress address : linkAddresses) { |
390 | - dbHelper.insertColumn2(network.toString(), address.getAddress().getHostAddress(), address.getPrefixLength()); | 368 | + dbNHelper.insertColumn2(network.toString(), address.getAddress().getHostAddress(), address.getPrefixLength()); |
391 | } | 369 | } |
392 | List<RouteInfo> routeInfos = linkProperties.getRoutes(); | 370 | List<RouteInfo> routeInfos = linkProperties.getRoutes(); |
393 | for(RouteInfo routeinfo : routeInfos){ | 371 | for(RouteInfo routeinfo : routeInfos){ |
394 | - dbHelper.insertColumn3(network.toString(), routeinfo.getDestination().toString() | 372 | + dbNHelper.insertColumn3(network.toString(), routeinfo.getDestination().toString() |
395 | , routeinfo.getDestination().getPrefixLength(), routeinfo.getGateway().toString() | 373 | , routeinfo.getDestination().getPrefixLength(), routeinfo.getGateway().toString() |
396 | ,routeinfo.getInterface()); | 374 | ,routeinfo.getInterface()); |
397 | } | 375 | } |
398 | } | 376 | } |
399 | } | 377 | } |
400 | } | 378 | } |
401 | - dbHelper.close(); | 379 | + dbNHelper.close(); |
402 | } | 380 | } |
403 | // private class GoogleAppIdTask extends AsyncTask<Void, Void, String> { | 381 | // private class GoogleAppIdTask extends AsyncTask<Void, Void, String> { |
404 | // protected String doInBackground(final Void... params) { | 382 | // protected String doInBackground(final Void... params) { |
... | @@ -434,8 +412,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -434,8 +412,7 @@ public class MainActivity extends AppCompatActivity { |
434 | if (checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { | 412 | if (checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { |
435 | Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show(); | 413 | Toast.makeText(getApplicationContext(), "권한문제", Toast.LENGTH_LONG).show(); |
436 | } | 414 | } |
437 | - DBHelper mDBhelper = new DBHelper(this); | 415 | + |
438 | - mDBhelper.open(); | ||
439 | String adid = ""; | 416 | String adid = ""; |
440 | // try { | 417 | // try { |
441 | // MainActivity.GoogleAppIdTask asyncTask = new MainActivity.GoogleAppIdTask(); | 418 | // MainActivity.GoogleAppIdTask asyncTask = new MainActivity.GoogleAppIdTask(); |
... | @@ -444,33 +421,29 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -444,33 +421,29 @@ public class MainActivity extends AppCompatActivity { |
444 | // e.printStackTrace(); | 421 | // e.printStackTrace(); |
445 | // } | 422 | // } |
446 | 423 | ||
447 | - mDBhelper.addPhoneInfo(tm.getPhoneType(), tm.getDeviceSoftwareVersion(), | 424 | + dbHelper.addPhoneInfo(tm.getPhoneType(), tm.getDeviceSoftwareVersion(), |
448 | tm.getLine1Number(), tm.getSubscriberId(), adid, tm.getCallState(), | 425 | tm.getLine1Number(), tm.getSubscriberId(), adid, tm.getCallState(), |
449 | tm.getDataState(),tm.getNetworkType(),tm.getNetworkCountryIso(), | 426 | tm.getDataState(),tm.getNetworkType(),tm.getNetworkCountryIso(), |
450 | tm.getSimCountryIso(),tm.getNetworkOperator(),tm.getSimOperator(), | 427 | tm.getSimCountryIso(),tm.getNetworkOperator(),tm.getSimOperator(), |
451 | tm.getNetworkOperatorName(),tm.getSimOperatorName() ,tm.getSimSerialNumber(), | 428 | tm.getNetworkOperatorName(),tm.getSimOperatorName() ,tm.getSimSerialNumber(), |
452 | tm.getSimState(),tm.isNetworkRoaming()); | 429 | tm.getSimState(),tm.isNetworkRoaming()); |
453 | 430 | ||
454 | - mDBhelper.close(); | ||
455 | 431 | ||
456 | } | 432 | } |
457 | 433 | ||
458 | public void getAccountInfo(){ | 434 | public void getAccountInfo(){ |
459 | - DBHelper mDBhelper = new DBHelper(this); | 435 | + |
460 | - mDBhelper.open(); | ||
461 | AccountManager am = AccountManager.get(this); | 436 | AccountManager am = AccountManager.get(this); |
462 | Account[] accounts = am.getAccounts(); | 437 | Account[] accounts = am.getAccounts(); |
463 | 438 | ||
464 | for(Account account : accounts) { | 439 | for(Account account : accounts) { |
465 | - mDBhelper.addAccountInfo(account.name,account.type); | 440 | + dbHelper.addAccountInfo(account.name,account.type); |
466 | //String password=accountManager.getPassword(account); | 441 | //String password=accountManager.getPassword(account); |
467 | } | 442 | } |
468 | - mDBhelper.close(); | ||
469 | } | 443 | } |
470 | 444 | ||
471 | public void getAppInfo() { | 445 | public void getAppInfo() { |
472 | - DBHelper mDBhelper = new DBHelper(this); | 446 | + |
473 | - mDBhelper.open(); | ||
474 | PackageManager pm = getPackageManager(); | 447 | PackageManager pm = getPackageManager(); |
475 | List<PackageInfo> packages = pm.getInstalledPackages(PackageManager.GET_META_DATA); | 448 | List<PackageInfo> packages = pm.getInstalledPackages(PackageManager.GET_META_DATA); |
476 | ApplicationInfo applicationInfo; | 449 | ApplicationInfo applicationInfo; |
... | @@ -520,10 +493,9 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -520,10 +493,9 @@ public class MainActivity extends AppCompatActivity { |
520 | }; | 493 | }; |
521 | mobilenetworkStats.getNextBucket(cellularbucket); | 494 | mobilenetworkStats.getNextBucket(cellularbucket); |
522 | 495 | ||
523 | - mDBhelper.addAppInfo(packageInfo.packageName,packageInfo.versionName, applicationName,packageInfo.firstInstallTime, packageInfo.lastUpdateTime, wifirxbytes+wifitxbytes, cellrxbytes+celltxbytes); | 496 | + dbHelper.addAppInfo(packageInfo.packageName,packageInfo.versionName, applicationName,packageInfo.firstInstallTime, packageInfo.lastUpdateTime, wifirxbytes+wifitxbytes, cellrxbytes+celltxbytes); |
524 | } | 497 | } |
525 | 498 | ||
526 | - mDBhelper.close(); | ||
527 | } | 499 | } |
528 | 500 | ||
529 | private String getSubscriberId(int networkType) { | 501 | private String getSubscriberId(int networkType) { |
... | @@ -541,32 +513,29 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -541,32 +513,29 @@ public class MainActivity extends AppCompatActivity { |
541 | } | 513 | } |
542 | 514 | ||
543 | public void getUsageStats() { | 515 | public void getUsageStats() { |
544 | - DBHelper mDBhelper = new DBHelper(this); | ||
545 | - mDBhelper.open(); | ||
546 | 516 | ||
547 | UsageStatsManager usageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE); | 517 | UsageStatsManager usageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE); |
548 | 518 | ||
549 | List<UsageStats> queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_YEARLY, 0, System.currentTimeMillis()); | 519 | List<UsageStats> queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_YEARLY, 0, System.currentTimeMillis()); |
550 | for (UsageStats usagestat : queryUsageStats) { | 520 | for (UsageStats usagestat : queryUsageStats) { |
551 | - mDBhelper.addAppUsage_YEAR(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); | 521 | + dbHelper.addAppUsage_YEAR(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); |
552 | } | 522 | } |
553 | 523 | ||
554 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_MONTHLY, 0, System.currentTimeMillis()); | 524 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_MONTHLY, 0, System.currentTimeMillis()); |
555 | for (UsageStats usagestat : queryUsageStats) { | 525 | for (UsageStats usagestat : queryUsageStats) { |
556 | - mDBhelper.addAppUsage_MONTH(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); | 526 | + dbHelper.addAppUsage_MONTH(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); |
557 | } | 527 | } |
558 | 528 | ||
559 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_WEEKLY, 0, System.currentTimeMillis()); | 529 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_WEEKLY, 0, System.currentTimeMillis()); |
560 | for (UsageStats usagestat : queryUsageStats) { | 530 | for (UsageStats usagestat : queryUsageStats) { |
561 | - mDBhelper.addAppUsage_WEEK(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); | 531 | + dbHelper.addAppUsage_WEEK(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); |
562 | } | 532 | } |
563 | 533 | ||
564 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, 0, System.currentTimeMillis()); | 534 | queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, 0, System.currentTimeMillis()); |
565 | for (UsageStats usagestat : queryUsageStats) { | 535 | for (UsageStats usagestat : queryUsageStats) { |
566 | - mDBhelper.addAppUsage_DAY(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); | 536 | + dbHelper.addAppUsage_DAY(usagestat.getPackageName(),usagestat.getFirstTimeStamp(), usagestat.getLastTimeStamp(),usagestat.getLastTimeUsed(), usagestat.getTotalTimeInForeground()); |
567 | } | 537 | } |
568 | 538 | ||
569 | - mDBhelper.close(); | ||
570 | } | 539 | } |
571 | 540 | ||
572 | 541 | ||
... | @@ -575,6 +544,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -575,6 +544,7 @@ public class MainActivity extends AppCompatActivity { |
575 | int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_CALL_LOG); | 544 | int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_CALL_LOG); |
576 | 545 | ||
577 | Uri uri = CallLog.Calls.CONTENT_URI; | 546 | Uri uri = CallLog.Calls.CONTENT_URI; |
547 | + | ||
578 | if(permissionCheck == PackageManager.PERMISSION_GRANTED) { | 548 | if(permissionCheck == PackageManager.PERMISSION_GRANTED) { |
579 | Cursor cursor = getBaseContext().getContentResolver().query(uri, null, null, null, CallLog.Calls.DEFAULT_SORT_ORDER); | 549 | Cursor cursor = getBaseContext().getContentResolver().query(uri, null, null, null, CallLog.Calls.DEFAULT_SORT_ORDER); |
580 | 550 | ... | ... |
-
Please register or login to post a comment