Turn on debugging override of idle time

'adb shell am idle-maintenance' has traditionally been used to force
the system to consider itself to be in an "idle" state.  Unfortunately
the new Job Manager hadn't yet been aware of this.  Rectify the situation.

Also fixes a bug in debug logging that would cause a system server
crash under certain race circumstances.

Change-Id: I8a29bd7757924f8e464865235c344233fc03d8c3
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 127b0fc..fa59e4b 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -1465,7 +1465,7 @@
 
         System.out.println("Performing idle maintenance...");
         Intent intent = new Intent(
-                "com.android.server.IdleMaintenanceService.action.FORCE_IDLE_MAINTENANCE");
+                "com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE");
         mAm.broadcastIntent(null, intent, null, null, 0, null, null, null,
                 android.app.AppOpsManager.OP_NONE, true, false, UserHandle.USER_ALL);
     }
diff --git a/services/core/java/com/android/server/job/JobServiceContext.java b/services/core/java/com/android/server/job/JobServiceContext.java
index eaf5480..ee45833 100644
--- a/services/core/java/com/android/server/job/JobServiceContext.java
+++ b/services/core/java/com/android/server/job/JobServiceContext.java
@@ -285,7 +285,7 @@
                 case MSG_CALLBACK:
                     if (DEBUG) {
                         Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob + " v:" +
-                                VERB_STRINGS[mVerb]);
+                                (mVerb >= 0 ? VERB_STRINGS[mVerb] : "[invalid]"));
                     }
                     removeMessages(MSG_TIMEOUT);
 
@@ -518,7 +518,7 @@
                     EXECUTING_TIMESLICE_MILLIS : OP_TIMEOUT_MILLIS;
             if (DEBUG) {
                 Slog.d(TAG, "Scheduling time out for '" +
-                        mRunningJob.getServiceComponent().getShortClassName() + "' tId: " +
+                        mRunningJob.getServiceComponent().getShortClassName() + "' jId: " +
                         mParams.getJobId() + ", in " + (timeoutMillis / 1000) + " s");
             }
             Message m = mCallbackHandler.obtainMessage(MSG_TIMEOUT);
diff --git a/services/core/java/com/android/server/job/controllers/IdleController.java b/services/core/java/com/android/server/job/controllers/IdleController.java
index 07ffe4d..451960c 100644
--- a/services/core/java/com/android/server/job/controllers/IdleController.java
+++ b/services/core/java/com/android/server/job/controllers/IdleController.java
@@ -137,6 +137,9 @@
             filter.addAction(Intent.ACTION_DREAMING_STARTED);
             filter.addAction(Intent.ACTION_DREAMING_STOPPED);
 
+            // Debugging/instrumentation
+            filter.addAction(ACTION_TRIGGER_IDLE);
+
             mContext.registerReceiver(this, filter);
         }