DIYP影音.apk(点击下载) / m.java


package c.c.a.a.k0;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.DeniedByServerException;
import android.media.MediaCrypto;
import android.media.NotProvisionedException;
import android.media.UnsupportedSchemeException;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import c.c.a.a.k0.a;
import c.c.a.a.k0.c;
import c.c.a.a.k0.d;
import c.c.a.a.r0.t;
import c.e.e.f.h.b.c.a;
import java.util.HashMap;
import java.util.UUID;

@TargetApi(18)
public class m<T extends c> implements b<T> {
    public static final UUID r = new UUID(-1301668207276963122L, -6645017420763422227L);
    public final Handler a;

    /* renamed from: b  reason: collision with root package name */
    public final b f1174b;

    /* renamed from: c  reason: collision with root package name */
    public final d<T> f1175c;

    /* renamed from: d  reason: collision with root package name */
    public final HashMap<String, String> f1176d;
    public final m<T>.d e;
    public final k f;
    public final m<T>.f g;
    public final UUID h;
    public HandlerThread i;
    public Handler j;
    public int k;
    public boolean l;
    public int m = 1;
    public T n;
    public Exception o;
    public a.b p;
    public byte[] q;

    public class a implements Runnable {

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ Exception f1177b;

        public a(Exception exc) {
            this.f1177b = exc;
        }

        public void run() {
            b bVar = m.this.f1174b;
            Exception exc = this.f1177b;
            a.b bVar2 = ((c.e.e.f.h.b.c.a) bVar).j;
            if (bVar2 != null) {
                ((c.e.e.f.h.b.a) bVar2).a("drmSessionManagerError", exc);
            }
        }
    }

    public interface b {
    }

    public class c implements d.b<T> {
        public /* synthetic */ c(l lVar) {
        }
    }

    @SuppressLint({"HandlerLeak"})
    public class d extends Handler {
        public d(Looper looper) {
            super(looper);
        }

        public void handleMessage(Message message) {
            m mVar = m.this;
            if (mVar.k != 0) {
                int i = mVar.m;
                if (i == 3 || i == 4) {
                    int i2 = message.what;
                    if (i2 == 1) {
                        m mVar2 = m.this;
                        mVar2.m = 3;
                        mVar2.c();
                    } else if (i2 == 2) {
                        m.this.b();
                    } else if (i2 == 3) {
                        m mVar3 = m.this;
                        mVar3.m = 3;
                        mVar3.a(new j());
                    }
                }
            }
        }
    }

    @SuppressLint({"HandlerLeak"})
    public class e extends Handler {
        public e(Looper looper) {
            super(looper);
        }

        public void handleMessage(Message message) {
            Object e;
            try {
                int i = message.what;
                if (i == 0) {
                    k kVar = m.this.f;
                    UUID uuid = m.this.h;
                    d.c cVar = (d.c) message.obj;
                    if (((c.e.e.f.h.b.b) kVar) != null) {
                        e = t.a(cVar.a() + "&signedRequest=" + new String(cVar.b()), (byte[]) null, c.e.e.f.h.b.b.a);
                    } else {
                        throw null;
                    }
                } else if (i == 1) {
                    k kVar2 = m.this.f;
                    UUID uuid2 = m.this.h;
                    d.a aVar = (d.a) message.obj;
                    if (((c.e.e.f.h.b.b) kVar2) != null) {
                        String a2 = aVar.a();
                        if (TextUtils.isEmpty(a2)) {
                            a2 = "http://playready.directtaps.net/pr/svc/rightsmanager.asmx";
                        }
                        e = t.a(a2, aVar.b(), c.e.e.f.h.b.b.f1925b);
                    } else {
                        throw null;
                    }
                } else {
                    throw new RuntimeException();
                }
            } catch (Exception e2) {
                e = e2;
            }
            m.this.g.obtainMessage(message.what, e).sendToTarget();
        }
    }

    @SuppressLint({"HandlerLeak"})
    public class f extends Handler {
        public f(Looper looper) {
            super(looper);
        }

