public PackageInfoData(String user, String name, String pkgNameStr) { this(android.os.Process.getUidForName(user), name, pkgNameStr); }
/** * Look up uid for each user by name, and if he exists, append an iptables rule. * * @param listCommands current list of iptables commands to execute * @param users list of users to whom the rule applies * @param prefix "iptables" command and the portion of the rule preceding "-m owner --uid-owner X" * @param suffix the remainder of the iptables rule, following "-m owner --uid-owner X" */ private static void addRuleForUsers(List<String> listCommands, String users[], String prefix, String suffix) { for (String user : users) { int uid = android.os.Process.getUidForName(user); if (uid != -1) listCommands.add(prefix + " -m owner --uid-owner " + uid + " " + suffix); } }
private static void initSpecial() { if (specialApps == null || specialApps.size() == 0) { specialApps = new HashMap<String, Integer>(); specialApps.put("dev.afwall.special.any", SPECIAL_UID_ANY); specialApps.put("dev.afwall.special.kernel", SPECIAL_UID_KERNEL); specialApps.put("dev.afwall.special.tether", SPECIAL_UID_TETHER); //specialApps.put("dev.afwall.special.dnsproxy",SPECIAL_UID_DNSPROXY); specialApps.put("dev.afwall.special.ntp", SPECIAL_UID_NTP); for (String acct : specialAndroidAccounts) { String pkg = "dev.afwall.special." + acct; int uid = android.os.Process.getUidForName(acct); specialApps.put(pkg, uid); } } }
/** * On Android 7.0+ the procfs filesystem is now mounted with hidepid=2, eliminating access to the /proc/PID * directories of other users. There's a group ("readproc") for making exceptions but it's not exposed as a * permission. To get a list of processes on Android 7.0+ you must use {@link android.app.usage.UsageStatsManager} * or have root access. * * @return {@code true} if procfs is mounted with hidepid=2 */ public static boolean isProcessInfoHidden() { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader("/proc/mounts")); for (String line = reader.readLine(); line != null; line = reader.readLine()) { String[] columns = line.split("\\s+"); if (columns.length == 6 && columns[1].equals("/proc")) { return columns[3].contains("hidepid=1") || columns[3].contains("hidepid=2"); } } } catch (IOException e) { Log.d(TAG, "Error reading /proc/mounts. Checking if UID 'readproc' exists."); } finally { if (reader != null) { try { reader.close(); } catch (IOException ignored) { } } } return android.os.Process.getUidForName("readproc") == AID_READPROC; }
public PackageInfoData(String user, String name, String pkgName) { this(android.os.Process.getUidForName(user), name, pkgName); }