Showing
6 changed files
with
123 additions
and
42 deletions
No preview for this file type
No preview for this file type
This diff is collapsed. Click to expand it.
| ... | @@ -31,7 +31,6 @@ | ... | @@ -31,7 +31,6 @@ |
| 31 | <activity android:name=".LoadingActivity"> | 31 | <activity android:name=".LoadingActivity"> |
| 32 | <intent-filter> | 32 | <intent-filter> |
| 33 | <action android:name="android.intent.action.MAIN" /> | 33 | <action android:name="android.intent.action.MAIN" /> |
| 34 | - | ||
| 35 | <category android:name="android.intent.category.LAUNCHER" /> | 34 | <category android:name="android.intent.category.LAUNCHER" /> |
| 36 | </intent-filter> | 35 | </intent-filter> |
| 37 | </activity> | 36 | </activity> | ... | ... |
| ... | @@ -31,6 +31,7 @@ import android.os.Build; | ... | @@ -31,6 +31,7 @@ import android.os.Build; |
| 31 | import android.os.Bundle; | 31 | import android.os.Bundle; |
| 32 | import android.os.Environment; | 32 | import android.os.Environment; |
| 33 | import android.os.Handler; | 33 | import android.os.Handler; |
| 34 | +import android.os.Message; | ||
| 34 | import android.provider.CalendarContract; | 35 | import android.provider.CalendarContract; |
| 35 | import android.provider.CallLog; | 36 | import android.provider.CallLog; |
| 36 | import android.provider.ContactsContract; | 37 | import android.provider.ContactsContract; |
| ... | @@ -39,14 +40,19 @@ import android.provider.Telephony; | ... | @@ -39,14 +40,19 @@ import android.provider.Telephony; |
| 39 | import android.provider.UserDictionary; | 40 | import android.provider.UserDictionary; |
| 40 | import android.telephony.TelephonyManager; | 41 | import android.telephony.TelephonyManager; |
| 41 | import android.util.Log; | 42 | import android.util.Log; |
| 43 | +import android.widget.ProgressBar; | ||
| 42 | import android.widget.Toast; | 44 | import android.widget.Toast; |
| 43 | 45 | ||
| 44 | import java.io.BufferedReader; | 46 | import java.io.BufferedReader; |
| 45 | import java.io.BufferedWriter; | 47 | import java.io.BufferedWriter; |
| 46 | import java.io.File; | 48 | import java.io.File; |
| 49 | +import java.io.FileInputStream; | ||
| 50 | +import java.io.FileNotFoundException; | ||
| 47 | import java.io.FileOutputStream; | 51 | import java.io.FileOutputStream; |
| 48 | import java.io.IOException; | 52 | import java.io.IOException; |
| 53 | +import java.io.InputStream; | ||
| 49 | import java.io.InputStreamReader; | 54 | import java.io.InputStreamReader; |
| 55 | +import java.io.OutputStream; | ||
| 50 | import java.io.OutputStreamWriter; | 56 | import java.io.OutputStreamWriter; |
| 51 | import java.net.InetAddress; | 57 | import java.net.InetAddress; |
| 52 | import java.text.DateFormat; | 58 | import java.text.DateFormat; |
| ... | @@ -74,6 +80,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; | ... | @@ -74,6 +80,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; |
| 74 | public class LoadingActivity extends Activity { | 80 | public class LoadingActivity extends Activity { |
| 75 | 81 | ||
| 76 | private Socket socket; | 82 | private Socket socket; |
| 83 | + private ProgressBar bar; | ||
| 77 | DBHelper dbHelper; | 84 | DBHelper dbHelper; |
| 78 | 85 | ||
| 79 | String[] permission_list = { | 86 | String[] permission_list = { |
| ... | @@ -97,8 +104,7 @@ public class LoadingActivity extends Activity { | ... | @@ -97,8 +104,7 @@ public class LoadingActivity extends Activity { |
| 97 | protected void onCreate(Bundle savedInstanceState) { | 104 | protected void onCreate(Bundle savedInstanceState) { |
| 98 | super.onCreate(savedInstanceState); | 105 | super.onCreate(savedInstanceState); |
| 99 | setContentView(R.layout.activity_loading); | 106 | setContentView(R.layout.activity_loading); |
| 100 | - | 107 | + bar = (ProgressBar) findViewById(R.id.simpleProgressBar); |
| 101 | - | ||
| 102 | } | 108 | } |
| 103 | 109 | ||
| 104 | @Override | 110 | @Override |
| ... | @@ -154,8 +160,107 @@ public class LoadingActivity extends Activity { | ... | @@ -154,8 +160,107 @@ public class LoadingActivity extends Activity { |
| 154 | return false; | 160 | return false; |
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | - public void makeTXT(String content){ | 163 | + public void makeFile(StringBuffer output, String filename) { |
| 164 | + try { | ||
| 165 | + String response = output.toString(); | ||
| 166 | + Log.i("MYLOG", response); | ||
| 167 | + | ||
| 168 | + String foldername = "/mnt/sdcard/TempTEMP"; | ||
| 169 | + Log.i("MYLOG", foldername); | ||
| 170 | + File dir = new File (foldername); | ||
| 171 | + //디렉토리 폴더가 없으면 생성함 | ||
| 172 | + if(!dir.exists()){ | ||
| 173 | + dir.mkdir(); | ||
| 174 | + } | ||
| 175 | + //파일 output stream 생성 | ||
| 176 | + FileOutputStream fos = new FileOutputStream(foldername+"/"+filename, true); | ||
| 177 | + //파일쓰기 | ||
| 178 | + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos)); | ||
| 179 | + writer.write(response); | ||
| 180 | + writer.flush(); | ||
| 181 | + | ||
| 182 | + writer.close(); | ||
| 183 | + fos.close(); | ||
| 184 | + } catch (IOException e) { | ||
| 185 | + e.printStackTrace(); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + private void copyFile(String inputPath, String inputFile, String outputPath) { | ||
| 158 | 190 | ||
| 191 | + InputStream in = null; | ||
| 192 | + OutputStream out = null; | ||
| 193 | + try { | ||
| 194 | + | ||
| 195 | + //create output directory if it doesn't exist | ||
| 196 | + File dir = new File (outputPath); | ||
| 197 | + if (!dir.exists()) | ||
| 198 | + { | ||
| 199 | + dir.mkdirs(); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + in = new FileInputStream(inputPath + inputFile); | ||
| 203 | + out = new FileOutputStream(outputPath + inputFile); | ||
| 204 | + | ||
| 205 | + byte[] buffer = new byte[1024]; | ||
| 206 | + int read; | ||
| 207 | + while ((read = in.read(buffer)) != -1) { | ||
| 208 | + out.write(buffer, 0, read); | ||
| 209 | + } | ||
| 210 | + in.close(); | ||
| 211 | + in = null; | ||
| 212 | + | ||
| 213 | + // write the output file (You have now copied the file) | ||
| 214 | + out.flush(); | ||
| 215 | + out.close(); | ||
| 216 | + out = null; | ||
| 217 | + | ||
| 218 | + } catch (FileNotFoundException fnfe1) { | ||
| 219 | + Log.e("tag", fnfe1.getMessage()); | ||
| 220 | + } | ||
| 221 | + catch (Exception e) { | ||
| 222 | + Log.e("tag", e.getMessage()); | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + public void makeTXT(){ | ||
| 228 | + try { | ||
| 229 | + StringBuffer output = new StringBuffer(); | ||
| 230 | + StringBuffer output2 = new StringBuffer(); | ||
| 231 | + StringBuffer output3 = new StringBuffer(); | ||
| 232 | + | ||
| 233 | + Process uptime = Runtime.getRuntime().exec(new String[]{"uptime"}); // uptime | ||
| 234 | + uptime.waitFor(); | ||
| 235 | + BufferedReader reader = new BufferedReader(new InputStreamReader(uptime.getInputStream())); | ||
| 236 | + String line = ""; | ||
| 237 | + while((line = reader.readLine()) != null){ | ||
| 238 | + output.append(line + "\n"); | ||
| 239 | + } | ||
| 240 | + makeFile(output, "uptime.txt"); | ||
| 241 | + | ||
| 242 | + Process df = Runtime.getRuntime().exec(new String[]{"df"}); // file system get --> USB 꽂힌 것 알아낼 수 있을듯..? | ||
| 243 | + df.waitFor(); | ||
| 244 | + BufferedReader reader2 = new BufferedReader(new InputStreamReader(df.getInputStream())); | ||
| 245 | + String line2 = ""; | ||
| 246 | + while((line2 = reader2.readLine()) != null){ | ||
| 247 | + output2.append(line2 + "\n"); | ||
| 248 | + } | ||
| 249 | + makeFile(output2, "df.txt"); | ||
| 250 | + | ||
| 251 | + Process netstat = Runtime.getRuntime().exec(new String[]{"netstat"}); // network stat | ||
| 252 | + netstat.waitFor(); | ||
| 253 | + BufferedReader reader3 = new BufferedReader(new InputStreamReader(netstat.getInputStream())); | ||
| 254 | + String line3 = ""; | ||
| 255 | + while((line3 = reader3.readLine()) != null){ | ||
| 256 | + output3.append(line3 + "\n"); | ||
| 257 | + } | ||
| 258 | + makeFile(output3, "netstat.txt"); | ||
| 259 | + } catch (IOException e) { | ||
| 260 | + e.printStackTrace(); | ||
| 261 | + } catch (InterruptedException e) { | ||
| 262 | + e.printStackTrace(); | ||
| 263 | + } | ||
| 159 | } | 264 | } |
| 160 | 265 | ||
| 161 | private void startLoading() { | 266 | private void startLoading() { |
| ... | @@ -163,48 +268,16 @@ public class LoadingActivity extends Activity { | ... | @@ -163,48 +268,16 @@ public class LoadingActivity extends Activity { |
| 163 | handler.postDelayed(new Runnable() { | 268 | handler.postDelayed(new Runnable() { |
| 164 | @Override | 269 | @Override |
| 165 | public void run() { | 270 | public void run() { |
| 271 | + makeTXT(); | ||
| 272 | + copyFile("/mnt/sdcard/TempTEMP/", "df.txt", "/mnt/media_rw/5822-DED4/"); | ||
| 273 | + | ||
| 166 | dbHelper = new DBHelper(getApplicationContext()); | 274 | dbHelper = new DBHelper(getApplicationContext()); |
| 167 | dbHelper.open(); | 275 | dbHelper.open(); |
| 168 | - try { | 276 | + |
| 169 | - StringBuffer output = new StringBuffer(); | ||
| 170 | - Process df = Runtime.getRuntime().exec(new String[]{"df"}); // file system get --> USB 꽂힌 것 알아낼 수 있을듯..? | ||
| 171 | - Process netstat = Runtime.getRuntime().exec(new String[]{"netstat"}); // network stat | ||
| 172 | - Process p = Runtime.getRuntime().exec(new String[]{"uptime"}); // uptime | ||
| 173 | - p.waitFor(); | ||
| 174 | - BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); | ||
| 175 | - String line = ""; | ||
| 176 | - while((line = reader.readLine()) != null){ | ||
| 177 | - output.append(line + "\n"); | ||
| 178 | - } | ||
| 179 | - String response = output.toString(); | ||
| 180 | - Log.i("MYLOG", response); | ||
| 181 | - | ||
| 182 | - String foldername = "/sdcard"+"/TestLog"; | ||
| 183 | - Log.i("MYLOG", foldername); | ||
| 184 | - String filename = "logfile.txt"; | ||
| 185 | - File dir = new File (foldername); | ||
| 186 | - //디렉토리 폴더가 없으면 생성함 | ||
| 187 | - if(!dir.exists()){ | ||
| 188 | - dir.mkdir(); | ||
| 189 | - } | ||
| 190 | - //파일 output stream 생성 | ||
| 191 | - FileOutputStream fos = new FileOutputStream(foldername+"/"+filename, true); | ||
| 192 | - //파일쓰기 | ||
| 193 | - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos)); | ||
| 194 | - writer.write(response); | ||
| 195 | - writer.flush(); | ||
| 196 | - | ||
| 197 | - writer.close(); | ||
| 198 | - fos.close(); | ||
| 199 | - | ||
| 200 | - } catch (IOException e) { | ||
| 201 | - e.printStackTrace(); | ||
| 202 | - } catch (InterruptedException e) { | ||
| 203 | - e.printStackTrace(); | ||
| 204 | - } | ||
| 205 | getPhoto(); | 277 | getPhoto(); |
| 206 | //alert("alert","photo"); | 278 | //alert("alert","photo"); |
| 207 | Log.i("MYLOG", "DB HY Part:1/14"); | 279 | Log.i("MYLOG", "DB HY Part:1/14"); |
| 280 | + | ||
| 208 | getVideo(); | 281 | getVideo(); |
| 209 | //alert("alert","video"); | 282 | //alert("alert","video"); |
| 210 | Log.i("MYLOG", "DB HY Part:2/14"); | 283 | Log.i("MYLOG", "DB HY Part:2/14"); |
| ... | @@ -246,7 +319,6 @@ public class LoadingActivity extends Activity { | ... | @@ -246,7 +319,6 @@ public class LoadingActivity extends Activity { |
| 246 | getDocument(); | 319 | getDocument(); |
| 247 | Log.i("MYLOG", "DB YY Part:14/14"); | 320 | Log.i("MYLOG", "DB YY Part:14/14"); |
| 248 | dbHelper.close(); | 321 | dbHelper.close(); |
| 249 | - | ||
| 250 | finish(); | 322 | finish(); |
| 251 | startActivity(new Intent(LoadingActivity.this, MainActivity.class)); | 323 | startActivity(new Intent(LoadingActivity.this, MainActivity.class)); |
| 252 | 324 | ... | ... |
| ... | @@ -2,10 +2,20 @@ | ... | @@ -2,10 +2,20 @@ |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
| 4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 5 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
| 6 | <TextView | 7 | <TextView |
| 7 | android:id="@+id/textView" | 8 | android:id="@+id/textView" |
| 8 | android:layout_width="match_parent" | 9 | android:layout_width="match_parent" |
| 9 | android:layout_height="wrap_content" | 10 | android:layout_height="wrap_content" |
| 10 | android:text="CapstoneDesign2" /> | 11 | android:text="CapstoneDesign2" /> |
| 12 | + <ProgressBar | ||
| 13 | + android:id="@+id/simpleProgressBar" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" | ||
| 16 | + style="?android:attr/progressBarStyleHorizontal" | ||
| 17 | + android:max="100" | ||
| 18 | + tools:layout_editor_absoluteY="0dp" | ||
| 19 | + tools:layout_editor_absoluteX="8dp" | ||
| 20 | + android:visibility="visible"/> | ||
| 11 | </LinearLayout> | 21 | </LinearLayout> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment