Merge "Fix UID tracking in ProcessCpuTracker." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5c5e22e910
@@ -19,10 +19,10 @@ package com.android.internal.os;
|
|||||||
import static android.os.Process.*;
|
import static android.os.Process.*;
|
||||||
|
|
||||||
import android.annotation.UnsupportedAppUsage;
|
import android.annotation.UnsupportedAppUsage;
|
||||||
import android.os.FileUtils;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -247,6 +247,7 @@ public class ProcessCpuTracker {
|
|||||||
pid = _pid;
|
pid = _pid;
|
||||||
if (parentPid < 0) {
|
if (parentPid < 0) {
|
||||||
final File procDir = new File("/proc", Integer.toString(pid));
|
final File procDir = new File("/proc", Integer.toString(pid));
|
||||||
|
uid = getUid(procDir.toString());
|
||||||
statFile = new File(procDir, "stat").toString();
|
statFile = new File(procDir, "stat").toString();
|
||||||
cmdlineFile = new File(procDir, "cmdline").toString();
|
cmdlineFile = new File(procDir, "cmdline").toString();
|
||||||
threadsDir = (new File(procDir, "task")).toString();
|
threadsDir = (new File(procDir, "task")).toString();
|
||||||
@@ -262,13 +263,22 @@ public class ProcessCpuTracker {
|
|||||||
parentPid));
|
parentPid));
|
||||||
final File taskDir = new File(
|
final File taskDir = new File(
|
||||||
new File(procDir, "task"), Integer.toString(pid));
|
new File(procDir, "task"), Integer.toString(pid));
|
||||||
|
uid = getUid(taskDir.toString());
|
||||||
statFile = new File(taskDir, "stat").toString();
|
statFile = new File(taskDir, "stat").toString();
|
||||||
cmdlineFile = null;
|
cmdlineFile = null;
|
||||||
threadsDir = null;
|
threadsDir = null;
|
||||||
threadStats = null;
|
threadStats = null;
|
||||||
workingThreads = null;
|
workingThreads = null;
|
||||||
}
|
}
|
||||||
uid = FileUtils.getUid(statFile.toString());
|
}
|
||||||
|
|
||||||
|
private static int getUid(String path) {
|
||||||
|
try {
|
||||||
|
return Os.stat(path).st_uid;
|
||||||
|
} catch (ErrnoException e) {
|
||||||
|
Slog.w(TAG, "Failed to stat(" + path + "): " + e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user