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

Commit eb2094ce authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Changed the action executed when "Take bug report" is selected."

parents 87ccd55e e974f7ef
Loading
Loading
Loading
Loading
+55 −55
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            } else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
                if (Settings.Global.getInt(mContext.getContentResolver(),
                        Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) {
                    mItems.add(getBugReportAction());
                    mItems.add(new BugReportAction());
                }
            } else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) {
                if (mShowSilentToggle) {
@@ -367,19 +367,14 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        }
    }

    private Action getBugReportAction() {
        return new SinglePressAction(com.android.internal.R.drawable.ic_lock_bugreport,
                R.string.bugreport_title) {
    private class BugReportAction extends SinglePressAction implements LongPressAction {

        public BugReportAction() {
            super(com.android.internal.R.drawable.ic_lock_bugreport, R.string.bugreport_title);
        }

            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) {
        public void onPress() {
            // don't actually trigger the bugreport if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
@@ -388,27 +383,40 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            // Add a little delay before executing, to give the
            // dialog a chance to go away before it takes a
            // screenshot.
            // TODO: remove once screenshots are handled by Shell (instead of dumpstate)
            mHandler.postDelayed(new Runnable() {
                                    @Override public void run() {
                                        //  TODO: select 'progress' flag according to menu choice
                @Override
                public void run() {
                    try {
                                            ActivityManagerNative.getDefault()
                                                    .requestBugReport(true);
                        // Take a "heavy" bugreport: it's more user friendly, but causes more
                        // interference.
                        ActivityManagerNative.getDefault().requestBugReport(true);
                    } catch (RemoteException e) {
                    }
                }
            }, 500);
        }
                        });
                AlertDialog dialog = builder.create();
                dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
                dialog.show();

        @Override
        public boolean onLongPress() {
            // don't actually trigger the bugreport if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
                return false;
            }
            try {
                // Take a "light" bugreport, with less interference.
                ActivityManagerNative.getDefault().requestBugReport(false);
            } catch (RemoteException e) {
            }
            return true;
        }

        public boolean showDuringKeyguard() {
            return true;
        }

        @Override
        public boolean showBeforeProvisioning() {
            return false;
        }
@@ -420,7 +428,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                    Build.VERSION.RELEASE,
                    Build.ID);
        }
        };
    }

    private Action getSettingsAction() {
@@ -742,13 +749,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            mIcon = icon;
        }

        protected SinglePressAction(int iconResId, CharSequence message) {
            mIconResId = iconResId;
            mMessageResId = 0;
            mMessage = message;
            mIcon = null;
        }

        public boolean isEnabled() {
            return true;
        }