09-25 08:46:46.091: ERROR/AndroidRuntime(280): Caused by: java.lang.ClassCastException: android.widget.Button
09-25 08:46:46.091: ERROR/AndroidRuntime(280):     at com.lu2300.optimizer.Page8.onCreate(Page8.java:101)
우선로그캣 이구요

-------------------------------------------------------------------------------------------------------------------------------------------------------------

 

xx
 package com.lu2300.optimizer;
xx
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
xx
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.StatFs;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
xx
public class Page8 extends Activity implements OnClickListener, OnItemSelectedListener{
 
 /** Called when the activity is first created. */
 String[] etcFileName = {"/system/fonts/Clockopia.ttf",
       "/system/fonts/DroidSans.ttf",
       "/system/fonts/DroidSans-Bold.ttf",
       "/system/fonts/LG_Android_SMS.ttf",
       "/system/fonts/OpQumizer.ttf",//"/system/fonts/DroidSansFallback.ttf",
       "/system/sounds/camerashutter/shutter1.ogg",
       "/system/media/audio/camera/shutter1.ogg",
       "/system/media/audio/camera/AutoFocus.ogg",
       "/system/media/audio/message/01_Acoustic_Guitar.ogg",
       "/system/sounds/poweron/pwron_1.ogg",
       "/system/sounds/poweroff/pwroff_1.ogg",
       "/system/app/PowerOff.apk",
       "/system/app/HangulIME.apk",
       "/system/app/Contacts.apk",
       "/system/app/Settings.apk",
       "/system/framework/framework-res.apk",
       "/system/framework/lge-res.apk",
       "/system/framework/services.jar",
       "/system/media/bootanimation.zip",
       };
 
 String[] etcName = {"잠금 시계",
      "일반 글꼴",
      "굵은 글꼴",
      "LG SMS",
      "한큐에 바꾸기",
      "카메라셔터음1(2.1)",
      "카메라셔터음1(2.2)",
      "초점조절음(2.2)",
      "문자음1",
      "부팅음1",
      "종료음1(2.2)",
      "PowerOff.apk",
      "HangulIME.apk",
      "Contacts.apk",
      "Settings.apk",
      "framework-res.apk",
      "lge-res.apk",
      "services.jar",
      "bootanimation.zip",
      };
 
// static final int ETC_CNT = 14;   // 기타 설정 수 = 14개
 final int ETC_CNT = etcFileName.length;   // 기타 설정 수
 int scrollCnt = 0;      // 스크롤 카운터
 ScrollView sv8;
 TextView tv8;
 
 TextView etcTvFlipFont;
 TextView etcTvPreview[] = new TextView[5];
 Spinner etcSpFlipFont;
 Button apButtonFlipFont;
 
 TextView etcTv[] = new TextView[ETC_CNT];
 Spinner etcSp[] = new Spinner[ETC_CNT];
 Button apButton[] = new Button[ETC_CNT];
 Button reButton[] = new Button[ETC_CNT];
xx
 int isTruth = 0;    // 0 : no, 1 : by me, 2 : by others
 Context mCtx;
 
 String SDstate = null;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.page8);
  
  sv8 = (ScrollView)findViewById(R.id.sv8);
  tv8 = (TextView)findViewById(R.id.tv8);
xx
  // 플립폰트 텍스트 맵핑
  etcTvFlipFont = (TextView)findViewById(R.id.EtcTvFlipFont);
  etcSpFlipFont = (Spinner)findViewById(R.id.EtcSpFlipFont);
  apButtonFlipFont = (Button)findViewById(R.id.EtcApFlipFont);
  etcTvPreview[0] = (TextView)findViewById(R.id.EtcTvPreview0);
  etcTvPreview[1] = (TextView)findViewById(R.id.EtcTvPreview1);
  etcTvPreview[2] = (TextView)findViewById(R.id.EtcTvPreview2);
  etcTvPreview[3] = (TextView)findViewById(R.id.EtcTvPreview3);
  etcTvPreview[4] = (TextView)findViewById(R.id.EtcTvPreview4);
  
  // 텍스트 박스와 버튼 맵핑
  
  etcTv[0] = (TextView)findViewById(R.id.EtcTv0);
  etcSp[0] = (Spinner)findViewById(R.id.EtcSp0);
  apButton[0] = (Button)findViewById(R.id.EtcAp0);
  reButton[0] = (Button)findViewById(R.id.EtcRe0);
  
  etcTv[1] = (TextView)findViewById(R.id.EtcTv1);
  etcSp[1] = (Spinner)findViewById(R.id.EtcSp1);
  apButton[1] = (Button)findViewById(R.id.EtcAp1);
  reButton[1] = (Button)findViewById(R.id.EtcRe1);
  
  etcTv[2] = (TextView)findViewById(R.id.EtcTv2);
  etcSp[2] = (Spinner)findViewById(R.id.EtcSp2);
  apButton[2] = (Button)findViewById(R.id.EtcAp2);
  reButton[2] = (Button)findViewById(R.id.EtcRe2);
  
  etcTv[3] = (TextView)findViewById(R.id.EtcTv3);
  etcSp[3] = (Spinner)findViewById(R.id.EtcSp3);
  apButton[3] = (Button)findViewById(R.id.EtcAp3);
  reButton[3] = (Button)findViewById(R.id.EtcRe3);
  
  etcTv[4] = (TextView)findViewById(R.id.EtcTv4);
  etcSp[4] = (Spinner)findViewById(R.id.EtcSp4);
  apButton[4] = (Button)findViewById(R.id.EtcAp4);
  reButton[4] = (Button)findViewById(R.id.EtcRe4);
xx
  etcTv[5] = (TextView)findViewById(R.id.EtcTv5);
  etcSp[5] = (Spinner)findViewById(R.id.EtcSp5);
  apButton[5] = (Button)findViewById(R.id.EtcAp5);
  reButton[5] = (Button)findViewById(R.id.EtcRe5);
  
  etcTv[6] = (TextView)findViewById(R.id.EtcTv6);
  etcSp[6] = (Spinner)findViewById(R.id.EtcSp6);
  apButton[6] = (Button)findViewById(R.id.EtcAp6);
  reButton[6] = (Button)findViewById(R.id.EtcRe6);
  
  etcTv[7] = (TextView)findViewById(R.id.EtcTv7);
  etcSp[7] = (Spinner)findViewById(R.id.EtcSp7);
  apButton[7] = (Button)findViewById(R.id.EtcAp7);
  reButton[7] = (Button)findViewById(R.id.EtcRe7);
