1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 package android.support.test.aupt;
18 
19 import java.util.List;
20 
21 /**
22  * Interface that defines contract of tracking process ids
23  */
24 public interface IProcessStatusTracker {
25 
26     public enum ProcessStatus {PROC_DIED, PROC_RESTARTED, PROC_NOT_STARTED, PROC_STARTED, PROC_OK};
27 
28     public class ProcessDetails {
29         public ProcessStatus processStatus;
30         public String processName;
31         public int pid0, pid1;
32     }
33 
34     /**
35      * add the named process to watch list
36      * @param processName name of the application process
37      */
addMonitoredProcess(String processName)38     public void addMonitoredProcess(String processName);
39     /**
40      * get the details of processes on the watch list
41      * @return a list of {@link ProcessDetails} describing each process on the watch list
42      */
getProcessDetails()43     public List<ProcessDetails> getProcessDetails();
44     /**
45      * Enable monitoring of process id changes of the named process
46      *
47      * Initially all process should be disabled for monitoring pid changes, since it may be running
48      * as a bg service and may be disposed of at anytime. Once an app has been launched into
49      * foreground, it should be enabled for pid monitoring
50      * @param processName
51      */
setAllowProcessTracking(String processName)52     public void setAllowProcessTracking(String processName);
53 
54     /**
55      * Perform a check of all running processes.
56      *
57      * Optionally throw exceptions if one of watched processes has died
58      */
verifyRunningProcess()59     public void verifyRunningProcess();
60 }
61