Search in sources :

Example 1 with FilteredNumberAsyncQueryHandler

use of com.android.dialer.blocking.FilteredNumberAsyncQueryHandler in project android_packages_apps_Dialer by LineageOS.

the class CallLogFragment method setupData.

protected void setupData() {
    int activityType = mIsCallLogActivity ? CallLogAdapter.ACTIVITY_TYPE_CALL_LOG : CallLogAdapter.ACTIVITY_TYPE_DIALTACTS;
    String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
    mContactInfoCache = new ContactInfoCache(ExpirableCacheHeadlessFragment.attach((AppCompatActivity) getActivity()).getRetainedCache(), new ContactInfoHelper(getActivity(), currentCountryIso), mOnContactInfoChangedListener);
    mAdapter = Bindings.getLegacy(getActivity()).newCallLogAdapter(getActivity(), mRecyclerView, this, this, activityType == CallLogAdapter.ACTIVITY_TYPE_DIALTACTS ? (CallLogAdapter.OnActionModeStateChangedListener) getActivity() : null, new CallLogCache(getActivity()), mContactInfoCache, getVoicemailPlaybackPresenter(), new FilteredNumberAsyncQueryHandler(getActivity()), activityType);
    mRecyclerView.setAdapter(mAdapter);
    fetchCalls();
}
Also used : CallLogCache(com.android.dialer.app.calllog.calllogcache.CallLogCache) ContactInfoHelper(com.android.dialer.phonenumbercache.ContactInfoHelper) AppCompatActivity(android.support.v7.app.AppCompatActivity) FilteredNumberAsyncQueryHandler(com.android.dialer.blocking.FilteredNumberAsyncQueryHandler) ContactInfoCache(com.android.dialer.app.contactinfo.ContactInfoCache)

Example 2 with FilteredNumberAsyncQueryHandler

use of com.android.dialer.blocking.FilteredNumberAsyncQueryHandler in project android_packages_apps_Dialer by LineageOS.

the class CallList method onCallAdded.

public void onCallAdded(final Context context, final android.telecom.Call telecomCall, LatencyReport latencyReport) {
    Trace.beginSection("onCallAdded");
    final DialerCall call = new DialerCall(context, this, telecomCall, latencyReport, true);
    logSecondIncomingCall(context, call);
    EnrichedCallManager manager = EnrichedCallComponent.get(context).getEnrichedCallManager();
    manager.registerCapabilitiesListener(call);
    manager.registerStateChangedListener(call);
    final DialerCallListenerImpl dialerCallListener = new DialerCallListenerImpl(call);
    call.addListener(dialerCallListener);
    LogUtil.d("CallList.onCallAdded", "callState=" + call.getState());
    if (Spam.get(context).isSpamEnabled()) {
        String number = TelecomCallUtil.getNumber(telecomCall);
        Spam.get(context).checkSpamStatus(number, null, new SpamBindings.Listener() {

            @Override
            public void onComplete(boolean isSpam) {
                boolean isIncomingCall = call.getState() == DialerCall.State.INCOMING || call.getState() == DialerCall.State.CALL_WAITING;
                if (isSpam) {
                    if (!isIncomingCall) {
                        LogUtil.i("CallList.onCallAdded", "marking spam call as not spam because it's not an incoming call");
                        isSpam = false;
                    } else if (isPotentialEmergencyCallback(context, call)) {
                        LogUtil.i("CallList.onCallAdded", "marking spam call as not spam because an emergency call was made on this" + " device recently");
                        isSpam = false;
                    }
                }
                if (isIncomingCall) {
                    Logger.get(context).logCallImpression(isSpam ? DialerImpression.Type.INCOMING_SPAM_CALL : DialerImpression.Type.INCOMING_NON_SPAM_CALL, call.getUniqueCallId(), call.getTimeAddedMs());
                }
                call.setSpam(isSpam);
                dialerCallListener.onDialerCallUpdate();
            }
        });
        updateUserMarkedSpamStatus(call, context, number, dialerCallListener);
    }
    FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(context);
    filteredNumberAsyncQueryHandler.isBlockedNumber(new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() {

        @Override
        public void onCheckComplete(Integer id) {
            if (id != null && id != FilteredNumberAsyncQueryHandler.INVALID_ID) {
                call.setBlockedStatus(true);
                dialerCallListener.onDialerCallUpdate();
            }
        }
    }, call.getNumber(), GeoUtil.getCurrentCountryIso(context));
    if (call.getState() == DialerCall.State.INCOMING || call.getState() == DialerCall.State.CALL_WAITING) {
        onIncoming(call);
    } else {
        dialerCallListener.onDialerCallUpdate();
    }
    if (call.getState() != State.INCOMING) {
        // Only report outgoing calls
        ShortcutUsageReporter.onOutgoingCallAdded(context, call.getNumber());
    }
    Trace.endSection();
}
Also used : SpamBindings(com.android.dialer.spam.SpamBindings) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager) FilteredNumberAsyncQueryHandler(com.android.dialer.blocking.FilteredNumberAsyncQueryHandler)

Example 3 with FilteredNumberAsyncQueryHandler

use of com.android.dialer.blocking.FilteredNumberAsyncQueryHandler in project android_packages_apps_Dialer by LineageOS.