xx
  etcTv[8] = (TextView)findViewById(R.id.EtcTv8);
  etcSp[8] = (Spinner)findViewById(R.id.EtcSp8);
  apButton[8] = (Button)findViewById(R.id.EtcAp8);
  reButton[8] = (Button)findViewById(R.id.EtcRe8);
  
  etcTv[9] = (TextView)findViewById(R.id.EtcTv9);
  etcSp[9] = (Spinner)findViewById(R.id.EtcSp9);
  apButton[9] = (Button)findViewById(R.id.EtcAp9);
  reButton[9] = (Button)findViewById(R.id.EtcRe9);
  
  etcTv[10] = (TextView)findViewById(R.id.EtcTv10);
  etcSp[10] = (Spinner)findViewById(R.id.EtcSp10);
  apButton[10] = (Button)findViewById(R.id.EtcAp10);
  reButton[10] = (Button)findViewById(R.id.EtcRe10);
  
  etcTv[11] = (TextView)findViewById(R.id.EtcTv11);
  etcSp[11] = (Spinner)findViewById(R.id.EtcSp11);
  apButton[11] = (Button)findViewById(R.id.EtcAp11);
  reButton[11] = (Button)findViewById(R.id.EtcRe11);
  
  etcTv[12] = (TextView)findViewById(R.id.EtcTv12);
  etcSp[12] = (Spinner)findViewById(R.id.EtcSp12);
  apButton[12] = (Button)findViewById(R.id.EtcAp12);
  reButton[12] = (Button)findViewById(R.id.EtcRe12);
  
  etcTv[13] = (TextView)findViewById(R.id.EtcTv13);
  etcSp[13] = (Spinner)findViewById(R.id.EtcSp13);
  apButton[13] = (Button)findViewById(R.id.EtcAp13);
  reButton[13] = (Button)findViewById(R.id.EtcRe13);
  
  etcTv[14] = (TextView)findViewById(R.id.EtcTv14);
  etcSp[14] = (Spinner)findViewById(R.id.EtcSp14);
  apButton[14] = (Button)findViewById(R.id.EtcAp14);
  reButton[14] = (Button)findViewById(R.id.EtcRe14);
  
  etcTv[15] = (TextView)findViewById(R.id.EtcTv15);
  etcSp[15] = (Spinner)findViewById(R.id.EtcSp15);
  apButton[15] = (Button)findViewById(R.id.EtcAp15);
  reButton[15] = (Button)findViewById(R.id.EtcRe15);
  
  etcTv[16] = (TextView)findViewById(R.id.EtcTv16);
  etcSp[16] = (Spinner)findViewById(R.id.EtcSp16);
  apButton[16] = (Button)findViewById(R.id.EtcAp16);
  reButton[16] = (Button)findViewById(R.id.EtcRe16);
  
  etcTv[17] = (TextView)findViewById(R.id.EtcTv17);
  etcSp[17] = (Spinner)findViewById(R.id.EtcSp17);
  apButton[17] = (Button)findViewById(R.id.EtcAp17);
  reButton[17] = (Button)findViewById(R.id.EtcRe17);
  
  etcTv[18] = (TextView)findViewById(R.id.EtcTv18);
  etcSp[18] = (Spinner)findViewById(R.id.EtcSp18);
  apButton[18] = (Button)findViewById(R.id.EtcAp18);
  reButton[18] = (Button)findViewById(R.id.EtcRe18);
  
  // 플립폰트
  etcTvFlipFont.setText("폰트 추출");
  etcSpFlipFont.setOnItemSelectedListener(this);
  apButtonFlipFont.setOnClickListener(this);
  
  for(int i = 0; i < ETC_CNT; i++){
   etcTv[i].setText(etcName[i]);
   etcSp[i].setOnItemSelectedListener(this);
   
   apButton[i].setOnClickListener(this);
   reButton[i].setOnClickListener(this);
  }
  initMsg();
        addMsg("----------------------------------");
        addMsg("상태진행표시줄");
        addMsg("----------------------------------");
        
  mCtx = this;
        isTruth = Truth.findTruth();
  if(isTruth == 0){
   addToast("시스템 접근 권한이 없어서 변경을 할 수 없습니다.");
  }
  
  if(isTruth != 0){
   for(int i = 0; i < ETC_CNT; i++){
    etcSp[i].setEnabled(true);
    apButton[i].setEnabled(true);
    reButton[i].setEnabled(true);
   }
   etcSpFlipFont.setEnabled(true);
   apButtonFlipFont.setEnabled(true);
  }else{
   for(int i = 0; i < ETC_CNT; i++){
    etcSp[i].setEnabled(false);
    apButton[i].setEnabled(false);
    reButton[i].setEnabled(false);
   }
   etcSpFlipFont.setEnabled(false);
   apButtonFlipFont.setEnabled(false);
   addMsg("시스템 설정 권한이 없습니다.");
  }
  
  // 파일이 존재하는지 검사
  
  SDstate = Environment.getExternalStorageState();
  if(SDstate.equals(Environment.MEDIA_MOUNTED)){
   etcSpFlipFont.setEnabled(true);
   apButtonFlipFont.setEnabled(true);
  }else{
   etcSpFlipFont.setEnabled(false);
   apButtonFlipFont.setEnabled(false);
  }
  
  listFileExistCheck();
  bakFileExistCheck();
  
 }
xx
 @Override
 protected void onResume() {
  // TODO Auto-generated method stub
  super.onResume();
 }
