Swap out rootfw for libsu.
THis compiles but I haven't yet tested it. It won't get merged back in until I test it fully.
This commit is contained in:
@@ -58,8 +58,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':libraries:sharedCode')
|
||||
//compile 'com.spazedog.lib:rootfw_gen4:+@aar'
|
||||
compile 'com.github.topjohnwu:libsu:1.2.0'
|
||||
compile project(':libraries:FloatingActionButton')
|
||||
compile 'org.apache.commons:commons-lang3:+'
|
||||
compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
|
||||
|
@@ -68,8 +68,7 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.faizmalkani.floatingactionbutton.FloatingActionButton;
|
||||
import com.spazedog.lib.rootfw4.RootFW;
|
||||
import com.spazedog.lib.rootfw4.utils.io.FileReader;
|
||||
import com.topjohnwu.superuser.io.SuFileInputStream;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@@ -978,10 +977,8 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
|
||||
encoding = "UTF-8";
|
||||
|
||||
// Connect the shared connection
|
||||
if (RootFW.connect()) {
|
||||
FileReader reader = RootFW.getFileReader(path);
|
||||
buffer = new BufferedReader(reader);
|
||||
}
|
||||
InputStreamReader reader = new InputStreamReader(new SuFileInputStream(path));
|
||||
buffer = new BufferedReader(reader);
|
||||
} else {
|
||||
|
||||
boolean autoencoding = PreferenceHelper.getAutoEncoding(MainActivity.this);
|
||||
@@ -1008,9 +1005,6 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
|
||||
buffer.close();
|
||||
fileText = stringBuilder.toString();
|
||||
}
|
||||
|
||||
if (isRootRequired)
|
||||
RootFW.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -39,7 +39,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.faizmalkani.floatingactionbutton.FloatingActionButton;
|
||||
import com.spazedog.lib.rootfw4.RootFW;
|
||||
import com.topjohnwu.superuser.io.SuFile;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -383,24 +383,22 @@ public class SelectFileActivity extends ActionBarActivity implements SearchView.
|
||||
currentFolder = tempFolder.getAbsolutePath();
|
||||
|
||||
if (!tempFolder.canRead()) {
|
||||
if (RootFW.connect()) {
|
||||
com.spazedog.lib.rootfw4.utils.File folder = RootFW.getFile(currentFolder);
|
||||
com.spazedog.lib.rootfw4.utils.File.FileStat[] stats = folder.getDetailedList();
|
||||
SuFile folder = new SuFile(currentFolder);
|
||||
SuFile[] files = folder.listFiles();
|
||||
|
||||
if (stats != null) {
|
||||
for (com.spazedog.lib.rootfw4.utils.File.FileStat stat : stats) {
|
||||
if (stat.type().equals("d")) {
|
||||
folderDetails.add(new AdapterDetailedList.FileDetail(stat.name(),
|
||||
getString(R.string.folder),
|
||||
""));
|
||||
} else if (!FilenameUtils.isExtension(stat.name().toLowerCase(), unopenableExtensions)
|
||||
&& stat.size() <= Build.MAX_FILE_SIZE * FileUtils.ONE_KB) {
|
||||
final long fileSize = stat.size();
|
||||
//SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
|
||||
//String date = format.format("");
|
||||
fileDetails.add(new AdapterDetailedList.FileDetail(stat.name(),
|
||||
FileUtils.byteCountToDisplaySize(fileSize), ""));
|
||||
}
|
||||
if (files != null) {
|
||||
for (SuFile file : files) {
|
||||
if (file.isDirectory()) {
|
||||
folderDetails.add(new AdapterDetailedList.FileDetail(file.getName(),
|
||||
getString(R.string.folder),
|
||||
""));
|
||||
} else if (!FilenameUtils.isExtension(file.getName().toLowerCase(), unopenableExtensions)
|
||||
&& file.length() <= Build.MAX_FILE_SIZE * FileUtils.ONE_KB) {
|
||||
final long fileSize = file.length();
|
||||
//SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
|
||||
//String date = format.format("");
|
||||
fileDetails.add(new AdapterDetailedList.FileDetail(file.getName(),
|
||||
FileUtils.byteCountToDisplaySize(fileSize), ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,11 +24,18 @@ import android.view.ViewConfiguration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class MyApp extends Application {
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
|
||||
public class MyApp extends Shell.ContainerApp {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// Shell initialization
|
||||
Shell.setFlags(Shell.FLAG_REDIRECT_STDERR);
|
||||
Shell.verboseLogging(true);
|
||||
|
||||
// force to sow the overflow menu icon
|
||||
try {
|
||||
ViewConfiguration config = ViewConfiguration.get(this);
|
||||
|
@@ -25,12 +25,9 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.spazedog.lib.rootfw4.RootFW;
|
||||
import com.spazedog.lib.rootfw4.Shell;
|
||||
import com.spazedog.lib.rootfw4.utils.File;
|
||||
import com.spazedog.lib.rootfw4.utils.Filesystem;
|
||||
|
||||
import com.topjohnwu.superuser.io.SuFileOutputStream;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -73,7 +70,6 @@ public class SaveFileTask extends AsyncTask<Void, Void, Void> {
|
||||
protected Void doInBackground(final Void... voids) {
|
||||
|
||||
boolean isRootNeeded = false;
|
||||
Shell.Result resultRoot = null;
|
||||
|
||||
try {
|
||||
String filePath = uri.getFilePath();
|
||||
@@ -93,34 +89,11 @@ public class SaveFileTask extends AsyncTask<Void, Void, Void> {
|
||||
}
|
||||
// if we can read the file associated with the uri
|
||||
else {
|
||||
|
||||
if (RootFW.connect()) {
|
||||
Filesystem.Disk systemPart = RootFW.getDisk(uri.getParentFolder());
|
||||
systemPart.mount(new String[]{"rw"});
|
||||
|
||||
File file = RootFW.getFile(uri.getFilePath());
|
||||
resultRoot = file.writeResult(newContent);
|
||||
|
||||
RootFW.disconnect();
|
||||
}
|
||||
|
||||
IOUtils.write(newContent, new SuFileOutputStream(uri.getFilePath()), encoding);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isRootNeeded) {
|
||||
if (resultRoot != null && resultRoot.wasSuccessful()) {
|
||||
message = positiveMessage;
|
||||
}
|
||||
else if (resultRoot != null) {
|
||||
message = negativeMessage + " command number: " + resultRoot.getCommandNumber() + " result code: " + resultRoot.getResultCode() + " error lines: " + resultRoot.getString();
|
||||
}
|
||||
else
|
||||
message = negativeMessage;
|
||||
}
|
||||
else
|
||||
message = positiveMessage;
|
||||
message = positiveMessage;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = e.getMessage();
|
||||
@@ -155,4 +128,4 @@ public class SaveFileTask extends AsyncTask<Void, Void, Void> {
|
||||
public interface SaveFileInterface {
|
||||
void fileSaved(Boolean success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user