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

Commit 33fc2dd6 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Fixup lint errors in ServiceWatcher

Allow subclass equality and use locks appropriately to avoid lint
warnings.

Bug: 181665909
Test: presubmits
Change-Id: I62fe67451fb59f634eb0448edef63e4a28bc476a
parent 5ee5b490
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public interface ServiceWatcher {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
            if (!(o instanceof BoundServiceInfo)) {
                return false;
            }

+13 −3
Original line number Diff line number Diff line
@@ -147,13 +147,23 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements

    @Override
    public String toString() {
        return mServiceConnection.getBoundServiceInfo().toString();
        MyServiceConnection serviceConnection;
        synchronized (this) {
            serviceConnection = mServiceConnection;
        }

        return serviceConnection.getBoundServiceInfo().toString();
    }

    @Override
    public void dump(PrintWriter pw) {
        pw.println("target service=" + mServiceConnection.getBoundServiceInfo());
        pw.println("connected=" + mServiceConnection.isConnected());
        MyServiceConnection serviceConnection;
        synchronized (this) {
            serviceConnection = mServiceConnection;
        }

        pw.println("target service=" + serviceConnection.getBoundServiceInfo());
        pw.println("connected=" + serviceConnection.isConnected());
    }

    // runs on the handler thread, and expects most of it's methods to be called from that thread