the class InCallServiceImpl method onBind.

@Override
public IBinder onBind(Intent intent) {
    final Context context = getApplicationContext();
    final ContactInfoCache contactInfoCache = ContactInfoCache.getInstance(context);
    InCallPresenter.getInstance().setUp(context, CallList.getInstance(), new ExternalCallList(), new StatusBarNotifier(context, contactInfoCache), new ExternalCallNotifier(context, contactInfoCache), contactInfoCache, new ProximitySensor(context, AudioModeProvider.getInstance(), new AccelerometerListener(context)), new FilteredNumberAsyncQueryHandler(context));
    InCallPresenter.getInstance().onServiceBind();
    InCallPresenter.getInstance().maybeStartRevealAnimation(intent);
    TelecomAdapter.getInstance().setInCallService(this);
    if (ReturnToCallController.isEnabled(this)) {
        returnToCallController = new ReturnToCallController(this);
    }
    return super.onBind(intent);
}
Also used : Context(android.content.Context) FilteredNumberAsyncQueryHandler(com.android.dialer.blocking.FilteredNumberAsyncQueryHandler) ExternalCallList(com.android.incallui.call.ExternalCallList)

Example 4 with FilteredNumberAsyncQueryHandler

use of com.android.dialer.blocking.FilteredNumberAsyncQueryHandler in project android_packages_apps_Dialer by LineageOS.

the class SpamNotificationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    LogUtil.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setFinishOnTouchOutside(true);
    filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(this);
    cancelNotification();
}
Also used : FilteredNumberAsyncQueryHandler(com.android.dialer.blocking.FilteredNumberAsyncQueryHandler)

Example 5 with FilteredNumberAsyncQueryHandler

use of com.android.dialer.blocking.FilteredNumberAsyncQueryHandler in project android_packages_apps_Dialer by LineageOS.

the class SpamNotificationService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LogUtil.d(TAG, "onStartCommand");
    if (intent == null) {
        LogUtil.d(TAG, "Null intent");
        stopSelf();
        // Return {@link #START_NOT_STICKY} so service is not restarted.
        return START_NOT_STICKY;
    }
    String number = intent.getStringExtra(EXTRA_PHONE_NUMBER);
    int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, 1);
    String countryIso = GeoUtil.getCurrentCountryIso(this);
    ContactLookupResult.Type contactLookupResultType = ContactLookupResult.Type.forNumber(intent.getIntExtra(EXTRA_CONTACT_LOOKUP_RESULT_TYPE, 0));
    ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(number, notificationId);
    switch(intent.getAction()) {
        case SpamNotificationActivity.ACTION_MARK_NUMBER_AS_SPAM:
            logCallImpression(intent, DialerImpression.Type.SPAM_NOTIFICATION_SERVICE_ACTION_MARK_NUMBER_AS_SPAM);
            Spam.get(this).reportSpamFromAfterCallNotification(number, countryIso, CallLog.Calls.INCOMING_TYPE, ReportingLocation.Type.FEEDBACK_PROMPT, contactLookupResultType);
            new FilteredNumberAsyncQueryHandler(this).blockNumber(null, number, countryIso);
            break;
        case SpamNotificationActivity.ACTION_MARK_NUMBER_AS_NOT_SPAM:
            logCallImpression(intent, DialerImpression.Type.SPAM_NOTIFICATION_SERVICE_ACTION_MARK_NUMBER_AS_NOT_SPAM);
            Spam.get(this).reportNotSpamFromAfterCallNotification(number, countryIso, CallLog.Calls.INCOMING_TYPE, ReportingLocation.Type.FEEDBACK_PROMPT, contactLookupResultType);
            break;
        // fall out
        default:
    }
    // TODO: call stopSelf() after async tasks complete (b/28441936)
    stopSelf();
    return START_NOT_STICKY;
}
Also used : ContactLookupResult(com.android.dialer.logging.ContactLookupResult) NotificationManager(android.app.NotificationManager) FilteredNumberAsyncQueryHandler(com.android.dialer.blocking.FilteredNumberAsyncQueryHandler)

Aggregations

FilteredNumberAsyncQueryHandler (com.android.dialer.blocking.FilteredNumberAsyncQueryHandler)8 Context (android.content.Context)2 NotificationManager (android.app.NotificationManager)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 WorkerThread (android.support.annotation.WorkerThread)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 TextUtils (android.text.TextUtils)1 ArrayMap (android.util.ArrayMap)1 R (com.android.dialer.app.R)1 NewCall (com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall)1 CallLogCache (com.android.dialer.app.calllog.calllogcache.CallLogCache)1 ContactInfoCache (com.android.dialer.app.contactinfo.ContactInfoCache)1 BlockedNumbersAutoMigrator (com.android.dialer.blocking.BlockedNumbersAutoMigrator)1 FilteredNumbersUtil (com.android.dialer.blocking.FilteredNumbersUtil)1 Assert (com.android.dialer.common.Assert)1 LogUtil (com.android.dialer.common.LogUtil)1 DefaultDialerExecutorFactory (com.android.dialer.common.concurrent.DefaultDialerExecutorFactory)1 Worker (com.android.dialer.common.concurrent.DialerExecutor.Worker)1 DialerExecutors (com.android.dialer.common.concurrent.DialerExecutors)1