切换风格

默认Lavender Sky Flowers Wizard Snow Beige California City Dragon Black London Sunset glow Pink Cloud

6

主题

118

积分

0

精华

用户组 

易积分
144
热心
0
好评
0
E4A 的核心类库JAR包[复制链接]
发表于 2020-8-17 01:16:40 | 显示全部楼层 |阅读模式
E4A 的核心类库JAR包 需要的拿去使用
图片上次不了 就不上传了  
下面是系统权限操作代码
package com.e4a.runtime;
游客,如果您要查看本帖隐藏内容请回复

import com.e4a.runtime.annotations.SimpleFunction;
import com.e4a.runtime.annotations.SimpleObject;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


@SimpleObject
public final class Root权限操作
{
  private static boolean haveRoot = false;
  private static DataInputStream inputStream;
  private static DataOutputStream outputStream;
  private static Process process;
  private static BufferedReader reader;

  @SimpleFunction
  public static boolean 手机是否已Root() {
    if (haveRoot == true) {
      return true;
    }
    i = 执行命令行("echo test");
    if (i != -1) {
      haveRoot = true;
    } else {
      haveRoot = false;
    }
    return haveRoot;
  }

  @SimpleFunction
  public static String 执行命令行2(String cmd) {
    String str1 = "";
    try {
      process = Runtime.getRuntime().exec("su");
      outputStream = new DataOutputStream(process.getOutputStream());
      inputStream = new DataInputStream(process.getInputStream());
      isreader = new InputStreamReader(inputStream);
      reader = new BufferedReader(isreader);
      byte[] data1 = (cmd + "\n").getBytes();
      outputStream.write(data1);
      outputStream.flush();
      byte[] data2 = "exit\n".getBytes();
      outputStream.write(data2);
      outputStream.flush();
      String str2 = null;
      while ((str2 = reader.readLine()) != null) {
        if (!str1.equals("")) {
          str1 = str1 + "\n" + str2; continue;
        }
        str1 = str2;
      }

      process.waitFor();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (outputStream != null) {
        try {
          outputStream.close();
        } catch (IOException e2) {
          e2.printStackTrace();
        }
      }
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e3) {
          e3.printStackTrace();
        }
      }
    }
    return str1;
  }

  @SimpleFunction
  public static String 执行命令行5(String cmd) {
    String str1 = "";
    try {
      process = Runtime.getRuntime().exec("sh");
      outputStream = new DataOutputStream(process.getOutputStream());
      inputStream = new DataInputStream(process.getInputStream());
      isreader = new InputStreamReader(inputStream);
      reader = new BufferedReader(isreader);
      byte[] data1 = (cmd + "\n").getBytes();
      outputStream.write(data1);
      outputStream.flush();
      byte[] data2 = "exit\n".getBytes();
      outputStream.write(data2);
      outputStream.flush();
      String str2 = null;
      while ((str2 = reader.readLine()) != null) {
        if (!str1.equals("")) {
          str1 = str1 + "\n" + str2; continue;
        }
        str1 = str2;
      }

      process.waitFor();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (outputStream != null) {
        try {
          outputStream.close();
        } catch (IOException e2) {
          e2.printStackTrace();
        }
      }
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e3) {
          e3.printStackTrace();
        }
      }
    }
    return str1;
  }


  @SimpleFunction
  public static int 执行命令行(String cmd) {
    int i = -1;
    try {
      process = Runtime.getRuntime().exec("su");
      outputStream = new DataOutputStream(process.getOutputStream());
      outputStream.writeBytes(cmd + "\n");
      outputStream.flush();
      outputStream.writeBytes("exit\n");
      outputStream.flush();
      process.waitFor();
      i = process.exitValue();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (outputStream != null) {
        try {
          outputStream.close();
        } catch (IOException e2) {
          e2.printStackTrace();
        }
      }
    }
    return i;
  }

  @SimpleFunction
  public static void 执行命令行3(String cmd) {
    try {
      if (process == null || outputStream == null) {
        process = Runtime.getRuntime().exec("su");
        outputStream = new DataOutputStream(process.getOutputStream());
      }
      outputStream.write((cmd + "\n").getBytes());
      outputStream.flush();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  @SimpleFunction
  public static void 模拟按键(int 键代码) {
    if (手机是否已Root() == true) {
      执行命令行3("input keyevent " + 键代码);
    }
  }

  @SimpleFunction
  public static void 模拟输入(String 内容) {
    if (手机是否已Root() == true) {
      执行命令行3("input text '" + 内容 + "'");
    }
  }

  @SimpleFunction
  public static void 模拟点击(int x, int y) {
    if (手机是否已Root() == true)
    {
      执行命令行3("input tap " + x + " " + y);
    }
  }

  @SimpleFunction
  public static void 模拟移动(int x1, int y1, int x2, int y2) {
    if (手机是否已Root() == true) {
      执行命令行3("input swipe " + x1 + " " + y1 + " " + x2 + " " + y2);
    }
  }

  @SimpleFunction
  public static String[] 取所有存储卡路径() {
    paths = new ArrayList();
    try {
      Process process = Runtime.getRuntime().exec("mount");
      InputStream is = process.getInputStream();
      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      String line = null;
      int mountPathIndex = 1;
      while ((line = br.readLine()) != null) {
        if ((line.contains("fat") || line.contains("fuse") || line.contains("storage")) && !line.contains("secure") && !line.contains("asec") && !line.contains("firmware") && !line.contains("shell") && !line.contains("obb") && !line.contains("legacy") && !line.contains("data")) {

          String[] parts = line.split(" ");
          int length = parts.length;
          if (mountPathIndex < length) {

            String mountPath = parts[mountPathIndex];
            if (mountPath.contains("/") && !mountPath.contains("data") && !mountPath.contains("Data"))

            { File mountRoot = new File(mountPath);
              if (mountRoot.exists() && mountRoot.isDirectory() && mountRoot.canWrite())
              {
                paths.add(mountPath); }  }
          }
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    String[] result = new String[paths.size()];
    paths.toArray(result);
    return result;
  }

  @SimpleFunction
  public static void 截取屏幕(String path) {
    if (手机是否已Root() == true) {
      执行命令行3("screencap " + path);
    }
  }

  @SimpleFunction
  public static boolean 强制结束进程(String packagename) {
    int 执行结果 = -1;
    if (手机是否已Root() == true) {
      执行结果 = 执行命令行("am force-stop " + packagename);
    }
    return (执行结果 != -1);
  }


  @SimpleFunction
  public static int 执行命令行4(String 命令行) {

    try { Process process = Runtime.getRuntime().exec(命令行);
      process.waitFor();
      return process.exitValue(); } catch (Throwable t)

    { return -1; }

  }

  @SimpleFunction
  public static void 启动应用页面(String 包名, String 包名和activity名) { 执行命令行("am start -n " + 包名 + "/" + 包名和activity名); }
}


易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

0

主题

120

积分

0

精华

用户组 

易积分
226
热心
0
好评
0
QQ
发表于 2020-8-17 07:43:29 | 显示全部楼层
就来看看了
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

7

主题

269

积分

0

精华

用户组 

易积分
696
热心
0
好评
0
发表于 2020-8-17 08:53:02 | 显示全部楼层
看看这个是做什么的
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

1

主题

175

积分

0

精华

用户组 

易积分
5909
热心
0
好评
0
发表于 2020-8-17 08:56:12 | 显示全部楼层
看看藏了什么
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

10

主题

152

积分

0

精华

用户组 

易积分
1881
热心
0
好评
0
发表于 2020-8-17 09:12:22 | 显示全部楼层
然并卵
111
回复

使用道具 举报

4

主题

862

积分

0

精华

用户组 

易积分
3114
热心
0
好评
1
发表于 2020-8-17 09:26:20 | 显示全部楼层
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

45

主题

1079

积分

1

精华

用户组 

易积分
47961
热心
2
好评
6
QQ

活跃会员热心会员

发表于 2020-8-17 09:39:25 | 显示全部楼层
E4A 的核心类库JAR包
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

17

主题

872

积分

0

精华

用户组 

易积分
1185
热心
1
好评
0

热心会员活跃会员

发表于 2020-8-17 10:25:11 | 显示全部楼层
E: E4A 的核心类库JAR包 [修
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

21

主题

923

积分

0

精华

用户组 

易积分
154
热心
0
好评
1
发表于 2020-8-18 20:58:07 | 显示全部楼层
4545566656
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

0

主题

4

积分

0

精华

用户组 

易积分
9
热心
0
好评
0
发表于 2020-8-18 20:59:28 来自手机 | 显示全部楼层
谢谢分享嘻嘻嘻
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

QQ|sitemap|免责声明|RGB颜色对照表|手机版|小黑屋| 易如意 - E4A中文编程学习交流论坛

GMT+8, 2024-5-25 02:17 , Processed in 0.049618 second(s), 33 queries .

Powered by Discuz! X3.4

© 2001-2018 eruyi.cn

返回顶部