Merge "Add some Process APIs to test_current" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0214bd512e
@@ -364,7 +364,7 @@ package android.os {
|
||||
|
||||
public class Process {
|
||||
method public static final boolean isSdkSandboxUid(int);
|
||||
method public static final int toAppUid(int);
|
||||
method public static final int sdkSandboxToAppUid(int);
|
||||
method public static final int toSdkSandboxUid(int);
|
||||
field public static final int NFC_UID = 1027; // 0x403
|
||||
field public static final int VPN_UID = 1016; // 0x3f8
|
||||
|
||||
@@ -1778,6 +1778,8 @@ package android.os {
|
||||
|
||||
public class Process {
|
||||
method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException;
|
||||
method public static final boolean isSdkSandboxUid(int);
|
||||
method public static final int sdkSandboxToAppUid(int);
|
||||
method public static final int toSdkSandboxUid(int);
|
||||
field public static final int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000; // 0x15f90
|
||||
field public static final int FIRST_ISOLATED_UID = 99000; // 0x182b8
|
||||
|
||||
@@ -374,7 +374,7 @@ public class Process {
|
||||
* ** Keep in sync with utils/threads.h **
|
||||
* ***************************************
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Lowest available thread priority. Only for those who really, really
|
||||
* don't want to run if anything else is happening.
|
||||
@@ -383,7 +383,7 @@ public class Process {
|
||||
* {@link java.lang.Thread} class.
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_LOWEST = 19;
|
||||
|
||||
|
||||
/**
|
||||
* Standard priority background threads. This gives your thread a slightly
|
||||
* lower than normal priority, so that it will have less chance of impacting
|
||||
@@ -393,7 +393,7 @@ public class Process {
|
||||
* {@link java.lang.Thread} class.
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_BACKGROUND = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Standard priority of threads that are currently running a user interface
|
||||
* that the user is interacting with. Applications can not normally
|
||||
@@ -404,7 +404,7 @@ public class Process {
|
||||
* {@link java.lang.Thread} class.
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_FOREGROUND = -2;
|
||||
|
||||
|
||||
/**
|
||||
* Standard priority of system display threads, involved in updating
|
||||
* the user interface. Applications can not
|
||||
@@ -414,7 +414,7 @@ public class Process {
|
||||
* {@link java.lang.Thread} class.
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_DISPLAY = -4;
|
||||
|
||||
|
||||
/**
|
||||
* Standard priority of the most important display threads, for compositing
|
||||
* the screen and retrieving input events. Applications can not normally
|
||||
@@ -654,19 +654,19 @@ public class Process {
|
||||
|
||||
/**
|
||||
* Start a new process.
|
||||
*
|
||||
*
|
||||
* <p>If processes are enabled, a new process is created and the
|
||||
* static main() function of a <var>processClass</var> is executed there.
|
||||
* The process will continue running after this function returns.
|
||||
*
|
||||
*
|
||||
* <p>If processes are not enabled, a new thread in the caller's
|
||||
* process is created and main() of <var>processClass</var> called there.
|
||||
*
|
||||
*
|
||||
* <p>The niceName parameter, if not an empty string, is a custom name to
|
||||
* give to the process instead of using processClass. This allows you to
|
||||
* make easily identifyable processes even if you are using the same base
|
||||
* <var>processClass</var> to start them.
|
||||
*
|
||||
*
|
||||
* When invokeWith is not null, the process will be started as a fresh app
|
||||
* and not a zygote fork. Note that this is only allowed for uid 0 or when
|
||||
* runtimeFlags contains DEBUG_ENABLE_DEBUGGER.
|
||||
@@ -906,6 +906,7 @@ public class Process {
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi(client = MODULE_LIBRARIES)
|
||||
@TestApi
|
||||
public static final boolean isSdkSandboxUid(int uid) {
|
||||
uid = UserHandle.getAppId(uid);
|
||||
return (uid >= FIRST_SDK_SANDBOX_UID && uid <= LAST_SDK_SANDBOX_UID);
|
||||
@@ -913,12 +914,13 @@ public class Process {
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the app process corresponding to a sdk sandbox process.
|
||||
* Returns the app process corresponding to an sdk sandbox process.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi(client = MODULE_LIBRARIES)
|
||||
public static final int toAppUid(int uid) {
|
||||
@TestApi
|
||||
public static final int sdkSandboxToAppUid(int uid) {
|
||||
return uid - (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
|
||||
}
|
||||
|
||||
@@ -947,7 +949,7 @@ public class Process {
|
||||
* directly to a uid.
|
||||
*/
|
||||
public static final native int getUidForName(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the GID assigned to a particular user name, or -1 if there is
|
||||
* none. If the given string consists of only numbers, it is converted
|
||||
@@ -1002,11 +1004,11 @@ public class Process {
|
||||
|
||||
/**
|
||||
* Set the priority of a thread, based on Linux priorities.
|
||||
*
|
||||
*
|
||||
* @param tid The identifier of the thread/process to change.
|
||||
* @param priority A Linux priority level, from -20 for highest scheduling
|
||||
* priority to 19 for lowest scheduling priority.
|
||||
*
|
||||
*
|
||||
* @throws IllegalArgumentException Throws IllegalArgumentException if
|
||||
* <var>tid</var> does not exist.
|
||||
* @throws SecurityException Throws SecurityException if your process does
|
||||
@@ -1065,7 +1067,7 @@ public class Process {
|
||||
* @hide
|
||||
* @param pid The identifier of the process to change.
|
||||
* @param group The target group for this process from THREAD_GROUP_*.
|
||||
*
|
||||
*
|
||||
* @throws IllegalArgumentException Throws IllegalArgumentException if
|
||||
* <var>tid</var> does not exist.
|
||||
* @throws SecurityException Throws SecurityException if your process does
|
||||
@@ -1154,37 +1156,37 @@ public class Process {
|
||||
/**
|
||||
* Set the priority of the calling thread, based on Linux priorities. See
|
||||
* {@link #setThreadPriority(int, int)} for more information.
|
||||
*
|
||||
*
|
||||
* @param priority A Linux priority level, from -20 for highest scheduling
|
||||
* priority to 19 for lowest scheduling priority.
|
||||
*
|
||||
*
|
||||
* @throws IllegalArgumentException Throws IllegalArgumentException if
|
||||
* <var>tid</var> does not exist.
|
||||
* @throws SecurityException Throws SecurityException if your process does
|
||||
* not have permission to modify the given thread, or to use the given
|
||||
* priority.
|
||||
*
|
||||
*
|
||||
* @see #setThreadPriority(int, int)
|
||||
*/
|
||||
public static final native void setThreadPriority(int priority)
|
||||
throws IllegalArgumentException, SecurityException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the current priority of a thread, based on Linux priorities.
|
||||
*
|
||||
*
|
||||
* @param tid The identifier of the thread/process. If tid equals zero, the priority of the
|
||||
* calling process/thread will be returned.
|
||||
*
|
||||
*
|
||||
* @return Returns the current priority, as a Linux priority level,
|
||||
* from -20 for highest scheduling priority to 19 for lowest scheduling
|
||||
* priority.
|
||||
*
|
||||
*
|
||||
* @throws IllegalArgumentException Throws IllegalArgumentException if
|
||||
* <var>tid</var> does not exist.
|
||||
*/
|
||||
public static final native int getThreadPriority(int tid)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the current scheduling policy of a thread, based on Linux.
|
||||
*
|
||||
@@ -1198,7 +1200,7 @@ public class Process {
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
|
||||
|
||||
@TestApi
|
||||
public static final native int getThreadScheduler(int tid)
|
||||
throws IllegalArgumentException;
|
||||
@@ -1224,7 +1226,7 @@ public class Process {
|
||||
|
||||
/**
|
||||
* Determine whether the current environment supports multiple processes.
|
||||
*
|
||||
*
|
||||
* @return Returns true if the system can run in multiple processes, else
|
||||
* false if everything is running in a single process.
|
||||
*
|
||||
@@ -1251,9 +1253,9 @@ public class Process {
|
||||
/**
|
||||
* Change this process's argv[0] parameter. This can be useful to show
|
||||
* more descriptive information in things like the 'ps' command.
|
||||
*
|
||||
*
|
||||
* @param text The new name of this process.
|
||||
*
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
@UnsupportedAppUsage(maxTargetSdk = VERSION_CODES.S, publicAlternatives = "Do not try to "
|
||||
@@ -1301,12 +1303,12 @@ public class Process {
|
||||
|
||||
/**
|
||||
* Send a signal to the given process.
|
||||
*
|
||||
*
|
||||
* @param pid The pid of the target process.
|
||||
* @param signal The signal to send.
|
||||
*/
|
||||
public static final native void sendSignal(int pid, int signal);
|
||||
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Private impl for avoiding a log message... DO NOT USE without doing
|
||||
@@ -1325,24 +1327,24 @@ public class Process {
|
||||
*/
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||
public static final native void sendSignalQuiet(int pid, int signal);
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public static final native long getFreeMemory();
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public static final native long getTotalMemory();
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public static final native void readProcLines(String path,
|
||||
String[] reqFields, long[] outSizes);
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public static final native int[] getPids(String path, int[] lastArray);
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
||||
public static final int PROC_TERM_MASK = 0xff;
|
||||
@@ -1413,7 +1415,7 @@ public class Process {
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public static final native boolean parseProcLine(byte[] buffer, int startIndex,
|
||||
public static final native boolean parseProcLine(byte[] buffer, int startIndex,
|
||||
int endIndex, int[] format, String[] outStrings, long[] outLongs, float[] outFloats);
|
||||
|
||||
/** @hide */
|
||||
@@ -1422,10 +1424,10 @@ public class Process {
|
||||
|
||||
/**
|
||||
* Gets the total Pss value for a given process, in bytes.
|
||||
*
|
||||
*
|
||||
* @param pid the process to the Pss for
|
||||
* @return the total Pss value for the given process in bytes,
|
||||
* or -1 if the value cannot be determined
|
||||
* or -1 if the value cannot be determined
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
|
||||
@@ -1893,7 +1893,7 @@ public final class ProcessList {
|
||||
/** Return true if the client app for the SDK sandbox process is debuggable. */
|
||||
private boolean isAppForSdkSandboxDebuggable(ProcessRecord sandboxProcess) {
|
||||
// TODO (b/221004701) use client app process name
|
||||
final int appUid = Process.toAppUid(sandboxProcess.uid);
|
||||
final int appUid = Process.sdkSandboxToAppUid(sandboxProcess.uid);
|
||||
IPackageManager pm = mService.getPackageManager();
|
||||
try {
|
||||
String[] packages = pm.getPackagesForUid(appUid);
|
||||
|
||||
Reference in New Issue
Block a user