Loading core/java/android/os/Process.java +15 −1 Original line number Diff line number Diff line Loading @@ -574,6 +574,20 @@ public class Process { */ 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. * Loading core/java/com/android/internal/os/BatteryStatsImpl.java +2 −4 Original line number Diff line number Diff line Loading @@ -2836,14 +2836,12 @@ public final class BatteryStatsImpl extends BatteryStats { * @param name process name * @return the statistics object for the process */ public Uid.Proc getProcessStatsLocked(String name) { public Uid.Proc getProcessStatsLocked(String name, int pid) { int uid; if (mUidCache.containsKey(name)) { uid = mUidCache.get(name); } else { // TODO: Find the actual uid from /proc/pid/status. For now use the hashcode of the // process name uid = name.hashCode(); uid = Process.getUidForPid(pid); mUidCache.put(name, uid); } Uid u = getUidStatsLocked(uid); Loading services/java/com/android/server/am/ActivityManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -1524,8 +1524,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } final BatteryStatsImpl bstats = (BatteryStatsImpl) mBatteryStatsService.getActiveStatistics(); final BatteryStatsImpl bstats = mBatteryStatsService.getActiveStatistics(); synchronized(bstats) { synchronized(mPidsSelfLocked) { if (haveNewCpuStats) { Loading @@ -1540,7 +1539,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen ps.addCpuTimeLocked(st.rel_utime, st.rel_stime); } else { BatteryStatsImpl.Uid.Proc ps = bstats.getProcessStatsLocked(st.name); bstats.getProcessStatsLocked(st.name, st.pid); if (ps != null) { ps.addCpuTimeLocked(st.rel_utime, st.rel_stime); } Loading Loading
core/java/android/os/Process.java +15 −1 Original line number Diff line number Diff line Loading @@ -574,6 +574,20 @@ public class Process { */ 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. * Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +2 −4 Original line number Diff line number Diff line Loading @@ -2836,14 +2836,12 @@ public final class BatteryStatsImpl extends BatteryStats { * @param name process name * @return the statistics object for the process */ public Uid.Proc getProcessStatsLocked(String name) { public Uid.Proc getProcessStatsLocked(String name, int pid) { int uid; if (mUidCache.containsKey(name)) { uid = mUidCache.get(name); } else { // TODO: Find the actual uid from /proc/pid/status. For now use the hashcode of the // process name uid = name.hashCode(); uid = Process.getUidForPid(pid); mUidCache.put(name, uid); } Uid u = getUidStatsLocked(uid); Loading
services/java/com/android/server/am/ActivityManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -1524,8 +1524,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } final BatteryStatsImpl bstats = (BatteryStatsImpl) mBatteryStatsService.getActiveStatistics(); final BatteryStatsImpl bstats = mBatteryStatsService.getActiveStatistics(); synchronized(bstats) { synchronized(mPidsSelfLocked) { if (haveNewCpuStats) { Loading @@ -1540,7 +1539,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen ps.addCpuTimeLocked(st.rel_utime, st.rel_stime); } else { BatteryStatsImpl.Uid.Proc ps = bstats.getProcessStatsLocked(st.name); bstats.getProcessStatsLocked(st.name, st.pid); if (ps != null) { ps.addCpuTimeLocked(st.rel_utime, st.rel_stime); } Loading