android.os.Process.getUidForName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中android.os.Process.getUidForName()方法的一些代码示例,展示了Process.getUidForName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Process.getUidForName()方法的具体详情如下:
包路径:android.os.Process
类名称:Process
方法名:getUidForName

Process.getUidForName介绍

暂无

代码示例

代码示例来源:origin: ukanth/afwall

  1. public PackageInfoData(String user, String name, String pkgNameStr) {
  2. this(android.os.Process.getUidForName(user), name, pkgNameStr);
  3. }

代码示例来源:origin: ukanth/afwall

  1. /**
  2. * Look up uid for each user by name, and if he exists, append an iptables rule.
  3. *
  4. * @param listCommands current list of iptables commands to execute
  5. * @param users list of users to whom the rule applies
  6. * @param prefix "iptables" command and the portion of the rule preceding "-m owner --uid-owner X"
  7. * @param suffix the remainder of the iptables rule, following "-m owner --uid-owner X"
  8. */
  9. private static void addRuleForUsers(List<String> listCommands, String users[], String prefix, String suffix) {
  10. for (String user : users) {
  11. int uid = android.os.Process.getUidForName(user);
  12. if (uid != -1)
  13. listCommands.add(prefix + " -m owner --uid-owner " + uid + " " + suffix);
  14. }
  15. }

代码示例来源:origin: ukanth/afwall

  1. private static void initSpecial() {
  2. if (specialApps == null || specialApps.size() == 0) {
  3. specialApps = new HashMap<String, Integer>();
  4. specialApps.put("dev.afwall.special.any", SPECIAL_UID_ANY);
  5. specialApps.put("dev.afwall.special.kernel", SPECIAL_UID_KERNEL);
  6. specialApps.put("dev.afwall.special.tether", SPECIAL_UID_TETHER);
  7. //specialApps.put("dev.afwall.special.dnsproxy",SPECIAL_UID_DNSPROXY);
  8. specialApps.put("dev.afwall.special.ntp", SPECIAL_UID_NTP);
  9. for (String acct : specialAndroidAccounts) {
  10. String pkg = "dev.afwall.special." + acct;
  11. int uid = android.os.Process.getUidForName(acct);
  12. specialApps.put(pkg, uid);
  13. }
  14. }
  15. }

代码示例来源:origin: jaredrummler/AndroidProcesses

  1. /**
  2. * On Android 7.0+ the procfs filesystem is now mounted with hidepid=2, eliminating access to the /proc/PID
  3. * directories of other users. There's a group ("readproc") for making exceptions but it's not exposed as a
  4. * permission. To get a list of processes on Android 7.0+ you must use {@link android.app.usage.UsageStatsManager}
  5. * or have root access.
  6. *
  7. * @return {@code true} if procfs is mounted with hidepid=2
  8. */
  9. public static boolean isProcessInfoHidden() {
  10. BufferedReader reader = null;
  11. try {
  12. reader = new BufferedReader(new FileReader("/proc/mounts"));
  13. for (String line = reader.readLine(); line != null; line = reader.readLine()) {
  14. String[] columns = line.split("\\s+");
  15. if (columns.length == 6 && columns[1].equals("/proc")) {
  16. return columns[3].contains("hidepid=1") || columns[3].contains("hidepid=2");
  17. }
  18. }
  19. } catch (IOException e) {
  20. Log.d(TAG, "Error reading /proc/mounts. Checking if UID 'readproc' exists.");
  21. } finally {
  22. if (reader != null) {
  23. try {
  24. reader.close();
  25. } catch (IOException ignored) {
  26. }
  27. }
  28. }
  29. return android.os.Process.getUidForName("readproc") == AID_READPROC;
  30. }

代码示例来源:origin: EthACKdotOrg/orWall

  1. public PackageInfoData(String user, String name, String pkgName) {
  2. this(android.os.Process.getUidForName(user), name, pkgName);
  3. }

相关文章