use of android.telecom.PhoneAccount 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.");
}
use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.
the class CallSubjectDialog method loadConfiguration.
/**
* Loads the message encoding and maximum message length from the phone account extras for the
* current phone account.
*/
private void loadConfiguration() {
// later. If we've got a prior SDK the default encoding and message length will suffice.
if (VERSION.SDK_INT < VERSION_CODES.N) {
return;
}
if (mPhoneAccountHandle == null) {
return;
}
TelecomManager telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
final PhoneAccount account = telecomManager.getPhoneAccount(mPhoneAccountHandle);
Bundle phoneAccountExtras = account.getExtras();
if (phoneAccountExtras == null) {
return;
}
// Get limit, if provided; otherwise default to existing value.
mLimit = phoneAccountExtras.getInt(PhoneAccount.EXTRA_CALL_SUBJECT_MAX_LENGTH, mLimit);
// Get charset; default to none (e.g. count characters 1:1).
String charsetName = phoneAccountExtras.getString(PhoneAccount.EXTRA_CALL_SUBJECT_CHARACTER_ENCODING);
if (!TextUtils.isEmpty(charsetName)) {
try {
mMessageEncoding = Charset.forName(charsetName);
} catch (java.nio.charset.UnsupportedCharsetException uce) {
// Character set was invalid; log warning and fallback to none.
LogUtil.e("CallSubjectDialog.loadConfiguration", "invalid charset: " + charsetName);
mMessageEncoding = null;
}
} else {
// No character set specified, so count characters 1:1.
mMessageEncoding = null;
}
}
use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.
the class CallUtil method isCallWithSubjectSupported.
/**
* Determines if one of the call capable phone accounts defined supports calling with a subject
* specified.
*
* @param context The context.
* @return {@code true} if one of the call capable phone accounts supports calling with a subject
* specified, {@code false} otherwise.
*/
public static boolean isCallWithSubjectSupported(Context context) {
if (!PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isCallSubjectCompatible()) {
return false;
}
TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
if (telecommMgr == null) {
return false;
}
List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts();
for (PhoneAccountHandle accountHandle : accountHandles) {
PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle);
if (account != null && account.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT)) {
return true;
}
}
return false;
}
use of android.telecom.PhoneAccount in project android_packages_apps_Dialer by LineageOS.
the class DialerSettingsActivity method getSoleSimAccount.
/**
* @return the only SIM phone account, or {@code null} if there are none or more than one. Note:
* having a empty SIM slot still count as a PhoneAccountHandle that is "invalid", and
* voicemail settings should still be available for it.
*/
@Nullable
private PhoneAccountHandle getSoleSimAccount() {
TelecomManager telecomManager = getSystemService(TelecomManager.class);
PhoneAccountHandle result = null;
for (PhoneAccountHandle phoneAccountHandle : telecomManager.getCallCapablePhoneAccounts()) {
PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
LogUtil.i("DialerSettingsActivity.getSoleSimAccount", phoneAccountHandle + " is a SIM account");
if (result != null) {
return null;
}
result = phoneAccountHandle;
}
}
return result;
}
use of android.telecom.PhoneAccount in project android_packages_apps_Settings by DirtyUnicorns.
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;
}
Aggregations