Search in sources :

Example 76 with TelecomManager

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

the class SpeedDialListActivity method showSelectAccountDialog.

private void showSelectAccountDialog(Context context) {
    TelecomManager telecomManager = getTelecomManager(context);
    List<PhoneAccountHandle> accountsList = telecomManager.getCallCapablePhoneAccounts();
    final PhoneAccountHandle[] accounts = accountsList.toArray(new PhoneAccountHandle[accountsList.size()]);
    CharSequence[] accountEntries = new CharSequence[accounts.length];
    for (int i = 0; i < accounts.length; i++) {
        CharSequence label = telecomManager.getPhoneAccount(accounts[i]).getLabel();
        accountEntries[i] = (label == null) ? null : label.toString();
    }
    AlertDialog dialog = new AlertDialog.Builder(context).setTitle(R.string.select_account_dialog_title).setItems(accountEntries, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(ACTION_ADD_VOICEMAIL);
            int sub = Integer.parseInt(accounts[which].getId());
            intent.setClassName("com.android.phone", "com.android.phone.MSimCallFeaturesSubSetting");
            intent.putExtra(SUBSCRIPTION_KEY, sub);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Log.w(TAG, "can not find activity deal with voice mail");
            }
        }
    }).create();
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) PhoneAccountHandle(android.telecom.PhoneAccountHandle) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) TelecomManager(android.telecom.TelecomManager) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 77 with TelecomManager

use of android.telecom.TelecomManager 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 78 with TelecomManager

use of android.telecom.TelecomManager 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 79 with TelecomManager

use of android.telecom.TelecomManager 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 80 with TelecomManager

use of android.telecom.TelecomManager 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

TelecomManager (android.telecom.TelecomManager)86 PhoneAccountHandle (android.telecom.PhoneAccountHandle)45 PhoneAccount (android.telecom.PhoneAccount)30 TelephonyManager (android.telephony.TelephonyManager)17 SubscriptionInfo (android.telephony.SubscriptionInfo)11 KeyEvent (android.view.KeyEvent)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.app.AlertDialog)8 ActivityNotFoundException (android.content.ActivityNotFoundException)8 DialogInterface (android.content.DialogInterface)8 Message (android.os.Message)8 SubscriptionManager (android.telephony.SubscriptionManager)8 Dialog (android.app.Dialog)7 ListAdapter (android.widget.ListAdapter)7 Intent (android.content.Intent)6 Preference (android.support.v7.preference.Preference)6 ComponentName (android.content.ComponentName)4 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 RemoteException (android.os.RemoteException)4 IntArray (android.util.IntArray)4