summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Tate <ctate@android.com> 2015-05-02 01:52:04 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-05-02 01:52:04 +0000
commit20fb8187c41cf0fd926620b9734b9211ce0c8306 (patch)
tree15c6224cbb4566e57bb848a453959da887100036
parent520b550564d9a640de655e10995a4007e836c1fa (diff)
parenta51f14d00edda3da103585bf7741502e866512e8 (diff)
am a51f14d0: Merge "Fix NPE in JobServiceContext when closing job."
* commit 'a51f14d00edda3da103585bf7741502e866512e8': Fix NPE in JobServiceContext when closing job.
-rw-r--r--services/core/java/com/android/server/job/JobServiceContext.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/job/JobServiceContext.java b/services/core/java/com/android/server/job/JobServiceContext.java
index b066d6bb46d0..1aba9a669043 100644
--- a/services/core/java/com/android/server/job/JobServiceContext.java
+++ b/services/core/java/com/android/server/job/JobServiceContext.java
@@ -73,7 +73,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
private static final long OP_TIMEOUT_MILLIS = 8 * 1000;
private static final String[] VERB_STRINGS = {
- "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING"
+ "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING", "VERB_FINISHED"
};
// States that a job occupies while interacting with the client.
@@ -81,6 +81,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
static final int VERB_STARTING = 1;
static final int VERB_EXECUTING = 2;
static final int VERB_STOPPING = 3;
+ static final int VERB_FINISHED = 4;
// Messages that result from interactions with the client service.
/** System timed out waiting for a response. */
@@ -171,6 +172,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
mRunningJob = null;
mParams = null;
mExecutionStartTimeElapsed = 0L;
+ mVerb = VERB_FINISHED;
removeOpTimeOut();
return false;
}
@@ -306,8 +308,8 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
break;
case MSG_CALLBACK:
if (DEBUG) {
- Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob + " v:" +
- (mVerb >= 0 ? VERB_STRINGS[mVerb] : "[invalid]"));
+ Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob
+ + " v:" + VERB_STRINGS[mVerb]);
}
removeOpTimeOut();
@@ -523,8 +525,12 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
* we want to clean up internally.
*/
private void closeAndCleanupJobH(boolean reschedule) {
- final JobStatus completedJob = mRunningJob;
+ final JobStatus completedJob;
synchronized (mLock) {
+ if (mVerb == VERB_FINISHED) {
+ return;
+ }
+ completedJob = mRunningJob;
try {
mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getUid());
} catch (RemoteException e) {
@@ -537,7 +543,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
mWakeLock = null;
mRunningJob = null;
mParams = null;
- mVerb = -1;
+ mVerb = VERB_FINISHED;
mCancelled.set(false);
service = null;
mAvailable = true;