김가영

add function adb command to txt file

This diff is collapsed. Click to expand it.
......@@ -20,7 +20,6 @@
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
......
......@@ -5,6 +5,7 @@ import android.Manifest;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.usage.NetworkStats;
import android.app.usage.NetworkStatsManager;
......@@ -41,8 +42,12 @@ import android.util.Log;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
......@@ -149,6 +154,10 @@ public class LoadingActivity extends Activity {
return false;
}
public void makeTXT(String content){
}
private void startLoading() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
......@@ -156,6 +165,43 @@ public class LoadingActivity extends Activity {
public void run() {
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");
......
......@@ -18,8 +18,8 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
copyFile("/data/data/com.example.dataextraction/databases/", "InnerDatabase.db", "/storage/UsbDriveA/InnerDatabase.db");
copyFile("/data/data/com.example.dataextraction/databases/", "networkDatabase.db", "/storage/UsbDriveA/networkDatabase.db");
copyFile("/data/data/com.example.dataextraction/databases/", "InnerDatabase.db", "/sdcard/TestLog/InnerDatabase.db");
copyFile("/data/data/com.example.dataextraction/databases/", "networkDatabase.db", "/sdcard/TestLog/networkDatabase.db");
}
private void copyFile(String inputPath, String inputFile, String outputPath) {
......