diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-23 01:46:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-23 01:46:59 +0000 |
commit | c979f257060fbcb95cbd4871461dd5eb1ae04f1b (patch) | |
tree | 9ae99486deaf71b55a3f2a635ff95581d703c90b /java/com/android/incallui | |
parent | e5a20898faa4c66758a30d12e9245f15d6685a37 (diff) | |
parent | 0e00f578d641440c5ddc4da48ab86eabbc21d403 (diff) |
Merge changes I1360b7ee,I587f5f4d,I8cb26827,Ib8766a89,I952f4935
* changes:
Implement System blocked number
Don't let the FAB obscure the last item of speed dial/call log/voicemail.
Changed PhoneLookup#lookup to accept a DialerPhoneNumber.
For call log entry labels, remove the dot after abbreviated time units.
Implement blocking commands
Diffstat (limited to 'java/com/android/incallui')
-rw-r--r-- | java/com/android/incallui/PhoneLookupHistoryRecorder.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/java/com/android/incallui/PhoneLookupHistoryRecorder.java b/java/com/android/incallui/PhoneLookupHistoryRecorder.java index 8517deb65..abbf934f0 100644 --- a/java/com/android/incallui/PhoneLookupHistoryRecorder.java +++ b/java/com/android/incallui/PhoneLookupHistoryRecorder.java @@ -19,18 +19,23 @@ import android.content.ContentValues; import android.content.Context; import android.support.annotation.Nullable; import android.telecom.Call; +import com.android.dialer.DialerPhoneNumber; import com.android.dialer.buildtype.BuildType; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.phonelookup.PhoneLookupComponent; import com.android.dialer.phonelookup.PhoneLookupInfo; import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract.PhoneLookupHistory; +import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil; import com.android.dialer.telecom.TelecomCallUtil; import com.google.common.base.Optional; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.i18n.phonenumbers.PhoneNumberUtil; /** * Fetches the current {@link PhoneLookupInfo} for the provided call and writes it to the @@ -46,10 +51,29 @@ final class PhoneLookupHistoryRecorder { if (!(BuildType.get() == BuildType.BUGFOOD || LogUtil.isDebugEnabled())) { return; } - ListenableFuture<PhoneLookupInfo> future = - PhoneLookupComponent.get(appContext).phoneLookup().lookup(call); + + ListeningExecutorService backgroundExecutor = + DialerExecutorComponent.get(appContext).backgroundExecutor(); + + ListenableFuture<DialerPhoneNumber> numberFuture = + backgroundExecutor.submit( + () -> { + DialerPhoneNumberUtil dialerPhoneNumberUtil = + new DialerPhoneNumberUtil(PhoneNumberUtil.getInstance()); + return dialerPhoneNumberUtil.parse( + TelecomCallUtil.getNumber(call), + TelecomCallUtil.getCountryCode(appContext, call).orNull()); + }); + + ListenableFuture<PhoneLookupInfo> infoFuture = + Futures.transformAsync( + numberFuture, + dialerPhoneNumber -> + PhoneLookupComponent.get(appContext).phoneLookup().lookup(dialerPhoneNumber), + MoreExecutors.directExecutor()); + Futures.addCallback( - future, + infoFuture, new FutureCallback<PhoneLookupInfo>() { @Override public void onSuccess(@Nullable PhoneLookupInfo result) { @@ -79,6 +103,6 @@ final class PhoneLookupHistoryRecorder { "PhoneLookupHistoryRecorder.onFailure", "could not write PhoneLookupHistory", t); } }, - DialerExecutors.getLowPriorityThreadPool(appContext)); + backgroundExecutor); } } |