• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Shell类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.stericson.RootShell.execution.Shell的典型用法代码示例。如果您正苦于以下问题:Java Shell类的具体用法?Java Shell怎么用?Java Shell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Shell类属于com.stericson.RootShell.execution包,在下文中一共展示了Shell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getInode

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
/**
 * This method will return the inode number of a file. This method is dependent on having a version of
 * ls that supports the -i parameter.
 *
 * @param file path to the file that you wish to return the inode number
 * @return String The inode number for this file or "" if the inode number could not be found.
 */
public String getInode(String file) {
    try {
        Command command = new Command(Constants.GI, false, "/data/local/ls -i " + file) {

            @Override
            public void commandOutput(int id, String line) {
                if (id == Constants.GI) {
                    if (!line.trim().equals("") && Character.isDigit(line.trim().substring(0, 1).toCharArray()[0])) {
                        InternalVariables.inode = line.trim().split(" ")[0];
                    }
                }

                super.commandOutput(id, line);
            }
        };
        Shell.startRootShell().add(command);
        commandWait(Shell.startRootShell(), command);

        return InternalVariables.inode;
    } catch (Exception ignore) {
        return "";
    }
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:31,代码来源:RootToolsInternalMethods.java


示例2: enableUMS

import com.stericson.RootShell.execution.Shell; //导入依赖的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


示例3: disableUMS

import com.stericson.RootShell.execution.Shell; //导入依赖的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


示例4: setNotificationLed

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setNotificationLed(int value) {
    if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_NOTIFICATION_LED, context)
            == PPApplication.PREFERENCE_ALLOWED) {
        if (android.os.Build.VERSION.SDK_INT < 23)    // Not working in Android M (exception)
            Settings.System.putInt(context.getContentResolver(), "notification_light_pulse", value);
        else {
            if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                synchronized (PPApplication.startRootCommandMutex) {
                    String command1 = "settings put system " + "notification_light_pulse" + " " + value;
                    //if (PPApplication.isSELinuxEnforcing())
                    //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                    Command command = new Command(0, false, command1); //, command2);
                    try {
                        //RootTools.closeAllShells();
                        RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                        commandWait(command);
                    } catch (Exception e) {
                        Log.e("ActivateProfileHelper.setNotificationLed", "Error on run su: " + e.toString());
                    }
                }
            }
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:25,代码来源:ActivateProfileHelper.java


示例5: setHeadsUpNotifications

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setHeadsUpNotifications(int value) {
    if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_HEADS_UP_NOTIFICATIONS, context)
            == PPApplication.PREFERENCE_ALLOWED) {
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
                Settings.Global.putInt(context.getContentResolver(), "heads_up_notifications_enabled", value);
            }
            else
            if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                synchronized (PPApplication.startRootCommandMutex) {
                    String command1 = "settings put global " + "heads_up_notifications_enabled" + " " + value;
                    //if (PPApplication.isSELinuxEnforcing())
                    //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                    Command command = new Command(0, false, command1); //, command2);
                    try {
                        //RootTools.closeAllShells();
                        RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                        commandWait(command);
                    } catch (Exception e) {
                        Log.e("ActivateProfileHelper.setHeadsUpNotifications", "Error on run su: " + e.toString());
                    }
                }
            }
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:27,代码来源:ActivateProfileHelper.java


