示例#1
0
 public void onCreate() {
   klogPath = Api.getKLogPath(getApplicationContext());
   Log.i(TAG, "Starting " + klogPath);
   handler = new Handler();
   rootSession =
       new Shell.Builder()
           .useSU()
           .setMinimalLogging(true)
           .setOnSTDOUTLineListener(
               new StreamGobbler.OnLineListener() {
                 @Override
                 public void onLine(String line) {
                   if (G.enableLogService()) {
                     if (line.trim().length() > 0) {
                       if (line.contains("AFL")) {
                         final String logData = LogInfo.parseLogs(line, getApplicationContext());
                         if (logData != null && logData.length() > 0) {
                           showToast(getApplicationContext(), handler, logData, false);
                         }
                       }
                     }
                   }
                 }
               })
           .open(
               new Shell.OnCommandResultListener() {
                 public void onCommandResult(int commandCode, int exitCode, List<String> output) {
                   if (exitCode != 0) {
                     Log.e(TAG, "Can't start klog shell: exitCode " + exitCode);
                     stopSelf();
                   } else {
                     Log.i(TAG, "logservice shell started");
                     rootSession.addCommand(klogPath);
                   }
                 }
               });
 }
示例#2
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   Log.i(TAG, "Received request to kill logservice");
   Api.killLogProcess(getApplicationContext(), klogPath);
 }