package com.tencent.mm.media.widget.a;

import a.f.b.j;
import a.l;
import android.content.Context;
import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.e.d.a.a;
import com.tencent.mm.sdk.g.d;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;

@l(dWo = {1, 1, 13}, dWp = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J&\u0010\u000b\u001a\u0004\u0018\u00010\n2\b\u0010\f\u001a\u0004\u0018\u00010\r2\u0006\u0010\u000e\u001a\u00020\u000f2\n\b\u0002\u0010\u0010\u001a\u0004\u0018\u00010\u0011R\u000e\u0010\u0003\u001a\u00020\u0004XD¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\nX\u000e¢\u0006\u0002\n\u0000¨\u0006\u0012"}, dWq = {"Lcom/tencent/mm/media/widget/camera/OpenCameraThread;", "", "()V", "TAG", "", "isTimeouted", "", "lock", "Ljava/lang/Object;", "res", "Lcom/tencent/mm/compatible/deviceinfo/CameraUtil$IImpl$OpenCameraRes;", "openCamera", "context", "Landroid/content/Context;", "nowCameraId", "", "looper", "Landroid/os/Looper;", "plugin-mediaeditor_release"})
public final class f {
    final String TAG = "MicroMsg.SightCamera.OpenCameraThread";
    boolean fbr;
    a fbs;
    final Object lock = new Object();

    public f() {
        AppMethodBeat.i(13227);
        AppMethodBeat.o(13227);
    }

    public final a a(Context context, int i, Looper looper) {
        AppMethodBeat.i(13226);
        if (context == null) {
            AppMethodBeat.o(13226);
            return null;
        }
        long anU = bo.anU();
        Thread currentThread = Thread.currentThread();
        j.o(currentThread, "Thread.currentThread()");
        long id = currentThread.getId();
        synchronized (this.lock) {
            try {
                this.fbr = false;
                this.fbs = null;
                d.post((Runnable) new a(this, id, anU, context, i, looper), "SightCamera_openCamera");
                this.lock.wait(30000);
            } catch (InterruptedException e) {
                ab.e(this.TAG, "Lock wait failed e:%s", new Object[]{e.getMessage()});
            } catch (Throwable th) {
                AppMethodBeat.o(13226);
            }
            if (this.fbs != null) {
                a aVar = this.fbs;
                if (aVar == null) {
                    j.dWJ();
                }
                if (aVar.erH != null) {
                    String str = this.TAG;
                    String str2 = "Open Camera Succ thread:%d Time:%d camera:%s";
                    Object[] objArr = new Object[3];
                    objArr[0] = Long.valueOf(id);
                    objArr[1] = Long.valueOf(bo.anU() - anU);
                    a aVar2 = this.fbs;
                    if (aVar2 == null) {
                        j.dWJ();
                    }
                    objArr[2] = aVar2.erH;
                    ab.i(str, str2, objArr);
                    aVar = this.fbs;
                    AppMethodBeat.o(13226);
                    return aVar;
                }
            }
            this.fbr = true;
            ab.e(this.TAG, "Open Camera Timeout:%d", new Object[]{Long.valueOf(bo.anU() - anU)});
            AppMethodBeat.o(13226);
            return null;
        }
    }
}
