Search in sources :

Example 1 with EnrichedCallManager

use of com.android.dialer.enrichedcall.EnrichedCallManager in project android_packages_apps_Dialer by LineageOS.

the class PostCall method promptUserToSendMessage.

private static void promptUserToSendMessage(Activity activity, View rootView) {
    LogUtil.i("PostCall.promptUserToSendMessage", "returned from call, showing post call SnackBar");
    String message = activity.getString(R.string.post_call_message);
    EnrichedCallManager manager = EnrichedCallComponent.get(activity).getEnrichedCallManager();
    EnrichedCallCapabilities capabilities = manager.getCapabilities(getPhoneNumber(activity));
    LogUtil.i("PostCall.promptUserToSendMessage", "number: %s, capabilities: %s", LogUtil.sanitizePhoneNumber(getPhoneNumber(activity)), capabilities);
    boolean isRcsPostCall = capabilities != null && capabilities.supportsPostCall();
    String actionText = isRcsPostCall ? activity.getString(R.string.post_call_add_message) : activity.getString(R.string.post_call_send_message);
    String number = Assert.isNotNull(getPhoneNumber(activity));
    OnClickListener onClickListener = v -> {
        Logger.get(activity).logImpression(DialerImpression.Type.POST_CALL_PROMPT_USER_TO_SEND_MESSAGE_CLICKED);
        activity.startActivity(PostCallActivity.newIntent(activity, number, isRcsPostCall));
    };
    int durationMs = (int) ConfigProviderBindings.get(activity).getLong("post_call_prompt_duration_ms", 8_000);
    activeSnackbar = Snackbar.make(rootView, message, durationMs).setAction(actionText, onClickListener).setActionTextColor(activity.getResources().getColor(R.color.dialer_snackbar_action_text_color));
    activeSnackbar.show();
    Logger.get(activity).logImpression(DialerImpression.Type.POST_CALL_PROMPT_USER_TO_SEND_MESSAGE);
    DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(activity).edit().remove(KEY_POST_CALL_CALL_DISCONNECT_TIME).apply();
}
Also used : Assert(com.android.dialer.common.Assert) Context(android.content.Context) LogUtil(com.android.dialer.common.LogUtil) DialerImpression(com.android.dialer.logging.DialerImpression) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager) Intent(android.content.Intent) ConfigProvider(com.android.dialer.configprovider.ConfigProvider) EnrichedCallComponent(com.android.dialer.enrichedcall.EnrichedCallComponent) PerformanceReport(com.android.dialer.performancereport.PerformanceReport) SharedPreferences(android.content.SharedPreferences) TelephonyManager(android.telephony.TelephonyManager) View(android.view.View) ConfigProviderBindings(com.android.dialer.configprovider.ConfigProviderBindings) Logger(com.android.dialer.logging.Logger) IntentUtil(com.android.dialer.util.IntentUtil) DialerUtils(com.android.dialer.util.DialerUtils) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) Activity(android.app.Activity) EnrichedCallCapabilities(com.android.dialer.enrichedcall.EnrichedCallCapabilities) BaseCallback(android.support.design.widget.BaseTransientBottomBar.BaseCallback) OnClickListener(android.view.View.OnClickListener) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager) OnClickListener(android.view.View.OnClickListener) EnrichedCallCapabilities(com.android.dialer.enrichedcall.EnrichedCallCapabilities)

Example 2 with EnrichedCallManager

use of com.android.dialer.enrichedcall.EnrichedCallManager 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 EnrichedCallManager

use of com.android.dialer.enrichedcall.EnrichedCallManager in project android_packages_apps_Dialer by LineageOS.

the class CallList method onCallRemoved.

public void onCallRemoved(Context context, android.telecom.Call telecomCall) {
    if (mCallByTelecomCall.containsKey(telecomCall)) {
        DialerCall call = mCallByTelecomCall.get(telecomCall);
        Assert.checkArgument(!call.isExternalCall());
        EnrichedCallManager manager = EnrichedCallComponent.get(context).getEnrichedCallManager();
        manager.unregisterCapabilitiesListener(call);
        manager.unregisterStateChangedListener(call);
        // for the same call due to b/24109437.
        if (call.getLogState() != null && !call.getLogState().isLogged) {
            getLegacyBindings(context).logCall(call);
            call.getLogState().isLogged = true;
        }
        if (updateCallInMap(call)) {
            LogUtil.w("CallList.onCallRemoved", "Removing call not previously disconnected " + call.getId());
        }
        call.onRemovedFromCallList();
    }
    if (!hasLiveCall()) {
        DialerCall.clearRestrictedCount();
    }
}
Also used : EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager)

Example 4 with EnrichedCallManager

use of com.android.dialer.enrichedcall.EnrichedCallManager in project android_packages_apps_Dialer by LineageOS.

the class PhoneNumberListAdapter method bindPhoneNumber.