        public void handleMessage(Message message) {
            Exception e;
            Exception e2;
            int i = message.what;
            if (i == 0) {
                m mVar = m.this;
                Object obj = message.obj;
                mVar.l = false;
                int i2 = mVar.m;
                if (i2 == 2 || i2 == 3 || i2 == 4) {
                    if (obj instanceof Exception) {
                        e = (Exception) obj;
                    } else {
                        try {
                            ((i) mVar.f1175c).a.provideProvisionResponse((byte[]) obj);
                            if (mVar.m == 2) {
                                mVar.a(false);
                                return;
                            } else {
                                mVar.b();
                                return;
                            }
                        } catch (DeniedByServerException e3) {
                            e = e3;
                        }
                    }
                    mVar.a(e);
                }
            } else if (i == 1) {
                m mVar2 = m.this;
                Object obj2 = message.obj;
                int i3 = mVar2.m;
                if (i3 == 3 || i3 == 4) {
                    if (obj2 instanceof Exception) {
                        e2 = (Exception) obj2;
                    } else {
                        try {
                            ((i) mVar2.f1175c).a.provideKeyResponse(mVar2.q, (byte[]) obj2);
                            mVar2.m = 4;
                            if (mVar2.a != null && mVar2.f1174b != null) {
                                mVar2.a.post(new l(mVar2));
                                return;
                            }
                            return;
                        } catch (Exception e4) {
                            e2 = e4;
                        }
                    }
                    mVar2.b(e2);
                }
            }
        }
    }

    static {
        new UUID(-7348484286925749626L, -6083546864340672619L);
    }

    public m(UUID uuid, Looper looper, k kVar, HashMap<String, String> hashMap, Handler handler, b bVar, d<T> dVar) {
        this.h = uuid;
        this.f = kVar;
        this.f1176d = hashMap;
        this.a = handler;
        this.f1174b = bVar;
        this.f1175c = dVar;
        i iVar = (i) dVar;
        iVar.a.setOnEventListener(new f(iVar, new c(null)));
        this.e = new d(looper);
        this.g = new f(looper);
    }

    public static m<e> a(UUID uuid, Looper looper, k kVar, HashMap<String, String> hashMap, Handler handler, b bVar) {
        try {
            return new m<>(uuid, looper, kVar, hashMap, handler, bVar, new i(uuid));
        } catch (UnsupportedSchemeException e2) {
            throw new n(1, e2);
        } catch (Exception e3) {
            throw new n(2, e3);
        }
    }

    public void a() {
        int i2 = this.k - 1;
        this.k = i2;
        if (i2 == 0) {
            this.m = 1;
            this.l = false;
            this.e.removeCallbacksAndMessages(null);
            this.g.removeCallbacksAndMessages(null);
            this.j.removeCallbacksAndMessages(null);
            this.j = null;
            this.i.quit();
            this.i = null;
            this.p = null;
            this.n = null;
            this.o = null;
            byte[] bArr = this.q;
            if (bArr != null) {
                ((i) this.f1175c).a.closeSession(bArr);
                this.q = null;
            }
        }
    }

    public final void a(Exception exc) {
        this.o = exc;
        Handler handler = this.a;
        if (!(handler == null || this.f1174b == null)) {
            handler.post(new a(exc));
        }
        if (this.m != 4) {
            this.m = 0;
        }
    }

    public final void a(boolean z) {
        try {
            byte[] openSession = ((i) this.f1175c).a.openSession();
            this.q = openSession;
            d<T> dVar = this.f1175c;
            UUID uuid = this.h;
            if (((i) dVar) != null) {
                this.n = new e(new MediaCrypto(uuid, openSession));
                this.m = 3;
                b();
                return;
            }
            throw null;
        } catch (NotProvisionedException e2) {
            if (z) {
                c();
            } else {
                a(e2);
            }
        } catch (Exception e3) {
            a(e3);
        }
    }

    public final void b() {
        try {
            d<T> dVar = this.f1175c;
            i iVar = (i) dVar;
            this.j.obtainMessage(1, new g(iVar, iVar.a.getKeyRequest(this.q, this.p.f1171b, this.p.a, 1, this.f1176d))).sendToTarget();
        } catch (NotProvisionedException e2) {
            b(e2);
        }
    }

    public final void b(Exception exc) {
        if (exc instanceof NotProvisionedException) {
            c();
        } else {
            a(exc);
        }
    }

    public final void c() {
        if (!this.l) {
            this.l = true;
            i iVar = (i) this.f1175c;
            this.j.obtainMessage(0, new h(iVar, iVar.a.getProvisionRequest())).sendToTarget();
        }
    }
}