Loading src/com/android/server/telecom/PhoneAccountRegistrar.java +6 −4 Original line number Diff line number Diff line Loading @@ -962,18 +962,20 @@ public class PhoneAccountRegistrar { String[] fields = {"Package Name", "Class Name", "PhoneAccountHandle Id", "Label", "ShortDescription", "GroupId", "Address"}; "GroupId", "Address", "SubscriptionAddress"}; CharSequence[] args = {handle.getComponentName().getPackageName(), handle.getComponentName().getClassName(), handle.getId(), account.getLabel(), account.getShortDescription(), account.getGroupId(), (account.getAddress() != null ? account.getAddress().toString() : "")}; (account.getAddress() != null ? account.getAddress().toString() : ""), (account.getSubscriptionAddress() != null ? account.getSubscriptionAddress().toString() : "")}; for (int i = 0; i < fields.length; i++) { if (args[i] != null && args[i].length() > MAX_PHONE_ACCOUNT_FIELD_CHAR_LIMIT) { EventLog.writeEvent(0x534e4554, "259064622", Binder.getCallingUid(), "enforceCharacterLimit"); throw new IllegalArgumentException("The PhoneAccount or PhoneAccountHandle" + fields[i] + " field has an invalid character count. PhoneAccount and " throw new IllegalArgumentException("The PhoneAccount or PhoneAccountHandle [" + fields[i] + "] field has an invalid character count. PhoneAccount and " + "PhoneAccountHandle String and Char-Sequence fields are limited to " + MAX_PHONE_ACCOUNT_FIELD_CHAR_LIMIT + " characters."); } Loading tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1667,6 +1667,23 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { } } /** * Ensure an IllegalArgumentException is thrown when providing a SubscriptionAddress that * exceeds the PhoneAccountRegistrar limit. */ @Test public void testLimitOnSubscriptionAddress() throws Exception { String text = "a".repeat(100); PhoneAccount.Builder builder = new PhoneAccount.Builder(makeQuickAccountHandle(TEST_ID), TEST_LABEL).setSubscriptionAddress(Uri.fromParts(text, text, text)); try { mRegistrar.enforceCharacterLimit(builder.build()); fail("failed to throw IllegalArgumentException"); } catch (IllegalArgumentException e) { // pass test } } 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 +6 −4 Original line number Diff line number Diff line Loading @@ -962,18 +962,20 @@ public class PhoneAccountRegistrar { String[] fields = {"Package Name", "Class Name", "PhoneAccountHandle Id", "Label", "ShortDescription", "GroupId", "Address"}; "GroupId", "Address", "SubscriptionAddress"}; CharSequence[] args = {handle.getComponentName().getPackageName(), handle.getComponentName().getClassName(), handle.getId(), account.getLabel(), account.getShortDescription(), account.getGroupId(), (account.getAddress() != null ? account.getAddress().toString() : "")}; (account.getAddress() != null ? account.getAddress().toString() : ""), (account.getSubscriptionAddress() != null ? account.getSubscriptionAddress().toString() : "")}; for (int i = 0; i < fields.length; i++) { if (args[i] != null && args[i].length() > MAX_PHONE_ACCOUNT_FIELD_CHAR_LIMIT) { EventLog.writeEvent(0x534e4554, "259064622", Binder.getCallingUid(), "enforceCharacterLimit"); throw new IllegalArgumentException("The PhoneAccount or PhoneAccountHandle" + fields[i] + " field has an invalid character count. PhoneAccount and " throw new IllegalArgumentException("The PhoneAccount or PhoneAccountHandle [" + fields[i] + "] field has an invalid character count. PhoneAccount and " + "PhoneAccountHandle String and Char-Sequence fields are limited to " + MAX_PHONE_ACCOUNT_FIELD_CHAR_LIMIT + " characters."); } Loading
tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1667,6 +1667,23 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase { } } /** * Ensure an IllegalArgumentException is thrown when providing a SubscriptionAddress that * exceeds the PhoneAccountRegistrar limit. */ @Test public void testLimitOnSubscriptionAddress() throws Exception { String text = "a".repeat(100); PhoneAccount.Builder builder = new PhoneAccount.Builder(makeQuickAccountHandle(TEST_ID), TEST_LABEL).setSubscriptionAddress(Uri.fromParts(text, text, text)); try { mRegistrar.enforceCharacterLimit(builder.build()); fail("failed to throw IllegalArgumentException"); } catch (IllegalArgumentException e) { // pass test } } private static PhoneAccount.Builder makeBuilderWithBindCapabilities(PhoneAccountHandle handle) { return new PhoneAccount.Builder(handle, TEST_LABEL) .setCapabilities(PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS); Loading