示例6: setNFC

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setNFC(Context context, boolean enable)
{
    //Log.e("ActivateProfileHelper.setNFC", "xxx");
    if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
        //Log.e("ActivateProfileHelper.setNFC", "permission granted!!");
        CmdNfc.run(enable);
    }
    else
    if (PPApplication.isRooted()/*PPApplication.isRootGranted()*/) {
        synchronized (PPApplication.startRootCommandMutex) {
            String command1 = PPApplication.getJavaCommandFile(CmdNfc.class, "nfc", context, enable);
            //Log.e("ActivateProfileHelper.setNFC", "command1="+command1);
            if (command1 != null) {
                Command command = new Command(0, false, command1);
                try {
                    //RootTools.closeAllShells();
                    RootTools.getShell(true, Shell.ShellContext.NORMAL).add(command);
                    commandWait(command);
                } catch (Exception e) {
                    Log.e("ActivateProfileHelper.setNFC", "Error on run su");
                }
            }
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:26,代码来源:ActivateProfileHelper.java


示例7: deleteFile_su

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private static boolean deleteFile_su(String file) {
    boolean OK;

    List<String> settingsPaths = RootTools.findBinary("rm", true);
    if (settingsPaths.size() > 0) {
        String command1 = "rm " + file;
        //if (PPApplication.isSELinuxEnforcing())
        //	command1 = PPApplication.getSELinuxEnforceCommand(command1);
        synchronized (PPApplication.startRootCommandMutex) {
            Command command = new Command(0, false, command1);
            try {
                //RootTools.closeAllShells();
                RootTools.getShell(true, Shell.ShellContext.RECOVERY).add(command);
                OK = commandWait(command);
                OK = OK && command.getExitCode() == 0;
            } catch (Exception e) {
                //e.printStackTrace();
                OK = false;
            }
        }
    }
    else {
        OK = RootTools.deleteFileOrDirectory(file, false);
    }
    return OK;
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:27,代码来源:PhoneProfilesHelper.java


示例8: executeRootForAdaptiveBrightness

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void executeRootForAdaptiveBrightness(final Profile profile, final Context context) {
    /* not working (private secure settings) :-/
    if (Permissions.hasPermission(appContext, Manifest.permission.WRITE_SECURE_SETTINGS)) {
        Settings.System.putFloat(appContext.getContentResolver(), ADAPTIVE_BRIGHTNESS_SETTING_NAME,
                profile.getDeviceBrightnessAdaptiveValue(appContext));
    }
    else {*/
    if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
        synchronized (PPApplication.startRootCommandMutex) {
            String command1 = "settings put system " + ADAPTIVE_BRIGHTNESS_SETTING_NAME + " " +
                    Float.toString(profile.getDeviceBrightnessAdaptiveValue(context));
            //if (PPApplication.isSELinuxEnforcing())
            //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
            Command command = new Command(0, false, command1); //, command2);
            try {
                //RootTools.closeAllShells();
                RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                commandWait(command);
            } catch (Exception e) {
                Log.e("ActivateProfileHelper.execute", "Error on run su: " + e.toString());
            }
        }
    }
    //}
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:26,代码来源:ActivateProfileHelper.java


示例9: deleteFile_su

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private static boolean deleteFile_su(String file) {
    boolean OK;

    List<String> settingsPaths = RootTools.findBinary("rm", true);
    if (settingsPaths.size() > 0) {
        synchronized (PPApplication.startRootCommandMutex) {
            String command1 = "rm " + file;
            //if (PPApplication.isSELinuxEnforcing())
            //	command1 = PPApplication.getSELinuxEnforceCommand(command1);
            Command command = new Command(0, false, command1);
            try {
                //RootTools.closeAllShells();
                RootTools.getShell(true, Shell.ShellContext.RECOVERY).add(command);
                OK = commandWait(command);
                OK = OK && command.getExitCode() == 0;
            } catch (Exception e) {
                //e.printStackTrace();
                OK = false;
            }
        }
    }
    else {
        OK = RootTools.deleteFileOrDirectory(file, false);
    }
    return OK;
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:27,代码来源:PhoneProfilesHelper.java


示例10: runAndWait

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
public static ExecutionResult runAndWait(String cmd, Shell shell, boolean exceptionOnFailure) throws IOException
{
	Logger.debug("Run&Wait: " + cmd);

	CommandCapture cc = new CommandCapture(0, cmd);
	shell.add(cc);

	if (!waitForCommand(cc))
	{
		throw new IOException(String.format("Error waiting for command to finish executing {%s}", cmd));
	}

	if (exceptionOnFailure && cc.getExitCode() != 0)
	{
		throw new IOException(String.format("Unsuccessful exit code (%d) when executing command {%s}", cc.getExitCode(), cmd));
	}

	return new ExecutionResult(cc.toString(), cc.getExitCode());
}
 
开发者ID:JohnNPhillips,项目名称:HistoryCleanerPro,代码行数:20,代码来源:RootHelper.java


示例11: getMounts

import com.stericson.RootShell.execution.Shell; //导入依赖的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


示例12: getSymlinks

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
/**
 * This will return an ArrayList of the class Symlink. The class Symlink contains the following
 * property's: path SymplinkPath
 * <p/>
 * These will provide you with any Symlinks in the given path.
 *
 * @param path path to search for Symlinks.
 * @return <code>ArrayList<Symlink></code> an ArrayList of the class Symlink.
 * @throws Exception if we cannot return the Symlinks.
 */
public ArrayList<Symlink> getSymlinks(String path) throws Exception {

    // this command needs find
    if (!checkUtil("find")) {
        throw new Exception();
    }

    InternalVariables.symlinks = new ArrayList<>();

    Command command = new Command(0, false, "find " + path + " -type l -exec ls -l {} \\;") {
        @Override
        public void commandOutput(int id, String line) {
            if (id == Constants.GET_SYMLINKS) {
                RootTools.log(line);

                String[] fields = line.split(" ");
                InternalVariables.symlinks.add(new Symlink(new File(fields[fields.length - 3]), // file
                        new File(fields[fields.length - 1]) // SymlinkPath
                ));

            }

            super.commandOutput(id, line);
        }
    };
    Shell.startRootShell().add(command);
    commandWait(Shell.startRootShell(), command);

    if (InternalVariables.symlinks != null) {
        return InternalVariables.symlinks;
    } else {
        throw new Exception();
    }
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:45,代码来源:RootToolsInternalMethods.java


示例13: closeShell

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
/**
 * This will close either the root shell or the standard shell depending on what you specify.
 *
 * @param root a <code>boolean</code> to specify whether to close the root shell or the standard shell.
 */
public static void closeShell(boolean root) throws IOException {
    if (root) {
        Shell.closeRootShell();
    } else {
        Shell.closeShell();
    }
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:13,代码来源:RootShell.java


示例14: isAccessGiven

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
/**
 * @return <code>true</code> if your app has been given root access.
 * @throws TimeoutException if this operation times out. (cannot determine if access is given)
 */
public static boolean isAccessGiven() {
    final Set<String> ID = new HashSet<String>();
    final int IAG = 158;

    try {
        RootShell.log("Checking for Root access");

        Command command = new Command(IAG, false, "id") {
            @Override
            public void commandOutput(int id, String line) {
                if (id == IAG) {
                    ID.addAll(Arrays.asList(line.split(" ")));
                }

                super.commandOutput(id, line);
            }
        };

        Shell.startRootShell().add(command);
        commandWait(Shell.startRootShell(), command);

        //parse the userid
        for (String userid : ID) {
            RootShell.log(userid);

            if (userid.toLowerCase().contains("uid=0")) {
                RootShell.log("Access Given");
                return true;
            }
        }

        return false;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:42,代码来源:RootShell.java


示例15: executeRootForAdaptiveBrightness

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void executeRootForAdaptiveBrightness(final Profile profile) {
    final Context appContext = context.getApplicationContext();
    PPApplication.startHandlerThread();
    final Handler handler = new Handler(PPApplication.handlerThread.getLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {

            PowerManager powerManager = (PowerManager) appContext.getSystemService(POWER_SERVICE);
            PowerManager.WakeLock wakeLock = null;
            if (powerManager != null) {
                wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ActivateProfileHelper.executeRootForAdaptiveBrightness");
                wakeLock.acquire(10 * 60 * 1000);
            }

            if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                synchronized (PPApplication.startRootCommandMutex) {
                    String command1 = "settings put system " + ADAPTIVE_BRIGHTNESS_SETTING_NAME + " " +
                            Float.toString(profile.getDeviceBrightnessAdaptiveValue(appContext));
                    //if (PPApplication.isSELinuxEnforcing())
                    //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                    Command command = new Command(0, false, command1); //, command2);
                    try {
                        //RootTools.closeAllShells();
                        RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                        commandWait(command);
                    } catch (Exception e) {
                        Log.e("ActivateProfileHelper.execute", "Error on run su: " + e.toString());
                    }
                }
            }

            if ((wakeLock != null) && wakeLock.isHeld())
                wakeLock.release();
        }
    });
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:38,代码来源:ActivateProfileHelper.java


示例16: setAirplaneMode_SDK17

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setAirplaneMode_SDK17(/*Context context, */boolean mode)
{
    if (PPApplication.isRooted() && PPApplication.settingsBinaryExists())
    {
        // device is rooted
        synchronized (PPApplication.startRootCommandMutex) {
            String command1;
            String command2;
            if (mode) {
                command1 = "settings put global airplane_mode_on 1";
                command2 = "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true";
            } else {
                command1 = "settings put global airplane_mode_on 0";
                command2 = "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false";
            }
            //if (PPApplication.isSELinuxEnforcing())
            //{
            //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
            //	command2 = PPApplication.getSELinuxEnforceCommand(command2, Shell.ShellContext.SYSTEM_APP);
            //}
            Command command = new Command(0, false, command1, command2);
            try {
                //RootTools.closeAllShells();
                RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                commandWait(command);
            } catch (Exception e) {
                Log.e("AirPlaneMode_SDK17.setAirplaneMode", "Error on run su");
            }
        }
    }
    //else
    //{
        //Log.e("ActivateProfileHelper.setAirplaneMode_SDK17","root NOT granted");
        // for normal apps it is only possible to open the system settings dialog
    /*	Intent intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent); */
    //}
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:40,代码来源:ActivateProfileHelper.java


示例17: setAdaptiveBrightness

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setAdaptiveBrightness(float value) {
    if (adaptiveAllowed) {
        if (android.os.Build.VERSION.SDK_INT < 23)    // Not working in Android M (exception)
            Settings.System.putFloat(_context.getContentResolver(),
                    ActivateProfileHelper.ADAPTIVE_BRIGHTNESS_SETTING_NAME, value);
        else {
            try {
                Settings.System.putFloat(_context.getContentResolver(),
                        ActivateProfileHelper.ADAPTIVE_BRIGHTNESS_SETTING_NAME, value);
            } catch (Exception ee) {
                if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                    synchronized (PPApplication.startRootCommandMutex) {
                        String command1 = "settings put system " + ActivateProfileHelper.ADAPTIVE_BRIGHTNESS_SETTING_NAME + " " +
                                Float.toString(value);
                        //if (PPApplication.isSELinuxEnforcing())
                        //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                        Command command = new Command(0, false, command1); //, command2);
                        try {
                            //RootTools.closeAllShells();
                            RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                            //commandWait(command);
                        } catch (Exception e) {
                            Log.e("BrightnessDialogPreference.setAdaptiveBrightness", "Error on run su: " + e.toString());
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:31,代码来源:BrightnessDialogPreference.java


示例18: setNotificationLed

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setNotificationLed(int value) {
    if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_NOTIFICATION_LED, context)
            == PPApplication.PREFERENCE_ALLOWED) {
        if (android.os.Build.VERSION.SDK_INT < 23)    // Not working in Android M (exception)
            Settings.System.putInt(context.getContentResolver(), "notification_light_pulse", value);
        else {
            /* not working (private secure settings) :-/
            if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
                Settings.System.putInt(context.getContentResolver(), "notification_light_pulse", value);
            }
            else*/
            if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                synchronized (PPApplication.startRootCommandMutex) {
                    String command1 = "settings put system " + "notification_light_pulse" + " " + value;
                    //if (PPApplication.isSELinuxEnforcing())
                    //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                    Command command = new Command(0, false, command1); //, command2);
                    try {
                        //RootTools.closeAllShells();
                        RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                        commandWait(command);
                    } catch (Exception e) {
                        Log.e("ActivateProfileHelper.setNotificationLed", "Error on run su: " + e.toString());
                    }
                }
            }
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:30,代码来源:ActivateProfileHelper.java


示例19: setNFC

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setNFC(Context context, boolean enable)
{
    /*
    Not working in debug version of application !!!!
    Test with release version.
    */

    //Log.e("ActivateProfileHelper.setNFC", "xxx");
    if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
        //Log.e("ActivateProfileHelper.setNFC", "permission granted!!");
        CmdNfc.run(enable);
    }
    else
    if (PPApplication.isRooted()/*PPApplication.isRootGranted()*/) {
        synchronized (PPApplication.startRootCommandMutex) {
            String command1 = PPApplication.getJavaCommandFile(CmdNfc.class, "nfc", context, enable);
            //Log.e("ActivateProfileHelper.setNFC", "command1="+command1);
            if (command1 != null) {
                Command command = new Command(0, false, command1);
                try {
                    //RootTools.closeAllShells();
                    RootTools.getShell(true, Shell.ShellContext.NORMAL).add(command);
                    commandWait(command);
                } catch (Exception e) {
                    Log.e("ActivateProfileHelper.setNFC", "Error on run su");
                }
            }
            //String command = PPApplication.getJavaCommandFile(CmdNfc.class, "nfc", context, enable);
            //if (command != null)
            //  RootToolsSmall.runSuCommand(command);
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:34,代码来源:ActivateProfileHelper.java


示例20: setAirplaneMode_SDK17

import com.stericson.RootShell.execution.Shell; //导入依赖的package包/类
private void setAirplaneMode_SDK17(/*Context context, */boolean mode)
{
    if (PPApplication.isRooted() && PPApplication.settingsBinaryExists())
    {
        // device is rooted
        synchronized (PPApplication.startRootCommandMutex) {
            String command1;
            String command2;
            if (mode) {
                command1 = "settings put global airplane_mode_on 1";
                command2 = "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true";
            } else {
                command1 = "settings put global airplane_mode_on 0";
                command2 = "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false";
            }
            //if (PPApplication.isSELinuxEnforcing())
            //{
            //	command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
            //	command2 = PPApplication.getSELinuxEnforceCommand(command2, Shell.ShellContext.SYSTEM_APP);
            //}
            Command command = new Command(0, true, command1, command2);
            try {
                //RootTools.closeAllShells();
                RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                //commandWait(command);
            } catch (Exception e) {
                Log.e("AirPlaneMode_SDK17.setAirplaneMode", "Error on run su");
            }
            PPApplication.logE("ActivateProfileHelper.setAirplaneMode_SDK17", "done");
        }
    }
    //else
    //{
        // for normal apps it is only possible to open the system settings dialog
    /*	Intent intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent); */
    //}
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:40,代码来源:ActivateProfileHelper.java



注:本文中的com.stericson.RootShell.execution.Shell类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CoordinateArrays类代码示例发布时间:2022-05-22
下一篇:
Java Callback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap