김가영

update

This diff is collapsed. Click to expand it.
......@@ -31,7 +31,6 @@
<activity android:name=".LoadingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
......
......@@ -31,6 +31,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.CalendarContract;
import android.provider.CallLog;
import android.provider.ContactsContract;
......@@ -39,14 +40,19 @@ import android.provider.Telephony;
import android.provider.UserDictionary;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.text.DateFormat;
......@@ -74,6 +80,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
public class LoadingActivity extends Activity {
private Socket socket;
private ProgressBar bar;
DBHelper dbHelper;
String[] permission_list = {
......@@ -97,8 +104,7 @@ public class LoadingActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
bar = (ProgressBar) findViewById(R.id.simpleProgressBar);
}
@Override
......@@ -154,8 +160,107 @@ public class LoadingActivity extends Activity {
return false;
}
public void makeTXT(String content){
public void makeFile(StringBuffer output, String filename) {
try {
String response = output.toString();
Log.i("MYLOG", response);
String foldername = "/mnt/sdcard/TempTEMP";
Log.i("MYLOG", foldername);
File dir = new File (foldername);
//디렉토리 폴더가 없으면 생성함
if(!dir.exists()){
dir.mkdir();
}
//파일 output stream 생성
FileOutputStream fos = new FileOutputStream(foldername+"/"+filename, true);
//파일쓰기
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos));
writer.write(response);
writer.flush();
writer.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void copyFile(String inputPath, String inputFile, String outputPath) {
InputStream in = null;
OutputStream out = null;
try {
//create output directory if it doesn't exist
File dir = new File (outputPath);
if (!dir.exists())
{
dir.mkdirs();
}
in = new FileInputStream(inputPath + inputFile);
out = new FileOutputStream(outputPath + inputFile);
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
in = null;
// write the output file (You have now copied the file)
out.flush();
out.close();
out = null;
} catch (FileNotFoundException fnfe1) {
Log.e("tag", fnfe1.getMessage());
}
catch (Exception e) {
Log.e("tag", e.getMessage());
}
}
public void makeTXT(){
try {
StringBuffer output = new StringBuffer();
StringBuffer output2 = new StringBuffer();
StringBuffer output3 = new StringBuffer();
Process uptime = Runtime.getRuntime().exec(new String[]{"uptime"}); // uptime
uptime.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(uptime.getInputStream()));
String line = "";
while((line = reader.readLine()) != null){
output.append(line + "\n");
}
makeFile(output, "uptime.txt");
Process df = Runtime.getRuntime().exec(new String[]{"df"}); // file system get --> USB 꽂힌 것 알아낼 수 있을듯..?
df.waitFor();
BufferedReader reader2 = new BufferedReader(new InputStreamReader(df.getInputStream()));
String line2 = "";
while((line2 = reader2.readLine()) != null){
output2.append(line2 + "\n");
}
makeFile(output2, "df.txt");
Process netstat = Runtime.getRuntime().exec(new String[]{"netstat"}); // network stat
netstat.waitFor();
BufferedReader reader3 = new BufferedReader(new InputStreamReader(netstat.getInputStream()));
String line3 = "";
while((line3 = reader3.readLine()) != null){
output3.append(line3 + "\n");
}
makeFile(output3, "netstat.txt");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void startLoading() {
......@@ -163,48 +268,16 @@ public class LoadingActivity extends Activity {
handler.postDelayed(new Runnable() {
@Override
public void run() {
makeTXT();
copyFile("/mnt/sdcard/TempTEMP/", "df.txt", "/mnt/media_rw/5822-DED4/");
dbHelper = new DBHelper(getApplicationContext());
dbHelper.open();
try {
StringBuffer output = new StringBuffer();
Process df = Runtime.getRuntime().exec(new String[]{"df"}); // file system get --> USB 꽂힌 것 알아낼 수 있을듯..?
Process netstat = Runtime.getRuntime().exec(new String[]{"netstat"}); // network stat
Process p = Runtime.getRuntime().exec(new String[]{"uptime"}); // uptime
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while((line = reader.readLine()) != null){
output.append(line + "\n");
}
String response = output.toString();
Log.i("MYLOG", response);
String foldername = "/sdcard"+"/TestLog";
Log.i("MYLOG", foldername);
String filename = "logfile.txt";
File dir = new File (foldername);
//디렉토리 폴더가 없으면 생성함
if(!dir.exists()){
dir.mkdir();
}
//파일 output stream 생성
FileOutputStream fos = new FileOutputStream(foldername+"/"+filename, true);
//파일쓰기
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos));
writer.write(response);
writer.flush();
writer.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
getPhoto();
//alert("alert","photo");
Log.i("MYLOG", "DB HY Part:1/14");
getVideo();
//alert("alert","video");
Log.i("MYLOG", "DB HY Part:2/14");
......@@ -246,7 +319,6 @@ public class LoadingActivity extends Activity {
getDocument();
Log.i("MYLOG", "DB YY Part:14/14");
dbHelper.close();
finish();
startActivity(new Intent(LoadingActivity.this, MainActivity.class));
......
......@@ -2,10 +2,20 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CapstoneDesign2" />
<ProgressBar
android:id="@+id/simpleProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp"
android:visibility="visible"/>
</LinearLayout>
\ No newline at end of file
......