本文整理匯總了Java中com.stericson.RootTools.RootTools類的典型用法代碼示例。如果您正苦於以下問題:Java RootTools類的具體用法?Java RootTools怎麽用?Java RootTools使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RootTools類屬於com.stericson.RootTools包,在下文中一共展示了RootTools類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.splash_activity);
((ProgressBar) findViewById(R.id.progressBar)).getIndeterminateDrawable()
.setColorFilter(Color.parseColor("#FFFFFF"), android.graphics.PorterDuff.Mode.SRC_ATOP);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(SplashActivity.this, ScriptActivity.class);
if (RootTools.isAccessGiven()) {
startActivity(i);
finish();
} else {
showDialog(ALERT_DIALOG);
}
}
}, SPLASH_TIME_OUT);
}
示例2: parseSpecialPermissions
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public int parseSpecialPermissions(String permission) {
int tmp = 0;
if (permission.charAt(2) == 's') {
tmp += 4;
}
if (permission.charAt(5) == 's') {
tmp += 2;
}
if (permission.charAt(8) == 't') {
tmp += 1;
}
RootTools.log("special permissions " + tmp);
return tmp;
}
示例3: fixUtils
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
/**
* This will check an array of binaries, determine if they exist and determine that it has
* either the permissions 755, 775, or 777. If an applet is not setup correctly it will try and
* fix it. (This is for Busybox applets or Toolbox applets)
*
* @param utils Name of the utility to check.
* @return boolean to indicate whether the operation completed. Note that this is not indicative
* of whether the problem was fixed, just that the method did not encounter any
* exceptions.
* @throws Exception if the operation cannot be completed.
*/
public boolean fixUtils(String[] utils) throws Exception {
for (String util : utils) {
if (!checkUtil(util)) {
if (checkUtil("busybox")) {
if (hasUtil(util, "busybox")) {
fixUtil(util, RootTools.utilPath);
}
} else {
if (checkUtil("toolbox")) {
if (hasUtil(util, "toolbox")) {
fixUtil(util, RootTools.utilPath);
}
} else {
return false;
}
}
}
}
return true;
}
示例4: isNativeToolsReady
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public boolean isNativeToolsReady(int nativeToolsId, Context context) {
RootTools.log("Preparing Native Tools");
InternalVariables.nativeToolsReady = false;
Installer installer;
try {
installer = new Installer(context);
} catch (IOException ex) {
if (RootTools.debugMode) {
ex.printStackTrace();
}
return false;
}
if (installer.isBinaryInstalled("nativetools")) {
InternalVariables.nativeToolsReady = true;
} else {
InternalVariables.nativeToolsReady = installer.installBinary(nativeToolsId,
"nativetools", "700");
}
return InternalVariables.nativeToolsReady;
}
示例5: hasEnoughSpaceOnSdCard
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
/**
* Checks if there is enough Space on SDCard
*
* @param updateSize size to Check (long)
* @return <code>true</code> if the Update will fit on SDCard, <code>false</code> if not enough
* space on SDCard. Will also return <code>false</code>, if the SDCard is not mounted as
* read/write
*/
@SuppressWarnings("deprecation")
public boolean hasEnoughSpaceOnSdCard(long updateSize) {
RootTools.log("Checking SDcard size and that it is mounted as RW");
String status = Environment.getExternalStorageState();
if (!status.equals(Environment.MEDIA_MOUNTED)) {
return false;
}
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = 0;
long availableBlocks = 0;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSize();
availableBlocks = stat.getAvailableBlocks();
} else {
blockSize = stat.getBlockSizeLong();
availableBlocks = stat.getAvailableBlocksLong();
}
return (updateSize < availableBlocks * blockSize);
}
示例6: createRootdir
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean createRootdir(String parentPath, String name) {
File dir = new File(parentPath + File.separator + name);
if (dir.exists())
return false;
try {
if (!readReadWriteFile())
RootTools.remount(parentPath, "rw");
execute("mkdir " + getCommandLineString(dir.getAbsolutePath()));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例7: createRootFile
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean createRootFile(String parentPath, String name) {
File dir = new File(parentPath + File.separator + name);
if (dir.exists())
return false;
try {
if (!readReadWriteFile())
RootTools.remount(parentPath, "rw");
execute("touch " + getCommandLineString(dir.getAbsolutePath()));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例8: renameRootTarget
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean renameRootTarget(String path, String oldname, String name) {
File file = new File(path + File.separator + oldname);
File newf = new File(path + File.separator + name);
if (name.length() < 1)
return false;
try {
if (!readReadWriteFile())
RootTools.remount(path, "rw");
execute("mv " + getCommandLineString(file.getAbsolutePath()) + " "
+ getCommandLineString(newf.getAbsolutePath()));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例9: deleteFileRoot
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean deleteFileRoot(String path) {
try {
if (!readReadWriteFile())
RootTools.remount(path, "rw");
if (new File(path).isDirectory()) {
execute("rm -f -r " + getCommandLineString(path));
} else {
execute("rm -r " + getCommandLineString(path));
}
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例10: delete
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
@Override
public void delete(final BoolResultListener listener) {
RootUtils.RootCommand command = new RootUtils.RootCommand("rm -rf \"%s\"", getAbsolutePath())
{
@Override
public void onFinish(boolean success, String output) {
listener.onResult(success && output.trim().isEmpty());
}
};
try {
RootTools.getShell(true).add(command);
}catch (Exception e) {
L.e(e);
listener.onResult(false);
}
}
示例11: checkRootFromRootTools
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
private void checkRootFromRootTools() {
RootStatus rootStatus;
if (RootTools.isRootAvailable()) {
try {
if (RootTools.isAccessGiven()) {
rootStatus = RootStatus.ROOT_GRANT;
} else {
rootStatus = RootStatus.ROOT_DENIED;
}
} catch (Exception e) {
rootStatus = RootStatus.ROOT_DENIED;
}
} else {
rootStatus = RootStatus.ROOT_DENIED;
}
if (rootStatus == RootStatus.ROOT_GRANT) {
rootListener.onRootAndBusyBoxOk();
} else {
rootListener.onRootDenied();
}
}
示例12: createRootdir
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean createRootdir(File dir, String path) {
if (dir.exists())
return false;
try {
if (!readReadWriteFile())
RootTools.remount(getCommandLineString(path), "rw");
runAndWait("mkdir " + getCommandLineString(dir.getAbsolutePath()));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例13: renameRootTarget
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static void renameRootTarget(String path, String oldname, String name) {
File file = new File(path + "/" + oldname);
File newf = new File(path + "/" + name);
if (name.length() < 1)
return;
try {
if (!readReadWriteFile())
RootTools.remount(getCommandLineString(path), "rw");
runAndWait("mv " + getCommandLineString(file.getAbsolutePath()) + " "
+ getCommandLineString(newf.getAbsolutePath()));
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: createRootFile
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
public static boolean createRootFile(String cdir, String name) {
File dir = new File(cdir + "/" + name);
if (dir.exists())
return false;
try {
if (!readReadWriteFile())
RootTools.remount(getCommandLineString(cdir), "rw");
runAndWait("touch " + getCommandLineString(dir.getAbsolutePath()));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例15: doInBackground
import com.stericson.RootTools.RootTools; //導入依賴的package包/類
@Override
protected PartitionInfo doInBackground(final File... params) {
final String path = params[0].getAbsolutePath();
final StatFsCompat statFs = new StatFsCompat(path);
final long valueTotal = statFs.getTotalBytes();
final long valueAvail = statFs.getAvailableBytes();
final long valueUsed = valueTotal - valueAvail;
String[] permission = null;
String perm;
if (RootTools.isAccessGiven())
permission = RootCommands.getFileProperties(params[0]);
perm = permission != null ? permission[0] : Permissions.getBasicPermission(params[0]);
return new PartitionInfo(path, perm, valueTotal,
statFs.getBlockSizeLong(), statFs.getFreeBytes(), valueUsed);
}