本文整理了Java中android.os.Process.getUidForName()
方法的一些代码示例,展示了Process.getUidForName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Process.getUidForName()
方法的具体详情如下:
包路径:android.os.Process
类名称:Process
方法名:getUidForName
暂无
代码示例来源:origin: ukanth/afwall
public PackageInfoData(String user, String name, String pkgNameStr) {
this(android.os.Process.getUidForName(user), name, pkgNameStr);
}
代码示例来源:origin: ukanth/afwall
/**
* 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);
}
}
代码示例来源:origin: ukanth/afwall
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);
}
}
}
代码示例来源:origin: jaredrummler/AndroidProcesses
/**
* 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;
}
代码示例来源:origin: EthACKdotOrg/orWall
public PackageInfoData(String user, String name, String pkgName) {
this(android.os.Process.getUidForName(user), name, pkgName);
}
内容来源于网络,如有侵权,请联系作者删除!