Search in sources :

Example 11 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.

the class VoicemailChannelUtils method createVoicemailChannelForAccount.

private static void createVoicemailChannelForAccount(@NonNull Context context, @NonNull PhoneAccountHandle handle) {
    PhoneAccount phoneAccount = context.getSystemService(TelecomManager.class).getPhoneAccount(handle);
    NotificationChannel channel = newChannel(context, getChannelIdForAccount(handle), phoneAccount.getLabel());
    migrateVoicemailSoundSettings(context, channel, handle);
    context.getSystemService(NotificationManager.class).createNotificationChannel(channel);
}
Also used : NotificationChannel(android.app.NotificationChannel) PhoneAccount(android.telecom.PhoneAccount) NotificationManager(android.app.NotificationManager) TelecomManager(android.telecom.TelecomManager)

Example 12 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.

the class LegacyVoicemailNotifier method getNotificationText.

@NonNull
private static String getNotificationText(@NonNull Context context, PhoneAccountHandle handle, String voicemailNumber) {
    if (PhoneAccountUtils.getSubscriptionPhoneAccounts(context).size() > 1) {
        TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
        PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
        return phoneAccount.getShortDescription().toString();
    } else {
        return String.format(context.getString(R.string.notification_voicemail_text_format), PhoneNumberUtils.formatNumber(voicemailNumber));
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager) NonNull(android.support.annotation.NonNull)

Example 13 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.

the class PhoneAccountSelectionFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getContext()));
    PreferenceScreen screen = getPreferenceScreen();
    TelecomManager telecomManager = getContext().getSystemService(TelecomManager.class);
    List<PhoneAccountHandle> accountHandles = telecomManager.getCallCapablePhoneAccounts();
    Context context = getActivity();
    for (PhoneAccountHandle handle : accountHandles) {
        PhoneAccount account = telecomManager.getPhoneAccount(handle);
        if (account != null) {
            final boolean isSimAccount = 0 != (account.getCapabilities() & PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION);
            if (isSimAccount) {
                screen.addPreference(new AccountPreference(context, handle, account));
            }
        }
    }
}
Also used : Context(android.content.Context) PhoneAccount(android.telecom.PhoneAccount) PreferenceScreen(android.preference.PreferenceScreen) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Example 14 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.

the class DialerCall method updateFromTelecomCall.

private void updateFromTelecomCall() {
    LogUtil.v("DialerCall.updateFromTelecomCall", mTelecomCall.toString());
    mVideoTechManager.dispatchCallStateChanged(mTelecomCall.getState());
    final int translatedState = translateState(mTelecomCall.getState());
    if (mState != State.BLOCKED) {
        setState(translatedState);
        setDisconnectCause(mTelecomCall.getDetails().getDisconnectCause());
    }
    mChildCallIds.clear();
    final int numChildCalls = mTelecomCall.getChildren().size();
    for (int i = 0; i < numChildCalls; i++) {
        mChildCallIds.add(mDialerCallDelegate.getDialerCallFromTelecomCall(mTelecomCall.getChildren().get(i)).getId());
    }
    // The number of conferenced calls can change over the course of the call, so use the
    // maximum number of conferenced child calls as the metric for conference call usage.
    mLogState.conferencedCalls = Math.max(numChildCalls, mLogState.conferencedCalls);
    updateFromCallExtras(mTelecomCall.getDetails().getExtras());
    // If the handle of the call has changed, update state for the call determining if it is an
    // emergency call.
    Uri newHandle = mTelecomCall.getDetails().getHandle();
    if (!Objects.equals(mHandle, newHandle)) {
        mHandle = newHandle;
        updateEmergencyCallState();
    }
    // If the phone account handle of the call is set, cache capability bit indicating whether
    // the phone account supports call subjects.
    PhoneAccountHandle newPhoneAccountHandle = mTelecomCall.getDetails().getAccountHandle();
    if (!Objects.equals(mPhoneAccountHandle, newPhoneAccountHandle)) {
        mPhoneAccountHandle = newPhoneAccountHandle;
        if (mPhoneAccountHandle != null) {
            PhoneAccount phoneAccount = mContext.getSystemService(TelecomManager.class).getPhoneAccount(mPhoneAccountHandle);
            if (phoneAccount != null) {
                mIsCallSubjectSupported = phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT);
            }
        }
    }
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) Uri(android.net.Uri) TelecomManager(android.telecom.TelecomManager)

Example 15 with PhoneAccount

use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.

the class CallUtil method getVideoCallingAvailability.

/**
 * Determines if video calling is available, and if so whether presence checking is available as
 * well.
 *
 * <p>Returns a bitmask with {@link #VIDEO_CALLING_ENABLED} to indicate that video calling is
 * available, and {@link #VIDEO_CALLING_PRESENCE} if presence indication is also available.
 *
 * @param context The context
 * @return A bit-mask describing the current video capabilities.
 */
public static int getVideoCallingAvailability(Context context) {
    if (!PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isVideoCompatible()) {
        return VIDEO_CALLING_DISABLED;
    }
    TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    if (telecommMgr == null) {
        return VIDEO_CALLING_DISABLED;
    }
    List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts();
    for (PhoneAccountHandle accountHandle : accountHandles) {
        PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle);
        if (account != null) {
            if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) {
                // Builds prior to N do not have presence support.
                if (!CompatUtils.isVideoPresenceCompatible()) {
                    return VIDEO_CALLING_ENABLED;
                }
                int videoCapabilities = VIDEO_CALLING_ENABLED;
                if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
                    videoCapabilities |= VIDEO_CALLING_PRESENCE;
                }
                return videoCapabilities;
            }
        }
    }
    return VIDEO_CALLING_DISABLED;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Aggregations

PhoneAccount (android.telecom.PhoneAccount)53 PhoneAccountHandle (android.telecom.PhoneAccountHandle)41 TelecomManager (android.telecom.TelecomManager)32 TelephonyManager (android.telephony.TelephonyManager)19 ArrayList (java.util.ArrayList)13 SubscriptionInfo (android.telephony.SubscriptionInfo)11 SubscriptionManager (android.telephony.SubscriptionManager)10 AlertDialog (android.app.AlertDialog)7 Dialog (android.app.Dialog)7 DialogInterface (android.content.DialogInterface)7 KeyEvent (android.view.KeyEvent)7 ListAdapter (android.widget.ListAdapter)7 Uri (android.net.Uri)3 Context (android.content.Context)2 NotificationChannel (android.app.NotificationChannel)1 NotificationManager (android.app.NotificationManager)1 ContentResolver (android.content.ContentResolver)1 ContentValues (android.content.ContentValues)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1