Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −2 Original line number Diff line number Diff line Loading @@ -498,6 +498,8 @@ public final class JobServiceContext implements ServiceConnection { Slog.d(TAG, job.getServiceComponent().getShortClassName() + " unavailable."); } mContext.unbindService(this); // Ensure this occurs while mRunningCallback is still set. removeOpTimeOutLocked(); mRunningJob = null; mRunningJobWorkType = WORK_TYPE_NONE; mRunningCallback = null; Loading @@ -505,7 +507,6 @@ public final class JobServiceContext implements ServiceConnection { mExecutionStartTimeElapsed = 0L; mWakeLock.release(); mVerb = VERB_FINISHED; removeOpTimeOutLocked(); return false; } mJobPackageTracker.noteActive(job); Loading Loading @@ -1213,6 +1214,8 @@ public final class JobServiceContext implements ServiceConnection { handleOpTimeoutLocked(); } else { JobCallback jc = (JobCallback)message.obj; // This is an unknown JobCallback. It may, or may not, have an // associated timer. mAnrTimer.discard(jc); StringBuilder sb = new StringBuilder(128); sb.append("Ignoring timeout of no longer active job"); Loading Loading @@ -1765,6 +1768,8 @@ public final class JobServiceContext implements ServiceConnection { } final int workType = mRunningJobWorkType; mContext.unbindService(JobServiceContext.this); // Ensure this occurs while mRunningCallback is still set. removeOpTimeOutLocked(); mWakeLock = null; mRunningJob = null; mRunningJobWorkType = WORK_TYPE_NONE; Loading @@ -1782,7 +1787,6 @@ public final class JobServiceContext implements ServiceConnection { mPendingInternalStopReason = 0; mPendingDebugStopReason = null; mPendingNetworkChange = null; removeOpTimeOutLocked(); if (completedJob.isUserVisibleJob()) { mService.informObserversOfUserVisibleJobChange(this, completedJob, false); } Loading services/core/java/com/android/server/utils/AnrTimer.java +8 −0 Original line number Diff line number Diff line Loading @@ -527,6 +527,8 @@ public class AnrTimer<V> implements AutoCloseable { @Override void start(@NonNull V arg, int pid, int uid, long timeoutMs) { synchronized (mLock) { if (mNative == 0) throw new IllegalStateException("timer service is closed"); // If there is an existing timer, cancel it. This is a nop if the timer does not // exist. if (cancel(arg)) mTotalRestarted++; Loading Loading @@ -554,6 +556,8 @@ public class AnrTimer<V> implements AutoCloseable { if (timer == null) { return false; } // Race conditions may lead to timer cancellation after the service was closed. if (mNative == 0) return false; if (!nativeAnrTimerCancel(mNative, timer)) { // There may be an expiration message in flight. Cancel it. mHandler.removeMessages(mWhat, arg); Loading @@ -579,6 +583,8 @@ public class AnrTimer<V> implements AutoCloseable { notFoundLocked("accept", arg); return null; } // Race conditions may lead to timer acceptance after the service was closed. if (mNative == 0) return null; boolean accepted = nativeAnrTimerAccept(mNative, timer); trace("accept", timer); // If "accepted" is true then the native layer has pending operations against this Loading @@ -601,6 +607,8 @@ public class AnrTimer<V> implements AutoCloseable { notFoundLocked("discard", arg); return false; } // Race conditions may lead to timer discard after the service was closed. if (mNative == 0) return false; nativeAnrTimerDiscard(mNative, timer); trace("discard", timer); return true; Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −2 Original line number Diff line number Diff line Loading @@ -498,6 +498,8 @@ public final class JobServiceContext implements ServiceConnection { Slog.d(TAG, job.getServiceComponent().getShortClassName() + " unavailable."); } mContext.unbindService(this); // Ensure this occurs while mRunningCallback is still set. removeOpTimeOutLocked(); mRunningJob = null; mRunningJobWorkType = WORK_TYPE_NONE; mRunningCallback = null; Loading @@ -505,7 +507,6 @@ public final class JobServiceContext implements ServiceConnection { mExecutionStartTimeElapsed = 0L; mWakeLock.release(); mVerb = VERB_FINISHED; removeOpTimeOutLocked(); return false; } mJobPackageTracker.noteActive(job); Loading Loading @@ -1213,6 +1214,8 @@ public final class JobServiceContext implements ServiceConnection { handleOpTimeoutLocked(); } else { JobCallback jc = (JobCallback)message.obj; // This is an unknown JobCallback. It may, or may not, have an // associated timer. mAnrTimer.discard(jc); StringBuilder sb = new StringBuilder(128); sb.append("Ignoring timeout of no longer active job"); Loading Loading @@ -1765,6 +1768,8 @@ public final class JobServiceContext implements ServiceConnection { } final int workType = mRunningJobWorkType; mContext.unbindService(JobServiceContext.this); // Ensure this occurs while mRunningCallback is still set. removeOpTimeOutLocked(); mWakeLock = null; mRunningJob = null; mRunningJobWorkType = WORK_TYPE_NONE; Loading @@ -1782,7 +1787,6 @@ public final class JobServiceContext implements ServiceConnection { mPendingInternalStopReason = 0; mPendingDebugStopReason = null; mPendingNetworkChange = null; removeOpTimeOutLocked(); if (completedJob.isUserVisibleJob()) { mService.informObserversOfUserVisibleJobChange(this, completedJob, false); } Loading
services/core/java/com/android/server/utils/AnrTimer.java +8 −0 Original line number Diff line number Diff line Loading @@ -527,6 +527,8 @@ public class AnrTimer<V> implements AutoCloseable { @Override void start(@NonNull V arg, int pid, int uid, long timeoutMs) { synchronized (mLock) { if (mNative == 0) throw new IllegalStateException("timer service is closed"); // If there is an existing timer, cancel it. This is a nop if the timer does not // exist. if (cancel(arg)) mTotalRestarted++; Loading Loading @@ -554,6 +556,8 @@ public class AnrTimer<V> implements AutoCloseable { if (timer == null) { return false; } // Race conditions may lead to timer cancellation after the service was closed. if (mNative == 0) return false; if (!nativeAnrTimerCancel(mNative, timer)) { // There may be an expiration message in flight. Cancel it. mHandler.removeMessages(mWhat, arg); Loading @@ -579,6 +583,8 @@ public class AnrTimer<V> implements AutoCloseable { notFoundLocked("accept", arg); return null; } // Race conditions may lead to timer acceptance after the service was closed. if (mNative == 0) return null; boolean accepted = nativeAnrTimerAccept(mNative, timer); trace("accept", timer); // If "accepted" is true then the native layer has pending operations against this Loading @@ -601,6 +607,8 @@ public class AnrTimer<V> implements AutoCloseable { notFoundLocked("discard", arg); return false; } // Race conditions may lead to timer discard after the service was closed. if (mNative == 0) return false; nativeAnrTimerDiscard(mNative, timer); trace("discard", timer); return true; Loading