當前位置: 首頁>>代碼示例>>Java>>正文


Java RootTools.getShell方法代碼示例

本文整理匯總了Java中com.stericson.RootTools.RootTools.getShell方法的典型用法代碼示例。如果您正苦於以下問題:Java RootTools.getShell方法的具體用法?Java RootTools.getShell怎麽用?Java RootTools.getShell使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.stericson.RootTools.RootTools的用法示例。


在下文中一共展示了RootTools.getShell方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enableUMS

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
boolean enableUMS(Context context) {
    try {
        String enableCommand = data.getString(Constants.setPermissionCmds, "")+"\n"+data.getString(Constants.enableUMScmds, "");
        if(enableCommand.isEmpty()) {
            Toast.makeText(context, context.getString(R.string.toast_open_app_once), Toast.LENGTH_SHORT).show();
            return false;
        }
        Shell rootShell = RootTools.getShell(true);
        Command cmd = new Command(0, "setenforce 0\n"+enableCommand);
        rootShell.add(cmd);
        //if(!rootShell.isExecuting) rootShell.close();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(context, context.getString(R.string.error_ums), Toast.LENGTH_SHORT).show();
        openApp(context);
        return false;
    }
    Toast.makeText(context, context.getString(R.string.toast_ums_enabled), Toast.LENGTH_SHORT).show();
    isUMSdisabled = false;
    showNotification(context);
    return true;
}
 
開發者ID:GokulNC,項目名稱:USB_Mass_Storage_Enabler,代碼行數:23,代碼來源:UsbBroadcastReceiver.java

示例2: disableUMS

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
boolean disableUMS(Context context, boolean removeNotif) {
    try {
        String disableCommand = data.getString(Constants.disableUMScmds, "");
        if(disableCommand.isEmpty()) {
            Toast.makeText(context, context.getString(R.string.toast_open_app_once), Toast.LENGTH_SHORT).show();
            return false;
        }
        Shell rootShell = RootTools.getShell(true);
        Command cmd = new Command(0, disableCommand);
        rootShell.add(cmd);
        //if(!rootShell.isExecuting) rootShell.close();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(context, context.getString(R.string.error_ums_disable), Toast.LENGTH_SHORT).show();
        return false;
    }
    Toast.makeText(context, context.getString(R.string.toast_ums_disabled), Toast.LENGTH_SHORT).show();
    isUMSdisabled = true;
    if(removeNotif) removeNotification(context);
    else showNotification(context);
    //TODO: if(MainActivity.isAppOpen) MainActivity.updateUSBconfig(); //When toggled from notif
    return true;
}
 
開發者ID:GokulNC,項目名稱:USB_Mass_Storage_Enabler,代碼行數:24,代碼來源:UsbBroadcastReceiver.java

示例3: getInstance

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
public static RootShell getInstance()
{
	if (m_instance == null)
	{
		m_instance = new RootShell();
		try
		{
			m_shell = RootTools.getShell(true);
		}
		catch (Exception e)
		{
			m_shell = null;
		}
	}
	
	return m_instance;
}
 
開發者ID:rahulkumar66,項目名稱:Performance-Tweaker,代碼行數:18,代碼來源:RootShell.java

示例4: getInstance

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
public static NonRootShell getInstance()
{
	if (m_instance == null)
	{
		m_instance = new NonRootShell();
		try
		{
			m_shell = RootTools.getShell(false);
		}
		catch (Exception e)
		{
			m_shell = null;
		}
	}
	
	return m_instance;
}
 
開發者ID:rahulkumar66,項目名稱:Performance-Tweaker,代碼行數:18,代碼來源:NonRootShell.java

