Android
android.os
public class

android.os.Process

java.lang.Object
android.os.Process

Tools for managing OS processes.

Summary

Constants

      Value  
int  BLUETOOTH_GID  Defines a secondary group id for access to the bluetooth hardware.  2000  0x000007d0 
int  FIRST_APPLICATION_UID  Defines the start of a range of UIDs (and GIDs), going from this number to LAST_APPLICATION_UID that are reserved for assigning to applications.  10000  0x00002710 
int  LAST_APPLICATION_UID  Last of application-specific UIDs starting at FIRST_APPLICATION_UID 99999  0x0001869f 
int  PHONE_UID  Defines the UID/GID under which the telephony code runs.  1001  0x000003e9 
int  SIGNAL_KILL    0x00000009 
int  SIGNAL_QUIT    0x00000003 
int  SIGNAL_USR1    10  0x0000000a 
int  SYSTEM_UID  Defines the UID/GID under which system code runs.  1000  0x000003e8 
int  THREAD_PRIORITY_AUDIO  Standard priority of audio threads.  -16  0xfffffff0 
int  THREAD_PRIORITY_BACKGROUND  Standard priority background threads.  10  0x0000000a 
int  THREAD_PRIORITY_DEFAULT  Standard priority of application threads.  0x00000000 
int  THREAD_PRIORITY_DISPLAY  Standard priority of system display threads, involved in updating the user interface.  -4  0xfffffffc 
int  THREAD_PRIORITY_FOREGROUND  Standard priority of threads that are currently running a user interface that the user is interacting with.  -2  0xfffffffe 
int  THREAD_PRIORITY_LESS_FAVORABLE  Minimum increment to make a priority less favorable.  0x00000001 
int  THREAD_PRIORITY_LOWEST  Lowest available thread priority.  19  0x00000013 
int  THREAD_PRIORITY_MORE_FAVORABLE  Minimum increment to make a priority more favorable.  -1  0xffffffff 
int  THREAD_PRIORITY_URGENT_AUDIO  Standard priority of the most important audio threads.  -19  0xffffffed 
int  THREAD_PRIORITY_URGENT_DISPLAY  Standard priority of the most important display threads, for compositing the screen and retrieving input events.  -8  0xfffffff8 

Public Constructors

            Process()

Public Methods

    final  static    long  getElapsedCpuTime()
Returns elapsed milliseconds of the time this process has run.
    final  static    int  getGidForName(String name)
Returns the GID assigned to a particular user name, or -1 if there is none.
    final  static    int  getThreadPriority(int tid)
Return the current priority of a thread, based on Linux priorities.
    final  static    int  getUidForName(String name)
Returns the UID assigned to a partlicular user name, or -1 if there is none.
    final  static    void  killProcess(int pid)
Kill the process with the given PID.
    final  static    int  myPid()
Returns the identifier of this process, which can be used with killProcess(int) and sendSignal(int, int).
    final  static    int  myTid()
Returns the identifier of the calling thread, which be used with setThreadPriority(int, int).
    final  static    void  sendSignal(int pid, int signal)
Send a signal to the given process.
    final  static    void  setThreadPriority(int priority)
Set the priority of the calling thread, based on Linux priorities.
    final  static    void  setThreadPriority(int tid, int priority)
Set the priority of a thread, based on Linux priorities.
    final  static    boolean  supportsProcesses()
Determine whether the current environment supports multiple processes.
Methods inherited from class java.lang.Object

Details

Constants

public static final int BLUETOOTH_GID

Defines a secondary group id for access to the bluetooth hardware.
Constant Value: 2000 (0x000007d0)

public static final int FIRST_APPLICATION_UID

Defines the start of a range of UIDs (and GIDs), going from this number to LAST_APPLICATION_UID that are reserved for assigning to applications.
Constant Value: 10000 (0x00002710)

public static final int LAST_APPLICATION_UID

Last of application-specific UIDs starting at FIRST_APPLICATION_UID.
Constant Value: 99999 (0x0001869f)

public static final int PHONE_UID

Defines the UID/GID under which the telephony code runs.
Constant Value: 1001 (0x000003e9)

public static final int SIGNAL_KILL

Constant Value: 9 (0x00000009)

public static final int SIGNAL_QUIT

Constant Value: 3 (0x00000003)

public static final int SIGNAL_USR1

Constant Value: 10 (0x0000000a)

