2525import android .content .Context ;
2626import android .content .Intent ;
2727import android .content .IntentFilter ;
28- import android .os .Build ;
2928import android .os .Debug ;
3029import android .os .Handler ;
3130import android .os .Message ;
3938import android .util .Slog ;
4039
4140import java .io .File ;
42- import java .io .FileWriter ;
43- import java .io .IOException ;
4441import java .util .ArrayList ;
4542import java .util .Calendar ;
4643
@@ -431,10 +428,11 @@ public void run() {
431428 }
432429
433430 // If we got here, that means that the system is most likely hung.
431+ // First collect stack traces from all threads of the system process.
432+ // Then kill this process so that the system will restart.
434433
435434 final String name = (mCurrentMonitor != null ) ?
436435 mCurrentMonitor .getClass ().getName () : "null" ;
437- Slog .w (TAG , "WATCHDOG PROBLEM IN SYSTEM SERVER: " + name );
438436 EventLog .writeEvent (EventLogTags .WATCHDOG , name );
439437
440438 ArrayList <Integer > pids = new ArrayList <Integer >();
@@ -469,15 +467,11 @@ public void run() {
469467 dropboxThread .join (2000 ); // wait up to 2 seconds for it to return.
470468 } catch (InterruptedException ignored ) {}
471469
472- // Only kill/crash the process if the debugger is not attached.
470+ // Only kill the process if the debugger is not attached.
473471 if (!Debug .isDebuggerConnected ()) {
474472 Slog .w (TAG , "*** WATCHDOG KILLING SYSTEM PROCESS: " + name );
475- if (!Build .TYPE .equals ("user" )) {
476- forceCrashDump ();
477- } else {
478- Process .killProcess (Process .myPid ());
479- System .exit (10 );
480- }
473+ Process .killProcess (Process .myPid ());
474+ System .exit (10 );
481475 } else {
482476 Slog .w (TAG , "Debugger connected: Watchdog is *not* killing the system process" );
483477 }
@@ -486,50 +480,6 @@ public void run() {
486480 }
487481 }
488482
489- private void forceCrashDump () {
490- /* Sync file system to flash the data which is written just before the
491- * crash.
492- */
493- java .lang .Process p = null ;
494- try {
495- p = Runtime .getRuntime ().exec ("sync" );
496- if (p != null ) {
497- // It is not necessary to check the exit code, here.
498- // 'sync' command always succeeds, and this function returns 0.
499- p .waitFor ();
500- } else {
501- Slog .e (TAG , "Failed to execute 'sync' command. (no process handle)" );
502- }
503- } catch (Exception e ) {
504- // This code is an emergency path to crash MUT. The system already
505- // caused fatal error, and then calls this function to create a
506- // crash dump. This function must run the code below to force a
507- // crash, even if the sync command failed.
508- // Therefore, ignore all exceptions, here.
509- Slog .e (TAG , "Failed to execute 'sync' command prior to forcing crash: " + e );
510- } finally {
511- if (p != null ) {
512- p .destroy ();
513- }
514- }
515-
516- FileWriter out = null ;
517- try {
518- out = new FileWriter ("/proc/sysrq-trigger" );
519- out .write ("c" );
520- } catch (IOException e ) {
521- Slog .e (TAG , "Failed to write to sysrq-trigger while triggering crash: " + e );
522- } finally {
523- if (out != null ) {
524- try {
525- out .close ();
526- } catch (IOException e ) {
527- Slog .e (TAG , "Failed to close sysrq-trigger while triggering crash: " + e );
528- }
529- }
530- }
531- }
532-
533483 private File dumpKernelStackTraces () {
534484 String tracesPath = SystemProperties .get ("dalvik.vm.stack-trace-file" , null );
535485 if (tracesPath == null || tracesPath .length () == 0 ) {
0 commit comments