Commits

Anonymous committed d13d57d Draft

Detect if system is compatible with busybox versions, bump version to 4.0

  • Participants
  • Parent commits 6d8f5fa

Comments (1)

Files changed (4)

File AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.jrummy.busybox.installer"
-    android:versionCode="39"
-    android:versionName="3.9" >
+    android:versionCode="40"
+    android:versionName="4.0" >
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

File 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 click menu > preferences and enable \"Debug Mode\". Then attempt the install again and go back to preferences and click \"Email logcat\".</string>
+    <string name="binary_install_failed">Installing %s failed.\n\nPlease try installing a different version.\n\nPlease note that Busybox Installer attempts to install busybox to your system. Some versions of busybox may not work with some devices. If problems persist please email us and we will be glad to offer our assistance.</string>
+    <string name="busybox_install_failed_system_error">Installing %1$s failed.\n\nWe have detected that your system cannot function with this version of busybox.\n\nPlease try installing a different ROM or fixing your system.\n\nError:\n%2$s</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>

File src/com/jrummy/busybox/installer/BusyboxActivity.java

 			title.setText(name);
 
 			if (id == DIALOG_INSTALL_FAILED) {
-				message.setText(getString(R.string.binary_install_failed, name));
+				if (installer.mErrorMessage == BusyboxInstaller.SYSTEM_ERROR_MESSAGE) {
+					message.setText(getString(R.string.busybox_install_failed_system_error, 
+							name, installer.mStderr));
+				} else {
+					message.setText(getString(R.string.binary_install_failed, name));
+				}
 			} else {
 				message.setText(getString(R.string.binary_install_success, name));
 			}
 			final TextView titleText = (TextView) dialog.findViewById(R.id.title);
 			final Scripter scripter = (Scripter) BusyboxFragment.getData(SCRIPTER_TAB_POS);
 			final Script script = scripter.mScript;
+
+			if (script == null) {
+				return null;
+			} else if (script.getName() == null) {
+				return null;
+			}
+
 			dialogIcon.setImageResource(R.drawable.script_file);
 			titleText.setText(script.getName());
 			titleText.setTypeface(mTitleFont);

File src/com/jrummy/busybox/installer/BusyboxInstaller.java

 	private static final int MSG_INSTALL_COMPLETE = 1;
 	private static final int MSG_UPDATE_PBAR = 2;
 
+	static final int SYSTEM_ERROR_MESSAGE = 0;
+	static final int DEFAULT_ERROR_MESSAGE = 1;
+
 	private SharedPreferences mPrefs;
 	private SharedPreferences.Editor mPrefsEditor;
 	private Activity mActivity;
 	private String mInstallLocation;
 	private String mBinaryName;
 	private ProgressDialog mPbarDialog;
+	protected int mErrorMessage;
+	protected String mStderr;
 
 	protected LinearLayout mLoadingProgress;
 	protected LinearLayout mSymlinkCheckBoxLayout;
 				BinaryInstaller installer = new BinaryInstaller(
 						mDownloadPath, mInstallLocation, mBinaryName);
 				boolean installSuccess = false;
+				mErrorMessage = DEFAULT_ERROR_MESSAGE;
 				Message msg = mHandler.obtainMessage(MSG_UPDATE_PBAR);
 				Bundle data = new Bundle();
 
 				// install binary
 				if (installer.installBinary()) {
 					if (mBinaryName.equals("busybox")) {
+						CMDProcessor.CommandResult result = new CMDProcessor().sh
+								.runWaitFor("busybox");
+						if (result.success()) {
+							installSuccess = true;
+						} else if (result.stderr.contains("CANNOT LINK EXECUTABLE")
+								|| result.stderr.contains("reloc_library")
+								|| result.stderr.contains("permission denied")) {
+							mErrorMessage = SYSTEM_ERROR_MESSAGE;
+							mStderr = result.stderr;
+						}
 						installSuccess = Helpers.isBusyboxInstalled();
 					} else {
 						installSuccess = true;