Class ShadowProcess


  • @Implements(android.os.Process.class)
    public class ShadowProcess
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ShadowProcess()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clearKilledProcesses()  
      protected static int getThreadPriority​(int tid)
      Returns priority stored for the given thread.
      protected static void killProcess​(int pid)
      Stores requests for killing processes.
      protected static int myPid()  
      protected static int myTid()
      Returns the identifier (Thread.getId()) of the current thread (Thread.currentThread()).
      protected static int myUid()
      Returns the identifier of this process's uid.
      static void reset()  
      static void setPid​(int pid)
      Sets the identifier of this process.
      protected static void setThreadPriority​(int priority)
      Stores priority for the current thread, but doesn't actually change it to not mess up with test runner.
      protected static void setThreadPriority​(int tid, int priority)
      Stores priority for the given thread, but doesn't actually change it to not mess up with test runner.
      static void setUid​(int uid)
      Sets the identifier of this process.
      static boolean wasKilled​(int pid)
      Gets an indication of whether or not a process was killed (using killProcess(int)).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowProcess

        public ShadowProcess()
    • Method Detail

      • killProcess

        @Implementation
        protected static final void killProcess​(int pid)
        Stores requests for killing processes. Processe that were requested to be killed can be retrieved by calling wasKilled(int). Use clearKilledProcesses() to clear the list.
      • myPid

        @Implementation
        protected static final int myPid()
      • myUid

        @Implementation
        protected static final int myUid()
        Returns the identifier of this process's uid. Unlike Android UIDs are randomly initialized to prevent tests from depending on any given value. Tests should access the current process UID via Process.myUid(). You can override this value by calling setUid(int).
      • myTid

        @Implementation
        protected static final int myTid()
        Returns the identifier (Thread.getId()) of the current thread (Thread.currentThread()).
      • setThreadPriority

        @Implementation
        protected static final void setThreadPriority​(int priority)
        Stores priority for the current thread, but doesn't actually change it to not mess up with test runner. Unlike real implementation does not throw any exceptions.
      • setThreadPriority

        @Implementation
        protected static final void setThreadPriority​(int tid,
                                                      int priority)
        Stores priority for the given thread, but doesn't actually change it to not mess up with test runner. Unlike real implementation does not throw any exceptions.
        Parameters:
        tid - The identifier of the thread. If equals zero, the identifier of the calling thread will be used.
      • getThreadPriority

        @Implementation
        protected static final int getThreadPriority​(int tid)
        Returns priority stored for the given thread.
        Parameters:
        tid - The identifier of the thread. If equals zero, the identifier of the calling thread will be used.
      • clearKilledProcesses

        public static void clearKilledProcesses()
      • setUid

        public static void setUid​(int uid)
        Sets the identifier of this process.
      • setPid

        public static void setPid​(int pid)
        Sets the identifier of this process.
      • reset

        @Resetter
        public static void reset()
      • wasKilled

        public static boolean wasKilled​(int pid)
        Gets an indication of whether or not a process was killed (using killProcess(int)).