示例5: initBamboo

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
private void initBamboo() {
    try {
        Shell shell = RootTools.getShell(true);
        shell.useCWD(this);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                + " init") {
        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Fusion,項目名稱:BambooGarden,代碼行數:18,代碼來源:Garden.java

示例6: createNewBamboo

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
private void createNewBamboo(final BambooInfo bamboo) {
    try {
        Shell shell = RootTools.getShell(true);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                + " create "
                + bamboo.getName()) {
        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Fusion,項目名稱:BambooGarden,代碼行數:18,代碼來源:Garden.java

示例7: updateBambooColor

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
protected void updateBambooColor(BambooInfo bamboo, int color) {
    try {
        Shell shell = RootTools.getShell(true);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                        + " color "
                        + bamboo.getName()
                        + " " + color) {

            @Override
            public void commandCompleted(int id, int exitCode) {
                super.commandCompleted(id, exitCode);
                refreshBambooGarden();
            }

        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Fusion,項目名稱:BambooGarden,代碼行數:26,代碼來源:Garden.java

示例8: deleteBamboo

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
private void deleteBamboo(final BambooInfo bamboo) {
    if(bamboo != null) {
        try {
            Shell shell = RootTools.getShell(true);
            JavaCommandCapture cmd = new JavaCommandCapture(
                    43,
                    false,
                    Garden.this,
                    "com.voilaweb.mobile.bamboogarden.RootHelper"
                            + " delete "
                            + bamboo.getName()) {

                @Override
                public void commandCompleted(int id, int exitCode) {
                    super.commandCompleted(id, exitCode);
                    refreshBambooGarden();
                }

            };
            shell.add(cmd);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Fusion,項目名稱:BambooGarden,代碼行數:27,代碼來源:Garden.java

示例9: getMounts

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
/**
 * This will return an ArrayList of the class Mount. The class mount contains the following
 * property's: device mountPoint type flags
 * <p/>
 * These will provide you with any information you need to work with the mount points.
 *
 * @return <code>ArrayList<Mount></code> an ArrayList of the class Mount.
 * @throws Exception if we cannot return the mount points.
 */
public ArrayList<Mount> getMounts() throws Exception {

    InternalVariables.mounts = new ArrayList<>();

    if (null == InternalVariables.mounts || InternalVariables.mounts.isEmpty()) {
        Shell shell = RootTools.getShell(true);

        Command cmd = new Command(Constants.GET_MOUNTS,
                false,
                "cat /proc/mounts") {

            @Override
            public void commandOutput(int id, String line) {
                if (id == Constants.GET_MOUNTS) {
                    RootTools.log(line);

                    String[] fields = line.split(" ");
                    InternalVariables.mounts.add(new Mount(new File(fields[0]), // device
                            new File(fields[1]), // mountPoint
                            fields[2], // fstype
                            fields[3] // flags
                    ));
                }

                super.commandOutput(id, line);
            }
        };
        shell.add(cmd);
        this.commandWait(shell, cmd);
    }

    return InternalVariables.mounts;
}
 
開發者ID:AlexanderKirillov,項目名稱:Script-Executor-ROOT,代碼行數:43,代碼來源:RootToolsInternalMethods.java

示例10: onCreate

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    try {
        mRootShell = RootTools.getShell(true);
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, R.string.requires_root, Toast.LENGTH_LONG).show();
        stopSelf();
        return;
    }

    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File mountDir = new File(Environment.getExternalStorageDirectory(), MOUNT_DIR);
        if (!mountDir.exists() && !mountDir.mkdir()) {
            Toast.makeText(this, R.string.failed_mkdir, Toast.LENGTH_LONG).show();
            stopSelf();
            return;
        }

        mAutomounter = new Automounter(mRootShell, MOUNT_DIR, this, this);
    }

    mBlockDeviceObserver = new BlockDeviceObserver(mRootShell, mAutomounter);
    mBlockDeviceObserver.startWatching();
    mNotification = new MountieNotification(this, this);
}
 
開發者ID:acomminos,項目名稱:Mountie,代碼行數:30,代碼來源:MountieService.java

示例11: setSettingForce

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
public void setSettingForce(String path, String value) throws Exception {
	Shell shell = RootTools.getShell(true);
	
	CommandCapture command = new CommandCapture(0, "chmod 777 " + path);
	shell.add(command);
	commandWait(command);

	try {
		CommandCapture command2 = new CommandCapture(0, "echo " + value + " > " + path);
		shell.add(command2);
		commandWait(command2);
	} catch (Exception e) {
	}
}
 
開發者ID:shaun2029,項目名稱:Multi-Core-Control,代碼行數:15,代碼來源:SysfsInterface.java

示例12: setFilePermissions

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
protected int setFilePermissions(Shell shell, String permissions, String file) throws Exception{
	if (shell == null) shell = RootTools.getShell(true);

	CommandCapture command = new CommandCapture(0, "chmod " + permissions + " " + file);
	shell.add(command);
	commandWait(command);
	
	return command.getExitCode();
}
 
開發者ID:shaun2029,項目名稱:Multi-Core-Control,代碼行數:10,代碼來源:SysfsInterface.java

示例13: getRootShell

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
@Nullable
static Pair<Boolean, Shell> getRootShell() {
    try {
        return new Pair<>(true, RootTools.getShell(true));
    } catch (IOException | RootDeniedException | TimeoutException e) {
        return null;
    }
}
 
開發者ID:Doctoror,項目名稱:Pure-File-Manager,代碼行數:9,代碼來源:ShellFactory.java

示例14: switchToBook

import com.stericson.RootTools.RootTools; //導入方法依賴的package包/類
private void switchToBook(final BambooInfo bamboo) {
    if(bamboo != null) {
        // Kill Bamboo so that it doesn't get
        // all mixed up.
        RootTools.killProcess("com.wacom.bamboopaper");

        try {
            Shell shell = RootTools.getShell(true);
            JavaCommandCapture cmd = new JavaCommandCapture(
                    43,
                    false,
                    Garden.this,
                    "com.voilaweb.mobile.bamboogarden.RootHelper"
                            + " switch "
                            + bamboo.getName()) {

                @Override
                public void commandCompleted(int id, int exitCode) {
                    super.commandCompleted(id, exitCode);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            maybeOpenBamboo();
                        }
                    });
                    refreshBambooGarden();
                }

            };
            shell.add(cmd);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Fusion,項目名稱:BambooGarden,代碼行數:37,代碼來源:Garden.java


注:本文中的com.stericson.RootTools.RootTools.getShell方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。