diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index f0823bb..697ae50 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -44,125 +44,153 @@
-
-
-
- xmlns:android
- Namespace:
-
-
-
-
-
-
- xmlns:.*
- Namespace:
-
-
- BY_NAME
-
-
-
-
- .*:id
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
- .*:name
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
- name
- ^$
-
-
-
-
-
-
- style
- ^$
-
-
-
-
-
-
- .*
- ^$
-
-
- BY_NAME
-
-
-
-
- .*:layout_width
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
- .*:layout_height
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
- .*:layout_.*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
- .*:width
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
- .*:height
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
- .*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
- .*
- .*
-
-
- BY_NAME
-
+
+
+
+
+ xmlns:android
+ Namespace:
+
+
+
+
+
+
+
+
+ xmlns:.*
+ Namespace:
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+ ^$
+
+
+
+
+
+
+
+
+ style
+ ^$
+
+
+
+
+
+
+
+
+ .*
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:layout_width
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_height
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:layout_.*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:width
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:height
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ http://schemas.android.com/apk/res/android
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+ .*
+
+
+ BY_NAME
+
+
@@ -170,5 +198,4 @@
-
-
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index d938ee6..f46b022 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -6,6 +6,7 @@
+
-
-
+
\ No newline at end of file
diff --git a/app-pro/src/main/AndroidManifest.xml b/app-pro/src/main/AndroidManifest.xml
index 552c4f8..595ec25 100644
--- a/app-pro/src/main/AndroidManifest.xml
+++ b/app-pro/src/main/AndroidManifest.xml
@@ -22,7 +22,6 @@
android:installLocation="auto">
-
-
diff --git a/build/intermediates/dex-cache/cache.xml b/build/intermediates/dex-cache/cache.xml
index d3b36c7..916627f 100644
--- a/build/intermediates/dex-cache/cache.xml
+++ b/build/intermediates/dex-cache/cache.xml
@@ -89,7 +89,7 @@
jar="/Users/mac/AndroidStudioProjects/turbo-editor/app/build/intermediates/exploded-aar/turbo-editor.libraries/sharedCode/unspecified/classes.jar"
jumboMode="false"
revision="22.0.0"
- sha1="6c6578ebabff77c87854baf7be7657d9e4df7ce0">
+ sha1="4d7789a42ceff3f474240180bb105f60d1ed9584">
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+ sha1="4d7789a42ceff3f474240180bb105f60d1ed9584">
diff --git a/libraries/sharedCode/build.gradle b/libraries/sharedCode/build.gradle
index b2765d7..114b686 100644
--- a/libraries/sharedCode/build.gradle
+++ b/libraries/sharedCode/build.gradle
@@ -61,14 +61,14 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:FloatingActionButton')
// compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
- compile 'org.apache.commons:commons-lang3:3.1'
+ compile 'org.apache.commons:commons-lang3:+'
compile files('libs/juniversalchardet-1.0.3.jar')
compile('com.android.support:appcompat-v7:22.+') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.android.support:support-v4:22.+'
- compile 'com.github.gabrielemariotti.changeloglib:library:1.5.1'
+ compile 'com.github.gabrielemariotti.changeloglib:library:+'
compile 'commons-io:commons-io:2.4'
- compile 'com.android.support:support-annotations:20.0.0'
+ compile 'com.android.support:support-annotations:+'
compile files('libs/markdownview-1.2.jar')
}
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/RootFW.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/RootFW.java
index 6bd24b9..a59d837 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/RootFW.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/RootFW.java
@@ -1,20 +1,20 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4;
@@ -39,7 +39,7 @@ import com.spazedog.lib.rootfw4.utils.io.FileReader;
import com.spazedog.lib.rootfw4.utils.io.FileWriter;
/**
- * This is a global static front-end to {@link com.spazedog.lib.rootfw4.Shell}. It allows one global shell connection to be
+ * This is a global static front-end to {@link Shell}. It allows one global shell connection to be
* easily shared across classes and threads without having to create multiple connections.
*/
public class RootFW {
@@ -53,7 +53,7 @@ public class RootFW {
/**
* An interface that can be used to monitor the current state of the global connection.
*
- * @see #addConnectionListener(com.spazedog.lib.rootfw4.RootFW.OnConnectionListener)
+ * @see #addConnectionListener(OnConnectionListener)
*/
public static interface OnConnectionListener extends OnShellConnectionListener {
/**
@@ -164,9 +164,9 @@ public class RootFW {
}
/**
- * Add a new {@link com.spazedog.lib.rootfw4.RootFW.OnConnectionListener} to the global shell
+ * Add a new {@link OnConnectionListener} to the global shell
*
- * @see #removeConnectionListener(com.spazedog.lib.rootfw4.RootFW.OnConnectionListener)
+ * @see #removeConnectionListener(OnConnectionListener)
*/
public static void addConnectionListener(OnConnectionListener listener) {
synchronized(mLock) {
@@ -175,9 +175,9 @@ public class RootFW {
}
/**
- * Remove a {@link com.spazedog.lib.rootfw4.RootFW.OnConnectionListener} from the global shell
+ * Remove a {@link OnConnectionListener} from the global shell
*
- * @see #addConnectionListener(com.spazedog.lib.rootfw4.RootFW.OnConnectionListener)
+ * @see #addConnectionListener(OnConnectionListener)
*/
public static void removeConnectionListener(OnConnectionListener listener) {
synchronized(mLock) {
@@ -186,161 +186,161 @@ public class RootFW {
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#execute(String)
+ * @see Shell#execute(String)
*/
public static Result execute(String command) {
return mShell.execute(command);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#execute(String[])
+ * @see Shell#execute(String[])
*/
public static Result execute(String[] commands) {
return mShell.execute(commands);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#execute(String[], Integer[], com.spazedog.lib.rootfw4.Shell.OnShellValidateListener)
+ * @see Shell#execute(String[], Integer[], OnShellValidateListener)
*/
public static Result execute(String[] commands, Integer[] resultCodes, OnShellValidateListener validater) {
return mShell.execute(commands, resultCodes, validater);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#executeAsync(String, com.spazedog.lib.rootfw4.Shell.OnShellResultListener)
+ * @see Shell#executeAsync(String, OnShellResultListener)
*/
public static void executeAsync(String command, OnShellResultListener listener) {
mShell.executeAsync(command, listener);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#executeAsync(String[], com.spazedog.lib.rootfw4.Shell.OnShellResultListener)
+ * @see Shell#executeAsync(String[], OnShellResultListener)
*/
public static void executeAsync(String[] commands, OnShellResultListener listener) {
mShell.executeAsync(commands, listener);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#executeAsync(String[], Integer[], com.spazedog.lib.rootfw4.Shell.OnShellValidateListener, com.spazedog.lib.rootfw4.Shell.OnShellResultListener)
+ * @see Shell#executeAsync(String[], Integer[], OnShellValidateListener, OnShellResultListener)
*/
public static void executeAsync(String[] commands, Integer[] resultCodes, OnShellValidateListener validater, OnShellResultListener listener) {
mShell.executeAsync(commands, resultCodes, validater, listener);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#isRoot()
+ * @see Shell#isRoot()
*/
public static Boolean isRoot() {
return mShell.isRoot();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#isConnected()
+ * @see Shell#isConnected()
*/
public static Boolean isConnected() {
return mShell != null && mShell.isConnected();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getTimeout()
+ * @see Shell#getTimeout()
*/
public static Integer getTimeout() {
return mShell.getTimeout();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#setTimeout(Integer)
+ * @see Shell#setTimeout(Integer)
*/
public static void setTimeout(Integer timeout) {
mShell.setTimeout(timeout);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getBinary(String)
+ * @see Shell#getBinary(String)
*/
public static String findCommand(String bin) {
return mShell.findCommand(bin);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#createAttempts(String)
+ * @see Shell#createAttempts(String)
*/
public static Attempts createAttempts(String command) {
return mShell.createAttempts(command);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getFileReader(String)
+ * @see Shell#getFileReader(String)
*/
public static FileReader getFileReader(String file) {
return mShell.getFileReader(file);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getFileWriter(String, Boolean)
+ * @see Shell#getFileWriter(String, Boolean)
*/
public static FileWriter getFileWriter(String file, Boolean append) {
return mShell.getFileWriter(file, append);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getFile(String)
+ * @see Shell#getFile(String)
*/
public static File getFile(String file) {
return mShell.getFile(file);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getFilesystem()
+ * @see Shell#getFilesystem()
*/
public static Filesystem getFilesystem() {
return mShell.getFilesystem();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getDisk(String)
+ * @see Shell#getDisk(String)
*/
public static Disk getDisk(String disk) {
return mShell.getDisk(disk);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getDevice()
+ * @see Shell#getDevice()
*/
public static Device getDevice() {
return mShell.getDevice();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getProcess(String)
+ * @see Shell#getProcess(String)
*/
public static Process getProcess(String process) {
return mShell.getProcess(process);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getProcess(Integer)
+ * @see Shell#getProcess(Integer)
*/
public static Process getProcess(Integer pid) {
return mShell.getProcess(pid);
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getMemory()
+ * @see Shell#getMemory()
*/
public static Memory getMemory() {
return mShell.getMemory();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getCompCache()
+ * @see Shell#getCompCache()
*/
public static CompCache getCompCache() {
return mShell.getCompCache();
}
/**
- * @see com.spazedog.lib.rootfw4.Shell#getSwap(String device)
+ * @see Shell#getSwap(String device)
*/
public static Swap getSwap(String device) {
return mShell.getSwap(device);
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/Shell.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/Shell.java
index 9fb3eef..6fa2626 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/Shell.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/Shell.java
@@ -19,6 +19,17 @@
package com.spazedog.lib.rootfw4;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
import android.os.Bundle;
import android.util.Log;
@@ -35,17 +46,6 @@ import com.spazedog.lib.rootfw4.utils.Memory.Swap;
import com.spazedog.lib.rootfw4.utils.io.FileReader;
import com.spazedog.lib.rootfw4.utils.io.FileWriter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
/**
* This class is a front-end to {@link ShellStream} which makes it easier to work
* with normal shell executions. If you need to execute a consistent command (one that never ends),
@@ -77,7 +77,7 @@ public class Shell {
}
/**
- * This interface is for use with {@link com.spazedog.lib.rootfw4.Shell#executeAsync(String[], com.spazedog.lib.rootfw4.Shell.OnShellResultListener)}.
+ * This interface is for use with {@link Shell#executeAsync(String[], OnShellResultListener)}.
*/
public static interface OnShellResultListener {
/**
@@ -127,7 +127,7 @@ public class Shell {
/**
* This class is used to store the result from shell executions.
- * It extends the {@link com.spazedog.lib.rootfw4.containers.Data} class.
+ * It extends the {@link Data} class.
*/
public static class Result extends Data {
private Integer mResultCode;
@@ -150,7 +150,7 @@ public class Shell {
}
/**
- * Compare the result code with {@link com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)} to determine
+ * Compare the result code with {@link Shell#addResultCode(Integer)} to determine
* whether or not the execution was a success.
*/
public Boolean wasSuccessful() {
@@ -172,7 +172,7 @@ public class Shell {
}
/**
- * A class containing automatically created shell attempts and links to both {@link com.spazedog.lib.rootfw4.Shell#executeAsync(String[], Integer[], com.spazedog.lib.rootfw4.Shell.OnShellResultListener)} and {@link com.spazedog.lib.rootfw4.Shell#execute(String[], Integer[])}
+ * A class containing automatically created shell attempts and links to both {@link Shell#executeAsync(String[], Integer[], OnShellResultListener)} and {@link Shell#execute(String[], Integer[])}
*
* All attempts are created based on {@link Common#BINARIES}.
*
@@ -182,7 +182,7 @@ public class Shell {
*
* Example: String("(%binary test -d '%binary pwd') || exit 1") would become String["(test -d 'pwd') || exit 1", "(busybox test -d 'busybox pwd') || exit 1", "(toolbox test -d 'toolbox pwd') || exit 1"]
*
- * @see com.spazedog.lib.rootfw4.Shell#createAttempts(String)
+ * @see Shell#createAttempts(String)
*/
public class Attempts {
protected String[] mAttempts;
@@ -322,7 +322,7 @@ public class Shell {
/**
* Execute a shell command.
*
- * @see com.spazedog.lib.rootfw4.Shell#execute(String[], Integer[])
+ * @see Shell#execute(String[], Integer[])
*
* @param command
* The command to execute
@@ -334,7 +334,7 @@ public class Shell {
/**
* Execute a range of commands until one is successful.
*
- * @see com.spazedog.lib.rootfw4.Shell#execute(String[], Integer[])
+ * @see Shell#execute(String[], Integer[])
*
* @param commands
* The commands to try
@@ -351,17 +351,17 @@ public class Shell {
*
* Shell.execute( new String(){"cat file", "toolbox cat file", "busybox cat file"} );
*
- * Whether or not a command was successful, depends on {@link com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)} which by default only contains '0'.
- * The command number that was successful can be checked using {@link com.spazedog.lib.rootfw4.Shell.Result#getCommandNumber()}.
+ * Whether or not a command was successful, depends on {@link Shell#addResultCode(Integer)} which by default only contains '0'.
+ * The command number that was successful can be checked using {@link Result#getCommandNumber()}.
*
* @param commands
* The commands to try
*
* @param resultCodes
- * Result Codes representing successful execution. These will be temp. merged with {@link com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)}.
+ * Result Codes representing successful execution. These will be temp. merged with {@link Shell#addResultCode(Integer)}.
*
* @param validater
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellValidateListener} instance or NULL
+ * A {@link OnShellValidateListener} instance or NULL
*/
public Result execute(String[] commands, Integer[] resultCodes, OnShellValidateListener validater) {
synchronized(mLock) {
@@ -399,7 +399,9 @@ public class Shell {
cmdCount += 1;
}
- return new Result(mOutput.toArray(new String[mOutput.size()]), mResultCode, codes.toArray(new Integer[codes.size()]), cmdCount);
+ if (mOutput != null) {
+ return new Result(mOutput.toArray(new String[mOutput.size()]), mResultCode, codes.toArray(new Integer[codes.size()]), cmdCount);
+ }
}
return null;
@@ -409,13 +411,13 @@ public class Shell {
/**
* Execute a shell command asynchronous.
*
- * @see com.spazedog.lib.rootfw4.Shell#executeAsync(String[], Integer[], com.spazedog.lib.rootfw4.Shell.OnShellResultListener)
+ * @see Shell#executeAsync(String[], Integer[], OnShellResultListener)
*
* @param command
* The command to execute
*
* @param listener
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellResultListener} callback instance
+ * A {@link OnShellResultListener} callback instance
*/
public void executeAsync(String command, OnShellResultListener listener) {
executeAsync(new String[]{command}, null, null, listener);
@@ -424,13 +426,13 @@ public class Shell {
/**
* Execute a range of commands asynchronous until one is successful.
*
- * @see com.spazedog.lib.rootfw4.Shell#executeAsync(String[], Integer[], com.spazedog.lib.rootfw4.Shell.OnShellResultListener)
+ * @see Shell#executeAsync(String[], Integer[], OnShellResultListener)
*
* @param commands
* The commands to try
*
* @param listener
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellResultListener} callback instance
+ * A {@link OnShellResultListener} callback instance
*/
public void executeAsync(String[] commands, OnShellResultListener listener) {
executeAsync(commands, null, null, listener);
@@ -439,19 +441,19 @@ public class Shell {
/**
* Execute a range of commands asynchronous until one is successful.
*
- * @see com.spazedog.lib.rootfw4.Shell#execute(String[], Integer[])
+ * @see Shell#execute(String[], Integer[])
*
* @param commands
* The commands to try
*
* @param resultCodes
- * Result Codes representing successful execution. These will be temp. merged with {@link com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)}.
+ * Result Codes representing successful execution. These will be temp. merged with {@link Shell#addResultCode(Integer)}.
*
* @param validater
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellValidateListener} instance or NULL
+ * A {@link OnShellValidateListener} instance or NULL
*
* @param listener
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellResultListener} callback instance
+ * A {@link OnShellResultListener} callback instance
*/
public synchronized void executeAsync(final String[] commands, final Integer[] resultCodes, final OnShellValidateListener validater, final OnShellResultListener listener) {
if(Common.DEBUG)Log.d(TAG, "executeAsync: Starting an async shell execution");
@@ -521,7 +523,7 @@ public class Shell {
* the shell changes.
*
* @param listener
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellConnectionListener} callback instance
+ * A {@link OnShellConnectionListener} callback instance
*/
public void addShellConnectionListener(OnShellConnectionListener listener) {
mConnectionRecievers.add(listener);
@@ -531,7 +533,7 @@ public class Shell {
* Remove a shell connection listener from the stack.
*
* @param listener
- * A {@link com.spazedog.lib.rootfw4.Shell.OnShellConnectionListener} callback instance
+ * A {@link OnShellConnectionListener} callback instance
*/
public void removeShellConnectionListener(OnShellConnectionListener listener) {
mConnectionRecievers.remove(listener);
@@ -583,7 +585,7 @@ public class Shell {
/**
* Remove a result code from the stack.
*
- * @see com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)
+ * @see Shell#addResultCode(Integer)
*
* @param resultCode
* The result code to remove from the stack
@@ -595,7 +597,7 @@ public class Shell {
/**
* Reset the stack containing result codes and set it back to default only containing '0'.
*
- * @see com.spazedog.lib.rootfw4.Shell#addResultCode(Integer)
+ * @see Shell#addResultCode(Integer)
*/
public void resetResultCodes() {
mResultCodes.clear();
@@ -654,7 +656,7 @@ public class Shell {
}
/**
- * Create a new instance of {@link com.spazedog.lib.rootfw4.Shell.Attempts}
+ * Create a new instance of {@link Attempts}
*
* @param command
* The command to convert into multiple attempts
@@ -668,7 +670,7 @@ public class Shell {
}
/**
- * Open a new RootFW {@link com.spazedog.lib.rootfw4.utils.io.FileReader}. This is the same as {@link com.spazedog.lib.rootfw4.utils.io.FileReader#FileReader(com.spazedog.lib.rootfw4.Shell, String)}.
+ * Open a new RootFW {@link FileReader}. This is the same as {@link FileReader#FileReader(Shell, String)}.
*
* @param file
* Path to the file
@@ -686,7 +688,7 @@ public class Shell {
}
/**
- * Open a new RootFW {@link com.spazedog.lib.rootfw4.utils.io.FileWriter}. This is the same as {@link com.spazedog.lib.rootfw4.utils.io.FileWriter#FileWriter(com.spazedog.lib.rootfw4.Shell, String, boolean)}.
+ * Open a new RootFW {@link FileWriter}. This is the same as {@link FileWriter#FileWriter(Shell, String, boolean)}.
*
* @param file
* Path to the file
@@ -707,7 +709,7 @@ public class Shell {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.File} instance.
+ * Get a new {@link File} instance.
*
* @param file
* Path to the file or directory
@@ -717,14 +719,14 @@ public class Shell {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Filesystem} instance.
+ * Get a new {@link Filesystem} instance.
*/
public Filesystem getFilesystem() {
return new Filesystem(this);
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Filesystem.Disk} instance.
+ * Get a new {@link Disk} instance.
*
* @param disk
* Path to a disk, partition or a mount point
@@ -735,14 +737,14 @@ public class Shell {
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Device} instance.
+ * Get a new {@link Device} instance.
*/
public Device getDevice() {
return new Device(this);
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Device.Process} instance.
+ * Get a new {@link Process} instance.
*
* @param process
* The name of the process
@@ -752,7 +754,7 @@ public class Shell {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Device.Process} instance.
+ * Get a new {@link Process} instance.
*
* @param pid
* The process id
@@ -762,21 +764,21 @@ public class Shell {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Memory} instance.
+ * Get a new {@link Memory} instance.
*/
public Memory getMemory() {
return new Memory(this);
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Memory.CompCache} instance.
+ * Get a new {@link CompCache} instance.
*/
public CompCache getCompCache() {
return new CompCache(this);
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Memory.Swap} instance.
+ * Get a new {@link Swap} instance.
*
* @param device
* The /dev/ swap device
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/ShellStream.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/ShellStream.java
index ad4b3f9..cb7674e 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/ShellStream.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/ShellStream.java
@@ -30,7 +30,7 @@ import android.util.Log;
/**
* This class opens a connection to the shell and creates a consistent output stream
- * that can be read using the {@link com.spazedog.lib.rootfw4.ShellStream.OnStreamListener} interface. It also
+ * that can be read using the {@link OnStreamListener} interface. It also
* contains an input stream that can be used to execute shell commands.
*/
public class ShellStream {
@@ -108,7 +108,7 @@ public class ShellStream {
/**
* This is called when the shell connection dies.
- * This can either be because a command executed 'exit', or if the method {@link com.spazedog.lib.rootfw4.ShellStream#destroy()} was called.
+ * This can either be because a command executed 'exit', or if the method {@link ShellStream#destroy()} was called.
*/
public void onStreamDied();
}
@@ -138,11 +138,16 @@ public class ShellStream {
try {
while (mIsActive && (output = mStdOutput.readLine()) != null) {
if (mListener != null && mCounter.size() > 0) {
- if (output.startsWith(mCommandEnd)) {
+ if (output.contains(mCommandEnd)) {
Integer result = 0;
try {
- result = Integer.parseInt(output.substring(mCommandEnd.length()+1));
+ if (output.startsWith(mCommandEnd)) {
+ result = Integer.parseInt(output.substring(mCommandEnd.length()+1));
+
+ } else {
+ result = 1;
+ }
} catch (Throwable e) {
Log.w(TAG, e.getMessage(), e);
@@ -182,7 +187,7 @@ public class ShellStream {
* Send a command to the shell input stream.
*
* This method is executed asynchronous. If you need to wait until the command finishes,
- * then use {@link com.spazedog.lib.rootfw4.ShellStream#waitFor()}.
+ * then use {@link ShellStream#waitFor()}.
*
* @param command
* The command to send to the shell
@@ -204,7 +209,7 @@ public class ShellStream {
mListener.onStreamStart();
String input = command + "\n";
- input += "echo " + mCommandEnd + " $?\n";
+ input += " echo " + mCommandEnd + " $?\n";
try {
mStdInput.write( input.getBytes() );
@@ -237,7 +242,7 @@ public class ShellStream {
/**
* Sleeps until the shell is done with a current command and ready for new input.
*
- * @see {@link com.spazedog.lib.rootfw4.ShellStream#waitFor(Integer)}
+ * @see {@link ShellStream#waitFor(Integer)}
*
* @return
* True if the shell connection is OK or false on connection error
@@ -327,7 +332,7 @@ public class ShellStream {
/**
* Close the shell connection.
*
- * This will force close the connection. Use this only when running a consistent command (if {@link com.spazedog.lib.rootfw4.ShellStream#isRunning()} returns true).
+ * This will force close the connection. Use this only when running a consistent command (if {@link ShellStream#isRunning()} returns true).
* When possible, sending the 'exit' command to the shell is a better choice.
*
* This method is executed asynchronous.
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/containers/Data.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/containers/Data.java
index 2c0b828..c4b3221 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/containers/Data.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/containers/Data.java
@@ -1,20 +1,20 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4.containers;
@@ -198,7 +198,7 @@ public class Data> extends BasicContainer {
}
/**
- * @see com.spazedog.lib.rootfw4.containers.Data#sort(Integer, Integer)
+ * @see Data#sort(Integer, Integer)
*/
public DATATYPE sort(Integer start) {
return (DATATYPE) sort(start, mLines.length);
@@ -296,7 +296,7 @@ public class Data> extends BasicContainer {
}
/**
- * @see com.spazedog.lib.rootfw4.containers.Data#assort(Integer, Integer)
+ * @see Data#assort(Integer, Integer)
*/
public DATATYPE assort(Integer start) {
return (DATATYPE) assort(mLines.length, start);
@@ -366,7 +366,7 @@ public class Data> extends BasicContainer {
}
/**
- * @see com.spazedog.lib.rootfw4.containers.Data#getLine(Integer, Boolean)
+ * @see Data#getLine(Integer, Boolean)
*/
public String getLine(Integer aLineNumber) {
return getLine(aLineNumber, false);
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Device.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Device.java
index 433ca69..552b70a 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Device.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Device.java
@@ -1,20 +1,20 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4.utils;
@@ -159,15 +159,15 @@ public class Device {
/**
* Reboots the device into the recovery.
*
- * This method first tries using the {@link android.os.PowerManager}, if that fails it fallbacks on using the reboot command from toolbox.
+ * This method first tries using the {@link PowerManager}, if that fails it fallbacks on using the reboot command from toolbox.
*
- * Note that using the {@link android.os.PowerManager} requires your app to optain the 'REBOOT' permission. If you don't want this, just parse NULL as {@link android.content.Context}
+ * Note that using the {@link PowerManager} requires your app to optain the 'REBOOT' permission. If you don't want this, just parse NULL as {@link Context}
* and the method will use the fallback. This however is more likely to fail, as many toolbox versions does not support the reboot command.
* And since only the kernel can write to the CBC, we need a native caller to invoke this. So there is no fallback for missing toolbox support when it comes
* to rebooting into the recovery.
*
* @param context
- * A {@link android.content.Context} or NULL to skip using the {@link android.os.PowerManager}
+ * A {@link Context} or NULL to skip using the {@link PowerManager}
*/
public Boolean rebootRecovery(Context context) {
if (context != null) {
@@ -230,7 +230,7 @@ public class Device {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Device.Process} instance
+ * Get a new {@link Process} instance
*
* @param process
* The name of the process
@@ -240,7 +240,7 @@ public class Device {
}
/**
- * Get a new {@link com.spazedog.lib.rootfw4.utils.Device.Process} instance
+ * Get a new {@link Process} instance
*
* @param pid
* The process id
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/File.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/File.java
index 6fe016a..f7dae91 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/File.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/File.java
@@ -1,20 +1,20 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4.utils;
@@ -218,7 +218,7 @@ public class File {
* size (on files), path to linked file (on links), permissions, group, user etc.
*
* @return
- * A new {@link com.spazedog.lib.rootfw4.utils.File.FileStat} object with all the file information
+ * A new {@link FileStat} object with all the file information
*/
public FileStat getDetails() {
synchronized (mLock) {
@@ -273,7 +273,7 @@ public class File {
* The max amount of lines to return. This also excepts negative numbers. 0 equals all lines.
*
* @return
- * An array of {@link com.spazedog.lib.rootfw4.utils.File.FileStat} object
+ * An array of {@link FileStat} object
*/
public FileStat[] getDetailedList(Integer maxLines) {
synchronized (mLock) {
@@ -432,7 +432,7 @@ public class File {
* Extract the content from the file and return it.
*
* @return
- * The entire file content wrapped in a {@link com.spazedog.lib.rootfw4.utils.File.FileData} object
+ * The entire file content wrapped in a {@link FileData} object
*/
public FileData read() {
synchronized (mLock) {
@@ -473,7 +473,7 @@ public class File {
* Whether or not to return the non-matching lines instead
*
* @return
- * All of the matched or non-matched lines wrapped in a {@link com.spazedog.lib.rootfw4.utils.File.FileData} object
+ * All of the matched or non-matched lines wrapped in a {@link FileData} object
*/
public FileData readMatch(final String match, final Boolean invert) {
synchronized (mLock) {
@@ -589,9 +589,10 @@ public class File {
for (String line : input) {
String escapedInput = oPatternEscape.matcher(line).replaceAll("\\\\$1");
Attempts attempts = mShell.createAttempts("echo '" + escapedInput + "' " + redirect + " '" + path + "' 2> /dev/null");
-
- if (!(status = attempts.execute().wasSuccessful())) {
- break;
+
+ Result result = attempts.execute();
+ if (result != null && !(status = result.wasSuccessful())) {
+ break;
}
redirect = ">>";
@@ -1092,6 +1093,8 @@ public class File {
}
if (builder.length() > 0) {
+ builder.append(" '" + getAbsolutePath() + "'");
+
Result result = mShell.createAttempts(builder.toString()).execute();
if (result != null && result.wasSuccessful()) {
@@ -1200,7 +1203,7 @@ public class File {
* if it is not already mounted.
*
* @param context
- * A {@link android.content.Context} that can be used together with the Android REBOOT permission
+ * A {@link Context} that can be used together with the Android REBOOT permission
* to use the PowerManager to reboot into recovery. This can be set to NULL
* if you want to just use the toolbox reboot command, however do note that not all
* toolbox versions support this command.
@@ -1356,7 +1359,7 @@ public class File {
}
/**
- * Get a {@link com.spazedog.lib.rootfw4.utils.io.FileWriter} pointing at this file
+ * Get a {@link FileWriter} pointing at this file
*/
public FileWriter getFileWriter() {
if (isFile()) {
@@ -1372,7 +1375,7 @@ public class File {
}
/**
- * Get a {@link com.spazedog.lib.rootfw4.utils.io.FileReader} pointing at this file
+ * Get a {@link FileReader} pointing at this file
*/
public FileReader getFileReader() {
if (isFile()) {
@@ -1632,7 +1635,7 @@ public class File {
}
/**
- * Open a new {@link com.spazedog.lib.rootfw4.utils.File} object pointed at another file.
+ * Open a new {@link File} object pointed at another file.
*
* @param fileName
* The file to point at
@@ -1645,7 +1648,7 @@ public class File {
}
/**
- * Open a new {@link com.spazedog.lib.rootfw4.utils.File} object with the parent of this file.
+ * Open a new {@link File} object with the parent of this file.
*
* @return
* A new instance of this class representing the parent directory
@@ -1655,7 +1658,7 @@ public class File {
}
/**
- * If this is a link, this method will return a new {@link com.spazedog.lib.rootfw4.utils.File} object with the real path attached.
+ * If this is a link, this method will return a new {@link File} object with the real path attached.
*
* @return
* A new instance of this class representing the real path of a possible link
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Filesystem.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Filesystem.java
index 4807ea3..a11ffb3 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Filesystem.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Filesystem.java
@@ -19,14 +19,6 @@
package com.spazedog.lib.rootfw4.utils;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.regex.Pattern;
-
import android.text.TextUtils;
import com.spazedog.lib.rootfw4.Common;
@@ -35,6 +27,14 @@ import com.spazedog.lib.rootfw4.Shell.Result;
import com.spazedog.lib.rootfw4.containers.BasicContainer;
import com.spazedog.lib.rootfw4.utils.File.FileData;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.regex.Pattern;
+
public class Filesystem {
public static final String TAG = Common.TAG + ".Filesystem";
@@ -162,7 +162,7 @@ public class Filesystem {
* Or perhaps you need the original device of a specific mount location.
*
* @return
- * An array of {@link com.spazedog.lib.rootfw4.utils.Filesystem.MountStat} objects
+ * An array of {@link MountStat} objects
*/
public MountStat[] getFsList() {
synchronized(oFstabLock) {
@@ -235,7 +235,7 @@ public class Filesystem {
* device path, mount location, file system type and mount options.
*
* @return
- * An array of {@link com.spazedog.lib.rootfw4.utils.Filesystem.MountStat} objects
+ * An array of {@link MountStat} objects
*/
public MountStat[] getMountList() {
FileData data = mShell.getFile("/proc/mounts").read();
@@ -264,7 +264,7 @@ public class Filesystem {
}
/**
- * Get an instance of the {@link com.spazedog.lib.rootfw4.utils.Filesystem.Disk} class.
+ * Get an instance of the {@link Disk} class.
*
* @param disk
* The location to the disk, partition or folder
@@ -528,7 +528,7 @@ public class Filesystem {
* only this method will just return the mount information for this specific device or mount location.
*
* @return
- * A single {@link com.spazedog.lib.rootfw4.utils.Filesystem.MountStat} object
+ * A single {@link MountStat} object
*/
public MountStat getMountDetails() {
MountStat[] list = getMountList();
@@ -563,7 +563,7 @@ public class Filesystem {
* only this method will just return the mount information for this specific device or mount location.
*
* @return
- * A single {@link com.spazedog.lib.rootfw4.utils.Filesystem.MountStat} object
+ * A single {@link MountStat} object
*/
public MountStat getFsDetails() {
MountStat[] list = getFsList();
@@ -599,7 +599,7 @@ public class Filesystem {
* information about the disk size, remaining bytes, used bytes and usage percentage.
*
* @return
- * A single {@link com.spazedog.lib.rootfw4.utils.Filesystem.DiskStat} object
+ * A single {@link DiskStat} object
*/
public DiskStat getDiskDetails() {
String[] commands = new String[]{"df -k '" + mFile.getAbsolutePath() + "'", "df '" + mFile.getAbsolutePath() + "'"};
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Memory.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Memory.java
index 06667cd..2195a46 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Memory.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/Memory.java
@@ -1,20 +1,20 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4.utils;
@@ -333,7 +333,7 @@ public class Memory {
}
/**
- * Get a new instance of {@link com.spazedog.lib.rootfw4.utils.Memory.Swap}
+ * Get a new instance of {@link Swap}
*
* @param device
* The Swap block device
@@ -343,7 +343,7 @@ public class Memory {
}
/**
- * Get a new instance of {@link com.spazedog.lib.rootfw4.utils.Memory.CompCache}
+ * Get a new instance of {@link CompCache}
*/
public CompCache getCompCache() {
return new CompCache(mShell);
@@ -386,7 +386,7 @@ public class Memory {
}
/**
- * This class is an extension of the {@link com.spazedog.lib.rootfw4.utils.Memory} class.
+ * This class is an extension of the {@link Memory} class.
* This can be used to get information about-, and handle swap and CompCache/ZRam devices.
*/
public static class Swap extends Memory {
@@ -534,7 +534,7 @@ public class Memory {
}
/**
- * This is an extension of the {@link com.spazedog.lib.rootfw4.utils.Memory.Swap} class. It's job is more CompCache/ZRam orientated.
+ * This is an extension of the {@link Swap} class. It's job is more CompCache/ZRam orientated.
* Unlike it's parent, this class can not only switch a CompCache/ZRam device on and off, it can also
* locate the proper supported type and load it's kernel module if not already done during boot.
*
@@ -582,11 +582,11 @@ public class Memory {
/**
* Enable this Swap device.
*
- * This overwrites {@link com.spazedog.lib.rootfw4.utils.Memory.Swap#setSwapOn()} to enable to feature of
+ * This overwrites {@link Swap#setSwapOn()} to enable to feature of
* setting a cache size for the CompCache/ZRam. This method sets the size to 18% of the total device memory.
*
* If you are sure that CompCache/ZRam is loaded and the device has been setup with size and swap partition and you don't want to change this,
- * then use {@link com.spazedog.lib.rootfw4.utils.Memory.Swap#setSwapOn()} instead. But if nothing has been setup yet, it could fail as it does nothing else but try to activate the device as Swap.
+ * then use {@link Swap#setSwapOn()} instead. But if nothing has been setup yet, it could fail as it does nothing else but try to activate the device as Swap.
*
* @see #setSwapOn(Integer)
*/
@@ -657,7 +657,7 @@ public class Memory {
/**
* Disable this Swap device.
*
- * This overwrites {@link com.spazedog.lib.rootfw4.utils.Memory.Swap#setSwapOff()} as this will also release the CompCache/ZRam from memory.
+ * This overwrites {@link Swap#setSwapOff()} as this will also release the CompCache/ZRam from memory.
*/
@Override
public Boolean setSwapOff() {
diff --git a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/io/FileReader.java b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/io/FileReader.java
index 32410ac..24ecbd6 100644
--- a/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/io/FileReader.java
+++ b/libraries/sharedCode/src/main/java/com/spazedog/lib/rootfw4/utils/io/FileReader.java
@@ -1,28 +1,25 @@
/*
- * Copyright (C) 2014 Vlad Mihalachi
+ * This file is part of the RootFW Project: https://github.com/spazedog/rootfw
+ *
+ * Copyright (c) 2015 Daniel Bergløv
*
- * This file is part of Turbo Editor.
- *
- * Turbo Editor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * RootFW is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * Turbo Editor is distributed in the hope that it will be useful,
+
+ * RootFW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with RootFW. If not, see
*/
package com.spazedog.lib.rootfw4.utils.io;
-import com.spazedog.lib.rootfw4.Common;
-import com.spazedog.lib.rootfw4.Shell;
-import com.spazedog.lib.rootfw4.ShellStream;
-
+import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -32,10 +29,14 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.CharBuffer;
+import com.spazedog.lib.rootfw4.Common;
+import com.spazedog.lib.rootfw4.Shell;
+import com.spazedog.lib.rootfw4.ShellStream;
+
/**
* This class allows you to open a file as root, if needed.
* Files that are not protected will be handled by a regular {@link java.io.FileReader} while protected files
- * will use a shell streamer instead. Both of which will act as a normal reader that can be used together with other classes like {@link java.io.BufferedReader} and such.
+ * will use a shell streamer instead. Both of which will act as a normal reader that can be used together with other classes like {@link BufferedReader} and such.
*
* Note that this should not be used for unending streams. This is only meant for regular files. If you need unending streams, like /dev/input/event*,
* you should use {@link ShellStream} instead.
@@ -46,14 +47,14 @@ public class FileReader extends Reader {
protected InputStreamReader mStream;
/**
- * Create a new {@link java.io.InputStreamReader}. However {@link com.spazedog.lib.rootfw4.utils.io.FileReader#FileReader(Shell, String)} is a better option.
+ * Create a new {@link InputStreamReader}. However {@link FileReader#FileReader(Shell, String)} is a better option.
*/
public FileReader(String file) throws FileNotFoundException {
this(null, file);
}
/**
- * Create a new {@link java.io.InputStreamReader}. If shell is not NULL, then
+ * Create a new {@link InputStreamReader}. If shell is not NULL, then
* the best match for cat will be located whenever a SuperUser connection is needed. This will be the best
* option for multiple environments.
*/
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
index 0a11f4b..4bc1447 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
@@ -166,7 +166,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
*/
private CustomDrawerLayout mDrawerLayout;
private static GoodScrollView verticalScroll;
- private static GreatUri greatUri = new GreatUri(Uri.EMPTY, "", "", false);
+ private static GreatUri greatUri = new GreatUri(Uri.EMPTY, "", "");
private Editor mEditor;
private HorizontalScrollView horizontalScroll;
private static SearchResult searchResult;
@@ -332,13 +332,13 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
if (requestCode == SELECT_FILE_CODE) {
final Uri data = intent.getData();
- final GreatUri newUri = new GreatUri(data, AccessStorageApi.getPath(this, data), AccessStorageApi.getName(this, data), false);
+ final GreatUri newUri = new GreatUri(data, AccessStorageApi.getPath(this, data), AccessStorageApi.getName(this, data));
newFileToOpen(newUri, "");
} else {
final Uri data = intent.getData();
- final GreatUri newUri = new GreatUri(data, AccessStorageApi.getPath(this, data), AccessStorageApi.getName(this, data), false);
+ final GreatUri newUri = new GreatUri(data, AccessStorageApi.getPath(this, data), AccessStorageApi.getName(this, data));
// grantUriPermission(getPackageName(), data, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final int takeFlags = intent.getFlags()
@@ -757,11 +757,11 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
//newFileToOpen(new File(intent
// .getData().getPath()), "");
Uri uri = intent.getData();
- GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri), false);
+ GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri));
newFileToOpen(newUri, "");
} else if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
- newFileToOpen(new GreatUri(Uri.EMPTY, "", "", false), intent.getStringExtra(Intent.EXTRA_TEXT));
+ newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), intent.getStringExtra(Intent.EXTRA_TEXT));
}
}
}
@@ -843,7 +843,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
good = false;
}
if (good) {
- greatUris.addFirst(new GreatUri(particularUri, AccessStorageApi.getPath(this, particularUri), name, false));
+ greatUris.addFirst(new GreatUri(particularUri, AccessStorageApi.getPath(this, particularUri), name));
sb.append(savedPaths[i]).append(",");
}
}
@@ -914,10 +914,9 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
fileName = FilenameUtils.getName(filePath);
fileExtension = FilenameUtils.getExtension(fileName).toLowerCase();
- isRootRequired = !(new File(filePath).canRead());
+ isRootRequired = !newUri.isReadable();
// if we cannot read the file, root permission required
if (isRootRequired) {
- newUri.setRootRequired(true);
readUri(newUri.getUri(), filePath, true);
}
// if we can read the file associated with the uri
@@ -987,6 +986,8 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
fileText = stringBuilder.toString();
}
+ if (isRootRequired)
+ RootFW.disconnect();
}
@Override
@@ -1160,7 +1161,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
}
void closedTheFile() {
- arrayAdapter.selectPosition(new GreatUri(Uri.EMPTY, "", "", false));
+ arrayAdapter.selectPosition(new GreatUri(Uri.EMPTY, "", ""));
}
//endregion
@@ -1197,7 +1198,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
//intent.putExtra(Intent.EXTRA_TITLE, ".txt");
startActivityForResult(intent, CREATE_REQUEST_CODE);
} else {
- newFileToOpen(new GreatUri(Uri.EMPTY, "", "", false), "");
+ newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), "");
}
}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
index 4796595..4318035 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
@@ -42,7 +42,7 @@ public class AdapterDrawer extends
private final LayoutInflater inflater;
// List of file details
private final LinkedList greatUris;
- private GreatUri selectedGreatUri = new GreatUri(Uri.EMPTY, "", "", false);
+ private GreatUri selectedGreatUri = new GreatUri(Uri.EMPTY, "", "");
public AdapterDrawer(Context context,
LinkedList greatUris,
@@ -75,7 +75,7 @@ public class AdapterDrawer extends
boolean closeOpenedFile = selectedGreatUri.getUri().equals(greatUri.getUri());
callbacks.CancelItem(position, closeOpenedFile);
if (closeOpenedFile)
- selectPosition(new GreatUri(Uri.EMPTY, "", "", false));
+ selectPosition(new GreatUri(Uri.EMPTY, "", ""));
}
});
@@ -97,7 +97,7 @@ public class AdapterDrawer extends
boolean closeOpenedFile = selectedGreatUri.getUri().equals(greatUri.getUri());
callbacks.CancelItem(position, closeOpenedFile);
if (closeOpenedFile)
- selectPosition(new GreatUri(Uri.EMPTY, "", "", false));
+ selectPosition(new GreatUri(Uri.EMPTY, "", ""));
}
});
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/NewFileDetailsDialog.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/NewFileDetailsDialog.java
index e18e859..7ef1e38 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/NewFileDetailsDialog.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/NewFileDetailsDialog.java
@@ -114,7 +114,7 @@ public class NewFileDetailsDialog extends DialogFragment {
file.getParentFile().mkdirs();
file.createNewFile();
- final GreatUri newUri = new GreatUri(Uri.fromFile(file), file.getAbsolutePath(), file.getName(), false);
+ final GreatUri newUri = new GreatUri(Uri.fromFile(file), file.getAbsolutePath(), file.getName());
new SaveFileTask((MainActivity) getActivity(), newUri, fileText, fileEncoding, new SaveFileTask.SaveFileInterface() {
@Override
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/SaveFileDialog.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/SaveFileDialog.java
index 323aa16..f5e1513 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/SaveFileDialog.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/SaveFileDialog.java
@@ -49,7 +49,7 @@ public class SaveFileDialog extends DialogFragment {
this.text = text;
this.encoding = encoding;
this.openNewFileAfter = false;
- this.newUri = new GreatUri(Uri.EMPTY, "", "", false);
+ this.newUri = new GreatUri(Uri.EMPTY, "", "");
}
@SuppressLint("ValidFragment")
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/task/SaveFileTask.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/task/SaveFileTask.java
index 203de63..762de27 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/task/SaveFileTask.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/task/SaveFileTask.java
@@ -27,6 +27,7 @@ import android.widget.Toast;
import com.spazedog.lib.rootfw4.RootFW;
import com.spazedog.lib.rootfw4.utils.File;
+import com.spazedog.lib.rootfw4.utils.Filesystem;
import org.apache.commons.io.FileUtils;
@@ -75,14 +76,7 @@ public class SaveFileTask extends AsyncTask {
if (TextUtils.isEmpty(filePath)) {
writeUri(uri.getUri(), newContent, encoding);
} else {
- if (uri.isRootRequired()) {
- if (RootFW.connect()) {
- File file = RootFW.getFile(filePath);
- file.write(newContent);
- }
- }
- // if we can read the file associated with the uri
- else {
+ if (uri.isWritable()) {
if (Device.hasKitKatApi())
writeUri(uri.getUri(), newContent, encoding);
else {
@@ -91,6 +85,21 @@ public class SaveFileTask extends AsyncTask {
encoding);
}
}
+ // 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());
+ file.write(newContent);
+
+ RootFW.disconnect();
+ }
+
+ }
+
}
message = positiveMessage;
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/GreatUri.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/GreatUri.java
index f58e9ca..d2e764f 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/GreatUri.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/GreatUri.java
@@ -33,13 +33,11 @@ public class GreatUri {
private Uri uri;
private String filePath;
private String fileName;
- private boolean isRootRequired;
- public GreatUri(Uri uri, String filePath, String fileName, boolean isRootRequired) {
+ public GreatUri(Uri uri, String filePath, String fileName) {
this.uri = uri;
this.filePath = filePath;
this.fileName = fileName;
- this.isRootRequired = isRootRequired;
}
@Override
@@ -92,11 +90,11 @@ public class GreatUri {
this.fileName = fileName;
}
- public boolean isRootRequired() {
- return isRootRequired;
+ public boolean isReadable() {
+ return new File(getFilePath()).canRead();
}
- public void setRootRequired(boolean isRootRequired) {
- this.isRootRequired = isRootRequired;
+ public boolean isWritable() {
+ return new File(getFilePath()).canWrite();
}
}