QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 h.java 源代码,内容仅作参考


package com.tencent.luggage.wxa.ki;

import MTT.WelfareBusiness;
import android.text.TextUtils;
import com.tencent.luggage.wxa.ki.b;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class h {

    static final boolean f20715a = !h.class.desiredAssertionStatus();

    private static final String f20716b = h.class.getSimpleName();

    private rx.subscriptions.b f20717c;

    private ReentrantReadWriteLock f20718d;
    private Lock e;
    private boolean f;
    private int g;
    private e h;
    private Pattern i;
    private Set<String> j;

    class AnonymousClass1 implements rx.a.c<com.tencent.luggage.wxa.kk.e> {

        final com.tencent.luggage.wxa.kj.a f20719a;

        @Override
        public void call(com.tencent.luggage.wxa.kk.e eVar) {
            if (this.f20719a != null) {
                if (eVar.f20744a == 200) {
                    this.f20719a.a(eVar);
                } else {
                    this.f20719a.b(eVar);
                }
            }
        }
    }

    public static class a {

        private static h f20730a = new h(null);
    }

    private h() {
        this.f20717c = new rx.subscriptions.b();
        this.f20718d = new ReentrantReadWriteLock(true);
        this.e = this.f20718d.writeLock();
        this.f = false;
        this.g = -1;
        this.j = new HashSet();
        this.i = Pattern.compile("uuid:([a-fA-F\\d]{8}(-[a-fA-F\\d]{4}){3}-[a-fA-F\\d]{12})");
    }

    h(AnonymousClass1 anonymousClass1) {
        this();
    }

    public static h a() {
        return a.f20730a;
    }

    public String a(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        Matcher matcher = this.i.matcher(str);
        String group = matcher.find() ? matcher.group(1) : null;
        if (group != null) {
            return group;
        }
        if (f20715a || str != null) {
            return b(str);
        }
        throw new AssertionError();
    }

    private void a(Lock lock) throws com.tencent.luggage.wxa.kl.a {
        a(lock, e());
    }

    private void a(Lock lock, int i) throws com.tencent.luggage.wxa.kl.a {
        try {
            if (lock.tryLock(i, TimeUnit.MILLISECONDS)) {
                return;
            }
            throw new com.tencent.luggage.wxa.kl.a("Router wasn't available exclusively after waiting " + i + "ms, lock failed: " + lock.getClass().getSimpleName());
        } catch (InterruptedException e) {
            throw new com.tencent.luggage.wxa.kl.a("Interruption while waiting for exclusive access: " + lock.getClass().getSimpleName(), e);
        }
    }

    private String b(String str) {
        com.tencent.luggage.wxa.kf.a.b(f20716b, "fallbackGetUuid: " + str);
        return str.startsWith("uuid:") ? str.substring(5) : str;
    }

    private void b(Lock lock) {
        lock.unlock();
    }

    private boolean b(com.tencent.luggage.wxa.kk.b bVar) {
        String a2 = bVar.a("NT");
        String a3 = bVar.a("ST");
        String a4 = bVar.a("NTS");
        String a5 = bVar.a("USN");
        String a6 = bVar.a("LOCATION");
        if (!"upnp:rootdevice".equals(a2) && !"upnp:rootdevice".equals(a3)) {
            return false;
        }
        if (this.j.size() > 0 && this.j.contains(a6)) {
            return false;
        }
        String a7 = a(a5);
        if (TextUtils.isEmpty(a7)) {
            return false;
        }
        com.tencent.luggage.wxa.kh.a a8 = com.tencent.luggage.wxa.kh.a.a();
        if (!"ssdp:alive".equals(a4)) {
            if ("ssdp:byebye".equals(a4)) {
                if (a8.a(a7)) {
                    a8.b(a7);
                }
                return false;
            }
            if (!TextUtils.isEmpty(a6)) {
                return !a8.a(a7);
            }
            com.tencent.luggage.wxa.kf.a.b(f20716b, "mDevice location is empty");
            return false;
        }
        com.tencent.luggage.wxa.kh.c c2 = a8.c(a7);
        if (c2 != null) {
            if (c2.a().f20641a.equals(a6)) {
                return false;
            }
            a8.b(a7);
        } else if (TextUtils.isEmpty(a6)) {
            return false;
        }
        this.j.add(a6);
        return true;
    }

    private int e() {
        return 6000;
    }

    public void a(com.tencent.luggage.wxa.kg.d dVar) {
        if (this.f) {
            this.f20717c.a(new b.c(dVar).a().subscribe(new rx.a.c<Void>() {
                @Override
                public void call(Void r1) {
                }
            }, new rx.a.c<Throwable>() {
                @Override
                public void call(Throwable th) {
                    if (th == null || th.getMessage() == null) {
                        com.tencent.luggage.wxa.kf.a.b(h.f20716b, "action send fail");
                        return;
                    }
                    com.tencent.luggage.wxa.kf.a.b(h.f20716b, "action send fail:" + th.getMessage());
                }
            }));
        } else {
            com.tencent.luggage.wxa.kf.a.b(f20716b, "DLNA Router is not enable");
        }
    }

    public void a(final com.tencent.luggage.wxa.kg.e eVar, final com.tencent.luggage.wxa.kj.a aVar) {
        if (this.f) {
            this.f20717c.a(new b.C0540b(eVar).a().subscribe(new rx.a.c<com.tencent.luggage.wxa.kk.e>() {
                @Override
                public void call(com.tencent.luggage.wxa.kk.e eVar2) {
                    com.tencent.luggage.wxa.kf.a.a(h.f20716b, "Send Tcp Custom:" + eVar.a() + " response: code=" + eVar2.f20744a);
                    if (aVar != null) {
                        if (eVar2.f20744a == 200) {
                            aVar.a(eVar2);
                        } else {
                            aVar.b(eVar2);
                        }
                    }
                }
            }, new rx.a.c<Throwable>() {
                @Override
                public void call(Throwable th) {
                    if (th != null && th.getMessage() != null) {
                        com.tencent.luggage.wxa.kf.a.b(h.f20716b, "sendTcpCustom fail: " + th.getMessage());
                    }
                    com.tencent.luggage.wxa.kj.a aVar2 = aVar;
                    if (aVar2 != null) {
                        aVar2.b(null);
                    }
                }
            }));
        } else {
            com.tencent.luggage.wxa.kf.a.b(f20716b, "DLNA Router is not enable");
        }
    }

    public void a(final com.tencent.luggage.wxa.kk.b bVar) {
        try {
            try {
                a(this.e);
            } catch (Exception e) {
                com.tencent.luggage.wxa.kf.a.a(f20716b, e, "");
            }
            if (this.f) {
                if (b(bVar)) {
                    this.f20717c.a(new b.a(bVar).a().subscribe(new rx.a.c<com.tencent.luggage.wxa.kh.b>() {
                        @Override
                        public void call(com.tencent.luggage.wxa.kh.b bVar2) {
                            if (bVar2 == null || bVar2.f == null || bVar2.g == null) {
                                return;
                            }
                            h.this.j.remove(bVar2.f20641a);
                            com.tencent.luggage.wxa.kh.c a2 = com.tencent.luggage.wxa.kh.c.a(bVar2);
                            if (a2 != null) {
                                String a3 = h.this.a(bVar.a("USN"));
                                if (TextUtils.isEmpty(a3)) {
                                    return;
                                }
                                a2.a().k = a3;
                                com.tencent.luggage.wxa.kh.a.a().a(a3, a2);
                            }
                        }
                    }, new rx.a.c<Throwable>() {
                        @Override
                        public void call(Throwable th) {
                            h.this.j.clear();
                            if (th == null || th.getMessage() == null) {
                                com.tencent.luggage.wxa.kf.a.b(h.f20716b, "get mDevice info err");
                                return;
                            }
                            com.tencent.luggage.wxa.kf.a.b(h.f20716b, "get mDevice info err:" + th.getMessage());
                        }
                    }));
                } else {
                    com.tencent.luggage.wxa.kf.a.a(f20716b, "parser fail");
                }
            }
        } finally {
            b(this.e);
        }
    }

    public void a(boolean z) {
        a(new com.tencent.luggage.wxa.kg.h(z));
    }

    public boolean b() throws com.tencent.luggage.wxa.kl.a {
        com.tencent.luggage.wxa.kf.a.a(f20716b, "mRouter is starting ...");
        this.g = i.a().c();
        try {
            if (this.f) {
                return false;
            }
            this.h = new e(new f("239.255.255.250", WelfareBusiness._WELFARE_SHARE), g.a(), this, this.g);
            this.h.b();
            this.f = true;
            return true;
        } catch (Exception e) {
            com.tencent.luggage.wxa.kf.a.a(f20716b, e, "");
            return false;
        }
    }

    public boolean c() throws com.tencent.luggage.wxa.kl.a {
        com.tencent.luggage.wxa.kf.a.a(f20716b, "mRouter is shutting down...");
        if (!this.f) {
            return false;
        }
        this.j.clear();
        this.h.c();
        this.f20717c.a();
        this.f = false;
        return true;
    }
}