Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1e1969c authored by Ruben Brunk's avatar Ruben Brunk Committed by Wale Ogunwale
Browse files

Add ProcessInfoService to activity manager.

- Adds a new AIDL interface for querying process
  information from activity manager.

Bug: 19186859
Change-Id: Ic08858f346d6b66e7bfc9da6faa2c6e38d9b2e82
parent 631565ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ LOCAL_SRC_FILES += \
	core/java/android/os/INetworkActivityListener.aidl \
	core/java/android/os/INetworkManagementService.aidl \
	core/java/android/os/IPermissionController.aidl \
	core/java/android/os/IProcessInfoService.aidl \
	core/java/android/os/IPowerManager.aidl \
	core/java/android/os/IRemoteCallback.aidl \
	core/java/android/os/ISchedulingPolicyService.aidl \
+3 −0
Original line number Diff line number Diff line
@@ -256,6 +256,9 @@ public class ActivityManager {
    /** @hide User operation call: given user id is the current user, can't be stopped. */
    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. */
    public static final int PROCESS_STATE_PERSISTENT = 0;

+29 −0
Original line number Diff line number Diff line
/*
 * 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);
}
+42 −1
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ import android.os.FileUtils;
import android.os.Handler;
import android.os.IBinder;
import android.os.IPermissionController;
import android.os.IProcessInfoService;
import android.os.IRemoteCallback;
import android.os.IUserManager;
import android.os.Looper;
@@ -1918,6 +1919,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                ServiceManager.addService("cpuinfo", new CpuBinder(this));
            }
            ServiceManager.addService("permission", new PermissionController(this));
            ServiceManager.addService("processinfo", new ProcessInfoService(this));
            ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(
                    "android", STOCK_PM_FLAGS);
@@ -6806,6 +6808,45 @@ 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
    // =========================================================