Loading src/com/android/contacts/common/model/account/ExternalAccountType.java +8 −3 Original line number Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class ExternalAccountType extends BaseAccountType { return -1; // Empty text is okay. } if (resourceName.charAt(0) != '@') { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, xmlAttributeName + " must be a resource name beginnig with '@'"); } return -1; Loading @@ -428,18 +428,23 @@ public class ExternalAccountType extends BaseAccountType { try { res = context.getPackageManager().getResourcesForApplication(packageName); } catch (NameNotFoundException e) { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, "Unable to load package " + packageName); } return -1; } final int resId = res.getIdentifier(name, null, packageName); if (resId == 0) { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, "Unable to load " + resourceName + " from package " + packageName); } return -1; } return resId; } @VisibleForTesting static boolean isFromTestApp(String packageName) { return TextUtils.equals(packageName, "com.google.android.contacts.tests"); } } tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,11 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase { "@string/test_string", packageName, "")); } public void testIsFromTestApp() { assertTrue(ExternalAccountType.isFromTestApp("com.google.android.contacts.tests")); assertFalse(ExternalAccountType.isFromTestApp("com.google.android.contacts")); } /** * Initialize with an invalid package name and see if type will be initialized, but empty. */ Loading Loading
src/com/android/contacts/common/model/account/ExternalAccountType.java +8 −3 Original line number Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class ExternalAccountType extends BaseAccountType { return -1; // Empty text is okay. } if (resourceName.charAt(0) != '@') { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, xmlAttributeName + " must be a resource name beginnig with '@'"); } return -1; Loading @@ -428,18 +428,23 @@ public class ExternalAccountType extends BaseAccountType { try { res = context.getPackageManager().getResourcesForApplication(packageName); } catch (NameNotFoundException e) { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, "Unable to load package " + packageName); } return -1; } final int resId = res.getIdentifier(name, null, packageName); if (resId == 0) { if (Log.isLoggable(TAG, Log.WARN)) { if (Log.isLoggable(TAG, Log.WARN) && !isFromTestApp(packageName)) { Log.w(TAG, "Unable to load " + resourceName + " from package " + packageName); } return -1; } return resId; } @VisibleForTesting static boolean isFromTestApp(String packageName) { return TextUtils.equals(packageName, "com.google.android.contacts.tests"); } }
tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,11 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase { "@string/test_string", packageName, "")); } public void testIsFromTestApp() { assertTrue(ExternalAccountType.isFromTestApp("com.google.android.contacts.tests")); assertFalse(ExternalAccountType.isFromTestApp("com.google.android.contacts")); } /** * Initialize with an invalid package name and see if type will be initialized, but empty. */ Loading