Loading services/core/java/com/android/server/Watchdog.java +13 −15 Original line number Diff line number Diff line Loading @@ -131,8 +131,6 @@ public class Watchdog extends Thread { private static Watchdog sWatchdog; private final Object mLock = new Object(); /* This handler will be used to post message back onto the main thread */ private final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<>(); private final HandlerChecker mMonitorChecker; Loading Loading @@ -242,13 +240,13 @@ public class Watchdog extends Thread { // point we have completed execution of this method. final int size = mMonitors.size(); for (int i = 0 ; i < size ; i++) { synchronized (mLock) { synchronized (Watchdog.this) { mCurrentMonitor = mMonitors.get(i); } mCurrentMonitor.monitor(); } synchronized (mLock) { synchronized (Watchdog.this) { mCompleted = true; mCurrentMonitor = null; } Loading Loading @@ -379,7 +377,7 @@ public class Watchdog extends Thread { public void processStarted(String processName, int pid) { if (isInterestingJavaProcess(processName)) { Slog.i(TAG, "Interesting Java process " + processName + " started. Pid " + pid); synchronized (mLock) { synchronized (this) { mInterestingJavaPids.add(pid); } } Loading @@ -391,26 +389,26 @@ public class Watchdog extends Thread { public void processDied(String processName, int pid) { if (isInterestingJavaProcess(processName)) { Slog.i(TAG, "Interesting Java process " + processName + " died. Pid " + pid); synchronized (mLock) { synchronized (this) { mInterestingJavaPids.remove(Integer.valueOf(pid)); } } } public void setActivityController(IActivityController controller) { synchronized (mLock) { synchronized (this) { mController = controller; } } public void setAllowRestart(boolean allowRestart) { synchronized (mLock) { synchronized (this) { mAllowRestart = allowRestart; } } public void addMonitor(Monitor monitor) { synchronized (mLock) { synchronized (this) { mMonitorChecker.addMonitorLocked(monitor); } } Loading @@ -420,7 +418,7 @@ public class Watchdog extends Thread { } public void addThread(Handler thread, long timeoutMillis) { synchronized (mLock) { synchronized (this) { final String name = thread.getLooper().getThread().getName(); mHandlerCheckers.add(new HandlerChecker(thread, name, timeoutMillis)); } Loading @@ -440,7 +438,7 @@ public class Watchdog extends Thread { * pauses have been resumed. */ public void pauseWatchingCurrentThread(String reason) { synchronized (mLock) { synchronized (this) { for (HandlerChecker hc : mHandlerCheckers) { if (Thread.currentThread().equals(hc.getThread())) { hc.pauseLocked(reason); Loading @@ -462,7 +460,7 @@ public class Watchdog extends Thread { * as many times as the calls to pause. */ public void resumeWatchingCurrentThread(String reason) { synchronized (mLock) { synchronized (this) { for (HandlerChecker hc : mHandlerCheckers) { if (Thread.currentThread().equals(hc.getThread())) { hc.resumeLocked(reason); Loading Loading @@ -559,7 +557,7 @@ public class Watchdog extends Thread { final String subject; final boolean allowRestart; int debuggerWasConnected = 0; synchronized (mLock) { synchronized (this) { long timeout = CHECK_INTERVAL; // Make sure we (re)spin the checkers that have become idle within // this wait-and-check interval Loading @@ -582,7 +580,7 @@ public class Watchdog extends Thread { debuggerWasConnected = 2; } try { mLock.wait(timeout); wait(timeout); // Note: mHandlerCheckers and mMonitorChecker may have changed after waiting } catch (InterruptedException e) { Log.wtf(TAG, e); Loading Loading @@ -680,7 +678,7 @@ public class Watchdog extends Thread { } catch (InterruptedException ignored) {} IActivityController controller; synchronized (mLock) { synchronized (this) { controller = mController; } if (controller != null) { Loading Loading
services/core/java/com/android/server/Watchdog.java +13 −15 Original line number Diff line number Diff line Loading @@ -131,8 +131,6 @@ public class Watchdog extends Thread { private static Watchdog sWatchdog; private final Object mLock = new Object(); /* This handler will be used to post message back onto the main thread */ private final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<>(); private final HandlerChecker mMonitorChecker; Loading Loading @@ -242,13 +240,13 @@ public class Watchdog extends Thread { // point we have completed execution of this method. final int size = mMonitors.size(); for (int i = 0 ; i < size ; i++) { synchronized (mLock) { synchronized (Watchdog.this) { mCurrentMonitor = mMonitors.get(i); } mCurrentMonitor.monitor(); } synchronized (mLock) { synchronized (Watchdog.this) { mCompleted = true; mCurrentMonitor = null; } Loading Loading @@ -379,7 +377,7 @@ public class Watchdog extends Thread { public void processStarted(String processName, int pid) { if (isInterestingJavaProcess(processName)) { Slog.i(TAG, "Interesting Java process " + processName + " started. Pid " + pid); synchronized (mLock) { synchronized (this) { mInterestingJavaPids.add(pid); } } Loading @@ -391,26 +389,26 @@ public class Watchdog extends Thread { public void processDied(String processName, int pid) { if (isInterestingJavaProcess(processName)) { Slog.i(TAG, "Interesting Java process " + processName + " died. Pid " + pid); synchronized (mLock) { synchronized (this) { mInterestingJavaPids.remove(Integer.valueOf(pid)); } } } public void setActivityController(IActivityController controller) { synchronized (mLock) { synchronized (this) { mController = controller; } } public void setAllowRestart(boolean allowRestart) { synchronized (mLock) { synchronized (this) { mAllowRestart = allowRestart; } } public void addMonitor(Monitor monitor) { synchronized (mLock) { synchronized (this) { mMonitorChecker.addMonitorLocked(monitor); } } Loading @@ -420,7 +418,7 @@ public class Watchdog extends Thread { } public void addThread(Handler thread, long timeoutMillis) { synchronized (mLock) { synchronized (this) { final String name = thread.getLooper().getThread().getName(); mHandlerCheckers.add(new HandlerChecker(thread, name, timeoutMillis)); } Loading @@ -440,7 +438,7 @@ public class Watchdog extends Thread { * pauses have been resumed. */ public void pauseWatchingCurrentThread(String reason) { synchronized (mLock) { synchronized (this) { for (HandlerChecker hc : mHandlerCheckers) { if (Thread.currentThread().equals(hc.getThread())) { hc.pauseLocked(reason); Loading @@ -462,7 +460,7 @@ public class Watchdog extends Thread { * as many times as the calls to pause. */ public void resumeWatchingCurrentThread(String reason) { synchronized (mLock) { synchronized (this) { for (HandlerChecker hc : mHandlerCheckers) { if (Thread.currentThread().equals(hc.getThread())) { hc.resumeLocked(reason); Loading Loading @@ -559,7 +557,7 @@ public class Watchdog extends Thread { final String subject; final boolean allowRestart; int debuggerWasConnected = 0; synchronized (mLock) { synchronized (this) { long timeout = CHECK_INTERVAL; // Make sure we (re)spin the checkers that have become idle within // this wait-and-check interval Loading @@ -582,7 +580,7 @@ public class Watchdog extends Thread { debuggerWasConnected = 2; } try { mLock.wait(timeout); wait(timeout); // Note: mHandlerCheckers and mMonitorChecker may have changed after waiting } catch (InterruptedException e) { Log.wtf(TAG, e); Loading Loading @@ -680,7 +678,7 @@ public class Watchdog extends Thread { } catch (InterruptedException ignored) {} IActivityController controller; synchronized (mLock) { synchronized (this) { controller = mController; } if (controller != null) { Loading