Loading src/com/android/server/telecom/PhoneAccountRegistrar.java +11 −8 Original line number Diff line number Diff line Loading @@ -873,7 +873,7 @@ public class PhoneAccountRegistrar { public void registerPhoneAccount(PhoneAccount account) { // Enforce the requirement that a connection service for a phone account has the correct // permission. if (!hasTransactionalCallCapabilites(account) && if (!hasTransactionalCallCapabilities(account) && !phoneAccountRequiresBindPermission(account.getAccountHandle())) { Log.w(this, "Phone account %s does not have BIND_TELECOM_CONNECTION_SERVICE permission.", Loading Loading @@ -1062,7 +1062,7 @@ public class PhoneAccountRegistrar { boolean isNewAccount; // add self-managed capability for transactional accounts that are missing it if (hasTransactionalCallCapabilites(account) && if (hasTransactionalCallCapabilities(account) && !account.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)) { account = account.toBuilder() .setCapabilities(account.getCapabilities() Loading Loading @@ -1367,13 +1367,13 @@ public class PhoneAccountRegistrar { * @return {@code True} if the phone account has permission. */ public boolean phoneAccountRequiresBindPermission(PhoneAccountHandle phoneAccountHandle) { List<ResolveInfo> resolveInfos = resolveComponent(phoneAccountHandle); if (resolveInfos.isEmpty()) { Log.w(this, "phoneAccount %s not found", phoneAccountHandle.getComponentName()); if (hasTransactionalCallCapabilities(getPhoneAccountUnchecked(phoneAccountHandle))) { return false; } if (hasTransactionalCallCapabilites(getPhoneAccountUnchecked(phoneAccountHandle))) { List<ResolveInfo> resolveInfos = resolveComponent(phoneAccountHandle); if (resolveInfos.isEmpty()) { Log.w(this, "phoneAccount %s not found", phoneAccountHandle.getComponentName()); return false; } Loading @@ -1396,7 +1396,7 @@ public class PhoneAccountRegistrar { } @VisibleForTesting public boolean hasTransactionalCallCapabilites(PhoneAccount phoneAccount) { public boolean hasTransactionalCallCapabilities(PhoneAccount phoneAccount) { if (phoneAccount == null) { return false; } Loading Loading @@ -1530,7 +1530,10 @@ public class PhoneAccountRegistrar { } PhoneAccountHandle handle = m.getAccountHandle(); if (resolveComponent(handle).isEmpty()) { // PhoneAccounts with CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS do not require a // ConnectionService and will fail [resolveComponent(PhoneAccountHandle)]. Bypass // the [resolveComponent(PhoneAccountHandle)] for transactional accounts. if (!hasTransactionalCallCapabilities(m) && resolveComponent(handle).isEmpty()) { // This component cannot be resolved anymore; skip this one. continue; } Loading tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java +21 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; Loading Loading @@ -707,7 +705,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .build(); assertFalse(mRegistrar.hasTransactionalCallCapabilites(accountWithoutCapability)); assertFalse(mRegistrar.hasTransactionalCallCapabilities(accountWithoutCapability)); try { mRegistrar.registerPhoneAccount(accountWithoutCapability); Loading @@ -730,7 +728,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS) .build(); assertTrue(mRegistrar.hasTransactionalCallCapabilites(accountWithCapability)); assertTrue(mRegistrar.hasTransactionalCallCapabilities(accountWithCapability)); try { mRegistrar.registerPhoneAccount(accountWithCapability); Loading @@ -752,7 +750,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS) .build(); assertTrue(mRegistrar.hasTransactionalCallCapabilites(accountWithCapability)); assertTrue(mRegistrar.hasTransactionalCallCapabilities(accountWithCapability)); try { // WHEN Loading Loading @@ -1684,6 +1682,24 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { } } /** * PhoneAccounts with CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS do not require a * ConnectionService. Ensure that such an account can be registered and fetched. */ @Test public void testFetchingTransactionalAccounts() { PhoneAccount account = makeBuilderWithBindCapabilities( makeQuickAccountHandle(TEST_ID)).build(); try { assertEquals(0, mRegistrar.getAllPhoneAccounts(null, true).size()); registerAndEnableAccount(account); assertEquals(1, mRegistrar.getAllPhoneAccounts(null, true).size()); } finally { mRegistrar.unregisterPhoneAccount(account.getAccountHandle()); } } private static PhoneAccount.Builder makeBuilderWithBindCapabilities(PhoneAccountHandle handle) { return new PhoneAccount.Builder(handle, TEST_LABEL) .setCapabilities(PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS); Loading Loading
src/com/android/server/telecom/PhoneAccountRegistrar.java +11 −8 Original line number Diff line number Diff line Loading @@ -873,7 +873,7 @@ public class PhoneAccountRegistrar { public void registerPhoneAccount(PhoneAccount account) { // Enforce the requirement that a connection service for a phone account has the correct // permission. if (!hasTransactionalCallCapabilites(account) && if (!hasTransactionalCallCapabilities(account) && !phoneAccountRequiresBindPermission(account.getAccountHandle())) { Log.w(this, "Phone account %s does not have BIND_TELECOM_CONNECTION_SERVICE permission.", Loading Loading @@ -1062,7 +1062,7 @@ public class PhoneAccountRegistrar { boolean isNewAccount; // add self-managed capability for transactional accounts that are missing it if (hasTransactionalCallCapabilites(account) && if (hasTransactionalCallCapabilities(account) && !account.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)) { account = account.toBuilder() .setCapabilities(account.getCapabilities() Loading Loading @@ -1367,13 +1367,13 @@ public class PhoneAccountRegistrar { * @return {@code True} if the phone account has permission. */ public boolean phoneAccountRequiresBindPermission(PhoneAccountHandle phoneAccountHandle) { List<ResolveInfo> resolveInfos = resolveComponent(phoneAccountHandle); if (resolveInfos.isEmpty()) { Log.w(this, "phoneAccount %s not found", phoneAccountHandle.getComponentName()); if (hasTransactionalCallCapabilities(getPhoneAccountUnchecked(phoneAccountHandle))) { return false; } if (hasTransactionalCallCapabilites(getPhoneAccountUnchecked(phoneAccountHandle))) { List<ResolveInfo> resolveInfos = resolveComponent(phoneAccountHandle); if (resolveInfos.isEmpty()) { Log.w(this, "phoneAccount %s not found", phoneAccountHandle.getComponentName()); return false; } Loading @@ -1396,7 +1396,7 @@ public class PhoneAccountRegistrar { } @VisibleForTesting public boolean hasTransactionalCallCapabilites(PhoneAccount phoneAccount) { public boolean hasTransactionalCallCapabilities(PhoneAccount phoneAccount) { if (phoneAccount == null) { return false; } Loading Loading @@ -1530,7 +1530,10 @@ public class PhoneAccountRegistrar { } PhoneAccountHandle handle = m.getAccountHandle(); if (resolveComponent(handle).isEmpty()) { // PhoneAccounts with CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS do not require a // ConnectionService and will fail [resolveComponent(PhoneAccountHandle)]. Bypass // the [resolveComponent(PhoneAccountHandle)] for transactional accounts. if (!hasTransactionalCallCapabilities(m) && resolveComponent(handle).isEmpty()) { // This component cannot be resolved anymore; skip this one. continue; } Loading
tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java +21 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; Loading Loading @@ -707,7 +705,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) .build(); assertFalse(mRegistrar.hasTransactionalCallCapabilites(accountWithoutCapability)); assertFalse(mRegistrar.hasTransactionalCallCapabilities(accountWithoutCapability)); try { mRegistrar.registerPhoneAccount(accountWithoutCapability); Loading @@ -730,7 +728,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS) .build(); assertTrue(mRegistrar.hasTransactionalCallCapabilites(accountWithCapability)); assertTrue(mRegistrar.hasTransactionalCallCapabilities(accountWithCapability)); try { mRegistrar.registerPhoneAccount(accountWithCapability); Loading @@ -752,7 +750,7 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS) .build(); assertTrue(mRegistrar.hasTransactionalCallCapabilites(accountWithCapability)); assertTrue(mRegistrar.hasTransactionalCallCapabilities(accountWithCapability)); try { // WHEN Loading Loading @@ -1684,6 +1682,24 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { } } /** * PhoneAccounts with CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS do not require a * ConnectionService. Ensure that such an account can be registered and fetched. */ @Test public void testFetchingTransactionalAccounts() { PhoneAccount account = makeBuilderWithBindCapabilities( makeQuickAccountHandle(TEST_ID)).build(); try { assertEquals(0, mRegistrar.getAllPhoneAccounts(null, true).size()); registerAndEnableAccount(account); assertEquals(1, mRegistrar.getAllPhoneAccounts(null, true).size()); } finally { mRegistrar.unregisterPhoneAccount(account.getAccountHandle()); } } private static PhoneAccount.Builder makeBuilderWithBindCapabilities(PhoneAccountHandle handle) { return new PhoneAccount.Builder(handle, TEST_LABEL) .setCapabilities(PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS); Loading