@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
public void bindPhoneNumber(ContactListItemView view, Cursor cursor, boolean displayNumber, int position) {
    CharSequence label = null;
    if (displayNumber && !cursor.isNull(PhoneQuery.PHONE_TYPE)) {
        final int type = cursor.getInt(PhoneQuery.PHONE_TYPE);
        final String customLabel = cursor.getString(PhoneQuery.PHONE_LABEL);
        // TODO cache
        label = Phone.getTypeLabel(mContext.getResources(), type, customLabel);
    }
    view.setLabel(label);
    final String text;
    String number = cursor.getString(PhoneQuery.PHONE_NUMBER);
    if (displayNumber) {
        text = number;
    } else {
        // Display phone label. If that's null, display geocoded location for the number
        final String phoneLabel = cursor.getString(PhoneQuery.PHONE_LABEL);
        if (phoneLabel != null) {
            text = phoneLabel;
        } else {
            final String phoneNumber = cursor.getString(PhoneQuery.PHONE_NUMBER);
            text = GeoUtil.getGeocodedLocationFor(mContext, phoneNumber);
        }
    }
    view.setPhoneNumber(text);
    @CallToAction int action = ContactListItemView.NONE;
    if (CompatUtils.isVideoCompatible()) {
        // Determine if carrier presence indicates the number supports video calling.
        int carrierPresence = cursor.getInt(PhoneQuery.CARRIER_PRESENCE);
        boolean isPresent = (carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0;
        boolean showViewIcon = mIsImsVideoEnabled && isPresent;
        if (showViewIcon) {
            action = ContactListItemView.VIDEO;
        }
    }
    if (action == ContactListItemView.NONE && LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) {
        action = ContactListItemView.LIGHTBRINGER;
    }
    if (action == ContactListItemView.NONE) {
        EnrichedCallManager manager = EnrichedCallComponent.get(mContext).getEnrichedCallManager();
        EnrichedCallCapabilities capabilities = manager.getCapabilities(number);
        if (capabilities != null && capabilities.supportsCallComposer()) {
            action = ContactListItemView.CALL_AND_SHARE;
        } else if (capabilities == null && getQueryString() != null && getQueryString().length() >= 3) {
            manager.requestCapabilities(number);
        }
    }
    view.setCallToAction(action, mListener, position);
}
Also used : CallToAction(com.android.contacts.common.list.ContactListItemView.CallToAction) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager) EnrichedCallCapabilities(com.android.dialer.enrichedcall.EnrichedCallCapabilities) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 5 with EnrichedCallManager

use of com.android.dialer.enrichedcall.EnrichedCallManager in project android_packages_apps_Dialer by LineageOS.

the class PhoneNumberPickerFragment method onCapabilitiesUpdated.

@Override
public void onCapabilitiesUpdated() {
    if (getAdapter() != null) {
        EnrichedCallManager manager = EnrichedCallComponent.get(getContext()).getEnrichedCallManager();
        Listener listener = ((PhoneNumberListAdapter) getAdapter()).getListener();
        for (int i = 0; i < getListView().getChildCount(); i++) {
            if (!(getListView().getChildAt(i) instanceof ContactListItemView)) {
                continue;
            }
            // Since call and share is the lowest priority call to action, if any others are set,
            // do not reset the call to action. Also do not set the call and share call to action if
            // the number doesn't support call composer.
            ContactListItemView view = (ContactListItemView) getListView().getChildAt(i);
            if (view.getCallToAction() != ContactListItemView.NONE || view.getPhoneNumber() == null || manager.getCapabilities(view.getPhoneNumber()) == null || !manager.getCapabilities(view.getPhoneNumber()).supportsCallComposer()) {
                continue;
            }
            view.setCallToAction(ContactListItemView.CALL_AND_SHARE, listener, view.getPosition());
        }
    }
}
Also used : Listener(com.android.contacts.common.list.PhoneNumberListAdapter.Listener) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager)

Aggregations

EnrichedCallManager (com.android.dialer.enrichedcall.EnrichedCallManager)6 EnrichedCallCapabilities (com.android.dialer.enrichedcall.EnrichedCallCapabilities)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Nullable (android.support.annotation.Nullable)1 VisibleForTesting (android.support.annotation.VisibleForTesting)1 BaseCallback (android.support.design.widget.BaseTransientBottomBar.BaseCallback)1 Snackbar (android.support.design.widget.Snackbar)1 TelephonyManager (android.telephony.TelephonyManager)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 CallToAction (com.android.contacts.common.list.ContactListItemView.CallToAction)1 Listener (com.android.contacts.common.list.PhoneNumberListAdapter.Listener)1 FilteredNumberAsyncQueryHandler (com.android.dialer.blocking.FilteredNumberAsyncQueryHandler)1 Assert (com.android.dialer.common.Assert)1 LogUtil (com.android.dialer.common.LogUtil)1 ConfigProvider (com.android.dialer.configprovider.ConfigProvider)1 ConfigProviderBindings (com.android.dialer.configprovider.ConfigProviderBindings)1