aboutsummaryrefslogtreecommitdiff
path: root/cpp/watchdog
diff options
context:
space:
mode:
authorJahdiel Alvarez <jahdiel@google.com>2021-07-12 21:31:01 +0000
committerJahdiel Alvarez <jahdiel@google.com>2021-07-19 17:59:35 +0000
commitc29893bdb8349e58893ae626a30b4fbe8f327575 (patch)
tree09607de9cc56f0e557c717f5ad6e91757637530a /cpp/watchdog
parent3be8e8a8507ecf414b6676272511d1223581c222 (diff)
downloadCar-c29893bdb8349e58893ae626a30b4fbe8f327575.tar.gz
Support temporary disabling watchdog killing
Added command: "adb shell cmd car_service watchdog-control-health-check true|false" Set flag to true to disable car watchdog's process health checks. False, to enable it. When using the debugger in CarService use the command "adb shell cmd car_service watchdog-control-health-check true" in order to avoid car watchdog killing car service because of ANR. Once you finish, debugging run the command but with the false flag, to enable watchdog again. Test: atest libwatchdog_test CarWatchdogDaemonHelperTest CarWatchdogServiceUnitTest Test: Run adb shell cmd car_service watchdog-control-health-check true Bug: 182570176 Change-Id: I566cf25f5e091e50eea97e45909dfa24224f4a81
Diffstat (limited to 'cpp/watchdog')
-rw-r--r--cpp/watchdog/aidl/android/automotive/watchdog/internal/ICarWatchdog.aidl8
-rw-r--r--cpp/watchdog/car-watchdog-lib/src/android/car/watchdoglib/CarWatchdogDaemonHelper.java10
-rw-r--r--cpp/watchdog/server/src/WatchdogInternalHandler.cpp9
-rw-r--r--cpp/watchdog/server/src/WatchdogInternalHandler.h5
-rw-r--r--cpp/watchdog/server/tests/WatchdogInternalHandlerTest.cpp13
5 files changed, 43 insertions, 2 deletions
diff --git a/cpp/watchdog/aidl/android/automotive/watchdog/internal/ICarWatchdog.aidl b/cpp/watchdog/aidl/android/automotive/watchdog/internal/ICarWatchdog.aidl
index 57d82cad45..c9ece218b0 100644
--- a/cpp/watchdog/aidl/android/automotive/watchdog/internal/ICarWatchdog.aidl
+++ b/cpp/watchdog/aidl/android/automotive/watchdog/internal/ICarWatchdog.aidl
@@ -128,4 +128,12 @@ interface ICarWatchdog {
* @param actions List of actions take on resource overusing packages.
*/
void actionTakenOnResourceOveruse(in List<PackageResourceOveruseAction> actions);
+
+ /**
+ * Enable/disable the internal client health check process.
+ * Disabling would stop the ANR killing process.
+ *
+ * @param isEnabled New enabled state.
+ */
+ void controlProcessHealthCheck(in boolean disable);
}
diff --git a/cpp/watchdog/car-watchdog-lib/src/android/car/watchdoglib/CarWatchdogDaemonHelper.java b/cpp/watchdog/car-watchdog-lib/src/android/car/watchdoglib/CarWatchdogDaemonHelper.java
index 1810c92eb2..e7229baf94 100644
--- a/cpp/watchdog/car-watchdog-lib/src/android/car/watchdoglib/CarWatchdogDaemonHelper.java
+++ b/cpp/watchdog/car-watchdog-lib/src/android/car/watchdoglib/CarWatchdogDaemonHelper.java
@@ -291,6 +291,16 @@ public final class CarWatchdogDaemonHelper {
invokeDaemonMethod((daemon) -> daemon.actionTakenOnResourceOveruse(actions));
}
+ /**
+ * Enable/disable the internal client health check process.
+ * Disabling would stop the ANR killing process.
+ *
+ * @param disable True to disable watchdog's health check process.
+ */
+ public void controlProcessHealthCheck(boolean disable) throws RemoteException {
+ invokeDaemonMethod((daemon) -> daemon.controlProcessHealthCheck(disable));
+ }
+
private void invokeDaemonMethod(Invokable r) throws RemoteException {
ICarWatchdog daemon;
synchronized (mLock) {
diff --git a/cpp/watchdog/server/src/WatchdogInternalHandler.cpp b/cpp/watchdog/server/src/WatchdogInternalHandler.cpp
index 6da5fb53c6..be49ff9359 100644
--- a/cpp/watchdog/server/src/WatchdogInternalHandler.cpp
+++ b/cpp/watchdog/server/src/WatchdogInternalHandler.cpp
@@ -268,6 +268,15 @@ Status WatchdogInternalHandler::actionTakenOnResourceOveruse(
return Status::ok();
}
+Status WatchdogInternalHandler::controlProcessHealthCheck(bool disable) {
+ Status status = checkSystemUser();
+ if (!status.isOk()) {
+ return status;
+ }
+ mWatchdogProcessService->setEnabled(!disable);
+ return Status::ok();
+}
+
} // namespace watchdog
} // namespace automotive
} // namespace android
diff --git a/cpp/watchdog/server/src/WatchdogInternalHandler.h b/cpp/watchdog/server/src/WatchdogInternalHandler.h
index a2b4892832..e23620eb87 100644
--- a/cpp/watchdog/server/src/WatchdogInternalHandler.h
+++ b/cpp/watchdog/server/src/WatchdogInternalHandler.h
@@ -91,8 +91,9 @@ public:
configs) override;
android::binder::Status actionTakenOnResourceOveruse(
const std::vector<
- android::automotive::watchdog::internal::PackageResourceOveruseAction>&
- actions);
+ android::automotive::watchdog::internal::PackageResourceOveruseAction>& actions)
+ override;
+ android::binder::Status controlProcessHealthCheck(bool disable) override;
protected:
void terminate() {
diff --git a/cpp/watchdog/server/tests/WatchdogInternalHandlerTest.cpp b/cpp/watchdog/server/tests/WatchdogInternalHandlerTest.cpp
index efa9eef099..4646a11cf7 100644
--- a/cpp/watchdog/server/tests/WatchdogInternalHandlerTest.cpp
+++ b/cpp/watchdog/server/tests/WatchdogInternalHandlerTest.cpp
@@ -470,6 +470,19 @@ TEST_F(WatchdogInternalHandlerTest,
ASSERT_FALSE(status.isOk()) << status;
}
+TEST_F(WatchdogInternalHandlerTest, TestControlProcessHealthCheck) {
+ setSystemCallingUid();
+ EXPECT_CALL(*mMockWatchdogProcessService, setEnabled(/*isEnabled=*/true)).Times(1);
+ Status status = mWatchdogInternalHandler->controlProcessHealthCheck(false);
+ ASSERT_TRUE(status.isOk()) << status;
+}
+
+TEST_F(WatchdogInternalHandlerTest, TestErrorOnControlProcessHealthCheckWithNonSystemCallingUid) {
+ EXPECT_CALL(*mMockWatchdogProcessService, setEnabled(_)).Times(0);
+ Status status = mWatchdogInternalHandler->controlProcessHealthCheck(false);
+ ASSERT_FALSE(status.isOk()) << status;
+}
+
} // namespace watchdog
} // namespace automotive
} // namespace android