Commits

Anonymous committed 4673407 Draft

Don't send logs unless debug mode is enabled

Comments (0)

Files changed (3)

res/values/strings.xml

     <string name="prg_symlinking">Symlinking ...</string>
     <string name="prg_remove_old">Removing old %s ...</string>
     <string name="prg_installing">Installing %s ...</string>
+    <string name="dt_debug_mode_not_enabled">Debug Mode</string>
+    <string name="dm_debug_mode_not_enabled">We noticed that \"Debug Mode\" is not enabled. This logcat will probably not have the information needed to figure out why Busybox Installer isn\'t working properly\n\nPlease enable \"Debug Mode\" and attempt the install again. After you attempt to install busybox again please send us the logcat.\n\nThank you!</string>
 
     <!-- TOAST MESSAGES -->
     <string name="invalid_directory">\'%s\' is not a valid directory</string>

res/xml/busybox_prefs.xml

     <PreferenceCategory android:title="@string/pt_troubleshoot" >
         <CheckBoxPreference
             android:defaultValue="false"
-            android:key="degub_mode"
+            android:key="debug_mode"
             android:title="@string/ps_debug_mode" />
 
         <PreferenceScreen

src/com/jrummy/busybox/installer/BusyboxPreferences.java

 
 	private static final int DIALOG_SET_SCHEDULE = 0;
 	private static final int DIALOG_CONFIRM_DELETE = 1;
+	private static final int DIALOG_DEBUG_MODE_DISABLED = 2;
 
 	private ProgressDialog mPbarDialog;
 	private SharedPreferences mPrefs;
 				}
 			})
 			.create();
+		} else if (id == DIALOG_DEBUG_MODE_DISABLED) {
+			return new AlertDialog.Builder(BusyboxPreferences.this)
+			.setIcon(android.R.drawable.ic_dialog_alert)
+			.setTitle(getString(R.string.dt_debug_mode_not_enabled))
+			.setCancelable(true)
+			.setMessage(getString(R.string.dm_debug_mode_not_enabled))
+			.setPositiveButton(getString(R.string.db_ok), 
+					new DialogInterface.OnClickListener() {
+				public void onClick(DialogInterface dialog, int whichButton) {
+					removeDialog(DIALOG_CONFIRM_DELETE);
+				}
+			})
+			.create();
 		} else {
 			return null;
 		}
 			showDialog(DIALOG_CONFIRM_DELETE);
 			return true;
 		} else if (key.equals(KEY_EMAIL_LOGCAT)) {
-			mPbarDialog = new ProgressDialog(BusyboxPreferences.this);
-			mPbarDialog.setMessage(getString(R.string.please_wait));
-			mPbarDialog.show();
-			new Thread() {
-				@Override
-				public void run() {
-					Looper.prepare();
-					File logcat = new File(Environment.getExternalStorageDirectory(),
-							"busybox_installer_logcat.txt");
-					new CMDProcessor().su.runWaitFor("logcat -d -f " + logcat);
-					Message msg = mHandler.obtainMessage(MSG_SEND_LOGCAT);
-					Bundle data = new Bundle();
-					data.putString("logcat", logcat.getAbsolutePath());
-					msg.setData(data);
-					mHandler.sendMessage(msg);
-				}
-			}.start();
+			if (!mPrefs.getBoolean(KEY_DEBUG_MODE, false)) {
+				showDialog(DIALOG_DEBUG_MODE_DISABLED);
+			} else {
+				sendLogcat();
+			}
 			return true;
 		}
 		return false;
 	}
 
+	private void sendLogcat() {
+		mPbarDialog = new ProgressDialog(BusyboxPreferences.this);
+		mPbarDialog.setMessage(getString(R.string.please_wait));
+		mPbarDialog.show();
+		new Thread() {
+			@Override
+			public void run() {
+				Looper.prepare();
+				File logcat = new File(Environment.getExternalStorageDirectory(),
+						"busybox_installer_logcat.txt");
+				new CMDProcessor().su.runWaitFor("logcat -d -f " + logcat);
+				Message msg = mHandler.obtainMessage(MSG_SEND_LOGCAT);
+				Bundle data = new Bundle();
+				data.putString("logcat", logcat.getAbsolutePath());
+				msg.setData(data);
+				mHandler.sendMessage(msg);
+			}
+		}.start();
+	}
 }