use of eu.chainfire.libsuperuser.Shell in project AmazeFileManager by TeamAmaze.
the class MainActivity method initializeInteractiveShell.
/**
* Initializes an interactive shell, which will stay throughout the app lifecycle
* The shell is associated with a handler thread which maintain the message queue from the
* callbacks of shell as we certainly cannot allow the callbacks to run on same thread because
* of possible deadlock situation and the asynchronous behaviour of LibSuperSU
*/
private void initializeInteractiveShell() {
// handler threads every time the code relaunch.
if (isRootExplorer()) {
handlerThread = new HandlerThread("handler");
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
shellInteractive = (new Shell.Builder()).useSU().setHandler(handler).open();
// TODO: check for busybox
/*try {
if (!RootUtils.isBusyboxAvailable()) {
Toast.makeText(this, getString(R.string.error_busybox), Toast.LENGTH_LONG).show();
closeInteractiveShell();
sharedPref.edit().putBoolean(PreferenceUtils.KEY_ROOT, false).apply();
}
} catch (ShellNotRunningException e) {
e.printStackTrace();
sharedPref.edit().putBoolean(PreferenceUtils.KEY_ROOT, false).apply();
}*/
}
}
use of eu.chainfire.libsuperuser.Shell in project XposedInstaller by rovo89.
the class RootUtil method startShell.
/**
* Starts an interactive shell with root permissions. Does nothing if
* already running.
*
* @return true if root access is available, false otherwise
*/
public synchronized boolean startShell() {
if (mShell != null) {
if (mShell.isRunning()) {
return true;
} else {
dispose();
}
}
mCallbackThread = new HandlerThread("su callback listener");
mCallbackThread.start();
mCommandRunning = true;
mShell = new Shell.Builder().useSU().setHandler(new Handler(mCallbackThread.getLooper())).setOnSTDERRLineListener(mStderrListener).open(mOpenListener);
waitForCommandFinished();
if (mLastExitCode != OnCommandResultListener.SHELL_RUNNING) {
dispose();
return false;
}
return true;
}
use of eu.chainfire.libsuperuser.Shell in project afwall by ukanth.
the class Api method cleanupUid.
// Cleanup unused shell opened by logservice
public static void cleanupUid() {
try {
Set<String> uids = G.storedPid();
if (uids != null && uids.size() > 0) {
Shell.Interactive tempSession = new Shell.Builder().useSU().open();
for (String uid : uids) {
Log.i(Api.TAG, "Cleaning up previous uid: " + uid);
tempSession.addCommand("kill -9 " + uid);
}
G.storedPid(new HashSet());
if (tempSession != null) {
tempSession.kill();
tempSession.close();
}
}
} catch (ClassCastException e) {
Log.e(TAG, "ClassCastException in cleanupUid: " + e.getMessage());
} catch (Exception e) {
Log.e(TAG, "Exception in cleanupUid: " + e.getMessage());
}
}
Aggregations