package com.ucar.vehiclesdk;

import a.a.a.b;
import a.b.a.i.i;
import a.c.b.k;
import a.c.b.o;
import a.c.b.s;
import a.c.d.b;
import a.c.d.c.a;
import a.c.d.g.a;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.view.Surface;
import com.share.connect.WifiOwnerConfig;
import com.ucar.databus.proto.UCarProto;
import com.ucar.sdk.R;
import com.ucar.vehiclesdk.UCarAdapter;
import com.ucar.vehiclesdk.UCarCommon;
import com.ucar.vehiclesdk.UCarConnectState;
import com.ucar.vehiclesdk.connect.UCarConnectProxy;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;

public class UCarAdapter {
    private static final String X = "UCarAdapter";
    private static final int Y = 500;
    private static final int Z = 500;
    private static final int a0 = 500;
    private static final int b0 = 200;
    private static final int c0 = 20;
    private static final int d0 = 3000;
    public static final int e0 = 0;
    public static final int f0 = 10;
    public static final int g0 = 20;
    public static final int h0 = 30;
    public static final int i0 = 40;
    public static final int j0 = 50;
    public static final int k0 = 60;
    public static final int l0 = 70;
    public static final int m0 = 80;
    public static final int n0 = 90;
    public static final int o0 = 100;
    public static final long p0 = 3000;
    private static final Map<Integer, Integer> q0 = new a();
    private static volatile UCarAdapter r0;
    private final byte[] A = new byte[2];
    private final byte[] B = new byte[6];
    private boolean C;
    private int D = 0;
    private boolean E = false;
    private boolean F = false;
    private boolean G = false;
    private AtomicBoolean H = new AtomicBoolean(false);
    private String I;
    private a.c.d.b J;
    private HandlerThread K;
    private Handler L;
    private a.c.d.k.a M;
    private a.c.d.k.c N;
    private CountDownLatch O = new CountDownLatch(1);
    private int P = -1;
    private int Q;
    private int R;
    private int S;
    private int T;
    private String U;
    private long V = 0;
    private final Runnable W = new b();

    /* renamed from: a  reason: collision with root package name */
    private UCarConfig f222a;
    private final ReentrantLock b = new ReentrantLock();
    private String c = "-1";
    private Handler d;
    private HandlerThread e;
    private Handler f;
    private boolean g = false;
    private volatile boolean h = true;
    private boolean i;
    private Context j;
    private final List<ICarConnectListener> k = new ArrayList();
    private final List<IPhoneDataListener> l = new ArrayList();
    private ICarInitCallback m = null;
    private UCarConnectProxy n;
    private a.c.d.f.a o;
    private a.c.d.e.b p;
    private a.c.d.g.a q;
    private a.c.d.c.a r;
    private a.c.d.g.b s;
    private a.c.d.h.d t;
    private a.c.d.h.b u;
    private a.c.d.d.b v;
    private int w;
    private int x;
    private int y;
    private int z;

    public class a extends HashMap {
        public a() {
            put(0, 0);
            put(1, 10);
            put(2, 20);
            put(3, 20);
            put(4, 30);
            put(5, 40);
            put(6, 40);
            put(7, 50);
            put(8, 60);
            put(9, 70);
            put(10, 80);
            put(11, 90);
            put(12, 100);
        }
    }

    public class b implements Runnable {
        public b() {
        }

        public void run() {
            if (UCarAdapter.this.p != null) {
                UCarAdapter.this.p.a();
            }
            UCarAdapter.this.pauseCast();
        }
    }

    public class c implements b.c {
        public c() {
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void c() {
            String str;
            if (UCarAdapter.this.n != null) {
                a.a.a.b.a(UCarAdapter.X, "connect time out, try stop advertise");
                UCarAdapter.this.n.i();
                UCarAdapter.this.n.b();
                UCarAdapter.this.b.lock();
                UCarAdapter uCarAdapter = UCarAdapter.this;
                MDevice a2 = uCarAdapter.a((UCarAdapter) uCarAdapter.c);
                if (a2.isWireless()) {
                    if (UCarAdapter.this.D >= 20) {
                        str = "connect time out in cast phase (wireless), try disconnect link";
                    }
                    UCarAdapter.this.b.unlock();
                }
                if (a2.isWired() && UCarAdapter.this.D >= 50) {
                    str = "connect time out in cast phase (usb), try disconnect link";
                }
                UCarAdapter.this.b.unlock();
                a.a.a.b.a(UCarAdapter.X, str);
                UCarAdapter.this.n.c();
                UCarAdapter.this.b.unlock();
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void d() {
            if (UCarAdapter.this.n != null) {
                a.a.a.b.a(UCarAdapter.X, "heart beat time out, try disconnect link");
                UCarAdapter.this.n.c();
            }
        }

        @Override // a.c.d.b.c
        public void a() {
            a.a.a.b.a(UCarAdapter.X, "onHeartBeatTimeout");
            UCarAdapter.this.f.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$c$V9Hm2yNd3Jw4UbraFol20LHs3LQ */

                public final void run() {
                    UCarAdapter.c.this.d();
                }
            });
        }

        @Override // a.c.d.b.c
        public void b() {
            a.a.a.b.a(UCarAdapter.X, "onConnectTimeout");
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) UCarConnectState.ErrorCode.ERROR_CONNECT_TIMEOUT);
            UCarAdapter.this.f.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$c$JJkSUR6CFGrqFXBqdA9jR8q4_kc */

