Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d57df9e authored by Yifan Hong's avatar Yifan Hong
Browse files

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
parent 8902c87e
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -102,8 +102,7 @@ public abstract class HealthServiceWrapper {
            @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);
    }
}
+1 −7
Original line number Diff line number Diff line
@@ -56,12 +56,6 @@ final class HealthServiceWrapperHidl extends HealthServiceWrapper {
    // 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 @@ final class HealthServiceWrapperHidl extends HealthServiceWrapper {
     * @throws NullPointerException when supplier is null
     */
    @VisibleForTesting
    void init(
    HealthServiceWrapperHidl(
            @Nullable Callback callback,
            @NonNull IServiceManagerSupplier managerSupplier,
            @NonNull IHealthSupplier healthSupplier)