xx
 private void click(View v){
  
  if( v == findViewById(apButtonFlipFont.getId())){  // 추출하기 버튼이면
xx
   // 먼저 tmp 폴더를 지우자. 깔끔하게.
   if(isTruth == 2){
    try {   
     Process p = Runtime.getRuntime().exec("su");
     DataOutputStream os = new DataOutputStream(p.getOutputStream());
xx
     os.writeBytes("rm -r /sdcard/OpQumizer/tmp/"+ "\n");
     os.flush();
     
     os.writeBytes("exit\n");
     addMsg("루트 권한 빠져나감");
     os.flush();
     os.close();
     try {   
      p.waitFor();   
      if (p.exitValue() != 255) {   
       addMsg("복사 완료");
      }   
      else {   
       addMsg("루팅 후 사용 가능");
      }   
     } catch (InterruptedException e) {   
      addMsg("루팅 후 사용 가능");
     }   
    } catch (IOException e) {   
     addMsg("루팅 후 사용 가능");
    }  
   }
   
   String fInName = "/sdcard/download/" + ((TextView)etcSpFlipFont.getSelectedView()).getText().toString();
   String fOutDir = "/sdcard/OpQumizer/tmp";
   if(fInName == null){
    addMsg(fInName + "종료함 : 파일이 존재하지 않음!");
    return;
   }else
    addMsg(fInName + "파일 존재함을 확인했습니다.");
   try {
    unZip(fInName, fOutDir);
   } catch (IOException e) {
    e.printStackTrace();
    addMsg("종료함 : 압축 해제 실패!");
    return;
   }
   
   // 뒤적뒤적하자.
   String srcDir = "/sdcard/OpQumizer/tmp/assets/fonts";
   File fontDir = new File(srcDir);
   ArrayList<String> fontAL = new ArrayList<String>();
   int fontCnt = 0;
   
   if(fontDir.listFiles().length > 0){ // 디렉토리 내에 파일이 있으면
    File[] fileList = fontDir.listFiles();
    for(int i = 0; i < fileList.length; i++){
     if(isExt(fileList[i].getName(), ".ttf")){  // 글꼴 추가
      fontAL.add(fileList[i].getName());
      fontCnt++;
     }
    }
   }
   addMsg("총 " + fontCnt + "개의 폰트를 찾았습니다.");
   
   // 폰트 이동하자.
xx
   if(isTruth == 2){
    try {   
     Process p = Runtime.getRuntime().exec("su");
     DataOutputStream os = new DataOutputStream(p.getOutputStream());
xx
     for(int i = 0; i < fontCnt; i++){
      String src = srcDir + "/" + fontAL.get(i);
      String dst = "/sdcard/OpQumizer/" + fontAL.get(i);
      os.writeBytes("cat " + src + " > " + dst + "\n");
      addMsg(src + " -> " + dst + "복사 완료.");
      os.writeBytes("rm -r /sdcard/OpQumizer/tmp/"+ "\n");
      addMsg("임시 파일 삭제 완료");
      addToast(dst + "파일을 생성하였습니다.\n 아래 리스트에서 확인하세요.");
      
     }
     os.writeBytes("exit\n");
     addMsg("루트 권한 빠져나감");
 
     os.flush();
     os.close();
     try {   
      p.waitFor();   
      if (p.exitValue() != 255) {   
       addMsg("복사 완료");
      }   
      else {   
       addMsg("루팅 후 사용 가능");
      }   
     } catch (InterruptedException e) {   
      addMsg("루팅 후 사용 가능");
     }   
    } catch (IOException e) {   
     addMsg("루팅 후 사용 가능");
    }  
   }
xx
   listFileExistCheck();
   
  }
  
  
  // 적용하기
  for(int i = 0; i < ETC_CNT; i++){
   if ( v == findViewById(apButton[i].getId()) && i != 4 ){    // 한큐에 복사 빼고 일괄 적용
    addMsg("메뉴 선택 : " + etcName[i] + "적용");
    String srcFile;
    String srcTmpFile;  // 소스 임시 파일 이히히힝
    String tmpFile;
    String dstFile;
    String bakFile;
    
    srcFile = "/sdcard/OpQumizer/" + ((TextView)etcSp[i].getSelectedView()).getText();
    srcTmpFile = "/sdcard/OpQumizer/tmpFile.tmp";
    tmpFile = etcFileName[i] + ".tmp";
    dstFile = etcFileName[i];
    bakFile = dstFile.subSequence(0, dstFile.length()-1) + "_";
    
    boolean isExistBak = false;
    boolean isExistSrcTmp = false;        // 소스 임시 파일 잘 생성됐는지 확인 플래그
    boolean isFailedCreateBak = false;       // 백업 파일 생성에 실패하였는가?
    
    // 백업 파일이 존재하는지 검사
    File fFileBak = new File(bakFile);
    if(fFileBak != null){
     if(fFileBak.canRead() && fFileBak.length() != 0){
      isExistBak = true;
     }else{
      isExistBak = false;
     }
    }else{
     isExistBak = false;
    }
    
    // 내부 용량 검사
    long systemTotalSize = getInternalMemorySize();
    long systemAvaibleSize = getInternalMemoryAvailableSize();
    long srcFileSize = getFileSize(srcFile);
    long bakFileSize = 0;
    if(isExistBak == true)      // 만약 백업 파일이 있다면 다시 안 만들어도 된다.
     bakFileSize = 0;
    else
     bakFileSize = getFileSize(dstFile);    // 그렇지 않다면 목적 파일 크기만큼의 백업 파일을 만들 공간이 있어야 한다.
    addMsg("시스템 가용 용량 : " + systemAvaibleSize + " / " + systemTotalSize + " byte");
    addMsg("적용 파일 크기 : " + srcFileSize + " byte");
    if(srcFileSize*2 + bakFileSize < systemAvaibleSize){  // 소스+시스템 임시(소스와 크기 동일) + 백업 파일
     addMsg("용량 확보 확인.");
    }else{
     addMsg("시스템 저장 공간이 부족합니다. 저장 공간을 확보하세요.");
     addMsg("작업을 중단합니다.");
     return;
    }
    
    
    // 원본 파일에서 이름만 살짝쿵 바꿔서 한번 해보자.
    // 만약 이 방법을 쓸 경우 finally에서 tmpFile이름을 srcFile로 rename해야함.
    File fSrcFile = new File(srcFile);
    File fSrcTmpFile = new File(srcTmpFile);
    long srcSize = fSrcFile.length();
    fSrcFile.renameTo(fSrcTmpFile);
    long srcTmpSize = fSrcTmpFile.length();
    if(srcSize == srcTmpSize){
     isExistSrcTmp = true;
     addMsg("임시 파일 생성 : " + srcTmpFile);
    }else{
     isExistSrcTmp = false;
     addMsg("임시 파일 생성에 실패했습니다.\n임시 파일은 " + srcTmpFile +" 로 저장됩니다.\n");
     return;
    }
    
    if(isExistSrcTmp == true){
     if(isExistBak == false){  // 백업 파일이 존재하지 않는다면
      if(isTruth == 2){
       try {
        // x. 백업파일만 일단 검사/ 생성한다.
        Process p;   
        p = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
         os.writeBytes("chmod 644 " + dstFile + "\n");
         os.writeBytes("cat " + dstFile + " > " + bakFile + "\n");  // 백업
         os.writeBytes("chmod 644 " + bakFile + "\n");
        
        os.writeBytes("exit\n");
        addMsg("루트 권한 빠져나감");
        
        os.flush();
        os.close();
   
        try {   
         p.waitFor();
         if (p.exitValue() != 255) {
          File fDstFile = new File(dstFile);
          File fBakFile = new File(bakFile);
          long dstSize = fDstFile.length();
          long bakSize = fBakFile.length();
          addMsg("dstSize : " + dstSize);
          addMsg("bakSize : " + bakSize);
          if(dstSize == bakSize){
           addMsg("백업 완료 : " + dstFile + " -> " + bakFile);
           isFailedCreateBak = false;
          }else{
           addMsg(bakFile + " 백업 파일 생성에 실패하였습니다. 시스템 여유 공간을 확인하세요.\n");
           isFailedCreateBak = true;
          }
         }   
         else {   
          // TODO Code to run on unsuccessful   
          addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
         }   
        } catch (InterruptedException e) {   
         // TODO Code to run in interrupted exception   
         addMsg("루팅 후 사용 가능" + e.toString());
        }   
       } catch (IOException e) {   
        // TODO Code to run in input/output exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }
      }
     }
xx
     if(isTruth == 2){
      boolean isAllRight = false;
      try {   
       Process p;   
       p = Runtime.getRuntime().exec("su");
       DataOutputStream os = new DataOutputStream(p.getOutputStream());
       if(isFailedCreateBak == false){    // 백업 파일을 생성에 실패하지 않았다면,
        os.writeBytes("chmod 644 " + srcTmpFile + "\n");
        os.writeBytes("cat " + srcTmpFile + " > " + tmpFile + "\n");
        os.writeBytes("chmod 644 " + tmpFile + "\n");
        addMsg("임시 파일 생성 완료");
        
        os.writeBytes("chmod 644 " + dstFile + "\n");
        os.writeBytes("cat " + tmpFile + " > " + dstFile + "\n");
        os.writeBytes("chmod 644 " + dstFile + "\n");
        addMsg(dstFile + "-> 복사 완료.");
        addMsg("최종 복사 완료");
        os.writeBytes("rm " + tmpFile + "\n");
        addMsg("임시 파일 삭제 완료");
       }
       os.writeBytes("exit\n");
       addMsg("루트 권한 빠져나감");
       
       os.flush();
       os.close();
  
       try {   
        p.waitFor();   
        if (p.exitValue() != 255) {   
         File fDstFile = new File(dstFile);
         long dstSize = fDstFile.length();
         if(srcTmpSize == dstSize && isFailedCreateBak == false)
          isAllRight = true;
         else{
          isAllRight = false;
         }
         if(isAllRight == true){
          addMsg("적용을 완료했습니다.");
          addMsg("재부팅해 주세요.");
          bakFileExistCheck();
          apButton[i].setEnabled(false);
         }else{
          addMsg("원본과 시스템 파일 크기가 다릅니다.\n복구를 권장합니다.");
          apButton[i].setEnabled(false);
         }
        }   
        else {   
         // TODO Code to run on unsuccessful   
         addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
        }   
       } catch (InterruptedException e) {   
        // TODO Code to run in interrupted exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }   
      } catch (IOException e) {   
       // TODO Code to run in input/output exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }
      
      // 임시 파일 -> 원 소스 파일로 이름 변경하기
      fSrcTmpFile.renameTo(fSrcFile);
      if(fSrcFile.isFile() != true || fSrcFile.canRead() != true || fSrcFile.length() == 0){ // 만약 이름 변경 실패이면
       addMsg("임시 파일 이름 변경에 실패했습니다.\n임시 파일은 " + srcTmpFile +" 로 저장되어 있으니 " + srcFile + " 로 수정하시기 바랍니다.\n");
      }
      if(isAllRight == true){
       Truth.qReboot(mCtx, isTruth);
      }
     }
    }
   }
   
   
   if ( v == findViewById(apButton[i].getId()) && i == 4){    // 한큐에 복사라면 1개로 4개 분신술 쓰기
    addMsg("메뉴 선택 : " + etcName[i] + "적용");
    String[] dstFile = {"/system/fonts/Clockopia.ttf",
          "/system/fonts/DroidSans.ttf",
          "/system/fonts/DroidSans-Bold.ttf",
          "/system/fonts/LG_Android_SMS.ttf",
    };
    String[] bakFile = {"/system/fonts/Clockopia.tt_",
         "/system/fonts/DroidSans.tt_",
         "/system/fonts/DroidSans-Bold.tt_",
         "/system/fonts/LG_Android_SMS.tt_",
    };
    String srcFile;  // 원 소스 멀티 유즈 이기 때문에 소스는 하나! 만세!
    String srcTmpFile;  // 소스 임시 파일 이히히힝
    String tmpFile;  // 시스템에 들어갈 임시 파일 이히히힝
    
    srcFile = "/sdcard/OpQumizer/" + ((TextView)etcSp[4].getSelectedView()).getText();
    srcTmpFile = "/sdcard/OpQumizer/font.tmp";
    tmpFile = "/system/fonts/tmp.ttf";  // 시스템에 들어갈 임시 파일 이히히힝
    
    boolean[] isExistBak = {false, false, false, false};
    boolean isExistSrcTmp = false;        // 소스 임시 파일 잘 생성됐는지 확인 플래그
    boolean[] isFailedCreateBak = {false, false, false, false}; // 백업 파일 생성에 실패하였는가?
    boolean isFailedAllCreateBak = false;      // 하나라도 실패하였는가?
    
    // 백업 파일이 존재하는지 검사
    for(int iFont = 0; iFont < 4; iFont++){
     File fFileBak = new File(bakFile[iFont]);
     if(fFileBak != null){
      if(fFileBak.canRead() && fFileBak.length() != 0){
       isExistBak[iFont] = true;
      }else{
       isExistBak[iFont] = false;
      }
     }else{
      isExistBak[iFont] = false;
     }
    }
    
    
    // 내부 용량 검사
    long systemTotalSize = getInternalMemorySize();
    long systemAvaibleSize = getInternalMemoryAvailableSize();
    long srcFileSize = getFileSize(srcFile);
    long bakFileSize = 0;
    
    for(int iFont = 0; iFont < 4; iFont++){
     if(isExistBak[iFont] == true)      // 만약 백업 파일이 있다면 다시 안 만들어도 된다.
      bakFileSize += 0;
     else{
      bakFileSize += getFileSize(dstFile[iFont]);  // 백업 파일이 없다면 목적 파일크기만큼의 백업 파일 생성 공간이 필요하다.
     }
    }
    addMsg("시스템 가용 용량 : " + systemAvaibleSize + " / " + systemTotalSize + " byte");
    addMsg("적용 파일 크기 : " + srcFileSize + " byte");
    if(srcFileSize*4 + srcFileSize + bakFileSize < systemAvaibleSize){  // 소스+시스템 임시(소스와 크기 동일) + 백업 파일
     addMsg("용량 확보 확인.");
    }else{
     addMsg("시스템 저장 공간이 부족합니다. 저장 공간을 확보하세요.");
     addMsg("작업을 중단합니다.");
     return;
    }
    
    
    // 원본 파일에서 이름만 살짝쿵 바꿔서 한번 해보자. 안 되겠나? 만약 이 방법을 쓸 경우 finally에서 tmpFile이름을 srcFile로 rename해야함.
    File fSrcFile = new File(srcFile);
    File fSrcTmpFile = new File(srcTmpFile);
    long srcSize = fSrcFile.length();
    fSrcFile.renameTo(fSrcTmpFile);
    long srcTmpSize = fSrcTmpFile.length();
    if(srcSize == srcTmpSize)
     isExistSrcTmp = true;
    else{
     isExistSrcTmp = false;
     addMsg("임시 파일 생성에 실패했습니다.\n임시 파일은 /sdcard/OpQumizer/font.tmp 로 저장됩니다.\n");
     return;
    }
    
    if(isExistSrcTmp == true){
     if(isTruth == 2){
      try {   
       // 백업 파일만 생성
       // 루트 권한 획득 후 작업
       Process p;
       p = Runtime.getRuntime().exec("su");
       DataOutputStream os = new DataOutputStream(p.getOutputStream());
       for(int iFont = 0; iFont < 4; iFont++){
        if(isExistBak[iFont] == false){  // 백업 파일이 존재하지 않는다면
         os.writeBytes("chmod 644 " + dstFile[iFont] + "\n");
         os.writeBytes("cat " + dstFile[iFont] + " > " + bakFile[iFont] + "\n");  // 백업
         os.writeBytes("chmod 644 " + bakFile[iFont] + "\n");
        }
       }
       
       os.writeBytes("exit\n");
       addMsg("루트 권한 빠져나감");
       
       os.flush();
       os.close();
       try {   
        p.waitFor();   
        if (p.exitValue() != 255) {   
         for(int iFont = 0; iFont < 4; iFont++){
          if(isExistBak[iFont] == false){  // 백업 파일이 존재하지 않는다면
           File fDstFile = new File(dstFile[iFont]);
           File fBakFile = new File(bakFile[iFont]);
           long dstSize = fDstFile.length();
           long bakSize = fBakFile.length();
           if(dstSize == bakSize){
            addMsg("백업 완료 : " + dstFile[iFont] + " -> " + bakFile[iFont]);
            isFailedCreateBak[iFont] = false;
           }else{
            addMsg(bakFile[iFont] + " 백업 파일 생성에 실패하였습니다. 시스템 여유 공간을 확인하세요.\n");
            isFailedCreateBak[iFont] = true;
           }
          }
         }
         // 하나라도 실패인지 검사하쟈
         for(int iFont = 0; iFont < 4; iFont++){
          if(isFailedCreateBak[iFont] == true){   // 하나라도 실패하면
           isFailedAllCreateBak = true;    // 전부 실패한 것이라 본다.
           break;
          }
         }
        }   
        else {   
         // TODO Code to run on unsuccessful   
         addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
        }   
       } catch (InterruptedException e) {   
        // TODO Code to run in interrupted exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }   
      } catch (IOException e) {   
       // TODO Code to run in input/output exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }
     }
     
     
     if(isTruth == 2 ){
      boolean isAllRight = false;
      try {   
       // x. copy now
       // 루트 권한 획득 후 작업
       Process p;
       p = Runtime.getRuntime().exec("su");
       DataOutputStream os = new DataOutputStream(p.getOutputStream());
       if(isFailedAllCreateBak == false){    // 백업 파일을 생성에 실패하지 않았다면,
        os.writeBytes("chmod 644 " + srcTmpFile + "\n");
        os.writeBytes("cat " + srcTmpFile + " > " + tmpFile + "\n");
        os.writeBytes("chmod 644 " + tmpFile + "\n");
        addMsg("임시 파일 생성 완료");
        for(int iFont = 0; iFont < 4; iFont++){
         os.writeBytes("chmod 644 " + dstFile[iFont] + "\n");
         os.writeBytes("cat " + tmpFile + " > " + dstFile[iFont] + "\n");
         os.writeBytes("chmod 644 " + dstFile[iFont] + "\n");
         addMsg(dstFile[iFont] + "-> 복사 완료.");
        }
        addMsg("최종 복사 완료");
        os.writeBytes("rm " + tmpFile + "\n");
        addMsg("임시 파일 삭제 완료");
       }
       os.writeBytes("exit\n");
       addMsg("루트 권한 빠져나감");
       
       os.flush();
       os.close();
       try {   
        p.waitFor();   
        if (p.exitValue() != 255) {   
         // TODO Code to run on success
         for(int iFont = 0; iFont < 4; iFont++){
          File fDstFile = new File(dstFile[iFont]);
          long dstSize = fDstFile.length();
          if(srcTmpSize == dstSize && isFailedAllCreateBak == false)
           isAllRight = true;
          else{
           isAllRight = false;
          }
         }
         if(isAllRight == true){
          addMsg("적용을 완료했습니다.");
          addMsg("재부팅해 주세요.");
          bakFileExistCheck();
          apButton[i].setEnabled(false);
         }else{
          addMsg("원본과 시스템 파일 크기가 다릅니다.\n복구를 권장합니다.");
          apButton[i].setEnabled(false);
         }
         // 재부팅을 합니다.
        }   
        else {   
         // TODO Code to run on unsuccessful   
         addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
        }   
       } catch (InterruptedException e) {   
        // TODO Code to run in interrupted exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }   
      } catch (IOException e) {   
       // TODO Code to run in input/output exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }
      // 임시 파일 -> 원 소스 파일로 이름 변경하기
      fSrcTmpFile.renameTo(fSrcFile);
      if(fSrcFile.isFile() != true || fSrcFile.canRead() != true || fSrcFile.length() == 0){ // 만약 이름 변경 실패이면
       addMsg("임시 파일 이름 변경에 실패했습니다.\n임시 파일은 " + srcTmpFile +" 로 저장되어 있으니 " + srcFile + " 로 수정하시기 바랍니다.\n");
      }
      if(isAllRight == true)
       Truth.qReboot(mCtx, isTruth);
     }
    }
   }
   
   if (v == findViewById(reButton[i].getId()) && i != 4){    // 한큐에 복구 빼고 모두 적용되는 복원
    addMsg("메뉴 선택 : " + etcName[i] + "복원");
    
    String dstFile;
    String bakFile;
    dstFile = etcFileName[i];
    bakFile = dstFile.subSequence(0, dstFile.length()-1) + "_";
    
    
    // 백업 파일이 존재하는지 검사
    boolean isExistBak = false;
    boolean isAllRight = false;
    
    File fFileBak = new File(bakFile);
    
    if(fFileBak != null){
     if(fFileBak.canRead() && fFileBak.length() != 0){
      isExistBak = true;
     }else{
      isExistBak = false;
     }
    }else{
     isExistBak = false;
    }
    if(isExistBak == false){
     addMsg("백업 파일이 존재하지 않습니다!!");
     return;
    }
    
    // 내부 용량 검사
    long systemTotalSize = getInternalMemorySize();
    long systemAvaibleSize = getInternalMemoryAvailableSize();
    long bakFileSize = getFileSize(bakFile);
    addMsg("시스템 가용 용량 : " + systemAvaibleSize + " / " + systemTotalSize + " byte");
    addMsg("복구 파일 크기 : " + bakFileSize + " byte");
    if(bakFileSize < systemAvaibleSize){  // 소스+시스템 임시(소스와 크기 동일) + 백업 파일
     addMsg("용량 확보 확인.");
    }else{
     addMsg("시스템 저장 공간이 부족합니다. 저장 공간을 확보하세요.");
     addMsg("작업을 중단합니다.");
     return;
    }
    
    if(isTruth == 2){
     try {   
      // x. 파일 복사하고 루트 권한 닫기
      // 루트 권한 획득 후 작업
      Process p;   
      p = Runtime.getRuntime().exec("su");
      DataOutputStream os = new DataOutputStream(p.getOutputStream());
      
      os.writeBytes("chmod 644 " + bakFile + "\n");
      os.writeBytes("chmod 644 " + dstFile + "\n");
      os.writeBytes("cat " + bakFile + " > " + dstFile + "\n");
      os.writeBytes("chmod 644 " + dstFile + "\n");
      addMsg("복구 완료");
 //     os.writeBytes("rm " + bakFile + "\n");
 //     addMsg("백업 파일 삭제 완료");
      os.writeBytes("exit\n");
      addMsg("루트 권한 빠져나감");
      
      os.flush();
      os.close();
 
      try {   
       p.waitFor();   
       if (p.exitValue() != 255) {   
        File fFileDst = new File(dstFile);
        long bakSize = fFileBak.length();
        long dstSize = fFileDst.length();
        if(bakSize == dstSize)
         isAllRight = true;
        else{
         isAllRight = false;
        }
        
        if(isAllRight == true){
         addMsg("복원을 완료했습니다.");
 //        addMsg("재부팅해 주세요.");  // 이거는 백업 파일을 지우면서 메시지 나타냄.
 //        fileExistCheck();
 //        reButton[i].setEnabled(false);
        }else{
         addMsg("백업 파일과 시스템 파일 크기가 다릅니다.\n다시 복구 하기를 권장합니다.");
         reButton[i].setEnabled(true);
        }
        // 재부팅을 합니다.
       }   
       else {   
        // TODO Code to run on unsuccessful   
        addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
       }   
      } catch (InterruptedException e) {   
       // TODO Code to run in interrupted exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }   
     } catch (IOException e) {   
      // TODO Code to run in input/output exception   
      addMsg("루팅 후 사용 가능" + e.toString());
     }
    }
    
    
    // 복원 성공시 백업 파일 지우기
    if(isAllRight == true){
     if(isTruth == 2){
      try {   
       // 루트 권한 획득 후 작업
       Process p;   
       p = Runtime.getRuntime().exec("su");
       DataOutputStream os = new DataOutputStream(p.getOutputStream());
       
       os.writeBytes("rm " + bakFile + "\n");
       addMsg("백업 파일 삭제 완료");
       os.writeBytes("exit\n");
       addMsg("루트 권한 빠져나감");
       os.flush();
       os.close();
       try {   
        p.waitFor();   
        if (p.exitValue() != 255) {   
          addMsg("백업 파일 삭제를 완료했습니다.");
          addMsg("재부팅해 주세요.");
          bakFileExistCheck();
          Truth.qReboot(mCtx, isTruth);
        }   
        else {   
         // TODO Code to run on unsuccessful   
         addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
        }   
       } catch (InterruptedException e) {   
        // TODO Code to run in interrupted exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }   
      } catch (IOException e) {   
       // TODO Code to run in input/output exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }
     }
    }
   }
   
   if (v == findViewById(reButton[i].getId()) && i == 4){    // 한큐에 복구라면
    addMsg("메뉴 선택 : " + etcName[i] + "복원");
    String[] dstFile = {"/system/fonts/Clockopia.ttf",
      "/system/fonts/DroidSans.ttf",
      "/system/fonts/DroidSans-Bold.ttf",
      "/system/fonts/LG_Android_SMS.ttf",
    };
    String[] bakFile = {"/system/fonts/Clockopia.tt_",
      "/system/fonts/DroidSans.tt_",
      "/system/fonts/DroidSans-Bold.tt_",
      "/system/fonts/LG_Android_SMS.tt_",
    };
    
    // 백업 파일이 존재하는지 검사
    boolean[] isExistBak = {false, false, false, false};
    boolean[] isRightSize = {false, false, false, false};  // 복구 후 파일 사이즈가 맞나염?
    boolean isAllRight = false;      // 괜찮나염?
    
    for(int iFont = 0; iFont < 4; iFont++){
     File fFileBak = new File(bakFile[iFont]);
     if(fFileBak != null){
      if(fFileBak.canRead() && fFileBak.length() != 0){
       isExistBak[iFont] = true;
      }else{
       isExistBak[iFont] = false;
      }
     }else{
      isExistBak[iFont] = false;
     }
    }
    int existCnt = 0;
    for(int iFont = 0; iFont < 4; iFont++){
     if(isExistBak[iFont] == true){
      existCnt++;
     }
    }
    if(existCnt == 0){
     addMsg("백업 파일이 존재하지 않습니다!!");
     return;
    }
    
    // 내부 용량 검사
    long systemTotalSize = getInternalMemorySize();
    long systemAvaibleSize = getInternalMemoryAvailableSize();
    long bakFileSize = 0;
    
    for(int iFont = 0; iFont < 4; iFont++){
     if(isExistBak[iFont] == true)      // 만약 백업 파일이 있다면 필요 용량에 추가
      bakFileSize += getFileSize(bakFile[iFont]);
     else{
      bakFileSize += 0;  // 백업 파일이 없다면 추가할 필요도 없다.
     }
    }
    addMsg("시스템 가용 용량 : " + systemAvaibleSize + " / " + systemTotalSize + " byte");
    addMsg("적용 파일 크기 : " + bakFileSize + " byte");
    if( bakFileSize < systemAvaibleSize ){  // 소스+시스템 임시(소스와 크기 동일) + 백업 파일
     addMsg("용량 확보 확인.");
    }else{
     addMsg("시스템 저장 공간이 부족합니다. 저장 공간을 확보하세요.");
     addMsg("작업을 중단합니다.");
     return;
    }
    if(isTruth == 2){
     try {   
      // x. 파일 복사하고 루트 권한 닫기
      // 루트 권한 획득 후 작업
      Process p;   
      p = Runtime.getRuntime().exec("su");
      DataOutputStream os = new DataOutputStream(p.getOutputStream());
      
      for(int iFont = 0; iFont < 4; iFont++){
       if(isExistBak[iFont] == true){  // 백업 파일이 존재한다믄
        os.writeBytes("chmod 644 " + bakFile[iFont] + "\n");
        os.writeBytes("chmod 644 " + dstFile[iFont] + "\n");
        os.writeBytes("cat " + bakFile[iFont] + " > " + dstFile[iFont] + "\n");
        os.writeBytes("chmod 644 " + dstFile[iFont] + "\n");
        addMsg("복사 완료 : " + dstFile[iFont]);
       }
      }
      
      os.writeBytes("exit\n");
      addMsg("루트 권한 빠져나감");
      
      os.flush();
      os.close();
 
      try {   
       p.waitFor();   
       if (p.exitValue() != 255) {
        for(int iFont = 0; iFont < 4; iFont++){
         if(isExistBak[iFont] == true){  // 백업 파일이 존재한다면
          File fFileBak = new File(bakFile[iFont]);
          File fFileDst = new File(dstFile[iFont]);
          long bakSize = fFileBak.length();
          long dstSize = fFileDst.length();
          if(bakSize == dstSize)
           isRightSize[iFont] = true;
          else{
           isRightSize[iFont] = false;
           addMsg(dstFile[iFont] + " 와 " + bakFile[iFont]+ " 의크기가 다릅니다.");
          }
         }
        }
        
        // 하나라도 실패인지 검사하쟈
        isAllRight = true;      // 일단은 검수를 통과함미다. 하지만
        for(int iFont = 0; iFont < 4; iFont++){
         if(isExistBak[iFont] == true){  // 백업 파일이 존재하는 것만 검사
          if(isRightSize[iFont] == false){   // 하나라도 사이즈가 다르면
           isAllRight = false;    // 전부 실패한 것이라 본다.
           break;
          }
         }
        }
        
        if(isAllRight == true){
         addMsg("복원을 완료했습니다.");
        }else{
         addMsg("백업 파일과 시스템 파일 크기가 다릅니다.\n다시 복구 하기를 권장합니다.");
         reButton[i].setEnabled(true);
        }
        // 재부팅을 합니다.
       }   
       else {   
        // TODO Code to run on unsuccessful   
        addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
       }   
      } catch (InterruptedException e) {   
       // TODO Code to run in interrupted exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }   
     } catch (IOException e) {   
      // TODO Code to run in input/output exception   
      addMsg("루팅 후 사용 가능" + e.toString());
     }
    }
    
    
    if(isAllRight == true){
     if(isTruth == 2){
      try {   
       // 루트 권한 획득 후 작업
       Process p;   
       p = Runtime.getRuntime().exec("su");
       DataOutputStream os = new DataOutputStream(p.getOutputStream());
       
       for(int iFont = 0; iFont < 4; iFont++){
        if(isExistBak[iFont] == true){  // 백업 파일이 존재하는 것만 삭제
         os.writeBytes("rm " + bakFile[iFont] + "\n");
        }
       }
       addMsg("백업 파일 삭제 완료");
       os.writeBytes("exit\n");
       addMsg("루트 권한 빠져나감");
       os.flush();
       os.close();
       try {   
        p.waitFor();   
        if (p.exitValue() != 255) {   
          addMsg("백업 파일 삭제를 완료했습니다.");
          addMsg("재부팅해 주세요.");
          bakFileExistCheck();
         // 재부팅을 합니다.
        }   
        else {   
         // TODO Code to run on unsuccessful   
         addMsg("루팅 후 사용 가능 p.exitValue() = " + p.exitValue() );
        }   
       } catch (InterruptedException e) {   
        // TODO Code to run in interrupted exception   
        addMsg("루팅 후 사용 가능" + e.toString());
       }   
      } catch (IOException e) {   
       // TODO Code to run in input/output exception   
       addMsg("루팅 후 사용 가능" + e.toString());
      }
     }
    }
   }
  }
  
  
  
  sv8.scrollTo(0, 0);
//  sv8.fullScroll(View.FOCUS_DOWN);
  
 }
xx
 @Override
 public void onClick(final View v) {
  boolean isApply = false;
  int select = -1;
  int reselect = -1;
  String str = "확실해요? 확실해요? 확실해요?";
  for(int i = 0; i < ETC_CNT; i++){
   if ( v == findViewById(apButton[i].getId())){    // 한큐에 복사 빼고 일괄 적용
    select = i;
   }
   if ( v == findViewById(reButton[i].getId())){    // 한큐에 복사 빼고 일괄 적용
    reselect = i;
   }
  }
  
  if(select != -1){
   str = etcName[select] + " :\n-> /sdcard/OpQumizer/" + ((TextView)etcSp[select].getSelectedView()).getText() + "\n파일로 변경합니다.\n\n" + str; 
  }
  if(reselect != -1){
   str = etcName[reselect] + " :\n이 항목을 복원합니다.\n\n" + str; 
  }
  
  
  AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); 
  alt_bld.setMessage(str).setCancelable(false).setPositiveButton(
    "예",  
    new DialogInterface.OnClickListener() {  
    public void onClick(DialogInterface dialog, int id) {
      click(v);
  }}).setNegativeButton(
    "아니오",  
    new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {
     dialog.cancel();
  }});  
  AlertDialog alert = alt_bld.create();  
  alert.setTitle("이게 최선입니까?");
  alert.setIcon(R.drawable.icon);
  alert.show(); 
 }
xx
 private boolean warningMsg = false;
 @Override
 public void onItemSelected(AdapterView<?> av, View v, int pos,
   long id) {
  
  int debugI = 0;
  String fName = "";
  try{
   for(int i = 0; i < 5; i++){
    if( av == etcSp[i] ){
     debugI = i;
     fName = (String)etcSp[i].getSelectedItem();
     Typeface face=Typeface.createFromFile("/sdcard/OpQumizer/" + fName);
     if(face != null){
      etcTvPreview[i].setTypeface(face);
      apButton[i].setEnabled(true);
     }
    }
   }
  }
  catch(Exception e){
   if(warningMsg == false){
    addToast("폴더 내에 잘못된 폰트 파일이 있습니다.");
    addToast("OpQumizer 폴더 내의 ttf 파일들을 확인해보세요.");
//    addToast("미리 보기가 지원되지 않는 폰트가 잘못된 폰트 파일입니다.");
//    addToast("잘못된 폰트 파일을 적용시에 폰이 벽돌이 됩니다.");
    warningMsg = true;
   }
   apButton[debugI].setEnabled(false);   // 잘못된 폰트는 적용 버튼을 disable 시킨다.
  }
 }
xx
 @Override
 public void onNothingSelected(AdapterView<?> arg0) {
  // TODO Auto-generated method stub
 }
xx
 private void initMsg(){
  tv8.setText("");
 }
 private void addMsg(String str){
  tv8.setText(scrollCnt ++ + " : " + str + "\n" + tv8.getText());
 }
 private void addMsg(int str){
  tv8.setText(scrollCnt ++ + " : " + Integer.toString(str) + "\n" + tv8.getText());
 }
 private void addToast(String str){
  Toast.makeText(this, str, Toast.LENGTH_LONG).show();
 }
 private void addToast(int str){
  Toast.makeText(this, Integer.toString(str), Toast.LENGTH_LONG).show();
 }
 
 private void listFileExistCheck(){
  // 폴더 찾아서 해당 파일이 있으면 스피너에 추가하기
  // sdcard 사용가능한지 테스트
  SDstate = Environment.getExternalStorageState();
  if( SDstate.equals(Environment.MEDIA_MOUNTED)){
   File fDir = new File("/sdcard/OpQumizer");
   fDir.mkdir();      // 폴더 생성 // 예제 처리 할것
   String path = "/sdcard/OpQumizer/"; // 파일 경로 지정
   
   File dir = new File(path);
   ArrayList<String> fontAL = new ArrayList<String>();
   ArrayList<String> oggAL = new ArrayList<String>();
   ArrayList<String> apkAL = new ArrayList<String>();
   ArrayList<String> zipAL = new ArrayList<String>();
   ArrayList<String> jarAL = new ArrayList<String>();
   
   int fontCnt = 0;
   int oggCnt = 0;
   int apkCnt = 0;
   int zipCnt = 0;
   int jarCnt = 0;
   
   if(dir.listFiles().length > 0){ // 디렉토리 내에 파일이 있으면
    File[] fileList = dir.listFiles();
    for(int i = 0; i < fileList.length; i++){
     if(isExt(fileList[i].getName(), ".ttf")){  // 글꼴 추가
      fontAL.add(fileList[i].getName());
      fontCnt++;
     }
     else if(isExt(fileList[i].getName(), ".ogg")){  // 글꼴 추가
      oggAL.add(fileList[i].getName());
      oggCnt++;
     }
     else if(isExt(fileList[i].getName(), ".apk")){  // apk 추가
      apkAL.add(fileList[i].getName());
      apkCnt++;
     }
     else if(isExt(fileList[i].getName(), ".zip")){  // zip 추가
      zipAL.add(fileList[i].getName());
      zipCnt++;
     }
     else if(isExt(fileList[i].getName(), ".jar")){  // jar 추가
      jarAL.add(fileList[i].getName());
      jarCnt++;
     }
     
    }
   }
   
   ArrayAdapter<String> fontAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, fontAL);
   ArrayAdapter<String> oggAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, oggAL);
   ArrayAdapter<String> apkAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, apkAL);
   ArrayAdapter<String> zipAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, zipAL);
   ArrayAdapter<String> jarAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, jarAL);
   fontAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   oggAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   apkAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   jarAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   zipAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
xx
   // 폰트
   for(int i = 0; i < 0+5; i++){
    etcSp[i].setAdapter(fontAA);
    if(fontCnt == 0 || isTruth == 0){
     etcSp[i].setEnabled(false);
     apButton[i].setEnabled(false);
    }
   }
   
   // 효과음
   for(int i = 5; i < 5+6; i++){
    etcSp[i].setAdapter(oggAA);
    if(oggCnt == 0 || isTruth == 0){
     etcSp[i].setEnabled(false);
     apButton[i].setEnabled(false);
    }
   }
   
   // apk
   for(int i = 11; i < 11+6; i++){
    etcSp[i].setAdapter(apkAA);
    if(apkCnt == 0 || isTruth == 0){
     etcSp[i].setEnabled(false);
     apButton[i].setEnabled(false);
    }
   }
   
   // jar
   for(int i = 17; i < 17+1; i++){
    etcSp[i].setAdapter(jarAA);
    if(jarCnt == 0 || isTruth == 0){
     etcSp[i].setEnabled(false);
     apButton[i].setEnabled(false);
    }
   }
   // zip
   for(int i = 18; i < 18+1; i++){
    etcSp[i].setAdapter(zipAA);
    if(zipCnt == 0 || isTruth == 0){
     etcSp[i].setEnabled(false);
     apButton[i].setEnabled(false);
    }
   }
  }
  
  
  
  
  // 플립폰트에 관하여
  // sdcard 사용가능한지 테스트
  SDstate = Environment.getExternalStorageState();
  if( SDstate.equals(Environment.MEDIA_MOUNTED)){
   File fDir = new File("/sdcard/download");
   fDir.mkdir();      // 폴더 생성 // 예제 처리 할것
   String path = "/sdcard/download/"; // 파일 경로 지정
   File dir = new File(path);
   ArrayList<String> apkAL = new ArrayList<String>();
   int apkCnt = 0;
   
   if(dir.listFiles().length > 0){ // 디렉토리 내에 파일이 있으면
    File[] fileList = dir.listFiles();
    for(int i = 0; i < fileList.length; i++){
     if(isExt(fileList[i].getName(), ".apk")){  // apk 추가
      apkAL.add(fileList[i].getName());
      apkCnt++;
     }
    }
   }
   ArrayAdapter<String> apkAA = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, apkAL);
   apkAA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   etcSpFlipFont.setAdapter(apkAA);
   if(apkCnt == 0 || isTruth == 0){
    etcSpFlipFont.setEnabled(false);
    apButtonFlipFont.setEnabled(false);
   }
  }
 }
 
 private void bakFileExistCheck(){
  // 복구 파일이 있는지 검사
  for(int i = 0; i < ETC_CNT; i++){
   
   if(i != 4){  // 한방에 복구가 아니면
    String fileStr = etcFileName[i];
    fileStr = fileStr.subSequence(0, fileStr.length()-1) + "_";
    if(Truth.isExistFile(fileStr) != 0 && isTruth != 0){
     reButton[i].setEnabled(true);
    }else{
     reButton[i].setEnabled(false);
    }
   }else if(i == 4){
    String[] bakFile = {"/system/fonts/Clockopia.tt_",
      "/system/fonts/DroidSans.tt_",
      "/system/fonts/DroidSans-Bold.tt_",
      "/system/fonts/LG_Android_SMS.tt_",
    };
    int bakCnt = 0;
    for(int iFont = 0; iFont < 4; iFont++){
     if(Truth.isExistFile(bakFile[iFont]) != 0)
       bakCnt++;
    }
    if(bakCnt == 0 || isTruth == 0){ // 복구 파일 없음;
     reButton[i].setEnabled(false);
    }else{
     reButton[i].setEnabled(true);
    }
   }
  }
 }
 
 
 
 // 확장자 확인
    public boolean isExt(String name, String ext) {
        return (name.endsWith(ext)); // 확장자가 ext인지 확인
    }
 
xx
//-------------------------------저장공간 관련 함수------------------------    
    public static long getInternalMemoryAvailableSize(){
     long size = -1;
xx
     File internalMemPath = Environment.getDataDirectory();
     if( internalMemPath != null ){
      StatFs fs = new StatFs(internalMemPath.getPath());
xx
      long blockSize = fs.getBlockSize();
      long availableBlockSize = fs.getAvailableBlocks();
      size = blockSize * availableBlockSize;
     }
     return size;
    } 
xx
    public static long getInternalMemorySize(){
     long size = -1;
xx
     File internalMemPath = Environment.getDataDirectory();
     if( internalMemPath != null ){
      StatFs fs = new StatFs(internalMemPath.getPath());
xx
      long bkSize = fs.getBlockSize();
      long bkCount = fs.getBlockCount();
xx
      size = bkSize * bkCount;
     }
     return size;
    }
xx
    
 // 외부 메모리가 사용가능한지 판단
    public static boolean canUseExternalMemory() {
    String state = Environment.getExternalStorageState();
    return state.equals(Environment.MEDIA_MOUNTED);
    }
xx
    // 외부 메모리가 사용가능하다면 마운트 Path GET
    public static File getExternalMemoryMoutedPath(){
    if( canUseExternalMemory() ){
    return Environment.getExternalStorageDirectory();
    }
    return null;
    }
xx
    // 외부 메모리 사용가능 용량
    public static long getExteranlMemoryAvailableSize(){
     long size = -1;
xx
     if( canUseExternalMemory() ){
      File exmemPath = getExternalMemoryMoutedPath();
      if( exmemPath != null ){
       StatFs fs = new StatFs(exmemPath.getPath());
xx
       long bkSize = fs.getBlockSize();
       long avaBlocks = fs.getAvailableBlocks();
xx
       size = bkSize * avaBlocks;
      }
     }
     return size;
    }
xx
    // 외부 메모리 총용량
    public static long getExteranlMemorySize(){
     long size = -1;
xx
     if( canUseExternalMemory() ){
      File exmemPath = getExternalMemoryMoutedPath();
      if( exmemPath != null ){
       StatFs fs = new StatFs(exmemPath.getPath());
xx
       long bkSize = fs.getBlockSize();
       long bkCount = fs.getBlockCount();
xx
       size = bkSize * bkCount;
      }
     }
     return size;
    }
    
    // 해당 파일 용량 구하기
    public static long getFileSize(String fName){
     long size = -1;
  File fFile = new File(fName);
  size = fFile.length();
     return size;
    }
  //-------------------------------저장공간 관련 함수 끝------------------------
    private void unZip(String inFileName, String outDirName) throws IOException{
xx
  File unZipFile = new File(inFileName);
  File dir = new File(outDirName);
  
        ZipInputStream zip = new ZipInputStream(new FileInputStream(unZipFile));     
      ZipEntry ze;
xx
     while( (ze = zip.getNextEntry()) != null ) {
       final String path =  dir.getAbsolutePath() + File.separator + ze.getName();
xx
       if( ze.getName().indexOf("/") != -1 ) {
         File parent = new File(path).getParentFile();
         if( !parent.exists() )
           if( !parent.mkdirs() )
             throw new IOException("Unable to create folder " + parent);
       }
       FileOutputStream fout = new FileOutputStream(path);
       byte[] bytes = new byte[1024];
xx
       for(int c=zip.read(bytes); c!=-1; c=zip.read(bytes)) {
         fout.write(bytes, 0, c);
       }
       zip.closeEntry();
       fout.close();
     }
     
    }
    
    private String m_strZipFileName;
}
xx
 
xx
// 아래 방법은 너무 느리다. 그냥 루팅해서 cat으로 때려넣자.
/*   
for(int iFont = 0; iFont < fontCnt; iFont++){
 //2.1 소스 파일 불러오기
   FileInputStream fis;
 try {
  fis = new FileInputStream(new File(srcDir + "/" + fontAL.get(iFont)));
 } catch (FileNotFoundException e1) {
  // TODO Auto-generated catch block
  e1.printStackTrace();
  addMsg("에러 : 소스 파일 열기 실패");
  return;
 }
 // 스트림을 읽쟈.
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 try{
  int i = fis.read();
  while(i != -1){
   baos.write(i);
   i = fis.read();
  }
 } catch(IOException e) {
  addMsg( e.getMessage());
 } finally {
  try {
   fis.close();
  } catch(IOException e) {
   addMsg( e.getMessage());
  }
 }
 // 2.2 SD 카드에 파일로 저장.
 String SDstate = Environment.getExternalStorageState();
 if( SDstate.equals(Environment.MEDIA_MOUNTED)){
  File fDir = new File("/sdcard/OpQumizer");
  fDir.mkdir();      // 폴더 생성 // 예제 처리 할것
  File fFile = new File("/sdcard/OpQumizer/" + fontAL.get(iFont));
  FileOutputStream fos;
  try{
   fos = new FileOutputStream(fFile);
   fos.write(baos.toByteArray());
   fos.close();
   addMsg(fontAL.get(iFont) + " -> 폰트 적용 완료");
  } catch( Exception e){
   addMsg("에러 : " + fontAL.get(iFont) + " -> 폰트 적용 실패.");
   return;
  }
 }
 else{
  addMsg("에러 : SDCARD 사용 불가");
  return;
 }
}
*/