Introduce LoggingRunnable for Session logging

Introduces a Session.LoggingRunnable class to reduce code duplication
when implementing Runnables in Telecom.

Bug: 26807413
Change-Id: I40c709fd09260c6a40b63fd2c401e5a582035a5c
diff --git a/src/com/android/server/telecom/AsyncBlockCheckTask.java b/src/com/android/server/telecom/AsyncBlockCheckTask.java
index 86c7a14..282a4eb 100644
--- a/src/com/android/server/telecom/AsyncBlockCheckTask.java
+++ b/src/com/android/server/telecom/AsyncBlockCheckTask.java
@@ -38,8 +38,18 @@
     private final Object mCallScreeningListenerLock = new Object();
 
     private Session mLogSubsession;
+    private Runnable mBlockCheckTimeoutRunnable = new Runnable("ABCT.oPE") {
+        @Override
+        public void loggedRun() {
+            synchronized (mCallScreeningListenerLock) {
+                if (mCallScreeningListener != null) {
+                    timeoutBlockCheck();
+                    mCallScreeningListener = null;
+                }
+            }
+        }
+    };
     private CallScreening.Listener mCallScreeningListener;
-    private Session mLogSubsessionForTimeout;
 
     AsyncBlockCheckTask(Context context, Call incomingCall, CallScreening callScreening,
                         CallScreening.Listener callScreeningListener,
@@ -54,26 +64,7 @@
     @Override
     protected void onPreExecute() {
         mLogSubsession = Log.createSubsession();
-        mLogSubsessionForTimeout = Log.createSubsession();
-        Runnable blockCheckTimeoutRunnable = new Runnable() {
-            @Override
-            public void run() {
-                synchronized (mCallScreeningListenerLock) {
-                    if (mCallScreeningListener != null) {
-                        try {
-                            Log.continueSession(mLogSubsessionForTimeout, "aBCT.oPEr");
-                            timeoutBlockCheck();
-                            mCallScreeningListener = null;
-                        } finally {
-                            Log.endSession();
-                            mLogSubsessionForTimeout = null;
-                        }
-                    }
-
-                }
-            }
-        };
-        mHandler.postDelayed(blockCheckTimeoutRunnable,
+        mHandler.postDelayed(mBlockCheckTimeoutRunnable.prepare(),
                 Timeouts.getBlockCheckTimeoutMillis(mContext.getContentResolver()));
     }
 
@@ -90,7 +81,7 @@
     @Override
     protected Boolean doInBackground(String... params) {
         try {
-            Log.continueSession(mLogSubsession, "aBCT.dIBg");
+            Log.continueSession(mLogSubsession, "ABCT.DIB");
             Log.event(mIncomingCall, Log.Events.BLOCK_CHECK_INITIATED);
             return BlockChecker.isBlocked(mContext, params[0]);
         } finally {
@@ -102,11 +93,10 @@
     protected void onPostExecute(Boolean isBlocked) {
         synchronized (mCallScreeningListenerLock) {
             mHandler.removeCallbacks(null);
+            mBlockCheckTimeoutRunnable.cancel();
             if (mCallScreeningListener != null) {
                 processIsBlockedLocked(isBlocked);
                 mCallScreeningListener = null;
-                Log.cancelSubsession(mLogSubsessionForTimeout);
-                mLogSubsessionForTimeout = null;
             }
         }
     }
diff --git a/src/com/android/server/telecom/BluetoothManager.java b/src/com/android/server/telecom/BluetoothManager.java
index 82c8d47..8dd5a7b 100644
--- a/src/com/android/server/telecom/BluetoothManager.java
+++ b/src/com/android/server/telecom/BluetoothManager.java
@@ -107,9 +107,9 @@
     private BluetoothHeadset mBluetoothHeadset;
     private boolean mBluetoothConnectionPending = false;
     private long mBluetoothConnectionRequestTime;
-    private final Runnable mBluetoothConnectionTimeout = new Runnable() {
+    private final Runnable mBluetoothConnectionTimeout = new Runnable("BM.cBA") {
         @Override
-        public void run() {
+        public void loggedRun() {
             if (!isBluetoothAudioConnected()) {
                 Log.v(this, "Bluetooth audio inexplicably disconnected within 5 seconds of " +
                         "connection. Updating UI.");
@@ -274,8 +274,11 @@
         // instantly. (See isBluetoothAudioConnectedOrPending() above.)
         mBluetoothConnectionPending = true;
         mBluetoothConnectionRequestTime = SystemClock.elapsedRealtime();
-        mHandler.removeCallbacks(mBluetoothConnectionTimeout);
-        mHandler.postDelayed(mBluetoothConnectionTimeout,
+        mHandler.removeCallbacks(mBluetoothConnectionTimeout.getRunnableToCancel());
+        mBluetoothConnectionTimeout.cancel();
+        // If the mBluetoothConnectionTimeout runnable has run, the session had been cleared...
+        // Create a new Session before putting it back in the queue to possibly run again.
+        mHandler.postDelayed(mBluetoothConnectionTimeout.prepare(),
                 Timeouts.getBluetoothPendingTimeoutMillis(mContext.getContentResolver()));
     }
 
@@ -285,7 +288,8 @@
         if (mBluetoothHeadset != null) {
             mBluetoothHeadset.disconnectAudio();
         }
-        mHandler.removeCallbacks(mBluetoothConnectionTimeout);
+        mHandler.removeCallbacks(mBluetoothConnectionTimeout.getRunnableToCancel());
+        mBluetoothConnectionTimeout.cancel();
         mBluetoothConnectionPending = false;
     }
 
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 29a1ab6..7b342bc 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -196,28 +196,6 @@
                 }
             };
 
-    private class DirectToVoicemailRunnable implements Runnable {
-
-        Session mSession;
-
-        public DirectToVoicemailRunnable(Session session) {
-            mSession = session;
-        }
-
-        @Override
-        public void run() {
-            try {
-                Log.continueSession(mSession, "DTVR.r");
-                synchronized (mLock) {
-                    processDirectToVoicemail();
-                }
-            } finally {
-                Log.endSession();
-                mSession = null;
-            }
-        }
-    }
-
     private class CallSessionCookie {
         Call mSessionCall;
         Session mSession;
@@ -1093,8 +1071,14 @@
 
                 // Timeout the direct-to-voicemail lookup execution so that we dont wait too long
                 // before showing the user the incoming call screen.
-                mHandler.postDelayed(new DirectToVoicemailRunnable(Log.createSubsession()),
-                        Timeouts.getDirectToVoicemailMillis(mContext.getContentResolver()));
+                mHandler.postDelayed(new Runnable("C.hCCS") {
+                    @Override
+                    public void loggedRun() {
+                         synchronized (mLock) {
+                             processDirectToVoicemail();
+                         }
+                    }
+                }.prepare(), Timeouts.getDirectToVoicemailMillis(mContext.getContentResolver()));
                 break;
             case CALL_DIRECTION_OUTGOING:
                 for (Listener l : mListeners) {
@@ -1595,13 +1579,11 @@
         mCallerInfo = null;
         if (!TextUtils.isEmpty(number)) {
             Log.v(this, "Looking up information for: %s.", Log.piiHandle(number));
-            final Session subsession = Log.createSubsession();
-            mHandler.post(new Runnable() {
+            mHandler.post(new Runnable("C.sCIL") {
                 @Override
-                public void run() {
+                public void loggedRun() {
                     Session subsubsession = null;
                     try {
-                        Log.continueSession(subsession, "CIAQF.sQ");
                         subsubsession = Log.createSubsession();
                         CallerInfoAsyncQuery value = mCallerInfoAsyncQueryFactory.startQuery(
                                 mQueryToken, mContext, number, mCallerInfoQueryListener,
@@ -1615,10 +1597,9 @@
                         if (subsubsession != null) {
                             Log.cancelSubsession(subsubsession);
                         }
-                        Log.endSession();
                     }
                 }
-            });
+            }.prepare());
         }
     }
 
diff --git a/src/com/android/server/telecom/CallAudioModeStateMachine.java b/src/com/android/server/telecom/CallAudioModeStateMachine.java
index d8b0aaf..8a1aef8 100644
--- a/src/com/android/server/telecom/CallAudioModeStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioModeStateMachine.java
@@ -130,7 +130,7 @@
                     mIsInitialized = true;
                     return HANDLED;
                 case RUN_RUNNABLE:
-                    Runnable r = (Runnable) msg.obj;
+                    java.lang.Runnable r = (java.lang.Runnable) msg.obj;
                     r.run();
                     return HANDLED;
                 default:
diff --git a/src/com/android/server/telecom/CallAudioRouteStateMachine.java b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
index b47b02e..7bb213a 100644
--- a/src/com/android/server/telecom/CallAudioRouteStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
@@ -1031,7 +1031,7 @@
                 }
                 return;
             case RUN_RUNNABLE:
-                Runnable r = (Runnable) msg.obj;
+                java.lang.Runnable r = (java.lang.Runnable) msg.obj;
                 r.run();
                 return;
             default:
diff --git a/src/com/android/server/telecom/CallScreening.java b/src/com/android/server/telecom/CallScreening.java
index 43ad867..f0ef5a6 100644
--- a/src/com/android/server/telecom/CallScreening.java
+++ b/src/com/android/server/telecom/CallScreening.java
@@ -78,23 +78,15 @@
             Log.d(this, "no service, giving up");
             performCleanup();
         } else {
-            final Session subsession = Log.createSubsession();
-            Runnable runnable = new Runnable() {
+            mHandler.postDelayed(new Runnable("CS.sC") {
                 @Override
-                public void run() {
-                    Log.continueSession(subsession, "CSCR.scrC");
-                    try {
-                        synchronized (mLock) {
-                            Log.event(mCall, Log.Events.SCREENING_TIMED_OUT);
-                            performCleanup();
-                        }
-                    } finally {
-                        Log.endSession();
+                public void loggedRun() {
+                    synchronized (mLock) {
+                        Log.event(mCall, Log.Events.SCREENING_TIMED_OUT);
+                        performCleanup();
                     }
                 }
-            };
-            mHandler.postDelayed(
-                runnable, Timeouts.getCallScreeningTimeoutMillis(mContext.getContentResolver()));
+            }.prepare(), Timeouts.getCallScreeningTimeoutMillis(mContext.getContentResolver()));
         }
     }
 
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 085b03d..fbb35ba 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -400,15 +400,16 @@
             // Play tone if it is one of the dialpad digits, canceling out the previously queued
             // up stopTone runnable since playing a new tone automatically stops the previous tone.
             if (mStopTone != null) {
-                mHandler.removeCallbacks(mStopTone);
+                mHandler.removeCallbacks(mStopTone.getRunnableToCancel());
+                mStopTone.cancel();
             }
 
             mDtmfLocalTonePlayer.playTone(call, nextChar);
 
             // TODO: Create a LockedRunnable class that does the synchronization automatically.
-            mStopTone = new Runnable() {
+            mStopTone = new Runnable("CM.oPDC") {
                 @Override
-                public void run() {
+                public void loggedRun() {
                     synchronized (mLock) {
                         // Set a timeout to stop the tone in case there isn't another tone to
                         // follow.
@@ -416,15 +417,15 @@
                     }
                 }
             };
-            mHandler.postDelayed(
-                    mStopTone,
+            mHandler.postDelayed(mStopTone.prepare(),
                     Timeouts.getDelayBetweenDtmfTonesMillis(mContext.getContentResolver()));
         } else if (nextChar == 0 || nextChar == TelecomManager.DTMF_CHARACTER_WAIT ||
                 nextChar == TelecomManager.DTMF_CHARACTER_PAUSE) {
             // Stop the tone if a tone is playing, removing any other stopTone callbacks since
             // the previous tone is being stopped anyway.
             if (mStopTone != null) {
-                mHandler.removeCallbacks(mStopTone);
+                mHandler.removeCallbacks(mStopTone.getRunnableToCancel());
+                mStopTone.cancel();
             }
             mDtmfLocalTonePlayer.stopTone(call);
         } else {
@@ -467,9 +468,9 @@
     @Override
     public boolean onCanceledViaNewOutgoingCallBroadcast(final Call call) {
         mPendingCallsToDisconnect.add(call);
-        mHandler.postDelayed(new Runnable() {
+        mHandler.postDelayed(new Runnable("CM.oCVNOCB") {
             @Override
-            public void run() {
+            public void loggedRun() {
                 synchronized (mLock) {
                     if (mPendingCallsToDisconnect.remove(call)) {
                         Log.i(this, "Delayed disconnection of call: %s", call);
@@ -477,7 +478,7 @@
                     }
                 }
             }
-        }, Timeouts.getNewOutgoingCallCancelMillis(mContext.getContentResolver()));
+        }.prepare(), Timeouts.getNewOutgoingCallCancelMillis(mContext.getContentResolver()));
 
         return true;
     }
diff --git a/src/com/android/server/telecom/CreateConnectionTimeout.java b/src/com/android/server/telecom/CreateConnectionTimeout.java
index 52a4643..69cc129 100644
--- a/src/com/android/server/telecom/CreateConnectionTimeout.java
+++ b/src/com/android/server/telecom/CreateConnectionTimeout.java
@@ -29,7 +29,7 @@
 /**
  * Registers a timeout for a call and disconnects the call when the timeout expires.
  */
-final class CreateConnectionTimeout implements Runnable {
+final class CreateConnectionTimeout extends Runnable {
     private final Context mContext;
     private final PhoneAccountRegistrar mPhoneAccountRegistrar;
     private final ConnectionServiceWrapper mConnectionService;
@@ -40,6 +40,7 @@
 
     CreateConnectionTimeout(Context context, PhoneAccountRegistrar phoneAccountRegistrar,
             ConnectionServiceWrapper service, Call call) {
+        super("CCT");
         mContext = context;
         mPhoneAccountRegistrar = phoneAccountRegistrar;
         mConnectionService = service;
@@ -85,7 +86,7 @@
         if (timeoutLengthMillis <= 0) {
             Log.d(this, "registerTimeout, timeout set to %d, skipping", timeoutLengthMillis);
         } else {
-            mHandler.postDelayed(this, timeoutLengthMillis);
+            mHandler.postDelayed(prepare(), timeoutLengthMillis);
         }
     }
 
@@ -93,6 +94,7 @@
         Log.d(this, "unregisterTimeout");
         mIsRegistered = false;
         mHandler.removeCallbacksAndMessages(null);
+        cancel();
     }
 
     boolean isCallTimedOut() {
@@ -100,7 +102,7 @@
     }
 
     @Override
-    public void run() {
+    public void loggedRun() {
         if (mIsRegistered && isCallBeingPlaced(mCall)) {
             Log.i(this, "run, call timed out, calling disconnect");
             mIsCallTimedOut = true;
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index 4789318..41c99db 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -219,27 +219,18 @@
             /** Let's add a 2 second delay before we send unbind to the services to hopefully
              *  give them enough time to process all the pending messages.
              */
-            final Session subsession = Log.createSubsession();
             Handler handler = new Handler(Looper.getMainLooper());
-            final Runnable runnableUnbind = new Runnable() {
+            handler.postDelayed(new Runnable("ICC.oCR") {
                 @Override
-                public void run() {
-                    try {
-                        Log.continueSession(subsession, "ICC.oCR");
-                        synchronized (mLock) {
-                            // Check again to make sure there are no active calls.
-                            if (mCallsManager.getCalls().isEmpty()) {
-                                unbindFromServices();
-                            }
+                public void loggedRun() {
+                    synchronized (mLock) {
+                        // Check again to make sure there are no active calls.
+                        if (mCallsManager.getCalls().isEmpty()) {
+                            unbindFromServices();
                         }
-                    } finally {
-                        Log.endSession();
                     }
                 }
-            };
-            handler.postDelayed(
-                    runnableUnbind,
-                    Timeouts.getCallRemoveUnbindInCallServicesDelay(
+            }.prepare(), Timeouts.getCallRemoveUnbindInCallServicesDelay(
                             mContext.getContentResolver()));
         }
         call.removeListener(mCallListener);
diff --git a/src/com/android/server/telecom/InCallTonePlayer.java b/src/com/android/server/telecom/InCallTonePlayer.java
index 77406d3..78c1395 100644
--- a/src/com/android/server/telecom/InCallTonePlayer.java
+++ b/src/com/android/server/telecom/InCallTonePlayer.java
@@ -275,8 +275,9 @@
 
     private void cleanUpTonePlayer() {
         // Release focus on the main thread.
-        mMainThreadHandler.post(new Runnable() {
-            @Override public void run() {
+        mMainThreadHandler.post(new Runnable("ICTP.cUTP") {
+            @Override
+            public void loggedRun() {
                 synchronized (mLock) {
                     if (sTonesPlaying == 0) {
                         Log.wtf(this, "Over-releasing focus for tone player.");
@@ -285,6 +286,6 @@
                     }
                 }
             }
-        });
+        }.prepare());
     }
 }
diff --git a/src/com/android/server/telecom/Log.java b/src/com/android/server/telecom/Log.java
index 09cfa28..5e2dc9d 100644
--- a/src/com/android/server/telecom/Log.java
+++ b/src/com/android/server/telecom/Log.java
@@ -256,9 +256,9 @@
     @VisibleForTesting
     public static Handler sSessionCleanupHandler = new Handler(Looper.getMainLooper());
     @VisibleForTesting
-    public static Runnable sCleanStaleSessions = new Runnable() {
+    public static Runnable sCleanStaleSessions = new Runnable("L.cSS") {
         @Override
-        public void run() {
+        public void loggedRun() {
             cleanupStaleSessions(getSessionCleanupTimeoutMs());
         }
     };
@@ -371,7 +371,11 @@
 
     private static synchronized void resetStaleSessionTimer() {
         sSessionCleanupHandler.removeCallbacksAndMessages(null);
-        sSessionCleanupHandler.postDelayed(sCleanStaleSessions, getSessionCleanupTimeoutMs());
+        // Will be null in Log Testing
+        if (sCleanStaleSessions != null) {
+            sSessionCleanupHandler.postDelayed(sCleanStaleSessions.prepare(),
+                    getSessionCleanupTimeoutMs());
+        }
     }
 
     /**
diff --git a/src/com/android/server/telecom/Runnable.java b/src/com/android/server/telecom/Runnable.java
new file mode 100644
index 0000000..ce5b6d2
--- /dev/null
+++ b/src/com/android/server/telecom/Runnable.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.server.telecom;
+
+/**
+ * Encapsulates session logging in a Runnable to reduce code duplication when continuing subsessions
+ * in a handler/thread.
+ */
+public abstract class Runnable {
+
+    private Session mSubsession;
+    private final String mSubsessionName;
+    private Object mLock = new Object();
+    private final java.lang.Runnable mRunnable = new java.lang.Runnable() {
+            @Override
+            public void run() {
+                synchronized (mLock) {
+                    try {
+                        Log.continueSession(mSubsession, mSubsessionName);
+                        loggedRun();
+                    } finally {
+                        Log.endSession();
+                        mSubsession = null;
+                    }
+                }
+            }
+        };
+
+    public Runnable(String subsessionName) {
+        mSubsessionName = subsessionName;
+    }
+
+    /**
+     * Return the runnable that will be canceled in the handler queue.
+     * @return Runnable object to cancel.
+     */
+    public final java.lang.Runnable getRunnableToCancel() {
+        return mRunnable;
+    }
+
+    /**
+     * Creates a Runnable and a logging subsession that can be used in a handler/thread. Be sure to
+     * call cancel() if this session is never going to be run (removed from a handler queue, for
+     * for example).
+     * @return A Java Runnable that can be used in a handler queue or thread.
+     */
+    public java.lang.Runnable prepare() {
+        cancel();
+        mSubsession = Log.createSubsession();
+        return mRunnable;
+    }
+
+    /**
+     * This method is used to clean up the active session if the Runnable gets removed from a
+     * handler and is never run.
+     */
+    public void cancel() {
+        synchronized (mLock) {
+            Log.cancelSubsession(mSubsession);
+            mSubsession = null;
+        }
+    }
+
+    /**
+     * The method that will be run in the handler/thread.
+     */
+    abstract public void loggedRun();
+
+}
diff --git a/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java b/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
index 6bd7951..67ca641 100644
--- a/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
+++ b/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
@@ -21,8 +21,6 @@
 import android.content.ComponentName;
 import android.content.ContentProvider;
 import android.content.pm.PackageManager.NameNotFoundException;
-import android.database.DatabaseUtils;
-import android.os.UserManager;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
 
@@ -37,9 +35,9 @@
 import com.android.server.telecom.MissedCallNotifier;
 import com.android.server.telecom.PhoneAccountRegistrar;
 import com.android.server.telecom.R;
+import com.android.server.telecom.Runnable;
 import com.android.server.telecom.TelecomBroadcastIntentProcessor;
 import com.android.server.telecom.TelecomSystem;
-import com.android.server.telecom.UserUtil;
 import com.android.server.telecom.components.TelecomBroadcastReceiver;
 
 import android.app.Notification;
@@ -50,7 +48,6 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.database.Cursor;
 import android.graphics.Bitmap;
@@ -180,9 +177,9 @@
     }
 
     private void markMissedCallsAsRead(final UserHandle userHandle) {
-        AsyncTask.execute(new Runnable() {
+        AsyncTask.execute(new Runnable("MCNI.mMCAR") {
             @Override
-            public void run() {
+            public void loggedRun() {
                 // Clear the list of new missed calls from the call log.
                 ContentValues values = new ContentValues();
                 values.put(Calls.NEW, 0);
@@ -202,7 +199,7 @@
                     Log.w(this, "ContactsProvider update command failed", e);
                 }
             }
-        });
+        }.prepare());
     }
 
     /**
diff --git a/tests/src/com/android/server/telecom/tests/LogTest.java b/tests/src/com/android/server/telecom/tests/LogTest.java
index 68ccb53..d6c534e 100644
--- a/tests/src/com/android/server/telecom/tests/LogTest.java
+++ b/tests/src/com/android/server/telecom/tests/LogTest.java
@@ -23,6 +23,7 @@
 import android.os.Message;
 
 import com.android.internal.os.SomeArgs;
+import com.android.server.telecom.Runnable;
 import com.android.server.telecom.Session;
 import com.android.server.telecom.SystemLoggingContainer;
 import com.android.server.telecom.Log;
@@ -192,7 +193,7 @@
     };
 
     private AtomicInteger mCompleteCount;
-    class LogTestRunnable implements Runnable {
+    class LogTestRunnable implements java.lang.Runnable {
         private String mshortMethodName;
         public LogTestRunnable(String shortMethodName) {
             mshortMethodName = shortMethodName;
@@ -414,7 +415,7 @@
         // Don't end session (Oops!)
         Log.startSession(sessionName);
         internalDanglingMethod();
-        Log.sSessionCleanupHandler.postDelayed(new Runnable() {
+        Log.sSessionCleanupHandler.postDelayed(new java.lang.Runnable() {
             @Override
             public void run() {
                 android.util.Log.i(TESTING_TAG, "Running Test SessionCleanupHandler method.");