health: Drop HealthServiceWrapperHidl.init.
Having a separate init function is a bad contract because
the client may not call it. Replace it with the constructor.
This reduces technical debt.
Test: pass
Change-Id: I3828903b006c32eb6898d36e64326520ef601ba8
diff --git a/services/core/java/com/android/server/health/HealthServiceWrapper.java b/services/core/java/com/android/server/health/HealthServiceWrapper.java
index 172730f..0b43f26 100644
--- a/services/core/java/com/android/server/health/HealthServiceWrapper.java
+++ b/services/core/java/com/android/server/health/HealthServiceWrapper.java
@@ -102,8 +102,7 @@
@NonNull HealthServiceWrapperHidl.IServiceManagerSupplier hidlServiceManagerSupplier,
@NonNull HealthServiceWrapperHidl.IHealthSupplier hidlHealthSupplier)
throws RemoteException, NoSuchElementException {
- HealthServiceWrapperHidl service = new HealthServiceWrapperHidl();
- service.init(hidlRegCallback, hidlServiceManagerSupplier, hidlHealthSupplier);
- return service;
+ return new HealthServiceWrapperHidl(
+ hidlRegCallback, hidlServiceManagerSupplier, hidlHealthSupplier);
}
}
diff --git a/services/core/java/com/android/server/health/HealthServiceWrapperHidl.java b/services/core/java/com/android/server/health/HealthServiceWrapperHidl.java
index 18d20bf..3bff2f8 100644
--- a/services/core/java/com/android/server/health/HealthServiceWrapperHidl.java
+++ b/services/core/java/com/android/server/health/HealthServiceWrapperHidl.java
@@ -56,12 +56,6 @@
// Last IHealth service received.
private final AtomicReference<IHealth> mLastService = new AtomicReference<>();
- /**
- * init should be called after constructor. For testing purposes, init is not called by
- * constructor.
- */
- HealthServiceWrapperHidl() {}
-
private static void traceBegin(String name) {
Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, name);
}
@@ -181,7 +175,7 @@
* @throws NullPointerException when supplier is null
*/
@VisibleForTesting
- void init(
+ HealthServiceWrapperHidl(
@Nullable Callback callback,
@NonNull IServiceManagerSupplier managerSupplier,
@NonNull IHealthSupplier healthSupplier)