1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.automotive.watchdog; 18 19 import android.automotive.watchdog.ICarWatchdogClient; 20 import android.automotive.watchdog.ICarWatchdogMonitor; 21 import android.automotive.watchdog.IResourceOveruseListener; 22 import android.automotive.watchdog.ResourceOveruseStats; 23 import android.automotive.watchdog.ResourceType; 24 import android.automotive.watchdog.StateType; 25 import android.automotive.watchdog.TimeoutLength; 26 27 /** 28 * ICarWatchdog is an interface implemented by watchdog server. This interface is used by the native 29 * side services to communicate with the watchdog server. 30 * For health check, 2 components are involved: watchdog server, watchdog client. 31 * - watchdog server: checks clients' health status by pinging and waiting for the response. 32 * - watchdog client: reports its health status by responding to server's ping within timeout. 33 */ 34 @VintfStability 35 interface ICarWatchdog { 36 /** 37 * Register the client to the watchdog server. 38 * 39 * @param client Watchdog client to register. 40 * @param timeout Timeout length specified through enum. 41 */ registerClient(in ICarWatchdogClient client, in TimeoutLength timeout)42 void registerClient(in ICarWatchdogClient client, in TimeoutLength timeout); 43 44 /** 45 * Unregister the client from the watchdog server. 46 * 47 * @param client Watchdog client to unregister. 48 */ unregisterClient(in ICarWatchdogClient client)49 void unregisterClient(in ICarWatchdogClient client); 50 51 /** 52 * Register the mediator to the watchdog server. 53 * Note that watchdog mediator is also a watchdog client. 54 * 55 * @param mediator Watchdog mediator to register. 56 * 57 * @deprecated Calling this API will result in unsupported operation binder error. 58 */ registerMediator(in ICarWatchdogClient mediator)59 void registerMediator(in ICarWatchdogClient mediator); 60 61 /** 62 * Unregister the mediator from the watchdog server. 63 * Note that watchdog mediator is also a watchdog client. 64 * 65 * @param mediator Watchdog mediator to unregister. 66 * 67 * @deprecated Calling this API will result in unsupported operation binder error. 68 */ unregisterMediator(in ICarWatchdogClient mediator)69 void unregisterMediator(in ICarWatchdogClient mediator); 70 71 /** 72 * Register the monitor to the watchdog server. 73 * 74 * @param monitor Watchdog monitor to register. 75 * 76 * @deprecated Calling this API will result in unsupported operation binder error. 77 */ registerMonitor(in ICarWatchdogMonitor monitor)78 void registerMonitor(in ICarWatchdogMonitor monitor); 79 80 /** 81 * Unregister the monitor from the watchdog server. 82 * 83 * @param monitor Watchdog monitor to unregister. 84 * 85 * @deprecated Calling this API will result in unsupported operation binder error. 86 */ unregisterMonitor(in ICarWatchdogMonitor monitor)87 void unregisterMonitor(in ICarWatchdogMonitor monitor); 88 89 /** 90 * Tell watchdog server that the client is alive. 91 * 92 * @param client Watchdog client that is responding. 93 * @param sessionId Session id given by watchdog server. 94 */ tellClientAlive(in ICarWatchdogClient client, in int sessionId)95 void tellClientAlive(in ICarWatchdogClient client, in int sessionId); 96 97 /** 98 * Tell watchdog server that the mediator is alive together with the status of clients under 99 * the mediator. 100 * 101 * @param mediator Watchdog mediator that is responding. 102 * @param clientsNotResponding Array of process id of clients which haven't responded to the 103 * mediator. 104 * @param sessionId Session id given by watchdog server. 105 * 106 * @deprecated Calling this API will result in unsupported operation binder error. 107 */ tellMediatorAlive( in ICarWatchdogClient mediator, in int[] clientsNotResponding, in int sessionId)108 void tellMediatorAlive( 109 in ICarWatchdogClient mediator, in int[] clientsNotResponding, in int sessionId); 110 111 /** 112 * Tell watchdog server that the monitor has finished dumping process information. 113 * 114 * @param monitor Watchdog monitor that is registered to watchdog server. 115 * @param pid Process id that has been dumped. 116 * 117 * @deprecated Calling this API will result in unsupported operation binder error. 118 */ tellDumpFinished(in ICarWatchdogMonitor monitor, in int pid)119 void tellDumpFinished(in ICarWatchdogMonitor monitor, in int pid); 120 121 /** 122 * Notify watchdog server about the system state change. 123 * 124 * @param type One of the change types defined in the StateType enum. 125 * @param arg1 First state change information for the specified type. 126 * @param arg2 Second state change information for the specified type. 127 * 128 * When type is POWER_CYCLE, arg1 should contain the current power cycle of the device. 129 * When type is USER_STATE, arg1 and arg2 should contain the user ID and the current user state. 130 * When type is BOOT_PHASE, arg1 should contain the current boot phase. 131 * 132 * @deprecated Calling this API will result in unsupported operation binder error. 133 */ notifySystemStateChange(in StateType type, in int arg1, in int arg2)134 void notifySystemStateChange(in StateType type, in int arg1, in int arg2); 135 136 /** 137 * Add a listener for resource overuse notification. 138 * 139 * @param resourceTypes Types of resource overuses to listen. 140 * @param listener Resource overuse handler to notify client. 141 */ addResourceOveruseListener(in ResourceType[] resourceTypes, in IResourceOveruseListener listener)142 void addResourceOveruseListener(in ResourceType[] resourceTypes, 143 in IResourceOveruseListener listener); 144 145 /** 146 * Remove the listener for resource overuse notification. 147 * 148 * @param listener Previously registered resource overuse handler. 149 */ removeResourceOveruseListener(in IResourceOveruseListener listener)150 void removeResourceOveruseListener(in IResourceOveruseListener listener); 151 152 /** 153 * Return the resource overuse stats for the calling package. 154 * 155 * @param resourceTypes Types of resource overuses stats to return. 156 * 157 * @return Overuse stats only for the monitored resources. Caller must call 158 * the methods {@link ResourceOveruseStats#getTag} and 159 * {@link ResourceOveruseStats#get<>} on the returned values 160 * to retrieve the type of resource overuse stats and the specific 161 * resource overuse stats, respectively. 162 */ getResourceOveruseStats(in ResourceType[] resourceTypes)163 List<ResourceOveruseStats> getResourceOveruseStats(in ResourceType[] resourceTypes); 164 } 165