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();
}
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();
}
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();
}
}
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);
}
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());
}
}
}
Aggregations