use of android.telecom.PhoneAccount in project android_packages_apps_Settings by SudaMod.
the class SimDialogActivity method subscriptionIdToPhoneAccountHandle.
private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
final TelecomManager telecomManager = TelecomManager.from(this);
final TelephonyManager telephonyManager = TelephonyManager.from(this);
final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator();
while (phoneAccounts.hasNext()) {
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
return phoneAccountHandle;
}
}
return null;
}
use of android.telecom.PhoneAccount in project platform_packages_apps_Settings by BlissRoms.
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;
}
use of android.telecom.PhoneAccount in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PhoneRingtonePreferenceController method getPhoneAccountHandles.
// This method is to get the available phone account handles of the SIMs.
private List<PhoneAccountHandle> getPhoneAccountHandles() {
List<PhoneAccountHandle> subscriptionAccountHandles = new ArrayList<>();
List<PhoneAccountHandle> accountHandles = mTelecomManager.getCallCapablePhoneAccounts(true);
for (PhoneAccountHandle accountHandle : accountHandles) {
PhoneAccount phoneAccount = mTelecomManager.getPhoneAccount(accountHandle);
// Emergency phone account also has CAPABILITY_SIM_SUBSCRIPTION, so should exclude it.
if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) && !EMERGENCY_PHONE_ACCOUNT_HANDLE_ID.equals(accountHandle.getId())) {
subscriptionAccountHandles.add(accountHandle);
}
}
return subscriptionAccountHandles;
}
use of android.telecom.PhoneAccount in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PhoneRingtonePreferenceController method getDisplayNameForRingtonePreference.
private CharSequence getDisplayNameForRingtonePreference(PhoneAccountHandle phoneAccountHandle) {
TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
SubscriptionManager subscriptionManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
PhoneAccount phoneAccount = mTelecomManager.getPhoneAccount(phoneAccountHandle);
int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subId);
if (subInfo != null) {
return subInfo.getDisplayName();
}
return null;
}
use of android.telecom.PhoneAccount in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class CallsSimListDialogFragment method getCurrentSubscriptions.
@Override
protected List<SubscriptionInfo> getCurrentSubscriptions() {
final Context context = getContext();
final SubscriptionManager subscriptionManager = context.getSystemService(SubscriptionManager.class);
final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
final List<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts();
final List<SubscriptionInfo> result = new ArrayList<>();
if (phoneAccounts == null) {
return result;
}
for (PhoneAccountHandle handle : phoneAccounts) {
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
final int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
continue;
}
result.add(subscriptionManager.getActiveSubscriptionInfo(subId));
}
return result;
}
Aggregations