diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index c8bb8861a7889..e1ef67cf15eee 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2584,6 +2584,13 @@ public final class Settings {
*/
public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
+ /**
+ * When the user has enable the option to have a "bug report" command
+ * in the power menu.
+ * @hide
+ */
+ public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
+
/**
* Whether ADB is enabled.
*/
@@ -4316,6 +4323,7 @@ public final class Settings {
*/
public static final String[] SETTINGS_TO_BACKUP = {
ADB_ENABLED,
+ BUGREPORT_IN_POWER_MENU,
ALLOW_MOCK_LOCATION,
PARENTAL_CONTROL_ENABLED,
PARENTAL_CONTROL_REDIRECT_URL,
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 4881a94cf5ffd..41abd9b6767c2 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1328,11 +1328,14 @@
+
+
+
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index b369744af9ec8..352c409788add 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -346,6 +346,17 @@
Power off
+
+ Bug report
+
+
+ Take bug report
+
+ This will collect information about your
+ current device state, to send as an e-mail message. It will take a little
+ time from starting the bug report until it is ready to be sent; please be
+ patient.
+
Silent mode
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index e9b8267bc086a..6c50f1cedb1d2 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -30,7 +30,6 @@ import android.content.IntentFilter;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.ScaleDrawable;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.os.Handler;
@@ -45,7 +44,6 @@ import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Log;
-import android.view.Gravity;
import android.view.IWindowManager;
import android.view.LayoutInflater;
import android.view.View;
@@ -231,6 +229,50 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// next: airplane mode
mItems.add(mAirplaneModeOn);
+ // next: bug report, if enabled
+ if (Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0) {
+ mItems.add(
+ new SinglePressAction(0, R.string.global_action_bug_report) {
+
+ public void onPress() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ builder.setTitle(com.android.internal.R.string.bugreport_title);
+ builder.setMessage(com.android.internal.R.string.bugreport_message);
+ builder.setNegativeButton(com.android.internal.R.string.cancel, null);
+ builder.setPositiveButton(com.android.internal.R.string.report,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Add a little delay before executing, to give the
+ // dialog a chance to go away before it takes a
+ // screenshot.
+ mHandler.postDelayed(new Runnable() {
+ @Override public void run() {
+ SystemProperties.set("ctl.start", "bugreport");
+ }
+ }, 500);
+ }
+ });
+ AlertDialog dialog = builder.create();
+ dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
+ dialog.show();
+ }
+
+ public boolean onLongPress() {
+ return false;
+ }
+
+ public boolean showDuringKeyguard() {
+ return true;
+ }
+
+ public boolean showBeforeProvisioning() {
+ return false;
+ }
+ });
+ }
+
// last: silent mode
if (SHOW_SILENT_TOGGLE) {
mItems.add(mSilentModeAction);