Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6eff50de authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am a4191505: Merge "Add power menu action to take a bug report" into jb-mr1-dev

* commit 'a4191505':
  Add power menu action to take a bug report
parents f442aac3 a4191505
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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,
+3 −0
Original line number Diff line number Diff line
@@ -1328,11 +1328,14 @@
  <java-symbol type="layout" name="screen_title_icons" />
  <java-symbol type="string" name="abbrev_wday_month_day_no_year" />
  <java-symbol type="string" name="android_upgrading_title" />
  <java-symbol type="string" name="bugreport_title" />
  <java-symbol type="string" name="bugreport_message" />
  <java-symbol type="string" name="faceunlock_multiple_failures" />
  <java-symbol type="string" name="global_action_power_off" />
  <java-symbol type="string" name="global_actions_airplane_mode_off_status" />
  <java-symbol type="string" name="global_actions_airplane_mode_on_status" />
  <java-symbol type="string" name="global_actions_toggle_airplane_mode" />
  <java-symbol type="string" name="global_action_bug_report" />
  <java-symbol type="string" name="global_action_silent_mode_off_status" />
  <java-symbol type="string" name="global_action_silent_mode_on_status" />
  <java-symbol type="string" name="global_action_toggle_silent_mode" />
+11 −0
Original line number Diff line number Diff line
@@ -346,6 +346,17 @@
    <!-- label for item that turns off power in phone options dialog -->
    <string name="global_action_power_off">Power off</string>

    <!-- label for item that generates a bug report in the phone options dialog -->
    <string name="global_action_bug_report">Bug report</string>

    <!-- Take bug report menu title [CHAR LIMIT=NONE] -->
    <string name="bugreport_title">Take bug report</string>
    <!-- Message in bugreport dialog describing what it does [CHAR LIMIT=NONE] -->
    <string name="bugreport_message">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.</string>

    <!-- label for item that enables silent mode in phone options dialog -->
    <string name="global_action_toggle_silent_mode">Silent mode</string>

+44 −2
Original line number Diff line number Diff line
@@ -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);