Introduce LoggingOtStatusReceiver for logging results of IOtDaemon methods
This is a refactor CL to get rid of two almost identical IOtStatusReceivers.
Bug: 362861470
Change-Id: Iae004eab0c6735359924ab0f6546e84d55d29ff7
Test: None
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
index 13817cf..6edaae9 100644
--- a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
@@ -1248,7 +1248,7 @@
.setInfraLinkState(
mInfraLinkState,
infraIcmp6Socket,
- new setInfraLinkStateStatusReceiver());
+ new LoggingOtStatusReceiver("setInfraLinkState"));
} catch (RemoteException | ThreadNetworkException e) {
LOG.e("Failed to configure border router " + mOtDaemonConfig, e);
}
@@ -1397,32 +1397,21 @@
}
}
- private static final class setOtDaemonConfigurationStatusReceiver
- extends IOtStatusReceiver.Stub {
- public setOtDaemonConfigurationStatusReceiver() {}
+ private static class LoggingOtStatusReceiver extends IOtStatusReceiver.Stub {
+ private final String mAction;
+
+ LoggingOtStatusReceiver(String action) {
+ mAction = action;
+ }
@Override
public void onSuccess() {
- LOG.i("Configured border router successfully");
+ LOG.i("The action " + mAction + " succeeded");
}
@Override
public void onError(int i, String s) {
- LOG.w(String.format("Failed to set configurations: %d %s", i, s));
- }
- }
-
- private static final class setInfraLinkStateStatusReceiver extends IOtStatusReceiver.Stub {
- public setInfraLinkStateStatusReceiver() {}
-
- @Override
- public void onSuccess() {
- LOG.i("Set the infra link state successfully");
- }
-
- @Override
- public void onError(int i, String s) {
- LOG.w(String.format("Failed to set the infra link state: %d %s", i, s));
+ LOG.w("The action " + mAction + " failed: " + i + " " + s);
}
}