Display a warning dialog when the user enables USB debugging.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2009-06-25 13:36:00 -04:00
parent 0f1e11e219
commit b7e46e89d7
2 changed files with 42 additions and 4 deletions

View File

@@ -1457,7 +1457,7 @@ found in the list of installed applications.</string>
<string name="quick_launch_no_shortcut">No shortcut</string> <string name="quick_launch_no_shortcut">No shortcut</string>
<!-- On the Quick launch settings screen, summary text under the item for each assigned letter. --> <!-- On the Quick launch settings screen, summary text under the item for each assigned letter. -->
<string name="quick_launch_shortcut">Search + <xliff:g id="shortcut_letter">%1$s</xliff:g></string> <string name="quick_launch_shortcut">Search + <xliff:g id="shortcut_letter">%1$s</xliff:g></string>
<!-- On the Quick launch settings screen, title of "Clear shortcut" confirmation dialog. This is reached by longpressing an item for a shortcut letter. This allows the user to clear the assigned applicatino for that shortcut letter. --> <!-- On the Quick launch settings screen, title of "Clear shortcut" confirmation dialog. This is reached by longpressing an item for a shortcut letter. This allows the user to clear the assigned application for that shortcut letter. -->
<string name="quick_launch_clear_dialog_title">Clear</string> <string name="quick_launch_clear_dialog_title">Clear</string>
<!-- On the Quick launch settings screen, message in the "Clear shortcut" confirmation dialog. See the title for this dialog for more info. --> <!-- On the Quick launch settings screen, message in the "Clear shortcut" confirmation dialog. See the title for this dialog for more info. -->
<string name="quick_launch_clear_dialog_message">Your shortcut for <xliff:g id="shortcut_letter">%1$s</xliff:g> (<xliff:g id="application_name">%2$s</xliff:g>) will be cleared.</string> <string name="quick_launch_clear_dialog_message">Your shortcut for <xliff:g id="shortcut_letter">%1$s</xliff:g> (<xliff:g id="application_name">%2$s</xliff:g>) will be cleared.</string>
@@ -1498,6 +1498,10 @@ found in the list of installed applications.</string>
<string name="allow_mock_location">Allow mock locations</string> <string name="allow_mock_location">Allow mock locations</string>
<!-- setting Checkbox summary whether to allow mock locations --> <!-- setting Checkbox summary whether to allow mock locations -->
<string name="allow_mock_location_summary">Allow mock locations</string> <string name="allow_mock_location_summary">Allow mock locations</string>
<!-- Title of warning dialog about the implications of enabling USB debugging -->
<string name="adb_warning_title">Enable USB debugging?</string>
<!-- Warning text to user about the implications of enabling USB debugging -->
<string name="adb_warning_message">USB debugging is intended for development purposes only. It can be used to copy data between your computer and your device, install applications on your device without notification, and read log data.</string>
<!-- Title for the screen that lets the user choose a gadget to add to the home screen <!-- Title for the screen that lets the user choose a gadget to add to the home screen
(or other screens that can host gadgets). Note to translators: we're still determining (or other screens that can host gadgets). Note to translators: we're still determining

View File

@@ -16,6 +16,8 @@
package com.android.settings; package com.android.settings;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemProperties; import android.os.SystemProperties;
@@ -29,7 +31,8 @@ import android.text.TextUtils;
/* /*
* Displays preferences for application developers. * Displays preferences for application developers.
*/ */
public class DevelopmentSettings extends PreferenceActivity { public class DevelopmentSettings extends PreferenceActivity
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String ENABLE_ADB = "enable_adb"; private static final String ENABLE_ADB = "enable_adb";
private static final String KEEP_SCREEN_ON = "keep_screen_on"; private static final String KEEP_SCREEN_ON = "keep_screen_on";
@@ -39,6 +42,9 @@ public class DevelopmentSettings extends PreferenceActivity {
private CheckBoxPreference mKeepScreenOn; private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mAllowMockLocation; private CheckBoxPreference mAllowMockLocation;
// To track whether Yes was clicked in the adb warning dialog
private boolean mOkClicked;
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@@ -72,8 +78,19 @@ public class DevelopmentSettings extends PreferenceActivity {
} }
if (preference == mEnableAdb) { if (preference == mEnableAdb) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, if (mEnableAdb.isChecked()) {
mEnableAdb.isChecked() ? 1 : 0); mOkClicked = false;
new AlertDialog.Builder(this).setMessage(
getResources().getString(R.string.adb_warning_message))
.setTitle(R.string.adb_warning_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show()
.setOnDismissListener(this);
} else {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
}
} else if (preference == mKeepScreenOn) { } else if (preference == mKeepScreenOn) {
Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn.isChecked() ? mKeepScreenOn.isChecked() ?
@@ -85,4 +102,21 @@ public class DevelopmentSettings extends PreferenceActivity {
return false; return false;
} }
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
mOkClicked = true;
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 1);
} else {
// Reset the toggle
mEnableAdb.setChecked(false);
}
}
public void onDismiss(DialogInterface dialog) {
// Assuming that onClick gets called first
if (!mOkClicked) {
mEnableAdb.setChecked(false);
}
}
} }