Skip to content

Commit 5773bfd

Browse files
author
Dianne Hackborn
committed
Add power menu action to take a bug report
Change-Id: I5f58d99e9a27a1fc496fa54e0c0ee333087155da
1 parent 4cb3384 commit 5773bfd

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

core/java/android/provider/Settings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,13 @@ public static boolean putFloat(ContentResolver cr, String name, float value) {
25842584
*/
25852585
public static final String DEVELOPMENT_SETTINGS_ENABLED = "development_settings_enabled";
25862586

2587+
/**
2588+
* When the user has enable the option to have a "bug report" command
2589+
* in the power menu.
2590+
* @hide
2591+
*/
2592+
public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
2593+
25872594
/**
25882595
* Whether ADB is enabled.
25892596
*/
@@ -4316,6 +4323,7 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
43164323
*/
43174324
public static final String[] SETTINGS_TO_BACKUP = {
43184325
ADB_ENABLED,
4326+
BUGREPORT_IN_POWER_MENU,
43194327
ALLOW_MOCK_LOCATION,
43204328
PARENTAL_CONTROL_ENABLED,
43214329
PARENTAL_CONTROL_REDIRECT_URL,

core/res/res/values/public.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,11 +1328,14 @@
13281328
<java-symbol type="layout" name="screen_title_icons" />
13291329
<java-symbol type="string" name="abbrev_wday_month_day_no_year" />
13301330
<java-symbol type="string" name="android_upgrading_title" />
1331+
<java-symbol type="string" name="bugreport_title" />
1332+
<java-symbol type="string" name="bugreport_message" />
13311333
<java-symbol type="string" name="faceunlock_multiple_failures" />
13321334
<java-symbol type="string" name="global_action_power_off" />
13331335
<java-symbol type="string" name="global_actions_airplane_mode_off_status" />
13341336
<java-symbol type="string" name="global_actions_airplane_mode_on_status" />
13351337
<java-symbol type="string" name="global_actions_toggle_airplane_mode" />
1338+
<java-symbol type="string" name="global_action_bug_report" />
13361339
<java-symbol type="string" name="global_action_silent_mode_off_status" />
13371340
<java-symbol type="string" name="global_action_silent_mode_on_status" />
13381341
<java-symbol type="string" name="global_action_toggle_silent_mode" />

core/res/res/values/strings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,17 @@
346346
<!-- label for item that turns off power in phone options dialog -->
347347
<string name="global_action_power_off">Power off</string>
348348

349+
<!-- label for item that generates a bug report in the phone options dialog -->
350+
<string name="global_action_bug_report">Bug report</string>
351+
352+
<!-- Take bug report menu title [CHAR LIMIT=NONE] -->
353+
<string name="bugreport_title">Take bug report</string>
354+
<!-- Message in bugreport dialog describing what it does [CHAR LIMIT=NONE] -->
355+
<string name="bugreport_message">This will collect information about your
356+
current device state, to send as an e-mail message. It will take a little
357+
time from starting the bug report until it is ready to be sent; please be
358+
patient.</string>
359+
349360
<!-- label for item that enables silent mode in phone options dialog -->
350361
<string name="global_action_toggle_silent_mode">Silent mode</string>
351362

policy/src/com/android/internal/policy/impl/GlobalActions.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import android.content.pm.UserInfo;
3131
import android.database.ContentObserver;
3232
import android.graphics.drawable.Drawable;
33-
import android.graphics.drawable.ScaleDrawable;
3433
import android.media.AudioManager;
3534
import android.net.ConnectivityManager;
3635
import android.os.Handler;
@@ -45,7 +44,6 @@
4544
import android.telephony.ServiceState;
4645
import android.telephony.TelephonyManager;
4746
import android.util.Log;
48-
import android.view.Gravity;
4947
import android.view.IWindowManager;
5048
import android.view.LayoutInflater;
5149
import android.view.View;
@@ -231,6 +229,50 @@ public boolean showBeforeProvisioning() {
231229
// next: airplane mode
232230
mItems.add(mAirplaneModeOn);
233231

232+
// next: bug report, if enabled
233+
if (Settings.Secure.getInt(mContext.getContentResolver(),
234+
Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0) {
235+
mItems.add(
236+
new SinglePressAction(0, R.string.global_action_bug_report) {
237+
238+
public void onPress() {
239+
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
240+
builder.setTitle(com.android.internal.R.string.bugreport_title);
241+
builder.setMessage(com.android.internal.R.string.bugreport_message);
242+
builder.setNegativeButton(com.android.internal.R.string.cancel, null);
243+
builder.setPositiveButton(com.android.internal.R.string.report,
244+
new DialogInterface.OnClickListener() {
245+
@Override
246+
public void onClick(DialogInterface dialog, int which) {
247+
// Add a little delay before executing, to give the
248+
// dialog a chance to go away before it takes a
249+
// screenshot.
250+
mHandler.postDelayed(new Runnable() {
251+
@Override public void run() {
252+
SystemProperties.set("ctl.start", "bugreport");
253+
}
254+
}, 500);
255+
}
256+
});
257+
AlertDialog dialog = builder.create();
258+
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
259+
dialog.show();
260+
}
261+
262+
public boolean onLongPress() {
263+
return false;
264+
}
265+
266+
public boolean showDuringKeyguard() {
267+
return true;
268+
}
269+
270+
public boolean showBeforeProvisioning() {
271+
return false;
272+
}
273+
});
274+
}
275+
234276
// last: silent mode
235277
if (SHOW_SILENT_TOGGLE) {
236278
mItems.add(mSilentModeAction);

0 commit comments

Comments
 (0)