Commits

Anonymous committed a44194d Draft

Add email logcat preference

Comments (0)

Files changed (3)

res/values/strings.xml

     <string name="dt_download_failed">Download Failed</string>
     <string name="no_internet_connection">Failed to download %s.\n\nPlease make sure you have a good internet connection and try again.</string>
     <string name="binary_install_success">Successfully installed %s.</string>
-    <string name="binary_install_failed">Installing %s failed.\n\nPlease try installing a different version.\n\nIf problems persist please email us and we will do our best to resolve your issue.</string>
+    <string name="binary_install_failed">Installing %s failed.\n\nPlease try installing a different version.\n\nIf problems persist please click menu > preferences and enable \"Debug Mode\". Then attempt the install again and go back to preferences and click \"Email logcat\".</string>
     <string name="dt_root_access_failed">Root Access</string>
     <string name="dm_root_access_failed">We failed to gain root access.\n\nBusybox Installer requires root access to install busybox on your system.\n\nIf you are rooted and you are receiving this message in error please email us and we can help you resolve the problem</string>
     <string name="menu_more_apps">More Apps</string>
     <string name="pt_delete_busybox">Delete busybox</string>
     <string name="ps_delete_busybox">Remove busybox from your system</string>
     <string name="ps_debug_mode">Debug Mode</string>
+    <string name="pt_troubleshoot">Troubleshoot</string>
+    <string name="ps_email_logcat">Email logcat</string>
 
     <!-- CHECKBOX -->
     <string name="cb_symlink">Symlink applets</string>

res/xml/busybox_prefs.xml

             android:key="delete_busybox"
             android:summary="@string/ps_delete_busybox"
             android:title="@string/pt_delete_busybox" />
-        <CheckBoxPreference
-            android:defaultValue="false"
-            android:key="degub_mode"
-            android:title="@string/ps_debug_mode" />
     </PreferenceCategory>
     <PreferenceCategory
         android:key="general_scripter_settings"
             android:summary="@string/ps_use_bash_shell"
             android:title="@string/pt_use_bash_shell" />
     </PreferenceCategory>
+    <PreferenceCategory android:title="@string/pt_troubleshoot" >
+        <CheckBoxPreference
+            android:defaultValue="false"
+            android:key="degub_mode"
+            android:title="@string/ps_debug_mode" />
+
+        <PreferenceScreen
+            android:defaultValue="false"
+            android:key="email_logcat"
+            android:title="@string/ps_email_logcat" />
+    </PreferenceCategory>
 
 </PreferenceScreen>

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

 
 package com.jrummy.busybox.installer;
 
+import java.io.File;
+
 import android.app.AlarmManager;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnCancelListener;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.content.res.Resources;
 import android.graphics.Color;
 import android.graphics.Typeface;
+import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
+import android.os.Environment;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.widget.TimePicker;
 import android.widget.Toast;
 
+import com.jrummy.busybox.installer.util.CMDProcessor;
 import com.jrummy.busybox.installer.util.Constants;
 import com.jrummy.busybox.installer.util.Helpers;
 import com.jrummy.busybox.installer.util.UpdateHelper;
 	public static final String KEY_USE_BASH_SHELL = "scripter_use_bash_shell";
 	public static final String KEY_DELETE_BUSYBOX = "delete_busybox";
 	public static final String KEY_DEBUG_MODE = "debug_mode";
+	public static final String KEY_EMAIL_LOGCAT = "email_logcat";
 
 	public static final int LAST_VERSION_NUMBER = 1200;
 
 	private static final int MSG_REMOVED_BUSYBOX = 0;
+	private static final int MSG_SEND_LOGCAT = 1;
 
 	private static final int DIALOG_SET_SCHEDULE = 0;
 	private static final int DIALOG_CONFIRM_DELETE = 1;
 
 	@Override
 	protected void onCreate(final Bundle savedInstanceState) {
-		mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
 		super.onCreate(savedInstanceState);
 		addPreferencesFromResource(R.xml.busybox_prefs);
+		
+		mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
 		mPrefs.registerOnSharedPreferenceChangeListener(this);
+		
 		mTitleFont = Typeface.createFromAsset(getAssets(), "fonts/sonysketch.ttf");
 		mMainFont = Typeface.createFromAsset(getAssets(), "fonts/default.ttf");
+		
 		PreferenceScreen time = (PreferenceScreen) getPreferenceScreen()
 				.findPreference(KEY_SCHEDULE_TIME);
 		PreferenceScreen deleteBusybox = (PreferenceScreen) getPreferenceScreen()
 				.findPreference(KEY_DELETE_BUSYBOX);
+		PreferenceScreen emailLogcat = (PreferenceScreen) getPreferenceScreen()
+				.findPreference(KEY_EMAIL_LOGCAT);
+		
+		deleteBusybox.setOnPreferenceClickListener(this);
+		emailLogcat.setOnPreferenceClickListener(this);
 		time.setOnPreferenceClickListener(this);
-		deleteBusybox.setOnPreferenceClickListener(this);
 	}
 
 	@Override
 				Toast.makeText(getApplicationContext(), getString(R.string.removed_busybox), 
 						Toast.LENGTH_SHORT).show();
 				break;
+			case MSG_SEND_LOGCAT:
+				mPbarDialog.dismiss();
+				StringBuilder debugInfo = new StringBuilder();
+				debugInfo.append("Attached is a logcat generated by " + getString(R.string.app_name));
+				debugInfo.append("\n\n");
+				debugInfo.append("----------------------------");
+				debugInfo.append("\n");
+				debugInfo.append("model: " + Build.MODEL + "\n");
+				debugInfo.append("brand: " + Build.BRAND + "\n");
+				debugInfo.append("device: " + Build.DEVICE + "\n");
+				debugInfo.append("display: " + Build.DISPLAY + "\n");
+				debugInfo.append("hardware: " + Build.HARDWARE + "\n");
+				debugInfo.append("manufacturer: " + Build.MANUFACTURER + "\n");
+				debugInfo.append("sdk version: " + Build.VERSION.SDK_INT + "\n\n");
+				Intent intent = new Intent(Intent.ACTION_SEND);
+				intent.setType("text/plain");
+				intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jrummy16@gmail.com" });
+				intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
+				intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(
+						"file://" + msg.getData().getString("logcat")));
+				intent.putExtra(Intent.EXTRA_TEXT, debugInfo.toString());
+                startActivity(Intent.createChooser(intent, getString(R.string.ps_email_logcat)));
+				break;
 			}
 		}
 	};
 		} else if (key.equals(KEY_DELETE_BUSYBOX)) {
 			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();
+			return true;
 		}
 		return false;
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.