                public final void run() {
                    UCarAdapter.c.this.c();
                }
            });
        }
    }

    public class d implements a.t {
        public d() {
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void e() {
            UCarAdapter.this.n.c();
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void f() {
            if (!UCarAdapter.this.h()) {
                UCarAdapter.this.t();
            }
            UCarAdapter.this.J.c();
            if (UCarAdapter.this.g()) {
                UCarAdapter.this.J.g();
            }
        }

        @Override // a.c.d.g.a.t
        public void a() {
            UCarAdapter.this.h = true;
            UCarAdapter.this.f.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$d$MH_TDEqJHKMSatCm1f8KcbVuR7w */

                public final void run() {
                    UCarAdapter.d.this.e();
                }
            });
        }

        @Override // a.c.d.g.a.t
        public void a(int i, boolean z, int i2, UCarCommon.AppState appState, long j) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a(uCarAdapter.c, i, z, i2, appState, j);
        }

        @Override // a.c.d.g.a.t
        public void a(long j) {
            a.a.a.b.a(UCarAdapter.X, "onHeartbeat, timeStamp = " + j);
            UCarAdapter.this.L.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$d$ODzKWJu4MxWfCZQzbjopRsFfE */

                public final void run() {
                    UCarAdapter.d.this.f();
                }
            });
        }

        @Override // a.c.d.g.a.t
        public void a(s sVar) {
            a.c.d.g.a aVar = UCarAdapter.this.q;
            UCarConfig uCarConfig = UCarAdapter.this.f222a;
            UCarAdapter uCarAdapter = UCarAdapter.this;
            aVar.a(uCarConfig, uCarAdapter.a((UCarAdapter) uCarAdapter.c), sVar);
        }

        @Override // a.c.d.g.a.t
        public void a(a.b bVar) {
            UCarAdapter.this.a((UCarAdapter) bVar);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.AudioType audioType, UCarCommon.AudioFormat audioFormat, a.d dVar) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) audioType, (UCarCommon.AudioType) audioFormat, (UCarCommon.AudioFormat) dVar);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.BluetoothMacInfo bluetoothMacInfo) {
            UCarAdapter.this.a((UCarAdapter) bluetoothMacInfo);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.CallInfo callInfo) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) callInfo);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.CameraAction cameraAction, UCarCommon.CameraActionArgs cameraActionArgs) {
            if (UCarAdapter.this.v != null && !UCarAdapter.this.v.a() && cameraAction == UCarCommon.CameraAction.CAMERA_OPEN) {
                a.a.a.b.a(UCarAdapter.X, "CameraManager.start with address:" + UCarAdapter.this.I);
                UCarAdapter.this.v.a(UCarAdapter.this.I);
                UCarAdapter.this.H.set(true);
            }
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) cameraAction, (UCarCommon.CameraAction) cameraActionArgs);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.MusicInfo musicInfo) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) musicInfo);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.NavigationInfo navigationInfo) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) navigationInfo);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.POIAddress pOIAddress) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) pOIAddress);
        }

        @Override // a.c.d.g.a.t
        public void a(UCarCommon.PhoneStateInfo phoneStateInfo) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) phoneStateInfo);
        }

        @Override // a.c.d.g.a.t
        public void a(List<Integer> list, UCarCommon.AppListState appListState) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) list, (List) appListState);
        }

        @Override // a.c.d.g.a.t
        public void a(boolean z, UCarCommon.AudioFormat audioFormat, boolean z2) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) audioFormat, (UCarCommon.AudioFormat) z, z2);
        }

        @Override // a.c.d.g.a.t
        public void b() {
            a.a.a.b.a(UCarAdapter.X, "stop mirror, not used yet.");
        }

        @Override // a.c.d.g.a.t
        public void c() {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) 7, -1);
        }

        @Override // a.c.d.g.a.t
        public void d() {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) 6, -1);
        }
    }

    public class e implements a.c.d.e.a {
        public e() {
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void b(String str) {
            if (UCarAdapter.this.n != null) {
                a.a.a.b.c(UCarAdapter.X, "onWfdSinkStopped, sessionId: " + str);
                if (UCarAdapter.this.g()) {
                    UCarAdapter.this.n.c();
                }
                UCarAdapter uCarAdapter = UCarAdapter.this;
                uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) 5, -1);
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void b(String str, int i, int i2, boolean z) {
            a.a.a.b.c(UCarAdapter.X, "onWfdSinkReady, sessionId: " + str + ", width: " + i + ", height: " + i2 + ", uibcEncryption: " + z);
            if (UCarAdapter.this.s != null) {
                UCarAdapter.this.s.a(str);
                UCarAdapter.this.s.a(z);
                UCarAdapter.this.a((UCarAdapter) i, i2);
            }
            UCarAdapter.this.c((UCarAdapter) 11);
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) 4, -1);
        }

        @Override // a.c.d.e.a
        public void a(UCarCommon.AudioFormat audioFormat) {
            UCarAdapter uCarAdapter = UCarAdapter.this;
            uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) UCarCommon.AudioType.STREAM_CAST_MUSIC, (UCarCommon.AudioType) audioFormat, (UCarCommon.AudioFormat) a.d.START_PLAYER);
        }

        @Override // a.c.d.e.a
        public void a(String str) {
            UCarAdapter.this.f.post(new Runnable(str) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$e$oCieEyL5cPL8qHgcARJqcNm3Y */
                public final /* synthetic */ String f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    UCarAdapter.e.this.b(this.f$1);
                }
            });
        }

        @Override // a.c.d.e.a
        public void a(String str, int i, int i2, boolean z) {
            UCarAdapter.this.f.post(new Runnable(str, i, i2, z) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$e$PvDBVoJbeGVg2nEO5XA2sY5Nwr8 */
                public final /* synthetic */ String f$1;
                public final /* synthetic */ int f$2;
                public final /* synthetic */ int f$3;
                public final /* synthetic */ boolean f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    UCarAdapter.e.this.b(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
        }
    }

    public class f implements a.c.d.f.a {

        public class a implements Runnable {

            /* renamed from: a  reason: collision with root package name */
            public final /* synthetic */ WifiOwnerConfig f228a;

            public a(WifiOwnerConfig wifiOwnerConfig) {
                this.f228a = wifiOwnerConfig;
            }

            public void run() {
                for (ICarConnectListener iCarConnectListener : UCarAdapter.this.k) {
                    if (iCarConnectListener != null) {
                        iCarConnectListener.onReconfigureWifiInfo(this.f228a);
                        return;
                    }
                }
            }
        }

        public f() {
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void a(boolean z) {
            UCarAdapter.this.a((UCarAdapter) z);
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void c() {
            UCarAdapter.this.J.b();
            UCarAdapter.this.J.f();
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void c(String str, int i) {
            UCarAdapter.this.L.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$qroAfUYG3FK6Alh_0FW21_EgMp4 */

                public final void run() {
                    UCarAdapter.f.this.d();
                }
            });
            if (!UCarAdapter.this.g()) {
                UCarAdapter.this.a((UCarAdapter) str, (String) i);
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void c(String str, String str2) {
            for (ICarConnectListener iCarConnectListener : UCarAdapter.this.k) {
                if (iCarConnectListener != null) {
                    iCarConnectListener.onPinCode(str, str2);
                }
            }
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void d() {
            UCarAdapter.this.J.b();
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void d(String str, String str2) {
            UCarAdapter.this.g((UCarAdapter) true);
            UCarAdapter.this.e((UCarAdapter) str);
            UCarAdapter.this.u();
            if (!UCarAdapter.this.b((UCarAdapter) str2)) {
                UCarAdapter.this.p.a(UCarAdapter.this.a((UCarAdapter) str2));
                a.c.d.e.b bVar = UCarAdapter.this.p;
                int i = UCarAdapter.this.w;
                int i2 = UCarAdapter.this.x;
                int i3 = UCarAdapter.this.y;
                int i4 = UCarAdapter.this.z;
                boolean z = UCarAdapter.this.C;
                UCarAdapter uCarAdapter = UCarAdapter.this;
                bVar.a(i, i2, i3, i4, z, uCarAdapter.c((UCarAdapter) uCarAdapter.c));
                UCarAdapter.this.i((UCarAdapter) true);
            }
            UCarAdapter.this.b();
            UCarAdapter.this.stopAdvertise();
        }

        /* access modifiers changed from: private */
        public /* synthetic */ void e() {
            UCarAdapter.this.a((UCarAdapter) false);
        }

        @Override // a.c.d.f.a
        public void a() {
            a.a.a.b.a(UCarAdapter.X, "onShareLinkServiceDisconnected");
            UCarAdapter.this.b.lock();
            UCarAdapter.this.O = new CountDownLatch(1);
            UCarAdapter.this.b.unlock();
            UCarAdapter.this.f.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$2sTPTxRsmJir3iaCJu5Xi8SVdaA */

                public final void run() {
                    UCarAdapter.f.this.e();
                }
            });
        }

        @Override // a.c.d.f.a
        public void a(String str) {
            UCarAdapter.this.L.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$ZjC9Jnnb6FQL6OvkODMxvvHiY */

                public final void run() {
                    UCarAdapter.f.this.c();
                }
            });
        }

        @Override // a.c.d.f.a
        public void a(String str, int i) {
            UCarAdapter.this.c((UCarAdapter) i);
        }

        @Override // a.c.d.f.a
        public void a(String str, String str2) {
            UCarAdapter.this.c = str;
        }

        @Override // a.c.d.f.a
        public void a(String str, boolean z) {
            a.a.a.b.a(UCarAdapter.X, "onDisconnected, deviceId: " + str);
            if (UCarAdapter.this.m != null) {
                UCarAdapter.this.f.post(new Runnable(z) {
                    /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$i89GFG6phVxzv1RhyKGG4vADPrY */
                    public final /* synthetic */ boolean f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        UCarAdapter.f.this.a((UCarAdapter.f) this.f$1);
                    }
                });
            } else {
                a.a.a.b.c(UCarAdapter.X, "mCarInitCallback is null, deInit method has called");
            }
        }

        @Override // a.c.d.f.a
        public void b() {
            a.a.a.b.a(UCarAdapter.X, "onShareLinkServiceConnected");
            UCarAdapter.this.O.countDown();
        }

        @Override // a.c.d.f.a
        public void b(String str, int i) {
            a.a.a.b.e(UCarAdapter.X, "onConnectFailed, errorCode: " + i);
            UCarAdapter.this.f.post(new Runnable(str, i) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$fnm3WcVBChFcAl8IzOKiLxzdHk */
                public final /* synthetic */ String f$1;
                public final /* synthetic */ int f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    UCarAdapter.f.this.c((UCarAdapter.f) this.f$1, (String) this.f$2);
                }
            });
        }

        @Override // a.c.d.f.a
        public void b(String str, String str2) {
            a.a.a.b.a(UCarAdapter.X, "onReceivedClientAddress, deviceId: " + str + ", ip: " + str2);
            UCarAdapter.this.h = false;
            if (UCarAdapter.this.p != null) {
                UCarAdapter.this.f.post(new Runnable(str2, str) {
                    /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$VTNSyr0nLsDuzPbyRjbLnpk1WDg */
                    public final /* synthetic */ String f$1;
                    public final /* synthetic */ String f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        UCarAdapter.f.this.d(this.f$1, this.f$2);
                    }
                });
            }
        }

        @Override // a.c.d.f.a
        public void onConnected() {
            a.a.a.b.a(UCarAdapter.X, "onConnected");
            UCarAdapter.this.b.lock();
            UCarAdapter.this.P = -1;
            UCarAdapter.this.b.unlock();
        }

        @Override // a.c.d.f.a
        public void onPinCode(String str, String str2) {
            UCarAdapter.this.d.post(new Runnable(str, str2) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f$33mOBAF_O5ubEnWwTOWjzmeo4Ug */
                public final /* synthetic */ String f$1;
                public final /* synthetic */ String f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    UCarAdapter.f.this.c((UCarAdapter.f) this.f$1, this.f$2);
                }
            });
        }

        @Override // a.c.d.f.a
        public void onReconfigureWifi(WifiOwnerConfig wifiOwnerConfig) {
            Future<?> submit = Executors.newSingleThreadExecutor().submit(new a(wifiOwnerConfig));
            try {
                submit.get(500, TimeUnit.MILLISECONDS);
            } catch (InterruptedException | ExecutionException | TimeoutException unused) {
                a.a.a.b.a(UCarAdapter.X, "onReconfigureWifi process timeout");
                submit.cancel(true);
            }
        }

        @Override // a.c.d.f.a
        public int onSelectWorkMode(int i) {
            boolean z;
            a.c.d.c.a aVar;
            UCarAdapter uCarAdapter = UCarAdapter.this;
            int i2 = uCarAdapter.a((UCarAdapter) uCarAdapter.c, (String) UCarCommon.WorkMode.fromInt(i)).toInt();
            if (UCarCommon.WorkMode.fromInt(i2).isSupportNormalCast()) {
                aVar = UCarAdapter.this.r;
                z = true;
            } else {
                aVar = UCarAdapter.this.r;
                z = false;
            }
            aVar.a(z);
            return i2;
        }

        @Override // a.c.d.f.a
        public void onUserInterventionNeeded(boolean z) {
            if (z) {
                UCarAdapter uCarAdapter = UCarAdapter.this;
                uCarAdapter.b((UCarAdapter) uCarAdapter.c, (String) 3, (int) UCarConnectState.ErrorCode.ERROR_USER_INTERVENTION_TIMEOUT);
                return;
            }
            UCarAdapter.this.b((UCarAdapter) 0);
        }
    }

    static {
        a.a.a.b.a("UCar_");
        k.a(new a.c.b.a0.a());
        k.a(o.CAR);
    }

    private UCarAdapter() {
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private MDevice a(String str) {
        UCarConnectProxy uCarConnectProxy = this.n;
        return uCarConnectProxy != null ? uCarConnectProxy.a(str) : new MDevice();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private UCarCommon.WorkMode a(String str, UCarCommon.WorkMode workMode) {
        UCarCommon.WorkMode onSelectWorkMode;
        UCarCommon.WorkMode workMode2 = UCarCommon.WorkMode.NORMAL_CAST;
        for (ICarConnectListener iCarConnectListener : this.k) {
            if (!(iCarConnectListener == null || (onSelectWorkMode = iCarConnectListener.onSelectWorkMode(str, workMode)) == null || !UCarCommon.WorkMode.isValidSelect(onSelectWorkMode))) {
                workMode2 = onSelectWorkMode;
            }
        }
        a.a.a.b.a(X, "notifySelectWorkMode, deviceId: " + str + ", selectedWorkMode: " + workMode2.toInt());
        return workMode2;
    }

    /* access modifiers changed from: private */
    public static /* synthetic */ String a(String str, List list) {
        return "getAppDetailInfo, deviceId: " + str + ", appIds: " + list;
    }

    /* access modifiers changed from: private */
    public static /* synthetic */ String a(ArrayList arrayList) {
        return "getAppDetailInfo, list: " + arrayList;
    }

    private void a() {
        a.c.d.k.a aVar = this.M;
        if (aVar != null) {
            aVar.interrupt();
        }
        a.c.d.k.c cVar = this.N;
        if (cVar != null) {
            cVar.a();
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(int i2) {
        a(this.c, i2, false, this.P, UCarCommon.AppState.STOPPED, 0);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(int i2, int i3) {
        this.b.lock();
        this.S = i2;
        this.Q = i2;
        this.T = i3;
        this.R = i3;
        this.s.f(i2);
        this.s.e(i3);
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(int i2, int i3, Surface surface, a.c.d.a aVar) {
        this.s.d(i2);
        this.s.c(i3);
        boolean z2 = true;
        if (!this.p.a(surface, this.Q, this.R, this.f222a.isSupportLowLatencyDecodingMode(), this.V, aVar) || !this.q.a(true)) {
            z2 = false;
        }
        if (g() && !z2) {
            a(this.c, UCarConnectState.ErrorCode.ERROR_START_CAST_FAILED);
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(int i2, boolean z2) {
        a(this.c, i2, true, !z2 ? 1 : 0, UCarCommon.AppState.STARTED, 0);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(a.b bVar) {
        this.f.post(new Runnable(bVar) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$wdVj095_1cQmUSdixuAPTBJcjuE */
            public final /* synthetic */ a.b f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                UCarAdapter.this.b((UCarAdapter) this.f$1);
            }
        });
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(a.d dVar, UCarCommon.AudioType audioType, UCarCommon.AudioFormat audioFormat) {
        UCarCommon.AudioAttributes audioAttributesByType;
        UCarCommon.AudioAttributes audioAttributes = null;
        if (dVar == a.d.START_PLAYER) {
            for (IPhoneDataListener iPhoneDataListener : this.l) {
                if (!(iPhoneDataListener == null || (audioAttributesByType = iPhoneDataListener.getAudioAttributesByType(audioType)) == null)) {
                    audioAttributes = audioAttributesByType;
                }
            }
        }
        this.r.a(audioType, audioFormat, dVar, audioAttributes);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(ICarInitCallback iCarInitCallback, UCarConfig uCarConfig, Context context) {
        a.a.a.b.a(X, "init, sdk version: v1.5.1-202307102121-6b313012");
        if (this.g) {
            a.a.a.b.e(X, "the adapter was initialized, just return!");
            return;
        }
        this.m = iCarInitCallback;
        byte[] carBrMac = uCarConfig.getCarBrMac();
        if (carBrMac == null || carBrMac.length != 6) {
            a.a.a.b.b(X, "carId is invalid, the length must be 6 size!");
            this.m.onInitFailed(UCarConnectState.ErrorCode.ERROR_INVALID_PARAMETER);
            return;
        }
        this.f222a = uCarConfig;
        System.arraycopy(carBrMac, 0, this.B, 0, 6);
        this.x = this.f222a.getVideoDisplayHeight();
        this.w = this.f222a.getVideoDisplayWidth();
        this.y = this.f222a.getDpi();
        this.z = this.f222a.getFps();
        this.C = this.f222a.isSupportHevc();
        byte[] carCustomField = uCarConfig.getCarCustomField();
        if (carCustomField != null && carCustomField.length == 2) {
            System.arraycopy(carCustomField, 0, this.A, 0, 2);
        }
        a.a.a.b.a(X, "init adapter");
        if (!a(context)) {
            this.m.onInitFailed(UCarConnectState.ErrorCode.ERROR_INIT_FAILED);
            a.a.a.b.b(X, "init adapter failed!");
            return;
        }
        a(this.w, this.x);
        this.b.lock();
        try {
            if (this.O.await(3000, TimeUnit.MILLISECONDS)) {
                this.g = true;
                ICarInitCallback iCarInitCallback2 = this.m;
                if (iCarInitCallback2 != null) {
                    iCarInitCallback2.onInitSuccess();
                }
            } else {
                this.g = false;
                a.a.a.b.b(X, "init adapter failed!");
                ICarInitCallback iCarInitCallback3 = this.m;
                if (iCarInitCallback3 != null) {
                    iCarInitCallback3.onInitFailed(UCarConnectState.ErrorCode.ERROR_INIT_FAILED);
                }
            }
        } catch (InterruptedException e2) {
            this.g = false;
            a.a.a.b.b(X, "init adapter interrupt.", e2);
        } catch (Throwable th) {
            this.b.unlock();
            throw th;
        }
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(UCarCommon.AudioFormat audioFormat, boolean z2, boolean z3) {
        this.r.a(audioFormat, z2, z3);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(UCarCommon.AudioType audioType, int i2) {
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onAudioFocusChanged(audioType, i2);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(UCarCommon.BluetoothMacInfo bluetoothMacInfo) {
        a.b.a.f.f fVar = new a.b.a.f.f(this.j);
        if (bluetoothMacInfo.getOpType() == UCarCommon.OPType.OP_ADD) {
            this.U = bluetoothMacInfo.getBluetoothMac();
            if (a.b.a.f.f.b(this.c, this.j) == null) {
                e(true);
            }
            a.a.a.b.a(X, "add mCurrentConnectBtMac: " + this.U);
            fVar.a(this.c, bluetoothMacInfo.getBluetoothMac());
        } else if (bluetoothMacInfo.getOpType() == UCarCommon.OPType.OP_DELETE) {
            fVar.a(this.c);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, int i2) {
        if (this.D > 0) {
            c(0);
        }
        c(str, i2);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, int i2, int i3) {
        for (ICarConnectListener iCarConnectListener : this.k) {
            if (iCarConnectListener != null) {
                iCarConnectListener.onConnectStateChanged(str, i2, i3);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, int i2, boolean z2, int i3, UCarCommon.AppState appState) {
        a.a.a.b.a(X, "notifyAppStateChanged, deviceId: " + str + ", appId: " + i2 + ", isNeedShow: " + z2 + ", displayMode: " + i3 + ", appState: " + appState);
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onAppStateChanged(str, i2, z2, this.S, this.T, appState);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, int i2, boolean z2, int i3, UCarCommon.AppState appState, long j2) {
        this.b.lock();
        if (!(!z2 || this.P == i3 || i3 == -1)) {
            this.P = i3;
        }
        if (appState == UCarCommon.AppState.STARTED || appState == UCarCommon.AppState.RESUMED) {
            this.L.removeCallbacks(this.W);
            this.V = j2;
        }
        this.b.unlock();
        this.d.post(new Runnable(str, i2, z2, i3, appState) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$_uwUHI3DIbFgae55bVuPeEoteOE */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ int f$2;
            public final /* synthetic */ boolean f$3;
            public final /* synthetic */ int f$4;
            public final /* synthetic */ UCarCommon.AppState f$5;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2, (int) this.f$3, (boolean) this.f$4, (int) this.f$5);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, UCarCommon.AudioFormat audioFormat, boolean z2, boolean z3) {
        this.f.post(new Runnable(audioFormat, z2, z3) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$_yRaA0bkslIp5JmTD0tIH9pvQo */
            public final /* synthetic */ UCarCommon.AudioFormat f$1;
            public final /* synthetic */ boolean f$2;
            public final /* synthetic */ boolean f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (UCarCommon.AudioFormat) this.f$2, this.f$3);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, UCarCommon.AudioType audioType, UCarCommon.AudioFormat audioFormat, a.d dVar) {
        this.f.post(new Runnable(dVar, audioType, audioFormat) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$EeEEXhSKYlH97ycyZgNSdXYuH1U */
            public final /* synthetic */ a.d f$1;
            public final /* synthetic */ UCarCommon.AudioType f$2;
            public final /* synthetic */ UCarCommon.AudioFormat f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (a.d) this.f$2, (UCarCommon.AudioType) this.f$3);
            }
        });
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, UCarCommon.CallInfo callInfo) {
        a.a.a.b.a(X, "notifyCallInfoReceived, deviceId: " + str + ", callInfo: " + callInfo);
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onCallInfoReceived(str, callInfo);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(String str, UCarCommon.CameraAction cameraAction, UCarCommon.CameraActionArgs cameraActionArgs) {
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.a(str, cameraAction, cameraActionArgs);
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, UCarCommon.MusicInfo musicInfo) {
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onMusicInfoReceived(str, musicInfo);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, UCarCommon.NavigationInfo navigationInfo) {
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onNavigationInfoReceived(str, navigationInfo);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, UCarCommon.POIAddress pOIAddress) {
        a.a.a.b.a(X, "notifyPOIAddressReceived, deviceId: " + str + ", poiAddress: " + pOIAddress);
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onPOIReceived(str, pOIAddress);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, UCarCommon.PhoneStateInfo phoneStateInfo) {
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onPhoneStateInfoReceived(str, phoneStateInfo);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, List list, UCarCommon.AppListState appListState) {
        a.a.a.b.a(X, "notifyAppListChanged, deviceId: " + str + ", appIds: " + list + ", appState: " + appListState);
        for (IPhoneDataListener iPhoneDataListener : this.l) {
            if (iPhoneDataListener != null) {
                iPhoneDataListener.onAppListStateChanged(str, list, appListState);
            }
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(String str, boolean z2) {
        if (this.D >= 90) {
            this.n.b();
        }
        b(str, 1, z2 ? 11 : -1);
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.a(1);
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void a(CountDownLatch countDownLatch) {
        this.g = false;
        this.m = null;
        this.h = true;
        stopAdvertise();
        UCarConnectProxy uCarConnectProxy = this.n;
        if (uCarConnectProxy != null) {
            uCarConnectProxy.a(false);
            this.n.c();
        }
        a(false);
        this.l.clear();
        this.k.clear();
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.b(null);
        }
        countDownLatch.countDown();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(boolean z2) {
        a.a.a.b.a(X, "handleDisconnectRequest, isConnected: " + g());
        if (this.D > 0) {
            c(0);
        }
        if (g()) {
            g(false);
            s();
            b(this.c, this.h || z2);
            e(false);
        }
    }

    private boolean a(Context context) {
        this.i = false;
        this.j = context;
        c();
        UCarConfig uCarConfig = this.f222a;
        if (uCarConfig != null && uCarConfig.isSupportCamera()) {
            this.v = new a.c.d.d.b(this.j);
        }
        this.s = new a.c.d.g.b();
        this.t = new a.c.d.h.d(this.j);
        this.u = new a.c.d.h.b(this.j, this.f222a.getCcdFilePath());
        f();
        d();
        return e();
    }

    /* access modifiers changed from: private */
    public static /* synthetic */ String b(ArrayList arrayList) {
        return "getAppList, list: " + arrayList;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b() {
        c(10);
        this.L.post(new Runnable() {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$f14JGxaSM3XkEL0KFsWCfZHLkY */

            public final void run() {
                UCarAdapter.this.j();
            }
        });
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            aVar.b(new a.u() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$cDTQ2LoaiG71trbmQ29rFdb23gU */

                @Override // a.c.d.g.a.u
                public final void a() {
                    UCarAdapter.this.l();
                }
            });
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(int i2) {
        a.a.a.b.a(X, "setConnectPhase, phase: " + i2);
        this.b.lock();
        this.D = i2;
        this.b.unlock();
        d(this.c, i2);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(a.b bVar) {
        this.r.a(bVar);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(String str, int i2) {
        for (ICarConnectListener iCarConnectListener : this.k) {
            if (iCarConnectListener != null) {
                iCarConnectListener.onConnectingProgress(str, i2);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, int i2, int i3) {
        this.d.post(new Runnable(str, i2, i3) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$KVWEESke1V1PNG4qhsxs_zGx7mI */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ int f$2;
            public final /* synthetic */ int f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2, this.f$3);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, UCarCommon.CallInfo callInfo) {
        this.d.post(new Runnable(str, callInfo) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$JuJur8lZiTjP79cOe1_Sd7qwISo */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ UCarCommon.CallInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, UCarCommon.MusicInfo musicInfo) {
        this.f.post(new Runnable(str, musicInfo) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$Uw_xNoXLb8KSQuThlIqEec9rc */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ UCarCommon.MusicInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, UCarCommon.NavigationInfo navigationInfo) {
        if (navigationInfo != null) {
            this.f.post(new Runnable(str, navigationInfo) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$F9vZXGRn2fRuRpHxFkA5MCyET2Y */
                public final /* synthetic */ String f$1;
                public final /* synthetic */ UCarCommon.NavigationInfo f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
                }
            });
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, UCarCommon.POIAddress pOIAddress) {
        this.d.post(new Runnable(str, pOIAddress) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$Zs3p_Z1rtojD2rlRDNkMzjGxu6g */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ UCarCommon.POIAddress f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, UCarCommon.PhoneStateInfo phoneStateInfo) {
        this.f.post(new Runnable(str, phoneStateInfo) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$qlq3fiyxBBN5rP3682yGBw9Yvao */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ UCarCommon.PhoneStateInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str, List<Integer> list, UCarCommon.AppListState appListState) {
        this.d.post(new Runnable(str, list, appListState) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$DbcWLkEjbZtYewI9jI_x7sJGF00 */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ List f$2;
            public final /* synthetic */ UCarCommon.AppListState f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2, (List) this.f$3);
            }
        });
    }

    private void b(String str, boolean z2) {
        a.a.a.b.e(X, "notifyDisconnected, deviceId: " + str + ", byUser: " + z2);
        this.f.post(new Runnable(str, z2) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$kxB69i5WJu5PemE21oVioYMtX8 */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ boolean f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(CountDownLatch countDownLatch) {
        this.p.e();
        countDownLatch.countDown();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void b(boolean z2) {
        this.n.a(z2);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean b(String str) {
        return a(str).getSelectedWorkMode() == UCarCommon.WorkMode.DATA_TRANSFER.toInt();
    }

    private void c() {
        this.r = new a.c.d.c.a(this.j, this.f222a.isSupportStereoRecord(), new a.c() {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$QTYd80by9BDOJdLjnpKoQsqU8 */

            @Override // a.c.d.c.a.c
            public final void onAudioFocusChanged(UCarCommon.AudioType audioType, int i) {
                UCarAdapter.this.a((UCarAdapter) audioType, (UCarCommon.AudioType) i);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void c(int i2) {
        Integer num = q0.get(Integer.valueOf(i2));
        if (num != null) {
            b(num.intValue());
        }
    }

    private void c(String str, int i2) {
        a.a.a.b.e(X, "notifyConnectFailed, deviceId: " + str + ", errorCode: " + i2);
        b(str, 3, i2);
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void c(boolean z2) {
        for (ICarConnectListener iCarConnectListener : this.k) {
            if (iCarConnectListener != null) {
                iCarConnectListener.onRethinkBluetoothConnect(z2);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean c(String str) {
        int selectedWorkMode = a(str).getSelectedWorkMode();
        return selectedWorkMode == UCarCommon.WorkMode.APP_FULLSCREEN_CAST.toInt() || selectedWorkMode == UCarCommon.WorkMode.APP_WINDOW_CAST.toInt();
    }

    private void d() {
        this.p = new a.c.d.e.b(this.r, new e());
    }

    private void d(String str, int i2) {
        this.d.post(new Runnable(str, i2) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$dOnLfhoPktfD2xcmVFMpiXRh_fQ */
            public final /* synthetic */ String f$1;
            public final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                UCarAdapter.this.b((UCarAdapter) this.f$1, (String) this.f$2);
            }
        });
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void d(boolean z2) {
        this.n.a(z2, this.f222a);
    }

    private boolean d(String str) {
        return a(str).getSelectedWorkMode() == UCarCommon.WorkMode.NORMAL_CAST.toInt();
    }

    public static void deletePhoneById(Context context, String str) {
        a.a.a.b.a(X, "deletePhoneById, deviceId: " + str);
        a.b.a.h.c.a(context, str);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void e(String str) {
        a.a.a.b.c(X, "startUCarChannel, peerAddress: " + str);
        this.I = str;
        if (this.q == null) {
            a.c.d.g.a aVar = new a.c.d.g.a();
            this.q = aVar;
            aVar.a(new d());
        }
        a.c.d.g.a aVar2 = this.q;
        if (aVar2 != null) {
            aVar2.e(a(this.c).getProtocolVersion());
            this.q.a(str);
        }
        a.c.d.h.d dVar = this.t;
        if (dVar != null) {
            dVar.a(str);
            h(true);
        }
        a.c.d.h.b bVar = this.u;
        if (bVar != null) {
            bVar.a(str);
        }
        a.c.d.c.a aVar3 = this.r;
        if (aVar3 != null) {
            aVar3.a(str);
            f(true);
        }
    }

    private boolean e() {
        if (this.n == null) {
            this.n = new UCarConnectProxy(this.j, this.f222a);
        }
        f fVar = new f();
        this.o = fVar;
        this.n.a(fVar);
        return this.n.a(this.B, this.A, this.f222a.getBleRSSIThreshold());
    }

    public static boolean existedCarBluetoothMac(String str, Context context) {
        return a.b.a.f.f.a(str, context);
    }

    private void f() {
        a.c.d.b bVar = new a.c.d.b();
        this.J = bVar;
        bVar.a(new c());
    }

    private void f(boolean z2) {
        this.b.lock();
        this.E = z2;
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void g(boolean z2) {
        a.a.a.b.a(X, "setConnectState, state: " + z2);
        this.b.lock();
        this.i = z2;
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean g() {
        return this.i;
    }

    public static UCarAdapter getInstance() {
        if (r0 == null) {
            synchronized (UCarAdapter.class) {
                if (r0 == null) {
                    r0 = new UCarAdapter();
                }
            }
        }
        return r0;
    }

    private void h(boolean z2) {
        this.b.lock();
        this.G = z2;
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean h() {
        return this.D == 100;
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void i() {
        UCarConnectProxy uCarConnectProxy = this.n;
        if (uCarConnectProxy != null) {
            uCarConnectProxy.c();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void i(boolean z2) {
        this.b.lock();
        this.F = z2;
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void j() {
        this.J.c();
        this.J.g();
    }

    private boolean j(boolean z2) {
        Handler handler;
        if (this.n == null || (handler = this.f) == null) {
            return false;
        }
        return handler.post(new Runnable(z2) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$gabKWUgapluCopjQi0cclowyc4 */
            public final /* synthetic */ boolean f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                UCarAdapter.this.d((UCarAdapter) this.f$1);
            }
        });
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void k() {
        if (this.n != null) {
            a.a.a.b.c(X, "send heart beat error, try disconnect link");
            this.n.c();
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void l() {
        a.a.a.b.b(X, "onSendHeartBeatError");
        Handler handler = this.f;
        if (handler != null) {
            handler.post(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$xStQQmNRmoIuF9COgTNn6_cfdko */

                public final void run() {
                    UCarAdapter.this.k();
                }
            });
        }
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void m() {
        this.q.h();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void n() {
        this.n.i();
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void o() {
        this.J.c();
        this.J.b();
    }

    private void p() {
        a.a.a.b.a(X, "Test : start send touch event.");
        if (this.M == null) {
            this.M = new a.c.d.k.a(this.w, this.x);
        }
        this.M.start();
    }

    private void q() {
        a.a.a.b.a(X, "start UCarAdapter api Test");
        if (this.N == null) {
            this.N = new a.c.d.k.c(this.j);
        }
        if (!this.N.isAlive()) {
            this.N.start();
        }
    }

    private boolean r() {
        this.b.lock();
        try {
            if (this.d == null) {
                this.d = new Handler(Looper.getMainLooper());
            }
            if (this.e == null) {
                a.a.a.b.a(X, "start worker thread");
                HandlerThread handlerThread = new HandlerThread("WorkerThread");
                this.e = handlerThread;
                handlerThread.start();
                Looper looper = this.e.getLooper();
                if (looper != null) {
                    this.f = new Handler(looper);
                } else {
                    a.a.a.b.b(X, "failed to get valid worker thread looper!");
                    this.f = null;
                    this.b.unlock();
                    return false;
                }
            }
            if (this.K == null) {
                a.a.a.b.a(X, "start timer thread");
                HandlerThread handlerThread2 = new HandlerThread("UCarAdapterTimerThread");
                this.K = handlerThread2;
                handlerThread2.start();
                Looper looper2 = this.K.getLooper();
                if (looper2 != null) {
                    this.L = new Handler(looper2);
                } else {
                    a.a.a.b.b(X, "failed to get valid timer thread looper!");
                    this.L = null;
                    this.b.unlock();
                    return false;
                }
            }
        } catch (Exception e2) {
            a.a.a.b.b(X, "failed to start HandlerThread: " + e2.getMessage());
        } catch (Throwable th) {
            this.b.unlock();
            throw th;
        }
        this.b.unlock();
        return true;
    }

    /* JADX INFO: finally extract failed */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x00af  */
    /* JADX WARNING: Removed duplicated region for block: B:50:? A[RETURN, SYNTHETIC] */
    private void s() {
        boolean z2;
        a.a.a.b.c(X, "stopMiracastAndUCarChannel");
        this.L.post(new Runnable() {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$rQveHayzSqb6xLc2KCd2EqjfoAM */

            public final void run() {
                UCarAdapter.this.o();
            }
        });
        this.b.lock();
        try {
            a.c.d.c.a aVar = this.r;
            if (aVar != null && this.E) {
                this.E = false;
                aVar.e();
            }
            if (this.v != null && this.H.get()) {
                this.H.set(false);
                this.v.b();
            }
            a.c.d.h.d dVar = this.t;
            if (dVar != null && this.G) {
                this.G = false;
                dVar.b();
            }
            a.c.d.g.a aVar2 = this.q;
            if (aVar2 != null) {
                this.U = null;
                aVar2.i();
            }
            a.c.d.h.b bVar = this.u;
            if (bVar != null) {
                bVar.a();
            }
            z2 = true;
            CountDownLatch countDownLatch = new CountDownLatch(1);
            if (this.p != null && this.F) {
                this.F = false;
                new Thread(new Runnable(countDownLatch) {
                    /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$bXe4iUJ0TAEpviloLq3IdhJHL5w */
                    public final /* synthetic */ CountDownLatch f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        UCarAdapter.this.b((UCarAdapter) this.f$1);
                    }
                }).start();
                try {
                    if (countDownLatch.await(500, TimeUnit.MILLISECONDS)) {
                        a.a.a.b.a(X, "stop sink tasks have been done.");
                    } else {
                        a.a.a.b.b(X, "stop sink not be fully executed, we need exit process.");
                        this.b.unlock();
                        a.a.a.b.a(X, "stopMiracastAndUCarChannel done~");
                        if (!z2) {
                            a.a.a.b.b(X, "exit process while stop the sink failed");
                            System.exit(0);
                            return;
                        }
                        return;
                    }
                } catch (InterruptedException e2) {
                    a.a.a.b.b(X, "catch InterruptedException", e2);
                }
            }
            z2 = false;
            this.b.unlock();
        } catch (Exception e3) {
            a.a.a.b.b(X, "stopMiracastAndUCarChannel Exception", e3);
            this.b.unlock();
            z2 = false;
        } catch (Throwable th) {
            this.b.unlock();
            throw th;
        }
        a.a.a.b.a(X, "stopMiracastAndUCarChannel done~");
        if (!z2) {
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void t() {
        this.b.lock();
        if (!b(this.c) ? this.D >= 90 : this.D >= 80) {
            c(12);
            b(this.c, 2, -1);
            a.c.d.d.b bVar = this.v;
            if (bVar != null) {
                bVar.a(2);
            }
            this.J.b();
            String b2 = a.b.a.f.f.b(this.c, this.j);
            if (b2 != null) {
                this.U = b2;
                e(true);
            }
            if (a.c.d.k.b.a()) {
                p();
            }
            if (a.c.d.k.b.b()) {
                q();
            }
        }
        this.b.unlock();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void u() {
        int connectType = getConnectType(this.c);
        a.b bVar = new a.b();
        bVar.a(UCarCommon.AudioType.STREAM_CAST_MUSIC);
        if (connectType == 2) {
            bVar.a(100);
            bVar.b(10);
        } else {
            bVar.a(a.b.e);
            bVar.b(100);
        }
        this.r.a(bVar);
        a.c.d.e.b bVar2 = this.p;
        if (bVar2 != null) {
            bVar2.a(a.c.d.l.a.a(this.j) + bVar.b());
        }
    }

    public boolean abandonAudioFocus() {
        a.a.a.b.a(X, "abandonAudioFocus");
        return this.r.a();
    }

    public void addCamera(UCarCommon.CameraInfo cameraInfo) {
        a.c.d.g.a aVar = this.q;
        if (aVar != null && this.v != null) {
            aVar.a(a.c.d.d.b.a(cameraInfo));
        }
    }

    public void allowGainAudioFocus() {
        a.a.a.b.a(X, "allowGainAudioFocus");
        this.r.b();
    }

    public boolean awakenVoiceAssistant(byte[] bArr, UCarCommon.AudioFormat audioFormat, String str) {
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.a(bArr, audioFormat, str);
        }
        return false;
    }

    public boolean changeAppRotation(String str, int i2) {
        a.c.d.g.a aVar;
        a.a.a.b.a(X, "changeAppRotation, deviceId: " + str + ", appId: " + i2);
        int i3 = 0;
        if (d(str) || (aVar = this.q) == null) {
            return false;
        }
        if (this.P == 0) {
            i3 = 1;
        }
        return aVar.a(i2, i3);
    }

    public void deInit() {
        a.a.a.b.a(X, "deInit");
        if (this.f == null) {
            a.a.a.b.b(X, "stop cast must be called after successful initialization");
            return;
        }
        CountDownLatch countDownLatch = new CountDownLatch(1);
        if (this.f.post(new Runnable(countDownLatch) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$20Pf3NITO3IkBmWpdfSUBzVzQ7I */
            public final /* synthetic */ CountDownLatch f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                UCarAdapter.this.a((UCarAdapter) this.f$1);
            }
        })) {
            try {
                a.a.a.b.a(X, countDownLatch.await(500, TimeUnit.MILLISECONDS) ? "deInit tasks have been done." : "deInit may not be fully executed.");
            } catch (InterruptedException e2) {
                a.a.a.b.b(X, "catch InterruptedException", e2);
            }
        } else {
            a.a.a.b.e(X, "add deInit tasks failed.");
        }
        a();
    }

    public boolean disconnect() {
        boolean z2;
        if (this.q != null) {
            this.h = true;
            z2 = this.q.g();
        } else {
            z2 = false;
        }
        if (z2) {
            this.f.postDelayed(new Runnable() {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$cyjXva6Z8Iv4P0X6N4nK5lzgfI */

                public final void run() {
                    UCarAdapter.this.i();
                }
            }, 200);
        }
        a.a.a.b.a(X, "disconnect, result = " + z2);
        return z2;
    }

    public void e(boolean z2) {
        this.f.post(new Runnable(z2) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$Ai5yDDwlzfP9BKbICextGq_rzlQ */
            public final /* synthetic */ boolean f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                UCarAdapter.this.c((UCarAdapter) this.f$1);
            }
        });
    }

    public void enableUsbDeviceDetection(boolean z2) {
        Handler handler;
        if (this.n != null && (handler = this.f) != null) {
            handler.post(new Runnable(z2) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$t2YknOzbN0KK6yhGRytTwOqyek */
                public final /* synthetic */ boolean f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    UCarAdapter.this.b((UCarAdapter) this.f$1);
                }
            });
        }
    }

    public ArrayList<UCarCommon.AppDetailInfo> getAppDetailInfo(String str, List<Integer> list) {
        a.a.a.b.a(X, new b.a(str, list) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$hATDGQgVC1hIRZxj1O2M3EgU8bc */
            public final /* synthetic */ String f$0;
            public final /* synthetic */ List f$1;

            {
                this.f$0 = r1;
                this.f$1 = r2;
            }

            @Override // a.a.a.b.a
            public final String a() {
                return UCarAdapter.a(this.f$0, this.f$1);
            }
        });
        if (list.size() > 20) {
            a.a.a.b.b(X, "app id list can not be larger than 20");
            return null;
        } else if (d(str)) {
            ArrayList<UCarCommon.AppDetailInfo> arrayList = new ArrayList<>(1);
            arrayList.add(new UCarCommon.AppDetailInfo(new UCarCommon.AppGeneralInfo(0, a(str).getProductName(), UCarCommon.AppCategory.MEDIA), "", a.c.d.l.b.a(this.j, R.drawable.ucar)));
            return arrayList;
        } else {
            a.c.d.g.a aVar = this.q;
            if (aVar == null) {
                return null;
            }
            ArrayList<UCarCommon.AppDetailInfo> a2 = aVar.a(list);
            a.a.a.b.a(X, new b.a(a2) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$8KmwQ59wpdNOt9jrRb1CfU3AenE */
                public final /* synthetic */ ArrayList f$0;

                {
                    this.f$0 = r1;
                }

                @Override // a.a.a.b.a
                public final String a() {
                    return UCarAdapter.a(this.f$0);
                }
            });
            return a2;
        }
    }

    public ArrayList<UCarCommon.AppGeneralInfo> getAppList(String str) {
        a.a.a.b.a(X, "getAppList, deviceId: " + str);
        if (d(str)) {
            ArrayList<UCarCommon.AppGeneralInfo> arrayList = new ArrayList<>();
            arrayList.add(new UCarCommon.AppGeneralInfo(0, a(str).getProductName(), UCarCommon.AppCategory.MEDIA));
            return arrayList;
        }
        a.c.d.g.a aVar = this.q;
        if (aVar == null) {
            return null;
        }
        ArrayList<UCarCommon.AppGeneralInfo> b2 = aVar.b();
        a.a.a.b.a(X, new b.a(b2) {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$13aHrviAGdwOLL5b4raMzVEN0zI */
            public final /* synthetic */ ArrayList f$0;

            {
                this.f$0 = r1;
            }

            @Override // a.a.a.b.a
            public final String a() {
                return UCarAdapter.b(this.f$0);
            }
        });
        return b2;
    }

    public int getConnectType(String str) {
        MDevice a2;
        UCarConnectProxy uCarConnectProxy = this.n;
        if (uCarConnectProxy == null || (a2 = uCarConnectProxy.a(str)) == null) {
            return 1;
        }
        return a2.getConnectType();
    }

    public UCarCommon.MobileDevice getMobileDevice(String str) {
        UCarConnectProxy uCarConnectProxy = this.n;
        if (uCarConnectProxy == null) {
            return null;
        }
        return uCarConnectProxy.a(str).toDeviceInfo();
    }

    public boolean init(Context context, UCarConfig uCarConfig, ICarInitCallback iCarInitCallback) {
        if (r()) {
            return this.f.post(new Runnable(iCarInitCallback, uCarConfig, context) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$OznLnMAqrv23WBp9q_JFjNMAz8 */
                public final /* synthetic */ ICarInitCallback f$1;
                public final /* synthetic */ UCarConfig f$2;
                public final /* synthetic */ Context f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    UCarAdapter.this.a((UCarAdapter) this.f$1, (ICarInitCallback) this.f$2, (UCarConfig) this.f$3);
                }
            });
        }
        iCarInitCallback.onInitFailed(UCarConnectState.ErrorCode.ERROR_INIT_FAILED);
        return false;
    }

    public boolean isConnectedMDevice(String str) {
        String str2 = this.U;
        return str2 != null && str2.equals(i.a(str));
    }

    public void notifyCameraStateChanged(String str, UCarCommon.CameraState cameraState) {
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            aVar.a(str, cameraState);
        }
    }

    public boolean notifyHungUpCall() {
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.e();
        }
        return false;
    }

    public boolean notifyPickUpCall() {
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.f();
        }
        return false;
    }

    public boolean notifySwitchDayOrNight(UCarCommon.DayNightMode dayNightMode) {
        a.a.a.b.a(X, "notifySwitchDayOrNight: " + dayNightMode);
        UCarConnectProxy uCarConnectProxy = this.n;
        if (uCarConnectProxy != null) {
            uCarConnectProxy.e(dayNightMode.getValue());
        }
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.a(dayNightMode);
        }
        return false;
    }

    public boolean pauseApp(String str, int i2) {
        a.a.a.b.a(X, "pauseApp, deviceId: " + str + ", appId: " + i2);
        if (d(str)) {
            return true;
        }
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.a(i2, UCarProto.AppInvokeCategory.PAUSE);
        }
        return false;
    }

    public boolean pauseCast() {
        a.a.a.b.a(X, "pauseCast");
        if (this.f == null || !this.g) {
            a.a.a.b.b(X, "start cast must be called after successful initialization");
            return false;
        }
        this.L.removeCallbacks(this.W);
        this.p.b();
        return this.f.post(new Runnable() {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$FzIwSTGCBBA9arnDqjRXWVMtdLU */

            public final void run() {
                UCarAdapter.this.m();
            }
        });
    }

    public void registerCameraInfoListener(ICameraInfoListener iCameraInfoListener) {
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.a(iCameraInfoListener);
        }
    }

    public void registerCarConnectListener(ICarConnectListener iCarConnectListener) {
        if (!this.k.contains(iCarConnectListener)) {
            this.k.add(iCarConnectListener);
        }
    }

    public void registerPhoneDataListener(IPhoneDataListener iPhoneDataListener) {
        if (!this.l.contains(iPhoneDataListener)) {
            this.l.add(iPhoneDataListener);
        }
    }

    public void removeCamera(String[] strArr) {
        a.c.d.g.a aVar = this.q;
        if (aVar != null && this.v != null) {
            aVar.a(a.c.d.d.b.a(strArr));
        }
    }

    public boolean resumeApp(String str, int i2) {
        a.a.a.b.a(X, "resumeApp, deviceId: " + str + ", appId: " + i2);
        if (d(str)) {
            return true;
        }
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.a(i2, UCarProto.AppInvokeCategory.RESUME);
        }
        return false;
    }

    public boolean sendAccelerationInfo(UCarCommon.AccelerationInfo accelerationInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendAccelerationInfo");
        return this.t.a(accelerationInfo);
    }

    public boolean sendBatteryInfo(UCarCommon.BatteryInfo batteryInfo) {
        return false;
    }

    public void sendCameraData(UCarCommon.VideoType videoType, ByteBuffer byteBuffer, short s2) {
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.a(videoType, byteBuffer, s2);
        }
    }

    public boolean sendGPSInfo(UCarCommon.GPSInfo gPSInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendGPSInfo");
        return this.t.a(gPSInfo);
    }

    public boolean sendGearStateInfo(UCarCommon.GearStateInfo gearStateInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendGearStateInfo");
        return this.t.a(gearStateInfo);
    }

    public boolean sendGyroscopeInfo(UCarCommon.GyroscopeInfo gyroscopeInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendGyroscopeInfo");
        return this.t.a(gyroscopeInfo);
    }

    public boolean sendKeyEvent(UCarCommon.KeyEventActionType keyEventActionType, UCarCommon.KeyCodeType keyCodeType, int i2) {
        if (keyCodeType == null || this.q == null) {
            return false;
        }
        a.a.a.b.c(X, "sendKeyEvent, action: " + keyEventActionType + ", keycode: " + keyCodeType + ", metaState: " + i2);
        return this.q.a(keyEventActionType, keyCodeType, i2);
    }

    public boolean sendLightSensorInfo(UCarCommon.LightSensorInfo lightSensorInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendLightSensorInfo");
        return this.t.a(lightSensorInfo);
    }

    public boolean sendLightsInfo(UCarCommon.LightsInfo lightsInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendLightsInfo");
        return this.t.a(lightsInfo);
    }

    public boolean sendMicRecordData(int i2, short[] sArr, long j2) {
        a.c.d.c.a aVar = this.r;
        if (aVar != null) {
            return aVar.a(i2, sArr, j2);
        }
        return false;
    }

    public boolean sendOilInfo(UCarCommon.OilInfo oilInfo) {
        if (this.t == null) {
            return false;
        }
        a.a.a.b.c(X, "sendOilInfo");
        return this.t.a(oilInfo);
    }

    public boolean sendTouchEvent(int i2, int i3, int[] iArr, int[] iArr2, int[] iArr3) {
        a.c.d.g.b bVar = this.s;
        if (bVar != null) {
            return bVar.a(i2, i3, iArr, iArr2, iArr3);
        }
        return false;
    }

    public boolean sendVRCMD(UCarCommon.VRCmdType vRCmdType, String str) {
        if (this.q == null) {
            return false;
        }
        a.a.a.b.c(X, "sendVRCMD, type: " + vRCmdType + ", source: " + str);
        return this.q.a(vRCmdType, str);
    }

    public boolean startAdvertise() {
        this.b.lock();
        boolean z2 = true;
        if (!this.h) {
            this.h = true;
        } else {
            z2 = false;
        }
        this.b.unlock();
        return j(z2);
    }

    public boolean startApp(String str, int i2) {
        return startApp(str, i2, true);
    }

    public boolean startApp(String str, int i2, boolean z2) {
        a.a.a.b.a(X, "startApp, deviceId: " + str + ", appId: " + i2 + ", isUseDefaultOrientation: " + z2);
        if (d(str)) {
            this.f.post(new Runnable(i2, z2) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$CddvExCdf3XY5uNgdQQHEcBepSg */
                public final /* synthetic */ int f$1;
                public final /* synthetic */ boolean f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    UCarAdapter.this.a((UCarAdapter) this.f$1, (int) this.f$2);
                }
            });
            return true;
        } else if (this.q == null) {
            return false;
        } else {
            this.L.removeCallbacks(this.W);
            this.L.postDelayed(this.W, 3000);
            return this.q.a(false) && this.q.a(i2, UCarProto.AppInvokeCategory.START, !z2 ? 1 : 0);
        }
    }

    public boolean startCast(Surface surface, int i2, int i3) {
        return startCast(surface, i2, i3, null);
    }

    public boolean startCast(Surface surface, int i2, int i3, a.c.d.a aVar) {
        a.a.a.b.a(X, "startCast, width: " + i2 + ", height: " + i3);
        Handler handler = this.f;
        if (handler != null && this.g) {
            return handler.post(new Runnable(i2, i3, surface, aVar) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$A48_U7e3_V_pl3DMguLh00ITIHM */
                public final /* synthetic */ int f$1;
                public final /* synthetic */ int f$2;
                public final /* synthetic */ Surface f$3;
                public final /* synthetic */ a.c.d.a f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    UCarAdapter.this.a((UCarAdapter) this.f$1, this.f$2, (int) this.f$3, (Surface) this.f$4);
                }
            });
        }
        a.a.a.b.b(X, "start cast must be called after successful initialization");
        return false;
    }

    public boolean stopAdvertise() {
        Handler handler;
        if (this.n == null || (handler = this.f) == null) {
            return false;
        }
        return handler.post(new Runnable() {
            /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$ZWySvOCET5mQ2iOEzc3S_d2d8g */

            public final void run() {
                UCarAdapter.this.n();
            }
        });
    }

    public boolean stopApp(String str, int i2) {
        a.a.a.b.a(X, "stopApp, deviceId: " + str + ", appId: " + i2);
        if (d(str)) {
            this.f.post(new Runnable(i2) {
                /* class com.ucar.vehiclesdk.$$Lambda$UCarAdapter$8pwcoQM9r9Bawns4UwSSxEHatTo */
                public final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    UCarAdapter.this.a((UCarAdapter) this.f$1);
                }
            });
            return true;
        }
        a.c.d.g.a aVar = this.q;
        if (aVar != null) {
            return aVar.a(i2, UCarProto.AppInvokeCategory.STOP);
        }
        return false;
    }

    public void unregisterCameraInfoListener(ICameraInfoListener iCameraInfoListener) {
        a.c.d.d.b bVar = this.v;
        if (bVar != null) {
            bVar.b(iCameraInfoListener);
        }
    }

    public void unregisterCarConnectListener(ICarConnectListener iCarConnectListener) {
        this.k.remove(iCarConnectListener);
    }

    public void unregisterPhoneDataListener(IPhoneDataListener iPhoneDataListener) {
        this.l.remove(iPhoneDataListener);
    }
}
