请问怎么把如下类在Native.JS怎么写?
或者说Native.JS有没有办法实现执行shell指令,进而实现模拟按键操作呢?
public class RootShellCmd
{
private OutputStream os;
/** * 执行shell指令 * * @param cmd * 指令 */
public final void exec(String cmd)
{
try
{
if (os == null)
{
os = Runtime.getRuntime().exec("su").getOutputStream();
}
os.write(cmd.getBytes()); os.flush();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** * 后台模拟全局按键 * * @param keyCode * 键值 */
public final void simulateKey(int keyCode)
{
exec("input keyevent " + keyCode + "\n");
}
}
1 个回复
c***@vip.qq.com
var Runtime = plus.android.importClass("java.lang.Runtime");
Runtime.getRuntime().exec("su");
var arr = ["su", "-c", "input keyevent 3"];
Runtime.getRuntime().exec(arr);