Search in sources :

Example 41 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by ResurrectionRemix.

the class Telecom method runRegisterPhoneAccount.

private void runRegisterPhoneAccount() throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final String label = nextArgRequired();
    PhoneAccount account = PhoneAccount.builder(handle, label).setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build();
    mTelecomService.registerPhoneAccount(account);
    System.out.println("Success - " + handle + " registered.");
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 42 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by ResurrectionRemix.

the class Telecom method runSetPhoneAccountEnabled.

private void runSetPhoneAccountEnabled(boolean enabled) throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final boolean success = mTelecomService.enablePhoneAccount(handle, enabled);
    if (success) {
        System.out.println("Success - " + handle + (enabled ? " enabled." : " disabled."));
    } else {
        System.out.println("Error - is " + handle + " a valid PhoneAccount?");
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Example 43 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by ResurrectionRemix.

the class Telecom method getPhoneAccountHandleFromArgs.

private PhoneAccountHandle getPhoneAccountHandleFromArgs() throws RemoteException {
    final ComponentName component = parseComponentName(nextArgRequired());
    final String accountId = nextArgRequired();
    final String userSnInStr = nextArgRequired();
    UserHandle userHandle;
    try {
        final int userSn = Integer.parseInt(userSnInStr);
        userHandle = UserHandle.of(mUserManager.getUserHandle(userSn));
    } catch (NumberFormatException ex) {
        throw new IllegalArgumentException("Invalid user serial number " + userSnInStr);
    }
    return new PhoneAccountHandle(component, accountId, userHandle);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName)

Example 44 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SimDialogActivity method createDialog.

public Dialog createDialog(final Context context, final int id) {
    final ArrayList<String> list = new ArrayList<String>();
    final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
    final List<SubscriptionInfo> subInfoList = subscriptionManager.getActiveSubscriptionInfoList();
    final int selectableSubInfoLength = subInfoList == null ? 0 : subInfoList.size();
    final DialogInterface.OnClickListener selectionListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int value) {
            final SubscriptionInfo sir;
            switch(id) {
                case DATA_PICK:
                    sir = subInfoList.get(value);
                    setDefaultDataSubId(context, sir.getSubscriptionId());
                    break;
                case CALLS_PICK:
                    final TelecomManager telecomManager = TelecomManager.from(context);
                    final List<PhoneAccountHandle> phoneAccountsList = telecomManager.getCallCapablePhoneAccounts();
                    setUserSelectedOutgoingPhoneAccount(value < 1 ? null : phoneAccountsList.get(value - 1));
                    break;
                case SMS_PICK:
                    sir = subInfoList.get(value);
                    setDefaultSmsSubId(context, sir.getSubscriptionId());
                    break;
                default:
                    throw new IllegalArgumentException("Invalid dialog type " + id + " in SIM dialog.");
            }
            finish();
        }
    };
    Dialog.OnKeyListener keyListener = new Dialog.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                finish();
            }
            return true;
        }
    };
    ArrayList<SubscriptionInfo> callsSubInfoList = new ArrayList<SubscriptionInfo>();
    if (id == CALLS_PICK) {
        final TelecomManager telecomManager = TelecomManager.from(context);
        final TelephonyManager telephonyManager = TelephonyManager.from(context);
        final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator();
        list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
        callsSubInfoList.add(null);
        while (phoneAccounts.hasNext()) {
            final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccounts.next());
            list.add((String) phoneAccount.getLabel());
            int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
            if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                final SubscriptionInfo sir = SubscriptionManager.from(context).getActiveSubscriptionInfo(subId);
                callsSubInfoList.add(sir);
            } else {
                callsSubInfoList.add(null);
            }
        }
    } else {
        for (int i = 0; i < selectableSubInfoLength; ++i) {
            final SubscriptionInfo sir = subInfoList.get(i);
            CharSequence displayName = sir.getDisplayName();
            if (displayName == null) {
                displayName = "";
            }
            list.add(displayName.toString());
        }
    }
    String[] arr = list.toArray(new String[0]);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    ListAdapter adapter = new SelectAccountListAdapter(id == CALLS_PICK ? callsSubInfoList : subInfoList, builder.getContext(), R.layout.select_account_list_item, arr, id);
    switch(id) {
        case DATA_PICK:
            builder.setTitle(R.string.select_sim_for_data);
            break;
        case CALLS_PICK:
            builder.setTitle(R.string.select_sim_for_calls);
            break;
        case SMS_PICK:
            builder.setTitle(R.string.sim_card_select_title);
            break;
        default:
            throw new IllegalArgumentException("Invalid dialog type " + id + " in SIM dialog.");
    }
    Dialog dialog = builder.setAdapter(adapter, selectionListener).create();
    dialog.setOnKeyListener(keyListener);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            finish();
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) KeyEvent(android.view.KeyEvent) TelephonyManager(android.telephony.TelephonyManager) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) ListAdapter(android.widget.ListAdapter) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager) PhoneAccount(android.telecom.PhoneAccount)

Example 45 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project android_frameworks_base by crdroidandroid.

the class Telecom method runSetPhoneAccountEnabled.

private void runSetPhoneAccountEnabled(boolean enabled) throws RemoteException {
    final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
    final boolean success = mTelecomService.enablePhoneAccount(handle, enabled);
    if (success) {
        System.out.println("Success - " + handle + (enabled ? " enabled." : " disabled."));
    } else {
        System.out.println("Error - is " + handle + " a valid PhoneAccount?");
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle)

Aggregations

PhoneAccountHandle (android.telecom.PhoneAccountHandle)49 PhoneAccount (android.telecom.PhoneAccount)17 TelecomManager (android.telecom.TelecomManager)14 ComponentName (android.content.ComponentName)9 Test (org.junit.Test)7 UserHandle (android.os.UserHandle)5 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 SubscriptionInfo (android.telephony.SubscriptionInfo)4 TelephonyManager (android.telephony.TelephonyManager)4 IntArray (android.util.IntArray)4 Config (org.robolectric.annotation.Config)3 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 LinkedList (java.util.LinkedList)2 Implementation (org.robolectric.annotation.Implementation)2 Dialog (android.app.Dialog)1 Resources (android.content.res.Resources)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 Preference (android.support.v7.preference.Preference)1