@@ -0,0 +1,2014 @@
+package at.amartinz.execution.helper;%0A%0Aimport android.text.TextUtils;%0A%0Aimport java.util.List;%0A%0Aimport at.amartinz.execution.NormalShell;%0A%0A/**%0A * Created by amartinz on 06.09.16.%0A */%0A%0Apublic class ProcessHelper %7B%0A    public static final int INVALID = -1;%0A%0A    public static int getUidFromPid(int pid) %7B%0A        int result = getUidFromPidPerStat(pid);%0A        if (result == INVALID) %7B%0A            result = getUidFromPidPerStatusFile(pid);%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static int getUidFromPidPerStat(int pid) %7B%0A        final String path = String.format(%22/proc/%25s%22, pid);%0A        final String cmd = String.format(%22stat -c %25%25u %25s%22, path);%0A        final String result = NormalShell.fireAndBlockString(cmd);%0A%0A        if (!TextUtils.isEmpty(result)) %7B%0A            try %7B%0A                return Integer.parseInt(result.trim());%0A            %7D catch (NumberFormatException ignored) %7B %7D%0A        %7D%0A        return INVALID;%0A    %7D%0A%0A    public static int getUidFromPidPerStatusFile(int pid) %7B%0A        final String path = String.format(%22/proc/%25s/status%22, pid);%0A        final String cmd = String.format(%22cat %25s%22, path);%0A        final List%3CString%3E result = NormalShell.fireAndBlockList(cmd);%0A%0A        if (result == null %7C%7C result.size() %3C 5) %7B%0A            return INVALID;%0A        %7D%0A%0A        String uidLine = %22%22;%0A        for (final String line : result) %7B%0A            if (line == null %7C%7C !line.toLowerCase().startsWith(%22uid%22)) %7B%0A                continue;%0A            %7D%0A%0A            uidLine = line;%0A            break;%0A        %7D%0A%0A        // Uid: 10102 10102 10102 10102%0A        uidLine = uidLine.replace(%22%5Ct%22, %22 %22);%0A        final String%5B%5D splitted = uidLine.split(%22 %22);%0A        if (splitted.length %3C 2) %7B%0A            return INVALID;%0A        %7D%0A%0A        try %7B%0A            return Integer.parseInt(splitted%5B1%5D);%0A        %7D catch (Exception ignored) %7B %7D%0A%0A        // try as a fallback%0A        try %7B%0A            return Integer.parseInt(splitted%5B2%5D);%0A        %7D catch (Exception ignored) %7B %7D%0A%0A        return INVALID;%0A    %7D%0A%7D%0A

add ProcessHelper class