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

This commit is contained in:
Dianne Hackborn
2012-08-07 11:45:23 -07:00
committed by Android (Google) Code Review
4 changed files with 66 additions and 2 deletions

View File

@@ -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,

View File

@@ -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" />

View File

@@ -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>

View File

@@ -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);