package P0;

import P0.c;
import P0.d;
import P0.e;
import android.graphics.Point;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.MotionEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class f {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private static f f1564d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private e f1565a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private Map f1566b = new HashMap();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private Map f1567c = new HashMap();

    class a extends d.a {
        a(P0.a aVar) {
        }

        @Override // P0.d
        public void u(String str, int i2, int i3) {
            g gVar = new g();
            gVar.c(i2);
            gVar.a(i3);
            gVar.b(f.this.c(str));
            throw null;
        }
    }

    class b extends c.a {
        b(P0.b bVar) {
        }

        @Override // P0.c
        public void w(MotionEvent motionEvent) {
            throw null;
        }
    }

    private f() {
    }

    public static f b() {
        if (f1564d == null) {
            f1564d = new f();
        }
        return f1564d;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public List c(String str) {
        String[] strArrSplit = str.split(",");
        ArrayList arrayList = new ArrayList();
        for (String str2 : strArrSplit) {
            String[] strArrSplit2 = str2.split("-");
            arrayList.add(new Point(Integer.parseInt(strArrSplit2[0]), Integer.parseInt(strArrSplit2[1])));
        }
        return arrayList;
    }

    private boolean d() {
        IBinder iBinderF = J0.c.g().f("opensdk_socketTouch");
        if (iBinderF == null) {
            return false;
        }
        this.f1565a = e.a.E(iBinderF);
        return true;
    }

    public void e() {
        Log.i("SDKTouch", "reConnect: ");
        Map map = this.f1566b;
        if (map != null && !map.isEmpty()) {
            for (String str : this.f1566b.keySet()) {
                android.support.v4.media.a.a(this.f1566b.get(str));
                f(str, null);
            }
        }
        Map map2 = this.f1567c;
        if (map2 == null || map2.isEmpty()) {
            return;
        }
        for (String str2 : this.f1567c.keySet()) {
            android.support.v4.media.a.a(this.f1567c.get(str2));
            g(str2, null);
        }
    }

    public boolean f(String str, P0.a aVar) {
        Log.d("SDKTouch", "registerCallBack: " + str);
        boolean zD = d();
        e eVar = this.f1565a;
        if (eVar != null) {
            try {
                eVar.t(str, new a(aVar));
                Map map = this.f1566b;
                if (map != null) {
                    map.put(str, aVar);
                }
            } catch (RemoteException e2) {
                Log.e("SDKTouch", "registerCallBack: ", e2);
            }
        }
        return zD && this.f1565a != null;
    }

    public boolean g(String str, P0.b bVar) {
        Log.d("SDKTouch", "registerTouchEventCallBack: " + str);
        boolean zD = d();
        e eVar = this.f1565a;
        if (eVar != null) {
            try {
                eVar.p(str, new b(bVar));
                Map map = this.f1567c;
                if (map != null) {
                    map.put(str, bVar);
                }
            } catch (RemoteException e2) {
                Log.e("SDKTouch", "registerCallBack: ", e2);
            }
        }
        return zD && this.f1565a != null;
    }
}