public static final int SYSTEM_UID

Defines the UID/GID under which system code runs.
Constant Value: 1000 (0x000003e8)

public static final int THREAD_PRIORITY_AUDIO

Standard priority of audio threads. Applications can not normally change to this priority. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: -16 (0xfffffff0)

public static final int THREAD_PRIORITY_BACKGROUND

Standard priority background threads. This gives your thread a slightly lower than normal priority, so that it will have less chance of impacting the responsiveness of the user interface. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: 10 (0x0000000a)

public static final int THREAD_PRIORITY_DEFAULT

Standard priority of application threads. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: 0 (0x00000000)

public static final int THREAD_PRIORITY_DISPLAY

Standard priority of system display threads, involved in updating the user interface. Applications can not normally change to this priority. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: -4 (0xfffffffc)

public static final int THREAD_PRIORITY_FOREGROUND

Standard priority of threads that are currently running a user interface that the user is interacting with. Applications can not normally change to this priority; the system will automatically adjust your application threads as the user moves through the UI. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: -2 (0xfffffffe)

public static final int THREAD_PRIORITY_LESS_FAVORABLE

Minimum increment to make a priority less favorable.
Constant Value: 1 (0x00000001)

public static final int THREAD_PRIORITY_LOWEST

Lowest available thread priority. Only for those who really, really don't want to run if anything else is happening. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: 19 (0x00000013)

public static final int THREAD_PRIORITY_MORE_FAVORABLE

Minimum increment to make a priority more favorable.
Constant Value: -1 (0xffffffff)

public static final int THREAD_PRIORITY_URGENT_AUDIO

Standard priority of the most important audio threads. Applications can not normally change to this priority. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: -19 (0xffffffed)

public static final int THREAD_PRIORITY_URGENT_DISPLAY

Standard priority of the most important display threads, for compositing the screen and retrieving input events. Applications can not normally change to this priority. Use with setThreadPriority(int) and setThreadPriority(int, int), not with the normal Java Thread class.
Constant Value: -8 (0xfffffff8)

Public Constructors

public Process()

Public Methods

public static final long getElapsedCpuTime()

Returns elapsed milliseconds of the time this process has run.

Returns

  • Returns the number of milliseconds this process has return.

public static final int getGidForName(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 directly to a gid.

public static final int getThreadPriority(int tid)

Return the current priority of a thread, based on Linux priorities.

Parameters

tid The identifier of the thread/process to change.

Returns

  • 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 tid does not exist.

public static final int getUidForName(String name)

Returns the UID assigned to a partlicular user name, or -1 if there is none. If the given string consists of only numbers, it is converted directly to a uid.

public static final void killProcess(int pid)

Kill the process with the given PID. Note that, though this API allows us to request to kill any process based on its PID, the kernel will still impose standard restrictions on which PIDs you are actually able to kill. Typically this means only the process running the caller's packages/application and any additional processes created by that app; packages sharing a common UID will also be able to kill each other's processes.

public static final int myPid()

Returns the identifier of this process, which can be used with killProcess(int) and sendSignal(int, int).

public static final int myTid()

Returns the identifier of the calling thread, which be used with setThreadPriority(int, int).

public static final void sendSignal(int pid, int signal)

Send a signal to the given process.

Parameters

pid The pid of the target process.
signal The signal to send.

public static final void setThreadPriority(int priority)

Set the priority of the calling thread, based on Linux priorities. See setThreadPriority(int, int) for more information.

Parameters

priority A Linux priority level, from -20 for highest scheduling priority to 19 for lowest scheduling priority.

Throws

IllegalArgumentException Throws IllegalArgumentException if tid does not exist.
SecurityException Throws SecurityException if your process does not have permission to modify the given thread, or to use the given priority.

public static final void setThreadPriority(int tid, int priority)

Set the priority of a thread, based on Linux priorities.

Parameters

tid The identifier of the thread/process to change.
priority A Linux priority level, from -20 for highest scheduling priority to 19 for lowest scheduling priority.

Throws

IllegalArgumentException Throws IllegalArgumentException if tid does not exist.
SecurityException Throws SecurityException if your process does not have permission to modify the given thread, or to use the given priority.

public static final boolean supportsProcesses()

Determine whether the current environment supports multiple processes.

Returns

  • Returns true if the system can run in multiple processes, else false if everything is running in a single process.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56