package com.pgl.ssdk;

import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.input.InputManager;
import android.os.Build;
import android.view.InputDevice;
import android.view.MotionEvent;
import org.json.JSONException;
import org.json.JSONObject;
/* renamed from: com.pgl.ssdk.u  reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public class C1481u {

    /* renamed from: a  reason: collision with root package name */
    private static int f4769a;
    private static int b;
    private static int c;
    private static int d;
    private static int e;
    private static int f;
    private static boolean g;
    private static InputManager h;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.pgl.ssdk.u$a */
    /* loaded from: classes6.dex */
    public static class a implements Runnable {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ Context f4770a;
        final /* synthetic */ int b;

        a(Context context, int i) {
            this.f4770a = context;
            this.b = i;
        }

        @Override // java.lang.Runnable
        public void run() {
            InputManager a2 = C1481u.a(this.f4770a);
            if (a2 == null) {
                return;
            }
            InputDevice inputDevice = a2.getInputDevice(this.b);
            C1481u.g();
            if (inputDevice == null) {
                C1481u.a();
                C1481u.b();
                C1481u.a("nihc");
            } else if (inputDevice.isVirtual()) {
                C1481u.c();
                C1481u.d();
                C1481u.a("vihc");
            } else if (Build.VERSION.SDK_INT < 29 || !inputDevice.isExternal()) {
            } else {
                C1481u.e();
                C1481u.f();
                C1481u.a("eihc");
            }
        }
    }

    static /* synthetic */ int a() {
        int i = c;
        c = i + 1;
        return i;
    }

    static /* synthetic */ int b() {
        int i = f;
        f = i + 1;
        return i;
    }

    static /* synthetic */ int c() {
        int i = f4769a;
        f4769a = i + 1;
        return i;
    }

    static /* synthetic */ int d() {
        int i = d;
        d = i + 1;
        return i;
    }

    static /* synthetic */ int e() {
        int i = b;
        b = i + 1;
        return i;
    }

    static /* synthetic */ int f() {
        int i = e;
        e = i + 1;
        return i;
    }

    public static void a(MotionEvent motionEvent, Context context) {
        if (motionEvent == null || context == null) {
            return;
        }
        if (motionEvent.getRawX() > 0.0f || motionEvent.getRawY() > 0.0f) {
            AbstractC1464c.a(new a(context, motionEvent.getDeviceId()));
        }
    }

    public static void g() {
        if (g) {
            return;
        }
        try {
            SharedPreferences a2 = L.a(C1482v.b());
            if (a2 != null) {
                f = a2.getInt("nihc", 0);
                e = a2.getInt("eihc", 0);
                d = a2.getInt("vihc", 0);
                g = true;
            }
        } catch (Throwable unused) {
        }
    }

    static void a(String str) {
        try {
            SharedPreferences a2 = L.a(C1482v.b());
            if (a2 != null) {
                a2.edit().putInt(str, a2.getInt(str, 0) + 1).apply();
            }
        } catch (Throwable unused) {
        }
    }

    public static void a(JSONObject jSONObject) {
        try {
            jSONObject.put("vihc", d);
            jSONObject.put("eihc", e);
            jSONObject.put("nihc", f);
            jSONObject.put("vic", f4769a);
            jSONObject.put("nic", c);
            jSONObject.put("eic", b);
        } catch (JSONException unused) {
        }
    }

    static InputManager a(Context context) {
        if (h == null) {
            h = (InputManager) context.getSystemService("input");
        }
        return h;
    }
}
