Log interrupted tasks in AOSP.
Bug 19987461. Change-Id: Ia2714f555146f8f31a6d8c61f555d2b6fecdab7dmain
parent
87eb7ac29c
commit
5a53505fe4
|
@ -650,7 +650,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
reloadDictionaryIfRequired();
|
||||
final String dictName = mDictName;
|
||||
final File dictFile = mDictFile;
|
||||
final AsyncResultHolder<DictionaryStats> result = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<DictionaryStats> result =
|
||||
new AsyncResultHolder<>("DictionaryStats");
|
||||
asyncExecuteTaskWithLock(mLock.readLock(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -724,7 +725,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
*/
|
||||
public WordProperty[] getWordPropertiesForSyncing() {
|
||||
reloadDictionaryIfRequired();
|
||||
final AsyncResultHolder<WordProperty[]> result = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<WordProperty[]> result =
|
||||
new AsyncResultHolder<>("WordPropertiesForSync");
|
||||
asyncExecuteTaskWithLock(mLock.readLock(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -1407,7 +1407,7 @@ public final class InputLogic {
|
|||
return;
|
||||
}
|
||||
|
||||
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<>("Suggest");
|
||||
mInputLogicHandler.getSuggestedWords(inputStyle, SuggestedWords.NOT_A_SEQUENCE_NUMBER,
|
||||
new OnGetSuggestedWordsCallback() {
|
||||
@Override
|
||||
|
|
|
@ -209,7 +209,7 @@ public class SettingsValues {
|
|||
prefs, DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
|
||||
defaultKeyPreviewDismissEndScale);
|
||||
mDisplayOrientation = res.getConfiguration().orientation;
|
||||
mAppWorkarounds = new AsyncResultHolder<>();
|
||||
mAppWorkarounds = new AsyncResultHolder<>("AppWorkarounds");
|
||||
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
|
||||
mInputAttributes.mTargetApplicationPackageName);
|
||||
if (null != packageInfo) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.android.inputmethod.latin.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -29,9 +31,11 @@ public class AsyncResultHolder<E> {
|
|||
private final Object mLock = new Object();
|
||||
|
||||
private E mResult;
|
||||
private final String mTag;
|
||||
private final CountDownLatch mLatch;
|
||||
|
||||
public AsyncResultHolder() {
|
||||
public AsyncResultHolder(final String tag) {
|
||||
mTag = tag;
|
||||
mLatch = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
|
@ -61,6 +65,7 @@ public class AsyncResultHolder<E> {
|
|||
try {
|
||||
return mLatch.await(timeOut, TimeUnit.MILLISECONDS) ? mResult : defaultValue;
|
||||
} catch (InterruptedException e) {
|
||||
Log.w(mTag, "get() : Interrupted after " + timeOut + " ms");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,27 +45,27 @@ public class AsyncResultHolderTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testGetWithoutSet() {
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
||||
assertEquals(DEFAULT_VALUE, resultValue);
|
||||
}
|
||||
|
||||
public void testGetBeforeSet() {
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS + MARGIN_IN_MILLISECONDS);
|
||||
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
||||
assertEquals(DEFAULT_VALUE, resultValue);
|
||||
}
|
||||
|
||||
public void testGetAfterSet() {
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||
holder.set(SET_VALUE);
|
||||
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
||||
assertEquals(SET_VALUE, resultValue);
|
||||
}
|
||||
|
||||
public void testGetBeforeTimeout() {
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>();
|
||||
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
|
||||
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS - MARGIN_IN_MILLISECONDS);
|
||||
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
|
||||
assertEquals(SET_VALUE, resultValue);
|
||||
|
|
Loading…
Reference in New Issue