mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Kill+restart tasks before/after decoder init.
Bug 19625976. Change-Id: I6d8b0d2b0a77ccda1bfc914501cf568b92862980
This commit is contained in:
parent
bd1bc4067f
commit
375035905d
@ -26,12 +26,17 @@ import com.android.inputmethod.latin.settings.SettingsValues;
|
||||
public class StatsUtilsManager {
|
||||
|
||||
private static final StatsUtilsManager sInstance = new StatsUtilsManager();
|
||||
private static StatsUtilsManager sTestInstance = null;
|
||||
|
||||
/**
|
||||
* @return the singleton instance of {@link StatsUtilsManager}.
|
||||
*/
|
||||
public static StatsUtilsManager getInstance() {
|
||||
return sInstance;
|
||||
return sTestInstance != null ? sTestInstance : sInstance;
|
||||
}
|
||||
|
||||
public static void setTestInstance(final StatsUtilsManager testInstance) {
|
||||
sTestInstance = testInstance;
|
||||
}
|
||||
|
||||
public void onCreate(final Context context, final DictionaryFacilitator dictionaryFacilitator) {
|
||||
|
@ -23,7 +23,6 @@ import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -74,6 +73,16 @@ public class ExecutorUtils {
|
||||
return sExecutorService;
|
||||
}
|
||||
|
||||
public static void killTasks() {
|
||||
getBackgroundExecutor().shutdownNow();
|
||||
try {
|
||||
getBackgroundExecutor().awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
Log.wtf(TAG, "Failed to shut down background task.");
|
||||
throw new IllegalStateException("Failed to shut down background task.");
|
||||
}
|
||||
}
|
||||
|
||||
public static Runnable chain(final Runnable... runnables) {
|
||||
return new RunnableChain(runnables);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user