import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.huawei.wfm.mobile.client.constants.LogConstants;
public class RecordLogService extends IntentService {
// 采集系统运行时异常日志的语句
private final List<String> fdfdf = new ArrayList<String>() {
private static final long serialVersionUID = 1L;
{// logcat -d -v time -f /mnt/sdcard/wfm/log/AndroidRuntime.log -s
// AndroidRuntime:E
add("logcat");
add("-d");
add("-v");
add("time");
add("-f");
add(SD_PATH + File.separator + LogConstants.WFM_LOG_DIR
+ File.separator + LogConstants.ANDROID_RUNTIME_FILE);
add("-s");
add(LogConstants.TAG_ANDROID_RUNTIME + ":E");
}
};
/**
* 在新的Process中执行shell命令
*
* @throws IOException
* IO异常
* @throws InterruptedException
* 进程异常
*/
private void executeShellInProcess(List<String> command)
throws IOException, InterruptedException {
ProcessBuilder builder = new ProcessBuilder();
builder.command(command);
Process process = builder.start();
clearCache(process);// 清空缓冲区
process.waitFor();
process.destroy();
}
}
final InputStream inputStream = process.getInputStream();
final InputStream errorStream = process.getErrorStream();
final OutputStream outputStream = process.getOutputStream();
new Thread() {
public void run() {
clearInputStream(inputStream);
}
}.start();
new Thread() {
public void run() {
clearInputStream(errorStream);
}
}.start();
new Thread() {
public void run() {
clearOutputStream(outputStream);
}
}.start();