From c14c020053d875d871493bca20d5d909f28f02e4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 16 Nov 2011 15:06:00 +0100 Subject: [PATCH] Tests: 5 second delay for LinphoneService ready --- AndroidManifest.xml | 4 ++-- src/org/linphone/LinphoneService.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 374c32592..14cbb02d4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -86,12 +86,12 @@ - + - + diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index b94896780..161c6e1fe 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -69,7 +69,12 @@ public final class LinphoneService extends Service implements LinphoneServiceLis private Handler mHandler = new Handler(); private static LinphoneService instance; - public static boolean isReady() { return (instance!=null); } +// private static boolean mTestDelayElapsed; // add a timer for testing + private static boolean mTestDelayElapsed = true; // no timer + + public static boolean isReady() { + return mTestDelayElapsed && instance!=null; + } /** * @throws RuntimeException service not instantiated @@ -147,6 +152,15 @@ public final class LinphoneService extends Service implements LinphoneServiceLis } startForegroundCompat(NOTIF_ID, mNotif); + + if (!mTestDelayElapsed) { + // Only used when testing. Simulates a 5 seconds delay for launching service + mHandler.postDelayed(new Runnable() { + @Override public void run() { + mTestDelayElapsed = true; + } + }, 5000); + } }