1 /* 2 * Copyright (C) 2020 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.internal; 18 19 import android.automotive.watchdog.internal.ComponentType; 20 import android.automotive.watchdog.internal.ICarWatchdogMonitor; 21 import android.automotive.watchdog.internal.ICarWatchdogServiceForSystem; 22 import android.automotive.watchdog.internal.ResourceOveruseConfiguration; 23 import android.automotive.watchdog.internal.StateType; 24 25 /** 26 * ICarWatchdog is an interface implemented by watchdog server. This interface is used only by the 27 * internal services to communicate with the watchdog server. 28 * Watchdog service is the counter part of the watchdog server to help communicate with 29 * the car service and Java side services. 30 * For health check, 3 components are involved: watchdog server, watchdog service, watchdog monitor. 31 * - watchdog server: 1. Checks clients' health status by pinging and waiting for the response. 32 * 2. Monitors I/O overuse for system, OEM and third-party applications. 33 * - watchdog service: is a watchdog client by reporting its health status to the server, and 34 * at the same time plays a role of watchdog server by checking its clients' 35 * health status. 36 * - watchdog monitor: captures and reports the process state of watchdog clients. 37 */ 38 interface ICarWatchdog { 39 /** 40 * Register the CarWatchdogService to the watchdog server. 41 * The caller should have system UID. Otherwise, returns security exception binder error. 42 * 43 * @param service CarWatchdogService to register. 44 */ registerCarWatchdogService(in ICarWatchdogServiceForSystem service)45 void registerCarWatchdogService(in ICarWatchdogServiceForSystem service); 46 47 /** 48 * Unregister the CarWatchdogService from the watchdog server. 49 * The caller should have system UID. Otherwise, returns security exception binder error. 50 * 51 * @param service CarWatchdogService to unregister. 52 */ unregisterCarWatchdogService(in ICarWatchdogServiceForSystem service)53 void unregisterCarWatchdogService(in ICarWatchdogServiceForSystem service); 54 55 /** 56 * Register the monitor to the watchdog server. 57 * The caller should have system UID. Otherwise, returns security exception binder error. 58 * 59 * @param monitor Watchdog monitor to register. 60 */ registerMonitor(in ICarWatchdogMonitor monitor)61 void registerMonitor(in ICarWatchdogMonitor monitor); 62 63 /** 64 * Unregister the monitor from the watchdog server. 65 * The caller should have system UID. Otherwise, returns security exception binder error. 66 * 67 * @param monitor Watchdog monitor to unregister. 68 */ unregisterMonitor(in ICarWatchdogMonitor monitor)69 void unregisterMonitor(in ICarWatchdogMonitor monitor); 70 71 /** 72 * Tell watchdog server that the CarWatchdogService is alive together with the status of clients 73 * under the CarWatchdogService. 74 * The caller should have system UID. Otherwise, returns security exception binder error. 75 * 76 * @param service Watchdog service that is responding. 77 * @param clientsNotResponding Array of process id of clients which haven't responded to the 78 * mediator. 79 * @param sessionId Session id given by watchdog server. 80 */ tellCarWatchdogServiceAlive( in ICarWatchdogServiceForSystem service, in int[] clientsNotResponding, in int sessionId)81 void tellCarWatchdogServiceAlive( 82 in ICarWatchdogServiceForSystem service, in int[] clientsNotResponding, in int sessionId); 83 84 /** 85 * Tell watchdog server that the monitor has finished dumping process information. 86 * The caller should have system UID. Otherwise, returns security exception binder error. 87 * 88 * @param monitor Watchdog monitor that is registered to watchdog server. 89 * @param pid Process id that has been dumped. 90 */ tellDumpFinished(in ICarWatchdogMonitor monitor, in int pid)91 void tellDumpFinished(in ICarWatchdogMonitor monitor, in int pid); 92 93 /** 94 * Notify watchdog server about the system state change. 95 * The caller should have system UID. Otherwise, returns security exception binder error. 96 * 97 * @param type One of the change types defined in the StateType enum. 98 * @param arg1 First state change information for the specified type. 99 * @param arg2 Second state change information for the specified type. 100 * 101 * When type is POWER_CYCLE, arg1 should contain the current power cycle of the device. 102 * When type is USER_STATE, arg1 and arg2 should contain the user ID and the current user state. 103 * When type is BOOT_PHASE, arg1 should contain the current boot phase. 104 */ notifySystemStateChange(in StateType type, in int arg1, in int arg2)105 void notifySystemStateChange(in StateType type, in int arg1, in int arg2); 106 107 /** 108 * Update the given resource overuse configurations. 109 * The caller should have system UID. Otherwise, returns security exception binder error. 110 * 111 * @param configs List of resource overuse configurations. 112 */ updateResourceOveruseConfigurations(in List<ResourceOveruseConfiguration> configs)113 void updateResourceOveruseConfigurations(in List<ResourceOveruseConfiguration> configs); 114 115 /** 116 * Return the latest list of resource overuse configuration per component. 117 * The caller should have system UID. Otherwise, returns security exception binder error. 118 * 119 * @return configs List of resource overuse configurations. 120 */ getResourceOveruseConfigurations()121 List<ResourceOveruseConfiguration> getResourceOveruseConfigurations(); 122 123 /** 124 * Enable/disable the internal client health check process. 125 * Disabling would stop the ANR killing process. 126 * 127 * @param isEnabled New enabled state. 128 */ controlProcessHealthCheck(in boolean disable)129 void controlProcessHealthCheck(in boolean disable); 130 } 131