Search in sources :

Example 41 with PhoneAccount

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

the class PhoneAccountUtils method getSubscriptionPhoneAccounts.

/**
 * Return a list of phone accounts that are subscription/SIM accounts.
 */
public static List<PhoneAccountHandle> getSubscriptionPhoneAccounts(Context context) {
    List<PhoneAccountHandle> subscriptionAccountHandles = new ArrayList<PhoneAccountHandle>();
    final List<PhoneAccountHandle> accountHandles = TelecomUtil.getCallCapablePhoneAccounts(context);
    for (PhoneAccountHandle accountHandle : accountHandles) {
        PhoneAccount account = TelecomUtil.getPhoneAccount(context, accountHandle);
        if (account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
            subscriptionAccountHandles.add(accountHandle);
        }
    }
    return subscriptionAccountHandles;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) ArrayList(java.util.ArrayList)

Example 42 with PhoneAccount

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

the class CallCardPresenter method getCallProviderIcon.

/**
 * Return the icon to represent the call provider
 */
private Drawable getCallProviderIcon(Call call) {
    PhoneAccount account = getAccountForCall(call);
    TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
    if (account != null && account.getIcon() != null && mgr.getCallCapablePhoneAccounts().size() > 1 && SubscriptionManager.from(mContext).getActiveSubscriptionInfoCount() > 1) {
        return account.getIcon().loadDrawable(mContext);
    }
    return null;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager)

Example 43 with PhoneAccount

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

the class CallCardPresenter method getSubscriptionNumber.

private String getSubscriptionNumber() {
    // If it's an emergency call, and they're not populating the callback number,
    // then try to fall back to the phone sub info (to hopefully get the SIM's
    // number directly from the telephony layer).
    PhoneAccountHandle accountHandle = mPrimary.getAccountHandle();
    if (accountHandle != null) {
        TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
        PhoneAccount account = TelecomManagerCompat.getPhoneAccount(mgr, accountHandle);
        if (account != null) {
            return getNumberFromHandle(account.getSubscriptionAddress());
        }
    }
    return null;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Example 44 with PhoneAccount

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

the class CallCardPresenter method getCallProviderLabel.

/**
 * Return the string label to represent the call provider
 */
private String getCallProviderLabel(Call call) {
    PhoneAccount account = getAccountForCall(call);
    TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
    if (account != null && !TextUtils.isEmpty(account.getLabel()) && TelecomManagerCompat.getCallCapablePhoneAccounts(mgr).size() >= 1) {
        return account.getLabel().toString();
    }
    return null;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) TelecomManager(android.telecom.TelecomManager)

Example 45 with PhoneAccount

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

the class Call method updateFromTelecomCall.

private void updateFromTelecomCall(boolean registerCallback) {
    Log.d(this, "updateFromTelecomCall: " + mTelecomCall.toString());
    final int translatedState = translateState(mTelecomCall.getState());
    if (mState != State.BLOCKED) {
        setState(translatedState);
        setDisconnectCause(mTelecomCall.getDetails().getDisconnectCause());
        maybeCancelVideoUpgrade(mTelecomCall.getDetails().getVideoState());
    }
    if (registerCallback && mTelecomCall.getVideoCall() != null) {
        if (mVideoCallCallback == null) {
            mVideoCallCallback = new InCallVideoCallCallback(this);
        }
        mTelecomCall.getVideoCall().registerCallback(mVideoCallCallback);
        mIsVideoCallCallbackRegistered = true;
    }
    mChildCallIds.clear();
    final int numChildCalls = mTelecomCall.getChildren().size();
    for (int i = 0; i < numChildCalls; i++) {
        mChildCallIds.add(CallList.getInstance().getCallByTelecomCall(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) {
            TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager();
            PhoneAccount phoneAccount = TelecomManagerCompat.getPhoneAccount(mgr, 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)

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