blob: 616090ebe13b88daf13a54a8234e2d5f5a1328af [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
Dianne Hackborn5b88a2f2013-05-03 16:25:11 -070019import android.app.IActivityController;
20import android.os.Binder;
21import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import com.android.server.am.ActivityManagerService;
Jeff Brown4f8ecd82012-06-18 18:29:13 -070023import com.android.server.power.PowerManagerService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25import android.app.AlarmManager;
26import android.app.PendingIntent;
27import android.content.BroadcastReceiver;
28import android.content.ContentResolver;
29import android.content.Context;
30import android.content.Intent;
31import android.content.IntentFilter;
Jeff Browna4d82042012-10-02 19:11:19 -070032import android.os.BatteryManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.os.Debug;
34import android.os.Handler;
John Michelau11641522013-03-18 18:28:23 -050035import android.os.Looper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.os.Process;
Suchi Amalapurapu6ffce2e2010-03-08 14:48:40 -080037import android.os.ServiceManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038import android.os.SystemClock;
39import android.os.SystemProperties;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.util.EventLog;
Dan Egnor9bdc94b2010-03-04 14:20:31 -080041import android.util.Log;
Joe Onorato8a9b2202010-02-26 18:56:32 -080042import android.util.Slog;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
Dan Egnor9bdc94b2010-03-04 14:20:31 -080044import java.io.File;
Colin Cross5df1d872012-11-29 11:42:11 -080045import java.io.FileWriter;
46import java.io.IOException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047import java.util.ArrayList;
48import java.util.Calendar;
49
50/** This class calls its monitor every minute. Killing this process if they don't return **/
51public class Watchdog extends Thread {
52 static final String TAG = "Watchdog";
Joe Onorato43a17652011-04-06 19:22:23 -070053 static final boolean localLOGV = false || false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054
55 // Set this to true to use debug default values.
56 static final boolean DB = false;
57
Christopher Tateecaa7b42010-06-04 14:55:02 -070058 // Set this to true to have the watchdog record kernel thread stacks when it fires
59 static final boolean RECORD_KERNEL_THREADS = true;
60
Dianne Hackbornf6438b12013-05-09 18:53:48 -070061 static final int TIME_TO_WAIT = DB ? 5*1000 : 30*1000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062
Dianne Hackbornf72467a2012-06-08 17:23:59 -070063 static final String[] NATIVE_STACKS_OF_INTEREST = new String[] {
64 "/system/bin/mediaserver",
65 "/system/bin/sdcard",
66 "/system/bin/surfaceflinger"
67 };
68
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 static Watchdog sWatchdog;
70
71 /* This handler will be used to post message back onto the main thread */
Dianne Hackborn8d044e82013-04-30 17:24:15 -070072 final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<HandlerChecker>();
73 final HandlerChecker mMonitorChecker;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 ContentResolver mResolver;
75 BatteryService mBattery;
76 PowerManagerService mPower;
77 AlarmManagerService mAlarm;
78 ActivityManagerService mActivity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 int mPhonePid;
Dianne Hackborn5b88a2f2013-05-03 16:25:11 -070081 IActivityController mController;
Dianne Hackborn8bd64df2013-05-06 16:07:26 -070082 boolean mAllowRestart = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 /**
Dianne Hackborn8d044e82013-04-30 17:24:15 -070085 * Used for checking status of handle threads and scheduling monitor callbacks.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 */
Dianne Hackborn8d044e82013-04-30 17:24:15 -070087 public final class HandlerChecker implements Runnable {
88 private final Handler mHandler;
89 private final String mName;
90 private final ArrayList<Monitor> mMonitors = new ArrayList<Monitor>();
Dianne Hackborn8d044e82013-04-30 17:24:15 -070091 private boolean mCompleted;
92 private Monitor mCurrentMonitor;
93
Dianne Hackbornf6438b12013-05-09 18:53:48 -070094 HandlerChecker(Handler handler, String name) {
Dianne Hackborn8d044e82013-04-30 17:24:15 -070095 mHandler = handler;
96 mName = name;
Dianne Hackborn8d044e82013-04-30 17:24:15 -070097 }
98
99 public void addMonitor(Monitor monitor) {
100 mMonitors.add(monitor);
101 }
102
103 public void scheduleCheckLocked() {
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700104 if (mMonitors.size() == 0 && mHandler.getLooper().isIdling()) {
Dianne Hackbornefa92b22013-05-03 14:11:43 -0700105 // If the target looper is or just recently was idling, then
106 // there is no reason to enqueue our checker on it since that
107 // is as good as it not being deadlocked. This avoid having
108 // to do a context switch to check the thread. Note that we
109 // only do this if mCheckReboot is false and we have no
110 // monitors, since those would need to be executed at this point.
111 mCompleted = true;
112 return;
113 }
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700114 mCompleted = false;
115 mCurrentMonitor = null;
116 mHandler.postAtFrontOfQueue(this);
117 }
118
119 public boolean isCompletedLocked() {
120 return mCompleted;
121 }
122
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700123 public Thread getThread() {
124 return mHandler.getLooper().getThread();
125 }
126
127 public String getName() {
128 return mName;
129 }
130
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700131 public String describeBlockedStateLocked() {
Jeff Brown7dd2d192013-09-06 15:05:23 -0700132 if (mCurrentMonitor == null) {
133 return "Blocked in handler on " + mName + " (" + getThread().getName() + ")";
134 } else {
135 return "Blocked in monitor " + mCurrentMonitor.getClass().getName()
136 + " on " + mName + " (" + getThread().getName() + ")";
137 }
John Michelau11641522013-03-18 18:28:23 -0500138 }
139
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 @Override
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700141 public void run() {
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700142 final int size = mMonitors.size();
143 for (int i = 0 ; i < size ; i++) {
144 synchronized (Watchdog.this) {
145 mCurrentMonitor = mMonitors.get(i);
146 }
147 mCurrentMonitor.monitor();
148 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700150 synchronized (Watchdog.this) {
151 mCompleted = true;
152 mCurrentMonitor = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153 }
154 }
155 }
156
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157 final class RebootRequestReceiver extends BroadcastReceiver {
158 @Override
159 public void onReceive(Context c, Intent intent) {
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700160 if (intent.getIntExtra("nowait", 0) != 0) {
161 rebootSystem("Received ACTION_REBOOT broadcast");
162 return;
163 }
164 Slog.w(TAG, "Unsupported ACTION_REBOOT broadcast: " + intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800165 }
166 }
167
168 public interface Monitor {
169 void monitor();
170 }
171
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800172 public static Watchdog getInstance() {
173 if (sWatchdog == null) {
174 sWatchdog = new Watchdog();
175 }
176
177 return sWatchdog;
178 }
179
180 private Watchdog() {
181 super("watchdog");
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700182 // Initialize handler checkers for each common thread we want to check. Note
183 // that we are not currently checking the background thread, since it can
184 // potentially hold longer running operations with no guarantees about the timeliness
185 // of operations there.
186
187 // The shared foreground thread is the main checker. It is where we
188 // will also dispatch monitor checks and do other work.
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700189 mMonitorChecker = new HandlerChecker(FgThread.getHandler(), "foreground thread");
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700190 mHandlerCheckers.add(mMonitorChecker);
191 // Add checker for main thread. We only do a quick check since there
192 // can be UI running on the thread.
193 mHandlerCheckers.add(new HandlerChecker(new Handler(Looper.getMainLooper()),
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700194 "main thread"));
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700195 // Add checker for shared UI thread.
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700196 mHandlerCheckers.add(new HandlerChecker(UiThread.getHandler(), "ui thread"));
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700197 // And also check IO thread.
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700198 mHandlerCheckers.add(new HandlerChecker(IoThread.getHandler(), "i/o thread"));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 }
200
201 public void init(Context context, BatteryService battery,
202 PowerManagerService power, AlarmManagerService alarm,
203 ActivityManagerService activity) {
204 mResolver = context.getContentResolver();
205 mBattery = battery;
206 mPower = power;
207 mAlarm = alarm;
208 mActivity = activity;
209
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210 context.registerReceiver(new RebootRequestReceiver(),
211 new IntentFilter(Intent.ACTION_REBOOT),
212 android.Manifest.permission.REBOOT, null);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800213 }
214
Christopher Tatec27181c2010-06-30 14:41:09 -0700215 public void processStarted(String name, int pid) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800216 synchronized (this) {
217 if ("com.android.phone".equals(name)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800218 mPhonePid = pid;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 }
220 }
221 }
222
Dianne Hackborn5b88a2f2013-05-03 16:25:11 -0700223 public void setActivityController(IActivityController controller) {
224 synchronized (this) {
225 mController = controller;
226 }
227 }
228
Dianne Hackborn8bd64df2013-05-06 16:07:26 -0700229 public void setAllowRestart(boolean allowRestart) {
230 synchronized (this) {
231 mAllowRestart = allowRestart;
232 }
233 }
234
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800235 public void addMonitor(Monitor monitor) {
236 synchronized (this) {
237 if (isAlive()) {
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700238 throw new RuntimeException("Monitors can't be added once the Watchdog is running");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239 }
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700240 mMonitorChecker.addMonitor(monitor);
241 }
242 }
243
244 public void addThread(Handler thread, String name) {
245 synchronized (this) {
246 if (isAlive()) {
247 throw new RuntimeException("Threads can't be added once the Watchdog is running");
248 }
Dianne Hackbornf6438b12013-05-09 18:53:48 -0700249 mHandlerCheckers.add(new HandlerChecker(thread, name));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800250 }
251 }
252
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253 /**
254 * Perform a full reboot of the system.
255 */
256 void rebootSystem(String reason) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800257 Slog.i(TAG, "Rebooting system because: " + reason);
Suchi Amalapurapu6ffce2e2010-03-08 14:48:40 -0800258 PowerManagerService pms = (PowerManagerService) ServiceManager.getService("power");
Dianne Hackbornc428aae2012-10-03 16:38:22 -0700259 pms.reboot(false, reason, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 }
261
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700262 private boolean haveAllCheckersCompletedLocked() {
263 for (int i=0; i<mHandlerCheckers.size(); i++) {
264 HandlerChecker hc = mHandlerCheckers.get(i);
265 if (!hc.isCompletedLocked()) {
266 return false;
267 }
268 }
269 return true;
270 }
271
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700272 private ArrayList<HandlerChecker> getBlockedCheckersLocked() {
273 ArrayList<HandlerChecker> checkers = new ArrayList<HandlerChecker>();
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700274 for (int i=0; i<mHandlerCheckers.size(); i++) {
275 HandlerChecker hc = mHandlerCheckers.get(i);
276 if (!hc.isCompletedLocked()) {
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700277 checkers.add(hc);
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700278 }
279 }
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700280 return checkers;
281 }
282
283 private String describeCheckersLocked(ArrayList<HandlerChecker> checkers) {
284 StringBuilder builder = new StringBuilder(128);
285 for (int i=0; i<checkers.size(); i++) {
286 if (builder.length() > 0) {
287 builder.append(", ");
288 }
289 builder.append(checkers.get(i).describeBlockedStateLocked());
290 }
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700291 return builder.toString();
292 }
293
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 @Override
295 public void run() {
Christopher Tate6ee412d2010-05-28 12:01:56 -0700296 boolean waitedHalf = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 while (true) {
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700298 final ArrayList<HandlerChecker> blockedCheckers;
Jeff Brown7dd2d192013-09-06 15:05:23 -0700299 final String subject;
Dianne Hackborn8bd64df2013-05-06 16:07:26 -0700300 final boolean allowRestart;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301 synchronized (this) {
302 long timeout = TIME_TO_WAIT;
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700303 if (!waitedHalf) {
304 // If we are not at the half-point of waiting, perform a
305 // new set of checks. Otherwise we are still waiting for a previous set.
306 for (int i=0; i<mHandlerCheckers.size(); i++) {
307 HandlerChecker hc = mHandlerCheckers.get(i);
308 hc.scheduleCheckLocked();
309 }
310 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311
312 // NOTE: We use uptimeMillis() here because we do not want to increment the time we
313 // wait while asleep. If the device is asleep then the thing that we are waiting
Christopher Tate6ee412d2010-05-28 12:01:56 -0700314 // to timeout on is asleep as well and won't have a chance to run, causing a false
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 // positive on when to kill things.
316 long start = SystemClock.uptimeMillis();
Michael Wright8fa56f62013-04-01 16:36:05 -0700317 while (timeout > 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 try {
Michael Wright8fa56f62013-04-01 16:36:05 -0700319 wait(timeout);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 } catch (InterruptedException e) {
Dan Egnor9bdc94b2010-03-04 14:20:31 -0800321 Log.wtf(TAG, e);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800322 }
323 timeout = TIME_TO_WAIT - (SystemClock.uptimeMillis() - start);
Dan Egnor9bdc94b2010-03-04 14:20:31 -0800324 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700326 if (haveAllCheckersCompletedLocked()) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 // The monitors have returned.
Christopher Tate6ee412d2010-05-28 12:01:56 -0700328 waitedHalf = false;
329 continue;
330 }
331
332 if (!waitedHalf) {
333 // We've waited half the deadlock-detection interval. Pull a stack
334 // trace and wait another half.
Dianne Hackborn6b1afeb2010-08-31 15:40:21 -0700335 ArrayList<Integer> pids = new ArrayList<Integer>();
Christopher Tate6ee412d2010-05-28 12:01:56 -0700336 pids.add(Process.myPid());
Dianne Hackbornf72467a2012-06-08 17:23:59 -0700337 ActivityManagerService.dumpStackTraces(true, pids, null, null,
338 NATIVE_STACKS_OF_INTEREST);
Christopher Tate6ee412d2010-05-28 12:01:56 -0700339 waitedHalf = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 continue;
341 }
Michael Wright8fa56f62013-04-01 16:36:05 -0700342
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700343 blockedCheckers = getBlockedCheckersLocked();
Jeff Brown7dd2d192013-09-06 15:05:23 -0700344 subject = describeCheckersLocked(blockedCheckers);
Dianne Hackborn8bd64df2013-05-06 16:07:26 -0700345 allowRestart = mAllowRestart;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 }
347
348 // If we got here, that means that the system is most likely hung.
Jean-Baptiste Queru784827b2012-09-04 13:35:12 -0700349 // First collect stack traces from all threads of the system process.
350 // Then kill this process so that the system will restart.
Jeff Brown7dd2d192013-09-06 15:05:23 -0700351 EventLog.writeEvent(EventLogTags.WATCHDOG, subject);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800352
Dianne Hackborn6b1afeb2010-08-31 15:40:21 -0700353 ArrayList<Integer> pids = new ArrayList<Integer>();
Dan Egnor9bdc94b2010-03-04 14:20:31 -0800354 pids.add(Process.myPid());
Dan Egnor4bded072010-03-11 22:00:47 -0800355 if (mPhonePid > 0) pids.add(mPhonePid);
Christopher Tate6ee412d2010-05-28 12:01:56 -0700356 // Pass !waitedHalf so that just in case we somehow wind up here without having
357 // dumped the halfway stacks, we properly re-initialize the trace file.
Brad Fitzpatrick9765c722011-01-14 11:28:22 -0800358 final File stack = ActivityManagerService.dumpStackTraces(
Dianne Hackbornf72467a2012-06-08 17:23:59 -0700359 !waitedHalf, pids, null, null, NATIVE_STACKS_OF_INTEREST);
Dan Egnor4bded072010-03-11 22:00:47 -0800360
361 // Give some extra time to make sure the stack traces get written.
362 // The system's been hanging for a minute, another second or two won't hurt much.
363 SystemClock.sleep(2000);
364
Christopher Tateecaa7b42010-06-04 14:55:02 -0700365 // Pull our own kernel thread stacks as well if we're configured for that
366 if (RECORD_KERNEL_THREADS) {
367 dumpKernelStackTraces();
368 }
369
Colin Cross5df1d872012-11-29 11:42:11 -0800370 // Trigger the kernel to dump all blocked threads to the kernel log
371 try {
372 FileWriter sysrq_trigger = new FileWriter("/proc/sysrq-trigger");
373 sysrq_trigger.write("w");
374 sysrq_trigger.close();
375 } catch (IOException e) {
376 Slog.e(TAG, "Failed to write to /proc/sysrq-trigger");
377 Slog.e(TAG, e.getMessage());
378 }
379
Brad Fitzpatrick9765c722011-01-14 11:28:22 -0800380 // Try to add the error to the dropbox, but assuming that the ActivityManager
381 // itself may be deadlocked. (which has happened, causing this statement to
382 // deadlock and the watchdog as a whole to be ineffective)
383 Thread dropboxThread = new Thread("watchdogWriteToDropbox") {
384 public void run() {
385 mActivity.addErrorToDropBox(
Jeff Sharkeya353d262011-10-28 11:12:06 -0700386 "watchdog", null, "system_server", null, null,
Jeff Brown7dd2d192013-09-06 15:05:23 -0700387 subject, null, stack, null);
Brad Fitzpatrick9765c722011-01-14 11:28:22 -0800388 }
389 };
390 dropboxThread.start();
391 try {
392 dropboxThread.join(2000); // wait up to 2 seconds for it to return.
393 } catch (InterruptedException ignored) {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394
Dianne Hackborn5b88a2f2013-05-03 16:25:11 -0700395 IActivityController controller;
396 synchronized (this) {
397 controller = mController;
398 }
399 if (controller != null) {
400 Slog.i(TAG, "Reporting stuck state to activity controller");
401 try {
402 Binder.setDumpDisabled("Service dumps disabled due to hung system process.");
403 // 1 = keep waiting, -1 = kill system
Jeff Brown7dd2d192013-09-06 15:05:23 -0700404 int res = controller.systemNotResponding(subject);
Dianne Hackborn5b88a2f2013-05-03 16:25:11 -0700405 if (res >= 0) {
406 Slog.i(TAG, "Activity controller requested to coninue to wait");
407 waitedHalf = false;
408 continue;
409 }
410 } catch (RemoteException e) {
411 }
412 }
413
Jean-Baptiste Queru784827b2012-09-04 13:35:12 -0700414 // Only kill the process if the debugger is not attached.
Dianne Hackborn8bd64df2013-05-06 16:07:26 -0700415 if (Debug.isDebuggerConnected()) {
416 Slog.w(TAG, "Debugger connected: Watchdog is *not* killing the system process");
417 } else if (!allowRestart) {
418 Slog.w(TAG, "Restart not allowed: Watchdog is *not* killing the system process");
419 } else {
Jeff Brown7dd2d192013-09-06 15:05:23 -0700420 Slog.w(TAG, "*** WATCHDOG KILLING SYSTEM PROCESS: " + subject);
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700421 for (int i=0; i<blockedCheckers.size(); i++) {
422 Slog.w(TAG, blockedCheckers.get(i).getName() + " stack trace:");
423 StackTraceElement[] stackTrace
424 = blockedCheckers.get(i).getThread().getStackTrace();
425 for (StackTraceElement element: stackTrace) {
426 Slog.w(TAG, " at " + element);
427 }
Michael Wright56a6c662013-04-30 20:13:07 -0700428 }
Dianne Hackbornfa012b32013-05-10 15:23:28 -0700429 Slog.w(TAG, "*** GOODBYE!");
Jean-Baptiste Queru784827b2012-09-04 13:35:12 -0700430 Process.killProcess(Process.myPid());
431 System.exit(10);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 }
Christopher Tate6ee412d2010-05-28 12:01:56 -0700433
434 waitedHalf = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 }
436 }
Christopher Tateecaa7b42010-06-04 14:55:02 -0700437
438 private File dumpKernelStackTraces() {
439 String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
440 if (tracesPath == null || tracesPath.length() == 0) {
441 return null;
442 }
443
444 native_dumpKernelStacks(tracesPath);
445 return new File(tracesPath);
446 }
447
448 private native void native_dumpKernelStacks(String tracesPath);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449}