Remove bugsender; now using dumpstate directly.
Bug: 8334369
Change-Id: I3a293c731bb9b02cc21e1df2863e2b0bc7a8f554
diff --git a/bugmailer/Android.mk b/bugmailer/Android.mk
deleted file mode 100644
index c5aea4b..0000000
--- a/bugmailer/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-LOCAL_PATH:= $(call my-dir)
-
-ifeq (platform,$(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE := send_bug
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_JAVA_LIBRARY)
-endif #JAVA_SUPPORT
diff --git a/bugmailer/bugmailer.sh b/bugmailer/bugmailer.sh
deleted file mode 100755
index c467aee..0000000
--- a/bugmailer/bugmailer.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/system/bin/sh
-
-# TODO: restructure this to keep bugreports entirely on internal storage
-
-# Do not allow bugreports on user builds unless USB debugging
-# is enabled.
-if [ "x$(getprop ro.build.type)" = "xuser" -a \
- "x$(getprop init.svc.adbd)" != "xrunning" ]; then
- exit 0
-fi
-
-# Build emulated storage paths when appropriate
-# See storage config details at http://source.android.com/tech/storage/
-if [ -n "$EMULATED_STORAGE_SOURCE" ]; then
- writePath="$EMULATED_STORAGE_SOURCE/0"
- readPath="$EMULATED_STORAGE_TARGET/0"
-else
- writePath="$EXTERNAL_STORAGE"
- readPath="$EXTERNAL_STORAGE"
-fi
-
-tmpPath="/data/local/tmp"
-bugreportPath="bugreports"
-screenshotPath="Pictures/Screenshots"
-
-# Create directories if needed
-if [ ! -e "$writePath/$bugreportPath" ]; then
- mkdir "$writePath/$bugreportPath"
-fi
-if [ ! -e "$writePath/$screenshotPath" ]; then
- mkdir "$writePath/$screenshotPath"
-fi
-
-timestamp=`date +'%Y-%m-%d-%H-%M-%S'`
-
-# take screen shot
-# we run this as a bg job in case screencap is stuck
-/system/bin/screencap -p "$writePath/$screenshotPath/Screenshot_$timestamp.png" &
-
-# run bugreport
-/system/bin/dumpstate -o "$tmpPath/bugreport-$timestamp" $@
-
-# copy finished bugreport into place for sending
-cp "$tmpPath/bugreport-$timestamp.txt" "$writePath/$bugreportPath/bugreport-$timestamp.txt"
-# clean up any remaining files
-rm $tmpPath/bugreport*
-
-# invoke send_bug to look up email accounts and fire intents
-# make it convenient to send bugreport to oneself
-/system/bin/send_bug "$readPath/$bugreportPath/bugreport-$timestamp.txt" "$readPath/$screenshotPath/Screenshot_$timestamp.png"
diff --git a/bugmailer/send_bug b/bugmailer/send_bug
deleted file mode 100755
index db58b32..0000000
--- a/bugmailer/send_bug
+++ /dev/null
@@ -1,5 +0,0 @@
-# Script to start "send_bug" on the device
-#
-base=/system
-export CLASSPATH=$base/framework/send_bug.jar
-exec app_process $base/bin com.android.commands.sendbug.SendBug "$@"
diff --git a/bugmailer/src/com/android/commands/sendbug/SendBug.java b/bugmailer/src/com/android/commands/sendbug/SendBug.java
deleted file mode 100644
index b650fe0..0000000
--- a/bugmailer/src/com/android/commands/sendbug/SendBug.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.commands.sendbug;
-
-import android.accounts.Account;
-import android.accounts.IAccountManager;
-import android.app.ActivityManagerNative;
-import android.app.IActivityManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.IPackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-import android.os.UserHandle;
-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 SEND_BUG_INTENT_ACTION = "android.testing.SEND_BUG";
-
- public static void main(String[] args) {
- if (args.length == 1) {
- new SendBug().run(args[0]);
- } else if (args.length == 2) {
- new SendBug().run(args[0], args[1]);
- }
- }
-
- private void run(String bugreportPath) {
- run(bugreportPath, null);
- }
-
- private void run(String bugreportPath, String screenShotPath) {
- final File bugreport = new File(bugreportPath);
- File screenShot = null;
- if (screenShotPath != null) {
- screenShot = new File(screenShotPath);
- }
- final Uri bugreportUri = Uri.fromFile(bugreport);
- // todo (aalbert): investigate adding a screenshot to BugReporter
- Intent intent = tryBugReporter(bugreportUri);
- if (intent == null) {
- final Uri screenshotUri = screenShot != null
- ? Uri.fromFile(screenShot) : null;
- intent = getSendMailIntent(bugreportUri, screenshotUri);
- }
- if (intent != null) {
- final IActivityManager am = ActivityManagerNative.getDefault();
- if (am == null) {
- Log.e(LOG_TAG, "Cannot get ActivityManager, is the system running?");
- return;
- }
- try {
- am.startActivityAsUser(null, null, intent, intent.getType(), null, null, 0, 0,
- null, null, null, UserHandle.USER_CURRENT);
- } catch (RemoteException e) {
- // ignore
- }
- } else {
- Log.w(LOG_TAG, "Cannot find account to send bugreport, local path: "
- + bugreportPath);
- }
- }
-
- private Intent tryBugReporter(Uri bugreportUri) {
- final Intent intent = new Intent(SEND_BUG_INTENT_ACTION);
- intent.setData(bugreportUri);
- final IPackageManager pm = IPackageManager.Stub.asInterface(
- ServiceManager.getService("package"));
- if (pm == null) {
- Log.e(LOG_TAG, "Cannot get PackageManager, is the system running?");
- return null;
- }
- final List<ResolveInfo> results;
- try {
- results = pm.queryIntentActivities(intent, null, 0, 0);
- } catch (RemoteException e) {
- return null;
- }
- if (results != null && results.size() > 0) {
- final ResolveInfo info = results.get(0);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName(info.activityInfo.applicationInfo.packageName,
- info.activityInfo.name);
- return intent;
- } else {
- return null;
- }
- }
-
- private Intent getSendMailIntent(Uri bugreportUri, Uri screenshotUri) {
- final Account sendToAccount = findSendToAccount();
- final Intent intent = new Intent(Intent.ACTION_SEND);
- intent.addCategory(Intent.CATEGORY_DEFAULT);
- intent.setType("application/octet-stream");
- intent.putExtra(Intent.EXTRA_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);
- if (screenshotUri != null) {
- final ArrayList<Uri> attachments = new ArrayList<Uri>();
- attachments.add(bugreportUri);
- attachments.add(screenshotUri);
- intent.setAction(Intent.ACTION_SEND_MULTIPLE);
- intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
- } else {
- intent.putExtra(Intent.EXTRA_STREAM, bugreportUri);
- }
- if (sendToAccount != null) {
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{sendToAccount.name});
- return intent;
- }
- return null;
- }
-
- private Account findSendToAccount() {
- final IAccountManager accountManager = IAccountManager.Stub.asInterface(ServiceManager
- .getService(Context.ACCOUNT_SERVICE));
- if (accountManager == null) {
- Log.e(LOG_TAG, "Cannot get AccountManager, is the system running?");
- return null;
- }
- 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) {
- // ignore
- }
- 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;
- }
- }
- }
- }
- return foundAccount;
- }
-}