diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallPresenter.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallPresenter.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index c3ca6de85..0103f61ed 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -27,6 +27,7 @@ import android.database.ContentObserver; import android.graphics.Point; import android.os.Bundle; import android.os.Handler; +import android.os.SystemClock; import android.provider.CallLog; import android.telecom.DisconnectCause; import android.telecom.PhoneAccount; @@ -56,6 +57,7 @@ import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.util.TelecomUtil; +import com.android.incallui.spam.SpamCallListListener; import com.android.incallui.util.TelecomCallUtil; import com.android.incalluibind.ObjectFactory; @@ -123,6 +125,7 @@ public class InCallPresenter implements CallList.Listener, private InCallCameraManager mInCallCameraManager = null; private AnswerPresenter mAnswerPresenter = new AnswerPresenter(); private FilteredNumberAsyncQueryHandler mFilteredQueryHandler; + private CallList.Listener mSpamCallListListener; /** * Whether or not we are currently bound and waiting for Telecom to send us a new call. @@ -345,13 +348,18 @@ public class InCallPresenter implements CallList.Listener, // will kick off an update and the whole process can start. mCallList.addListener(this); + // Create spam call list listener and add it to the list of listeners + mSpamCallListListener = new SpamCallListListener(context); + mCallList.addListener(mSpamCallListListener); + VideoPauseController.getInstance().setUp(this); InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this); mFilteredQueryHandler = new FilteredNumberAsyncQueryHandler(context.getContentResolver()); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); - mCallList.setFilteredNumberQueryHandler(mFilteredQueryHandler); + mCallList.setExtendedCallInfoService( + com.android.dialerbind.ObjectFactory.newExtendedCallInfoService(context)); Log.d(this, "Finished InCallPresenter.setUp"); } @@ -506,14 +514,16 @@ public class InCallPresenter implements CallList.Listener, } public void onCallAdded(final android.telecom.Call call) { + LatencyReport latencyReport = new LatencyReport(call); if (shouldAttemptBlocking(call)) { - maybeBlockCall(call); + maybeBlockCall(call, latencyReport); } else { + latencyReport.onCallBlockingDone(); if (call.getDetails() .hasProperty(CallSdkCompat.Details.PROPERTY_IS_EXTERNAL_CALL)) { mExternalCallList.onCallAdded(call); } else { - mCallList.onCallAdded(call); + mCallList.onCallAdded(call, latencyReport); } } @@ -547,7 +557,8 @@ public class InCallPresenter implements CallList.Listener, * checking whether a function is blocked does not return in a reasonable time, we proceed * with adding the call anyways. */ - private void maybeBlockCall(final android.telecom.Call call) { + private void maybeBlockCall(final android.telecom.Call call, + final LatencyReport latencyReport) { final String countryIso = GeoUtil.getCurrentCountryIso(mContext); final String number = TelecomCallUtil.getNumber(call); final long timeAdded = System.currentTimeMillis(); @@ -563,7 +574,8 @@ public class InCallPresenter implements CallList.Listener, final Runnable runnable = new Runnable() { public void run() { hasTimedOut.set(true); - mCallList.onCallAdded(call); + latencyReport.onCallBlockingDone(); + mCallList.onCallAdded(call, latencyReport); } }; handler.postDelayed(runnable, BLOCK_QUERY_TIMEOUT_MS); @@ -576,7 +588,8 @@ public class InCallPresenter implements CallList.Listener, } if (id == null) { if (!hasTimedOut.get()) { - mCallList.onCallAdded(call); + latencyReport.onCallBlockingDone(); + mCallList.onCallAdded(call, latencyReport); } } else { Log.i(this, "Rejecting incoming call from blocked number"); @@ -600,7 +613,9 @@ public class InCallPresenter implements CallList.Listener, Log.d(this, "checkForBlockedCall: invalid number, skipping block checking"); if (!hasTimedOut.get()) { handler.removeCallbacks(runnable); - mCallList.onCallAdded(call); + + latencyReport.onCallBlockingDone(); + mCallList.onCallAdded(call, latencyReport); } } } @@ -1534,6 +1549,7 @@ public class InCallPresenter implements CallList.Listener, if (mCallList != null) { mCallList.removeListener(this); + mCallList.removeListener(mSpamCallListListener); } mCallList = null; @@ -1783,7 +1799,14 @@ public class InCallPresenter implements CallList.Listener, if (call == null) { return getColorsFromPhoneAccountHandle(mPendingPhoneAccountHandle); } else { - return getColorsFromPhoneAccountHandle(call.getAccountHandle()); + if (call.isSpam()) { + Resources resources = mContext.getResources(); + return new InCallUIMaterialColorMapUtils( + resources).calculatePrimaryAndSecondaryColor( + resources.getColor(R.color.incall_call_spam_background_color)); + } else { + return getColorsFromPhoneAccountHandle(call.getAccountHandle()); + } } } |