diff options
author | The Android Automerger <android-build@android.com> | 2012-08-17 14:55:49 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2012-08-17 14:55:49 -0700 |
commit | 534399c01650f3b145d34c1077e54be0b36a51a4 (patch) | |
tree | b4371f17f970435802750eb8a10804284a189dcd | |
parent | 6ce024cb7599cb0f6f1d80598c46fb1bae860363 (diff) | |
download | extras-534399c01650f3b145d34c1077e54be0b36a51a4.tar.gz |
Revert "sendbug improvements on email address handling"
This reverts commit 9ebc639a313d143ade1293cb5932b446d5e623d5.
-rw-r--r-- | bugmailer/src/com/android/commands/sendbug/SendBug.java | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/bugmailer/src/com/android/commands/sendbug/SendBug.java b/bugmailer/src/com/android/commands/sendbug/SendBug.java index 1b8d669c..da8788e4 100644 --- a/bugmailer/src/com/android/commands/sendbug/SendBug.java +++ b/bugmailer/src/com/android/commands/sendbug/SendBug.java @@ -27,18 +27,15 @@ import android.net.Uri; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.util.Log; import java.io.File; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; public class SendBug { - private static final String LOG_TAG = SendBug.class.getSimpleName(); - private static final Pattern EMAIL_REGEX = Pattern.compile( - "^[\\w.%+-]+@[\\w.-]+\\.[a-zA-Z]{2,}$"); + private static final String GOOGLE_ACCOUNT_TYPE = "com.google"; + private static final String EMAIL_ACCOUNT_TYPE = "com.android.email"; private static final String SEND_BUG_INTENT_ACTION = "android.testing.SEND_BUG"; public static void main(String[] args) { @@ -72,17 +69,12 @@ public class SendBug { ? Uri.fromFile(screenShot) : null; intent = getSendMailIntent(bugreportUri, screenshotUri); } - if (intent != null) { - final IActivityManager mAm = ActivityManagerNative.getDefault(); - try { - mAm.startActivity(null, intent, intent.getType(), null, null, 0, 0, - null, null, null); - } catch (RemoteException e) { - // ignore - } - } else { - Log.w(LOG_TAG, "Cannot find account to send bugreport, local path: " - + bugreportPath); + final IActivityManager mAm = ActivityManagerNative.getDefault(); + try { + mAm.startActivity(null, intent, intent.getType(), null, null, 0, 0, + null, null, null); + } catch (RemoteException e) { + // ignore } } } @@ -117,11 +109,11 @@ public class SendBug { final Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType("application/octet-stream"); - intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment()); + intent.putExtra("subject", bugreportUri.getLastPathSegment()); final StringBuilder sb = new StringBuilder(); sb.append(SystemProperties.get("ro.build.description")); sb.append("\n(Sent from BugMailer)"); - intent.putExtra(Intent.EXTRA_TEXT, (CharSequence)sb); + intent.putExtra("body", sb.toString()); if (screenshotUri != null) { final ArrayList<Uri> attachments = new ArrayList<Uri>(); attachments.add(bugreportUri); @@ -132,10 +124,9 @@ public class SendBug { intent.putExtra(Intent.EXTRA_STREAM, bugreportUri); } if (sendToAccount != null) { - intent.putExtra(Intent.EXTRA_EMAIL, new String[]{sendToAccount.name}); - return intent; + intent.putExtra("to", sendToAccount.name); } - return null; + return intent; } private Account findSendToAccount() { @@ -143,10 +134,6 @@ public class SendBug { .getService(Context.ACCOUNT_SERVICE)); Account[] accounts = null; Account foundAccount = null; - String preferredDomain = SystemProperties.get("sendbug.preferred.domain"); - if (!preferredDomain.startsWith("@")) { - preferredDomain = "@" + preferredDomain; - } try { accounts = accountManager.getAccounts(null); } catch (RemoteException e) { @@ -154,20 +141,13 @@ public class SendBug { } if (accounts != null) { for (Account account : accounts) { - if (EMAIL_REGEX.matcher(account.name).matches()) { - if (!preferredDomain.isEmpty()) { - // if we have a preferred domain and it matches, return; otherwise keep - // looking - if (account.name.endsWith(preferredDomain)) { - return account; - } else { - foundAccount = account; - } - // if we don't have a preferred domain, just return since it looks like - // an email address - } else { - return account; - } + if (GOOGLE_ACCOUNT_TYPE.equals(account.type)) { + // return first gmail account found + return account; + } else if (EMAIL_ACCOUNT_TYPE.equals(account.type)) { + // keep regular email account for now in case there are gmail accounts + // found later + foundAccount = account; } } } |