@Test @Config(minSdk = LOLLIPOP_MR1) public void clearAccountsForPackage() { PhoneAccountHandle accountHandle1 = createHandle("a.package", "id1"); telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle1, "another_package") .build()); PhoneAccountHandle accountHandle2 = createHandle("some.other.package", "id2"); telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle2, "another_package") .build()); telecomService.clearAccountsForPackage(accountHandle1.getComponentName().getPackageName()); assertThat(telecomService.getPhoneAccount(accountHandle1)).isNull(); assertThat(telecomService.getPhoneAccount(accountHandle2)).isNotNull(); }
@Test public void registerAndUnRegister() { assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0); assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0); PhoneAccountHandle handler = createHandle("id"); PhoneAccount phoneAccount = PhoneAccount.builder(handler, "main_account").build(); telecomService.registerPhoneAccount(phoneAccount); assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(1); assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(1); assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(1); assertThat(telecomService.getAllPhoneAccountHandles()).contains(handler); assertThat(telecomService.getPhoneAccount(handler).getLabel()).isEqualTo(phoneAccount.getLabel()); telecomService.unregisterPhoneAccount(handler); assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0); assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0); assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(0); }
/** * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes * resources which can be used in a user interface. * * @param telecomManager the {@link TelecomManager} used for method calls, if possible. * @param account The {@link PhoneAccountHandle}. * @return The {@link PhoneAccount} object or null if it doesn't exist. */ @Nullable public static PhoneAccount getPhoneAccount(@Nullable TelecomManager telecomManager, @Nullable PhoneAccountHandle accountHandle) { if (telecomManager != null && (CompatUtils.isMethodAvailable( TELECOM_MANAGER_CLASS, "getPhoneAccount", PhoneAccountHandle.class))) { return telecomManager.getPhoneAccount(accountHandle); } return null; }
final PhoneAccount account = telecomManager.getPhoneAccount(mPhoneAccountHandle);
PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle); if (account == null) { return rowView;
/** * 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; } }
PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle); if (account != null) { if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) {