am 4af5bd7c: Merge "Add ProcessInfoService to activity manager."
* commit '4af5bd7cdaccdba6001a384a81c258f542e74075': Add ProcessInfoService to activity manager.
This commit is contained in:
@@ -199,6 +199,7 @@ LOCAL_SRC_FILES += \
|
|||||||
core/java/android/os/INetworkActivityListener.aidl \
|
core/java/android/os/INetworkActivityListener.aidl \
|
||||||
core/java/android/os/INetworkManagementService.aidl \
|
core/java/android/os/INetworkManagementService.aidl \
|
||||||
core/java/android/os/IPermissionController.aidl \
|
core/java/android/os/IPermissionController.aidl \
|
||||||
|
core/java/android/os/IProcessInfoService.aidl \
|
||||||
core/java/android/os/IPowerManager.aidl \
|
core/java/android/os/IPowerManager.aidl \
|
||||||
core/java/android/os/IRemoteCallback.aidl \
|
core/java/android/os/IRemoteCallback.aidl \
|
||||||
core/java/android/os/ISchedulingPolicyService.aidl \
|
core/java/android/os/ISchedulingPolicyService.aidl \
|
||||||
|
|||||||
@@ -256,6 +256,9 @@ public class ActivityManager {
|
|||||||
/** @hide User operation call: given user id is the current user, can't be stopped. */
|
/** @hide User operation call: given user id is the current user, can't be stopped. */
|
||||||
public static final int USER_OP_IS_CURRENT = -2;
|
public static final int USER_OP_IS_CURRENT = -2;
|
||||||
|
|
||||||
|
/** @hide Process does not exist. */
|
||||||
|
public static final int PROCESS_STATE_NONEXISTENT = -1;
|
||||||
|
|
||||||
/** @hide Process is a persistent system process. */
|
/** @hide Process is a persistent system process. */
|
||||||
public static final int PROCESS_STATE_PERSISTENT = 0;
|
public static final int PROCESS_STATE_PERSISTENT = 0;
|
||||||
|
|
||||||
|
|||||||
29
core/java/android/os/IProcessInfoService.aidl
Normal file
29
core/java/android/os/IProcessInfoService.aidl
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.os;
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
interface IProcessInfoService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* For each PID in the given input array, write the current process state
|
||||||
|
* for that process into the output array, or ActivityManager.PROCESS_STATE_NONEXISTENT
|
||||||
|
* to indicate that no process with the given PID exists.
|
||||||
|
*/
|
||||||
|
void getProcessStatesFromPids(in int[] pids, out int[] states);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -170,6 +170,7 @@ import android.os.FileUtils;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IPermissionController;
|
import android.os.IPermissionController;
|
||||||
|
import android.os.IProcessInfoService;
|
||||||
import android.os.IRemoteCallback;
|
import android.os.IRemoteCallback;
|
||||||
import android.os.IUserManager;
|
import android.os.IUserManager;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -1919,6 +1920,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
ServiceManager.addService("cpuinfo", new CpuBinder(this));
|
ServiceManager.addService("cpuinfo", new CpuBinder(this));
|
||||||
}
|
}
|
||||||
ServiceManager.addService("permission", new PermissionController(this));
|
ServiceManager.addService("permission", new PermissionController(this));
|
||||||
|
ServiceManager.addService("processinfo", new ProcessInfoService(this));
|
||||||
|
|
||||||
ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(
|
ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(
|
||||||
"android", STOCK_PM_FLAGS);
|
"android", STOCK_PM_FLAGS);
|
||||||
@@ -6806,7 +6808,46 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// PROCESS INFO
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
static class ProcessInfoService extends IProcessInfoService.Stub {
|
||||||
|
final ActivityManagerService mActivityManagerService;
|
||||||
|
ProcessInfoService(ActivityManagerService activityManagerService) {
|
||||||
|
mActivityManagerService = activityManagerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getProcessStatesFromPids(/*in*/ int[] pids, /*out*/ int[] states) {
|
||||||
|
mActivityManagerService.getProcessStatesForPIDs(/*in*/ pids, /*out*/ states);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each PID in the given input array, write the current process state
|
||||||
|
* for that process into the output array, or -1 to indicate that no
|
||||||
|
* process with the given PID exists.
|
||||||
|
*/
|
||||||
|
public void getProcessStatesForPIDs(/*in*/ int[] pids, /*out*/ int[] states) {
|
||||||
|
if (pids == null) {
|
||||||
|
throw new NullPointerException("pids");
|
||||||
|
} else if (states == null) {
|
||||||
|
throw new NullPointerException("states");
|
||||||
|
} else if (pids.length != states.length) {
|
||||||
|
throw new IllegalArgumentException("input and output arrays have different lengths!");
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (mPidsSelfLocked) {
|
||||||
|
for (int i = 0; i < pids.length; i++) {
|
||||||
|
ProcessRecord pr = mPidsSelfLocked.get(pids[i]);
|
||||||
|
states[i] = (pr == null) ? ActivityManager.PROCESS_STATE_NONEXISTENT :
|
||||||
|
pr.curProcState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =========================================================
|
// =========================================================
|
||||||
// PERMISSIONS
|
// PERMISSIONS
|
||||||
// =========================================================
|
// =========================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user