From 6a4cebdb4ccc974d04f125847c03fddec18b2b9f Mon Sep 17 00:00:00 2001 From: zachh Date: Tue, 24 Oct 2017 17:10:06 -0700 Subject: Improved dagger support for executor services. By always creating executor services via dagger, we can now bind special versions during espresso tests that can implement idling resources. We should be using idling resources during espresso tests for threads that we create ourselves, because espresso does not know about them. Hopefully this reduces some of the flakiness of espresso tests that we have today. This required converting all existing calls to DialerExecutors to pass a context used to fetch the component, and also required creating new application classes for espresso tests. Test: temporarily added a task which just slept to DialtactsActivity and verified that its integration test failed due to idling resource timeout PiperOrigin-RevId: 173334773 Change-Id: I876a93022d235d62cfc377bf5b06687e21a34758 --- java/com/android/incallui/ContactInfoCache.java | 6 ++++-- java/com/android/incallui/ContactsAsyncHelper.java | 2 +- java/com/android/incallui/InCallPresenter.java | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'java/com/android/incallui') diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java index 272c2b776..2735461b2 100644 --- a/java/com/android/incallui/ContactInfoCache.java +++ b/java/com/android/incallui/ContactInfoCache.java @@ -86,8 +86,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { private final ConcurrentHashMap mInfoMap = new ConcurrentHashMap<>(); private final Map> mCallBacks = new ArrayMap<>(); private int mQueryId; - private final DialerExecutor cachedNumberLookupExecutor = - DialerExecutors.createNonUiTaskBuilder(new CachedNumberLookupWorker()).build(); + private final DialerExecutor cachedNumberLookupExecutor; private static class CachedNumberLookupWorker implements Worker { @Nullable @@ -126,6 +125,8 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { Trace.beginSection("ContactInfoCache constructor"); mContext = context; mPhoneNumberService = Bindings.get(context).newPhoneNumberService(context); + cachedNumberLookupExecutor = + DialerExecutors.createNonUiTaskBuilder(mContext, new CachedNumberLookupWorker()).build(); Trace.endSection(); } @@ -718,6 +719,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { int queryId; /** The phone number without any changes to display to the user (ex: cnap...) */ String originalPhoneNumber; + boolean shouldShowLocation; boolean isBusiness; diff --git a/java/com/android/incallui/ContactsAsyncHelper.java b/java/com/android/incallui/ContactsAsyncHelper.java index 6237ca3e5..2e893b01a 100644 --- a/java/com/android/incallui/ContactsAsyncHelper.java +++ b/java/com/android/incallui/ContactsAsyncHelper.java @@ -94,7 +94,7 @@ public class ContactsAsyncHelper { args.displayPhotoUri = displayPhotoUri; args.listener = listener; - DialerExecutors.createNonUiTaskBuilder(new Worker()) + DialerExecutors.createNonUiTaskBuilder(context, new Worker()) .onSuccess( output -> { if (args.listener != null) { diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index b8a2baa00..8535cbc3e 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -45,7 +45,7 @@ import com.android.dialer.blocking.FilteredNumberCompat; import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DefaultDialerExecutorFactory; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.InteractionEvent; @@ -373,7 +373,9 @@ public class InCallPresenter implements CallList.Listener { mCallList.addListener(this); // Create spam call list listener and add it to the list of listeners - mSpamCallListListener = new SpamCallListListener(context, new DefaultDialerExecutorFactory()); + mSpamCallListListener = + new SpamCallListListener( + context, DialerExecutorComponent.get(context).dialerExecutorFactory()); mCallList.addListener(mSpamCallListListener); VideoPauseController.getInstance().setUp(this); -- cgit v1.2.3