Skip to content

Commit

Permalink
Guard against a few rare errors from Play logs
Browse files Browse the repository at this point in the history
  • Loading branch information
srowen committed Nov 2, 2017
1 parent 49d90b6 commit 7eae23f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Expand Up @@ -122,13 +122,15 @@ public void handleMessage(Message message) {
} }


// Needed for default Android browser / Chrome only apparently // Needed for default Android browser / Chrome only apparently
switch (browserPackageName) { if (browserPackageName != null) {
case "com.android.browser": switch (browserPackageName) {
case "com.android.chrome": case "com.android.browser":
intent.setPackage(browserPackageName); case "com.android.chrome":
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setPackage(browserPackageName);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, browserPackageName); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
break; intent.putExtra(Browser.EXTRA_APPLICATION_ID, browserPackageName);
break;
}
} }


try { try {
Expand Down
Expand Up @@ -201,7 +201,7 @@ final void addContact(String[] names,
// Only use the first name in the array, if present. // Only use the first name in the array, if present.
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, ContactsContract.Contacts.CONTENT_URI); Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, ContactsContract.Contacts.CONTENT_URI);
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
putExtra(intent, ContactsContract.Intents.Insert.NAME, names != null ? names[0] : null); putExtra(intent, ContactsContract.Intents.Insert.NAME, names != null && names.length > 0 ? names[0] : null);


putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation); putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation);


Expand Down Expand Up @@ -270,7 +270,7 @@ final void addContact(String[] names,
if (note != null) { if (note != null) {
aggregatedNotes.append('\n').append(note); aggregatedNotes.append('\n').append(note);
} }
if (geo != null) { if (geo != null && geo.length >= 2) {
aggregatedNotes.append('\n').append(geo[0]).append(',').append(geo[1]); aggregatedNotes.append('\n').append(geo[0]).append(',').append(geo[1]);
} }


Expand Down
Expand Up @@ -196,7 +196,11 @@ static List<List<String>> matchVCardPrefixedField(CharSequence prefix,
if ("uri".equals(valueType)) { if ("uri".equals(valueType)) {
// Don't actually support dereferencing URIs, but use scheme-specific part not URI // Don't actually support dereferencing URIs, but use scheme-specific part not URI
// as value, to support tel: and mailto: // as value, to support tel: and mailto:
element = URI.create(element).getSchemeSpecificPart(); try {
element = URI.create(element).getSchemeSpecificPart();
} catch (IllegalArgumentException iae) {
// ignore
}
} }
if (metadata == null) { if (metadata == null) {
List<String> match = new ArrayList<>(1); List<String> match = new ArrayList<>(1);
Expand Down

0 comments on commit 7eae23f

Please sign in to comment.