summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-06-25 00:47:51 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-06-25 00:47:51 -0700
commit2383415ab982ff156a85929f58029c0b863750c5 (patch)
tree4fe9a9b3c6a167941bc7beba4f4e3503a7428f31 /core/java/android/os
parente92b1e7633188e9e72a237f84266d390bb4b87ed (diff)
parentf881762f97c74253bbc7f629380bb65739457041 (diff)
downloadframeworks_base-2383415ab982ff156a85929f58029c0b863750c5.zip
frameworks_base-2383415ab982ff156a85929f58029c0b863750c5.tar.gz
frameworks_base-2383415ab982ff156a85929f58029c0b863750c5.tar.bz2
am f881762f: Merge change 5351 into donut
Merge commit 'f881762f97c74253bbc7f629380bb65739457041' * commit 'f881762f97c74253bbc7f629380bb65739457041': Add a method to Process to get uid for a pid.
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/Process.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 333c7cb..1214abc 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -573,7 +573,21 @@ public class Process {
* directly to a gid.
*/
public static final native int getGidForName(String name);
-
+
+ /**
+ * Returns a uid for a currently running process.
+ * @param pid the process id
+ * @return the uid of the process, or -1 if the process is not running.
+ * @hide pending API council review
+ */
+ public static final int getUidForPid(int pid) {
+ String[] procStatusLabels = { "Uid:" };
+ long[] procStatusValues = new long[1];
+ procStatusValues[0] = -1;
+ Process.readProcLines("/proc/" + pid + "/status", procStatusLabels, procStatusValues);
+ return (int) procStatusValues[0];
+ }
+
/**
* Set the priority of a thread, based on Linux priorities.
*