APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Նվագարկիչ
版本号:9.9.9
包名称:com.iptv.player

MD5 校验值:d7f913ab91d7343430e85d5ce2e5aff0

反编译源代码说明

l.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package p2;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.media.MediaRoute2Info;
import android.media.MediaRouter2;
import android.media.VolumeProvider;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.ParcelableVolumeInfo;
import android.text.TextUtils;
import android.util.Log;
import androidx.appcompat.widget.x0;
import com.mopub.common.Constants;
import d9.oe;
import g1.e;
import h9.m5;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.concurrent.Executor;
import p2.e;
import p2.h;
import p2.i0;
import p2.j0;
import p2.k0;

public final class l {

    public static final boolean f37734c = Log.isLoggable("MediaRouter", 3);

    public static e f37735d;

    public final Context f37736a;

    public final ArrayList<c> f37737b = new ArrayList<>();

    public static abstract class b {
        public void a(l lVar, h hVar) {
        }

        public void b(l lVar, h hVar) {
        }

        public void c(l lVar, h hVar) {
        }

        public void d(l lVar, i iVar) {
        }

        public void e(l lVar, i iVar) {
        }

        public void f(l lVar, i iVar) {
        }

        @Deprecated
        public void g(l lVar, i iVar) {
        }

        public void h(l lVar, i iVar, int i10) {
            g(lVar, iVar);
        }

        @Deprecated
        public void i(l lVar, i iVar) {
        }

        public void j(l lVar, i iVar, int i10) {
            i(lVar, iVar);
        }

        public void k(l lVar, i iVar) {
        }
    }

    public static final class c {

        public final l f37738a;

        public final b f37739b;

        public k f37740c = k.f37713c;

        public int f37741d;

        public c(l lVar, b bVar) {
            this.f37738a = lVar;
            this.f37739b = bVar;
        }
    }

    public static abstract class d {
        @SuppressLint({"UnknownNullness"})
        public void a(String str, Bundle bundle) {
        }

        public void b(Bundle bundle) {
        }
    }

    public static final class e implements k0.e, i0.c {
        public d A;
        public MediaSessionCompat B;

        public final Context f37742a;

        public final boolean f37743b;

        public final p2.e f37744c;

        public final k0 f37753l;

        public final boolean f37754m;

        public c0 f37755n;

        public i f37756o;

        public i f37757p;

        public i f37758q;

        public h.e f37759r;

        public i f37760s;

        public h.e f37761t;

        public p2.g f37763v;

        public p2.g f37764w;

        public int f37765x;

        public f f37766y;

        public g f37767z;

        public final ArrayList<WeakReference<l>> f37745d = new ArrayList<>();

        public final ArrayList<i> f37746e = new ArrayList<>();

        public final Map<n0.c<String, String>, String> f37747f = new HashMap();

        public final ArrayList<h> f37748g = new ArrayList<>();

        public final ArrayList<g> f37749h = new ArrayList<>();

        public final j0.a f37750i = new j0.a();

        public final f f37751j = new f();

        public final c f37752k = new c();

        public final Map<String, h.e> f37762u = new HashMap();
        public MediaSessionCompat.h C = new a();
        public h.b.c D = new b();

        public class a implements MediaSessionCompat.h {
            public a() {
            }

            @Override
            public void a() {
                Objects.requireNonNull(e.this);
            }
        }

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

            public void a(h.b bVar, p2.f fVar, Collection<h.b.C0229b> collection) {
                e eVar = e.this;
                if (bVar != eVar.f37761t || fVar == null) {
                    if (bVar == eVar.f37759r) {
                        if (fVar != null) {
                            eVar.p(eVar.f37758q, fVar);
                        }
                        e.this.f37758q.o(collection);
                        return;
                    }
                    return;
                }
                h hVar = eVar.f37760s.f37794a;
                String i10 = fVar.i();
                i iVar = new i(hVar, i10, e.this.b(hVar, i10));
                iVar.j(fVar);
                e eVar2 = e.this;
                if (eVar2.f37758q == iVar) {
                    return;
                }
                eVar2.j(eVar2, iVar, eVar2.f37761t, 3, eVar2.f37760s, collection);
                e eVar3 = e.this;
                eVar3.f37760s = null;
                eVar3.f37761t = null;
            }
        }

        public final class c extends Handler {

            public final ArrayList<c> f37770a = new ArrayList<>();

            public final List<i> f37771b = new ArrayList();

            public c() {
            }

            public final void a(c cVar, int i10, Object obj, int i11) {
                c0 c0Var;
                l lVar = cVar.f37738a;
                b bVar = cVar.f37739b;
                int i12 = 65280 & i10;
                if (i12 != 256) {
                    if (i12 != 512) {
                        return;
                    }
                    h hVar = (h) obj;
                    switch (i10) {
                        case 513:
                            bVar.a(lVar, hVar);
                            return;
                        case 514:
                            bVar.c(lVar, hVar);
                            return;
                        case 515:
                            bVar.b(lVar, hVar);
                            return;
                        default:
                            return;
                    }
                }
                i iVar = (i10 == 264 || i10 == 262) ? (i) ((n0.c) obj).f36609b : (i) obj;
                i iVar2 = (i10 == 264 || i10 == 262) ? (i) ((n0.c) obj).f36608a : null;
                if (iVar != null) {
                    boolean z10 = true;
                    if ((cVar.f37741d & 2) == 0 && !iVar.i(cVar.f37740c)) {
                        e eVar = l.f37735d;
                        z10 = (((eVar != null && (c0Var = eVar.f37755n) != null) ? c0Var.f37584c : false) && iVar.e() && i10 == 262 && i11 == 3 && iVar2 != null) ? true ^ iVar2.e() : false;
                    }
                    if (z10) {
                        switch (i10) {
                            case 257:
                                bVar.d(lVar, iVar);
                                return;
                            case 258:
                                bVar.f(lVar, iVar);
                                return;
                            case 259:
                                bVar.e(lVar, iVar);
                                return;
                            case 260:
                                bVar.k(lVar, iVar);
                                return;
                            case 261:
                                Objects.requireNonNull(bVar);
                                return;
                            case 262:
                                bVar.h(lVar, iVar, i11);
                                return;
                            case 263:
                                bVar.j(lVar, iVar, i11);
                                return;
                            case 264:
                                bVar.h(lVar, iVar, i11);
                                return;
                            default:
                                return;
                        }
                    }
                }
            }

            public void b(int i10, Object obj) {
                obtainMessage(i10, obj).sendToTarget();
            }

            public void c(int i10, Object obj, int i11) {
                Message obtainMessage = obtainMessage(i10, obj);
                obtainMessage.arg1 = i11;
                obtainMessage.sendToTarget();
            }

            @Override
            public void handleMessage(Message message) {
                int i10 = message.what;
                Object obj = message.obj;
                int i11 = message.arg1;
                if (i10 == 259 && e.this.g().f37796c.equals(((i) obj).f37796c)) {
                    e.this.q(true);
                }
                if (i10 == 262) {
                    i iVar = (i) ((n0.c) obj).f36609b;
                    e.this.f37753l.u(iVar);
                    if (e.this.f37756o != null && iVar.e()) {
                        Iterator<i> it = this.f37771b.iterator();
                        while (it.hasNext()) {
                            e.this.f37753l.t(it.next());
                        }
                        this.f37771b.clear();
                    }
                } else if (i10 != 264) {
                    switch (i10) {
                        case 257:
                            e.this.f37753l.r((i) obj);
                            break;
                        case 258:
                            e.this.f37753l.t((i) obj);
                            break;
                        case 259:
                            e.this.f37753l.s((i) obj);
                            break;
                    }
                } else {
                    i iVar2 = (i) ((n0.c) obj).f36609b;
                    this.f37771b.add(iVar2);
                    e.this.f37753l.r(iVar2);
                    e.this.f37753l.u(iVar2);
                }
                try {
                    int size = e.this.f37745d.size();
                    while (true) {
                        size--;
                        if (size < 0) {
                            int size2 = this.f37770a.size();
                            for (int i12 = 0; i12 < size2; i12++) {
                                a(this.f37770a.get(i12), i10, obj, i11);
                            }
                            return;
                        }
                        l lVar = e.this.f37745d.get(size).get();
                        if (lVar == null) {
                            e.this.f37745d.remove(size);
                        } else {
                            this.f37770a.addAll(lVar.f37737b);
                        }
                    }
                } finally {
                    this.f37770a.clear();
                }
            }
        }

        public final class d {

            public final MediaSessionCompat f37773a;

            public g1.e f37774b;

            public d(MediaSessionCompat mediaSessionCompat) {
                this.f37773a = mediaSessionCompat;
            }

            public void a() {
                MediaSessionCompat mediaSessionCompat = this.f37773a;
                if (mediaSessionCompat != null) {
                    mediaSessionCompat.f8723a.g(e.this.f37750i.f37710d);
                    this.f37774b = null;
                }
            }
        }

        public final class C0231e extends e.a {
            public C0231e(a aVar) {
            }
        }

        public final class f extends h.a {
            public f() {
            }
        }

        public final class g {

            public final j0 f37778a;

            public final e f37779b;
        }

        @SuppressLint({"SyntheticAccessor", "NewApi"})
        public e(Context context) {
            this.f37742a = context;
            WeakHashMap<Context, i0.a> weakHashMap = i0.a.f32098a;
            synchronized (weakHashMap) {
                if (weakHashMap.get(context) == null) {
                    weakHashMap.put(context, new i0.a(context));
                }
            }
            this.f37754m = ((ActivityManager) context.getSystemService("activity")).isLowRamDevice();
            int i10 = Build.VERSION.SDK_INT;
            if (i10 >= 30) {
                int i11 = d0.f37589a;
                Intent intent = new Intent(context, (Class<?>) d0.class);
                intent.setPackage(context.getPackageName());
                this.f37743b = context.getPackageManager().queryBroadcastReceivers(intent, 0).size() > 0;
            } else {
                this.f37743b = false;
            }
            if (this.f37743b) {
                this.f37744c = new p2.e(context, new C0231e(null));
            } else {
                this.f37744c = null;
            }
            this.f37753l = i10 >= 24 ? new k0.a(context, this) : new k0.d(context, this);
        }

        public void a(p2.h hVar) {
            if (d(hVar) == null) {
                h hVar2 = new h(hVar);
                this.f37748g.add(hVar2);
                if (l.f37734c) {
                    Log.d("MediaRouter", "Provider added: " + hVar2);
                }
                this.f37752k.b(513, hVar2);
                o(hVar2, hVar.f37670g);
                f fVar = this.f37751j;
                l.b();
                hVar.f37667d = fVar;
                hVar.q(this.f37763v);
            }
        }

        public String b(h hVar, String str) {
            String flattenToShortString = hVar.f37792c.f37687a.flattenToShortString();
            String a10 = android.support.v4.media.c.a(flattenToShortString, ":", str);
            if (e(a10) < 0) {
                this.f37747f.put(new n0.c<>(flattenToShortString, str), a10);
                return a10;
            }
            Log.w("MediaRouter", m.a("Either ", str, " isn't unique in ", flattenToShortString, " or we're trying to assign a unique ID for an already added route"));
            int i10 = 2;
            while (true) {
                String format = String.format(Locale.US, "%s_%d", a10, Integer.valueOf(i10));
                if (e(format) < 0) {
                    this.f37747f.put(new n0.c<>(flattenToShortString, str), format);
                    return format;
                }
                i10++;
            }
        }

        public i c() {
            Iterator<i> it = this.f37746e.iterator();
            while (it.hasNext()) {
                i next = it.next();
                if (next != this.f37756o && h(next) && next.g()) {
                    return next;
                }
            }
            return this.f37756o;
        }

        public final h d(p2.h hVar) {
            int size = this.f37748g.size();
            for (int i10 = 0; i10 < size; i10++) {
                if (this.f37748g.get(i10).f37790a == hVar) {
                    return this.f37748g.get(i10);
                }
            }
            return null;
        }

        public final int e(String str) {
            int size = this.f37746e.size();
            for (int i10 = 0; i10 < size; i10++) {
                if (this.f37746e.get(i10).f37796c.equals(str)) {
                    return i10;
                }
            }
            return -1;
        }

        public i f() {
            i iVar = this.f37756o;
            if (iVar != null) {
                return iVar;
            }
            throw new IllegalStateException("There is no default route.  The media router has not yet been fully initialized.");
        }

        public i g() {
            i iVar = this.f37758q;
            if (iVar != null) {
                return iVar;
            }
            throw new IllegalStateException("There is no currently selected route.  The media router has not yet been fully initialized.");
        }

        public final boolean h(i iVar) {
            return iVar.d() == this.f37753l && iVar.n("android.media.intent.category.LIVE_AUDIO") && !iVar.n("android.media.intent.category.LIVE_VIDEO");
        }

        public void i() {
            if (this.f37758q.f()) {
                List<i> c10 = this.f37758q.c();
                HashSet hashSet = new HashSet();
                Iterator<i> it = c10.iterator();
                while (it.hasNext()) {
                    hashSet.add(it.next().f37796c);
                }
                Iterator<Map.Entry<String, h.e>> it2 = this.f37762u.entrySet().iterator();
                while (it2.hasNext()) {
                    Map.Entry<String, h.e> next = it2.next();
                    if (!hashSet.contains(next.getKey())) {
                        h.e value = next.getValue();
                        value.h(0);
                        value.d();
                        it2.remove();
                    }
                }
                for (i iVar : c10) {
                    if (!this.f37762u.containsKey(iVar.f37796c)) {
                        h.e n10 = iVar.d().n(iVar.f37795b, this.f37758q.f37795b);
                        n10.e();
                        this.f37762u.put(iVar.f37796c, n10);
                    }
                }
            }
        }

        public void j(e eVar, i iVar, h.e eVar2, int i10, i iVar2, Collection<h.b.C0229b> collection) {
            f fVar;
            g gVar = this.f37767z;
            if (gVar != null) {
                gVar.a();
                this.f37767z = null;
            }
            g gVar2 = new g(eVar, iVar, eVar2, i10, iVar2, collection);
            this.f37767z = gVar2;
            if (gVar2.f37781b != 3 || (fVar = this.f37766y) == null) {
                gVar2.b();
                return;
            }
            i iVar3 = this.f37758q;
            i iVar4 = gVar2.f37783d;
            h9.c cVar = (h9.c) fVar;
            h9.c.f31737c.b("Prepare transfer from Route(%s) to Route(%s)", iVar3, iVar4);
            m5 m5Var = new m5();
            cVar.f31739b.post(new oe(cVar, iVar3, iVar4, m5Var));
            g gVar3 = this.f37767z;
            e eVar3 = gVar3.f37786g.get();
            if (eVar3 == null || eVar3.f37767z != gVar3) {
                Log.w("MediaRouter", "Router is released. Cancel transfer");
                gVar3.a();
            } else {
                if (gVar3.f37787h != null) {
                    throw new IllegalStateException("future is already set");
                }
                gVar3.f37787h = m5Var;
                q qVar = new q(gVar3, 1);
                c cVar2 = eVar3.f37752k;
                Objects.requireNonNull(cVar2);
                m5Var.c(qVar, new p2.a(cVar2));
            }
        }

        public void k(i iVar, int i10) {
            if (!this.f37746e.contains(iVar)) {
                Log.w("MediaRouter", "Ignoring attempt to select removed route: " + iVar);
                return;
            }
            if (!iVar.f37800g) {
                Log.w("MediaRouter", "Ignoring attempt to select disabled route: " + iVar);
                return;
            }
            if (Build.VERSION.SDK_INT >= 30) {
                p2.h d10 = iVar.d();
                p2.e eVar = this.f37744c;
                if (d10 == eVar && this.f37758q != iVar) {
                    String str = iVar.f37795b;
                    MediaRoute2Info r10 = eVar.r(str);
                    if (r10 == null) {
                        x0.a("transferTo: Specified route not found. routeId=", str, "MR2Provider");
                        return;
                    } else {
                        eVar.f37591i.transferTo(r10);
                        return;
                    }
                }
            }
            l(iVar, i10);
        }

        public void l(i iVar, int i10) {
            boolean z10 = false;
            if (l.f37735d != null) {
                if (this.f37757p != null) {
                    Objects.requireNonNull(iVar);
                    l.b();
                }
                if (this.f37758q != iVar) {
                    return;
                }
                if (this.f37760s != null) {
                    this.f37760s = null;
                    h.e eVar = this.f37761t;
                    if (eVar != null) {
                        eVar.h(3);
                        this.f37761t.d();
                        this.f37761t = null;
                    }
                }
                if (this.f37743b) {
                    j jVar = iVar.f37794a.f37793d;
                    if (jVar != null && jVar.f37706b) {
                        z10 = true;
                    }
                    if (z10) {
                        h.b l10 = iVar.d().l(iVar.f37795b);
                        if (l10 != null) {
                            Executor c10 = e0.a.c(this.f37742a);
                            h.b.c cVar = this.D;
                            synchronized (l10.f37672a) {
                                if (c10 == null) {
                                    throw new NullPointerException("Executor shouldn't be null");
                                }
                                if (cVar == null) {
                                    throw new NullPointerException("Listener shouldn't be null");
                                }
                                l10.f37673b = c10;
                                l10.f37674c = cVar;
                                Collection<h.b.C0229b> collection = l10.f37676e;
                                if (collection != null && !collection.isEmpty()) {
                                    p2.f fVar = l10.f37675d;
                                    Collection<h.b.C0229b> collection2 = l10.f37676e;
                                    l10.f37675d = null;
                                    l10.f37676e = null;
                                    l10.f37673b.execute(new p2.i(l10, cVar, fVar, collection2));
                                }
                            }
                            this.f37760s = iVar;
                            this.f37761t = l10;
                            l10.e();
                            return;
                        }
                        Log.w("MediaRouter", "setSelectedRouteInternal: Failed to create dynamic group route controller. route=" + iVar);
                    }
                }
                h.e m10 = iVar.d().m(iVar.f37795b);
                if (m10 != null) {
                    m10.e();
                }
                if (l.f37734c) {
                    Log.d("MediaRouter", "Route selected: " + iVar);
                }
                if (this.f37758q != null) {
                    j(this, iVar, m10, i10, null, null);
                    return;
                }
                this.f37758q = iVar;
                this.f37759r = m10;
                this.f37752k.c(262, new n0.c(null, iVar), i10);
                return;
            }
            StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
            StringBuilder sb2 = new StringBuilder();
            for (int i11 = 3; i11 < stackTrace.length; i11++) {
                StackTraceElement stackTraceElement = stackTrace[i11];
                sb2.append(stackTraceElement.getClassName());
                sb2.append(".");
                sb2.append(stackTraceElement.getMethodName());
                sb2.append(":");
                sb2.append(stackTraceElement.getLineNumber());
                sb2.append("  ");
            }
            if (l.f37735d == null) {
                StringBuilder a10 = android.support.v4.media.b.a("setSelectedRouteInternal is called while sGlobal is null: pkgName=");
                a10.append(this.f37742a.getPackageName());
                a10.append(", callers=");
                a10.append(sb2.toString());
                Log.w("MediaRouter", a10.toString());
            } else {
                StringBuilder a11 = android.support.v4.media.b.a("Default route is selected while a BT route is available: pkgName=");
                a11.append(this.f37742a.getPackageName());
                a11.append(", callers=");
                a11.append(sb2.toString());
                Log.w("MediaRouter", a11.toString());
            }
            if (this.f37758q != iVar) {
            }
        }

        public void m() {
            k kVar;
            k kVar2;
            int size = this.f37745d.size();
            int i10 = 0;
            boolean z10 = false;
            boolean z11 = false;
            ArrayList<String> arrayList = null;
            while (true) {
                size--;
                if (size < 0) {
                    this.f37765x = i10;
                    if (!z10) {
                        kVar = k.f37713c;
                    } else if (arrayList == null) {
                        kVar = k.f37713c;
                    } else {
                        Bundle bundle = new Bundle();
                        bundle.putStringArrayList("controlCategories", arrayList);
                        kVar = new k(bundle, arrayList);
                    }
                    if (arrayList == null) {
                        kVar2 = k.f37713c;
                    } else {
                        Bundle bundle2 = new Bundle();
                        bundle2.putStringArrayList("controlCategories", arrayList);
                        kVar2 = new k(bundle2, arrayList);
                    }
                    if (this.f37743b) {
                        p2.g gVar = this.f37764w;
                        if (gVar != null) {
                            gVar.a();
                            if (gVar.f37662b.equals(kVar2)) {
                            }
                        }
                        if (!kVar2.c() || z11) {
                            this.f37764w = new p2.g(kVar2, z11);
                        } else if (this.f37764w != null) {
                            this.f37764w = null;
                        }
                        if (l.f37734c) {
                            StringBuilder a10 = android.support.v4.media.b.a("Updated MediaRoute2Provider's discovery request: ");
                            a10.append(this.f37764w);
                            Log.d("MediaRouter", a10.toString());
                        }
                        this.f37744c.q(this.f37764w);
                    }
                    p2.g gVar2 = this.f37763v;
                    if (gVar2 != null) {
                        gVar2.a();
                        if (gVar2.f37662b.equals(kVar) && this.f37763v.b() == z11) {
                            return;
                        }
                    }
                    if (!kVar.c() || z11) {
                        this.f37763v = new p2.g(kVar, z11);
                    } else if (this.f37763v == null) {
                        return;
                    } else {
                        this.f37763v = null;
                    }
                    if (l.f37734c) {
                        StringBuilder a11 = android.support.v4.media.b.a("Updated discovery request: ");
                        a11.append(this.f37763v);
                        Log.d("MediaRouter", a11.toString());
                    }
                    if (z10 && !z11 && this.f37754m) {
                        Log.i("MediaRouter", "Forcing passive route discovery on a low-RAM device, system performance may be affected.  Please consider using CALLBACK_FLAG_REQUEST_DISCOVERY instead of CALLBACK_FLAG_FORCE_DISCOVERY.");
                    }
                    int size2 = this.f37748g.size();
                    for (int i11 = 0; i11 < size2; i11++) {
                        p2.h hVar = this.f37748g.get(i11).f37790a;
                        if (hVar != this.f37744c) {
                            hVar.q(this.f37763v);
                        }
                    }
                    return;
                }
                l lVar = this.f37745d.get(size).get();
                if (lVar == null) {
                    this.f37745d.remove(size);
                } else {
                    int size3 = lVar.f37737b.size();
                    i10 += size3;
                    for (int i12 = 0; i12 < size3; i12++) {
                        c cVar = lVar.f37737b.get(i12);
                        k kVar3 = cVar.f37740c;
                        if (kVar3 == null) {
                            throw new IllegalArgumentException("selector must not be null");
                        }
                        kVar3.a();
                        List<String> list = kVar3.f37715b;
                        if (list == null) {
                            throw new IllegalArgumentException("categories must not be null");
                        }
                        if (!list.isEmpty()) {
                            for (String str : list) {
                                if (str == null) {
                                    throw new IllegalArgumentException("category must not be null");
                                }
                                if (arrayList == null) {
                                    arrayList = new ArrayList<>();
                                }
                                if (!arrayList.contains(str)) {
                                    arrayList.add(str);
                                }
                            }
                        }
                        int i13 = cVar.f37741d;
                        if ((i13 & 1) != 0) {
                            z10 = true;
                            z11 = true;
                        }
                        if ((i13 & 4) != 0 && !this.f37754m) {
                            z10 = true;
                        }
                        if ((i13 & 8) != 0) {
                            z10 = true;
                        }
                    }
                }
            }
        }

        @SuppressLint({"NewApi"})
        public void n() {
            MediaRouter2.RoutingController routingController;
            i iVar = this.f37758q;
            if (iVar == null) {
                d dVar = this.A;
                if (dVar != null) {
                    dVar.a();
                    return;
                }
                return;
            }
            j0.a aVar = this.f37750i;
            aVar.f37707a = iVar.f37808o;
            aVar.f37708b = iVar.f37809p;
            aVar.f37709c = iVar.f37807n;
            aVar.f37710d = iVar.f37805l;
            aVar.f37711e = iVar.f37804k;
            String str = null;
            if (this.f37743b && iVar.d() == this.f37744c) {
                j0.a aVar2 = this.f37750i;
                h.e eVar = this.f37759r;
                int i10 = p2.e.f37590r;
                if ((eVar instanceof e.c) && (routingController = ((e.c) eVar).f37602g) != null) {
                    str = routingController.getId();
                }
                aVar2.f37712f = str;
            } else {
                this.f37750i.f37712f = null;
            }
            int size = this.f37749h.size();
            for (int i11 = 0; i11 < size; i11++) {
                g gVar = this.f37749h.get(i11);
                gVar.f37778a.a(gVar.f37779b.f37750i);
            }
            if (this.A != null) {
                if (this.f37758q == f() || this.f37758q == this.f37757p) {
                    this.A.a();
                    return;
                }
                j0.a aVar3 = this.f37750i;
                int i12 = aVar3.f37709c == 1 ? 2 : 0;
                d dVar2 = this.A;
                int i13 = aVar3.f37708b;
                int i14 = aVar3.f37707a;
                String str2 = aVar3.f37712f;
                MediaSessionCompat mediaSessionCompat = dVar2.f37773a;
                if (mediaSessionCompat != null) {
                    g1.e eVar2 = dVar2.f37774b;
                    if (eVar2 == null || i12 != 0 || i13 != 0) {
                        p pVar = new p(dVar2, i12, i13, i14, str2);
                        dVar2.f37774b = pVar;
                        mediaSessionCompat.f8723a.o(pVar);
                        return;
                    }
                    eVar2.f31160d = i14;
                    e.c.a((VolumeProvider) eVar2.a(), i14);
                    e.d dVar3 = eVar2.f31161e;
                    if (dVar3 != null) {
                        MediaSessionCompat.g gVar2 = ((MediaSessionCompat.g.a) dVar3).f8756a;
                        if (gVar2.f8755c != eVar2) {
                            return;
                        }
                        gVar2.a(new ParcelableVolumeInfo(gVar2.f8753a, gVar2.f8754b, eVar2.f31157a, eVar2.f31158b, eVar2.f31160d));
                    }
                }
            }
        }

        public final void o(h hVar, j jVar) {
            boolean z10;
            boolean z11;
            int i10;
            int i11;
            if (hVar.f37793d != jVar) {
                hVar.f37793d = jVar;
                z10 = true;
            } else {
                z10 = false;
            }
            if (z10) {
                if (jVar == null || !(jVar.b() || jVar == this.f37753l.f37670g)) {
                    Log.w("MediaRouter", "Ignoring invalid provider descriptor: " + jVar);
                    z11 = false;
                    i10 = 0;
                } else {
                    List<p2.f> list = jVar.f37705a;
                    ArrayList arrayList = new ArrayList();
                    ArrayList arrayList2 = new ArrayList();
                    boolean z12 = false;
                    i10 = 0;
                    for (p2.f fVar : list) {
                        if (fVar == null || !fVar.r()) {
                            Log.w("MediaRouter", "Ignoring invalid system route descriptor: " + fVar);
                        } else {
                            String i12 = fVar.i();
                            int size = hVar.f37791b.size();
                            int i13 = 0;
                            while (true) {
                                if (i13 >= size) {
                                    i13 = -1;
                                    break;
                                } else if (hVar.f37791b.get(i13).f37795b.equals(i12)) {
                                    break;
                                } else {
                                    i13++;
                                }
                            }
                            if (i13 < 0) {
                                i iVar = new i(hVar, i12, b(hVar, i12));
                                i11 = i10 + 1;
                                hVar.f37791b.add(i10, iVar);
                                this.f37746e.add(iVar);
                                if (fVar.g().size() > 0) {
                                    arrayList.add(new n0.c(iVar, fVar));
                                } else {
                                    iVar.j(fVar);
                                    if (l.f37734c) {
                                        Log.d("MediaRouter", "Route added: " + iVar);
                                    }
                                    this.f37752k.b(257, iVar);
                                }
                            } else if (i13 < i10) {
                                Log.w("MediaRouter", "Ignoring route descriptor with duplicate id: " + fVar);
                            } else {
                                i iVar2 = hVar.f37791b.get(i13);
                                i11 = i10 + 1;
                                Collections.swap(hVar.f37791b, i13, i10);
                                if (fVar.g().size() > 0) {
                                    arrayList2.add(new n0.c(iVar2, fVar));
                                } else if (p(iVar2, fVar) != 0 && iVar2 == this.f37758q) {
                                    i10 = i11;
                                    z12 = true;
                                }
                            }
                            i10 = i11;
                        }
                    }
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        n0.c cVar = (n0.c) it.next();
                        i iVar3 = (i) cVar.f36608a;
                        iVar3.j((p2.f) cVar.f36609b);
                        if (l.f37734c) {
                            Log.d("MediaRouter", "Route added: " + iVar3);
                        }
                        this.f37752k.b(257, iVar3);
                    }
                    Iterator it2 = arrayList2.iterator();
                    z11 = z12;
                    while (it2.hasNext()) {
                        n0.c cVar2 = (n0.c) it2.next();
                        i iVar4 = (i) cVar2.f36608a;
                        if (p(iVar4, (p2.f) cVar2.f36609b) != 0 && iVar4 == this.f37758q) {
                            z11 = true;
                        }
                    }
                }
                for (int size2 = hVar.f37791b.size() - 1; size2 >= i10; size2--) {
                    i iVar5 = hVar.f37791b.get(size2);
                    iVar5.j(null);
                    this.f37746e.remove(iVar5);
                }
                q(z11);
                for (int size3 = hVar.f37791b.size() - 1; size3 >= i10; size3--) {
                    i remove = hVar.f37791b.remove(size3);
                    if (l.f37734c) {
                        Log.d("MediaRouter", "Route removed: " + remove);
                    }
                    this.f37752k.b(258, remove);
                }
                if (l.f37734c) {
                    Log.d("MediaRouter", "Provider changed: " + hVar);
                }
                this.f37752k.b(515, hVar);
            }
        }

        public int p(i iVar, p2.f fVar) {
            int j10 = iVar.j(fVar);
            if (j10 != 0) {
                if ((j10 & 1) != 0) {
                    if (l.f37734c) {
                        Log.d("MediaRouter", "Route changed: " + iVar);
                    }
                    this.f37752k.b(259, iVar);
                }
                if ((j10 & 2) != 0) {
                    if (l.f37734c) {
                        Log.d("MediaRouter", "Route volume changed: " + iVar);
                    }
                    this.f37752k.b(260, iVar);
                }
                if ((j10 & 4) != 0) {
                    if (l.f37734c) {
                        Log.d("MediaRouter", "Route presentation display changed: " + iVar);
                    }
                    this.f37752k.b(261, iVar);
                }
            }
            return j10;
        }

        public void q(boolean z10) {
            i iVar = this.f37756o;
            if (iVar != null && !iVar.g()) {
                StringBuilder a10 = android.support.v4.media.b.a("Clearing the default route because it is no longer selectable: ");
                a10.append(this.f37756o);
                Log.i("MediaRouter", a10.toString());
                this.f37756o = null;
            }
            if (this.f37756o == null && !this.f37746e.isEmpty()) {
                Iterator<i> it = this.f37746e.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    i next = it.next();
                    if ((next.d() == this.f37753l && next.f37795b.equals("DEFAULT_ROUTE")) && next.g()) {
                        this.f37756o = next;
                        StringBuilder a11 = android.support.v4.media.b.a("Found default route: ");
                        a11.append(this.f37756o);
                        Log.i("MediaRouter", a11.toString());
                        break;
                    }
                }
            }
            i iVar2 = this.f37757p;
            if (iVar2 != null && !iVar2.g()) {
                StringBuilder a12 = android.support.v4.media.b.a("Clearing the bluetooth route because it is no longer selectable: ");
                a12.append(this.f37757p);
                Log.i("MediaRouter", a12.toString());
                this.f37757p = null;
            }
            if (this.f37757p == null && !this.f37746e.isEmpty()) {
                Iterator<i> it2 = this.f37746e.iterator();
                while (true) {
                    if (!it2.hasNext()) {
                        break;
                    }
                    i next2 = it2.next();
                    if (h(next2) && next2.g()) {
                        this.f37757p = next2;
                        StringBuilder a13 = android.support.v4.media.b.a("Found bluetooth route: ");
                        a13.append(this.f37757p);
                        Log.i("MediaRouter", a13.toString());
                        break;
                    }
                }
            }
            i iVar3 = this.f37758q;
            if (iVar3 == null || !iVar3.f37800g) {
                StringBuilder a14 = android.support.v4.media.b.a("Unselecting the current route because it is no longer selectable: ");
                a14.append(this.f37758q);
                Log.i("MediaRouter", a14.toString());
                l(c(), 0);
                return;
            }
            if (z10) {
                i();
                n();
            }
        }
    }

    public interface f {
    }

    public static final class g {

        public final h.e f37780a;

        public final int f37781b;

        public final i f37782c;

        public final i f37783d;

        public final i f37784e;

        public final List<h.b.C0229b> f37785f;

        public final WeakReference<e> f37786g;

        public ib.a<Void> f37787h = null;

        public boolean f37788i = false;

        public boolean f37789j = false;

        public g(e eVar, i iVar, h.e eVar2, int i10, i iVar2, Collection<h.b.C0229b> collection) {
            this.f37786g = new WeakReference<>(eVar);
            this.f37783d = iVar;
            this.f37780a = eVar2;
            this.f37781b = i10;
            this.f37782c = eVar.f37758q;
            this.f37784e = iVar2;
            this.f37785f = collection != null ? new ArrayList(collection) : null;
            eVar.f37752k.postDelayed(new q(this, 0), 15000L);
        }

        public void a() {
            if (this.f37788i || this.f37789j) {
                return;
            }
            this.f37789j = true;
            h.e eVar = this.f37780a;
            if (eVar != null) {
                eVar.h(0);
                this.f37780a.d();
            }
        }

        public void b() {
            ib.a<Void> aVar;
            l.b();
            if (this.f37788i || this.f37789j) {
                return;
            }
            e eVar = this.f37786g.get();
            if (eVar == null || eVar.f37767z != this || ((aVar = this.f37787h) != null && aVar.isCancelled())) {
                a();
                return;
            }
            this.f37788i = true;
            eVar.f37767z = null;
            e eVar2 = this.f37786g.get();
            if (eVar2 != null) {
                i iVar = eVar2.f37758q;
                i iVar2 = this.f37782c;
                if (iVar == iVar2) {
                    eVar2.f37752k.c(263, iVar2, this.f37781b);
                    h.e eVar3 = eVar2.f37759r;
                    if (eVar3 != null) {
                        eVar3.h(this.f37781b);
                        eVar2.f37759r.d();
                    }
                    if (!eVar2.f37762u.isEmpty()) {
                        for (h.e eVar4 : eVar2.f37762u.values()) {
                            eVar4.h(this.f37781b);
                            eVar4.d();
                        }
                        eVar2.f37762u.clear();
                    }
                    eVar2.f37759r = null;
                }
            }
            e eVar5 = this.f37786g.get();
            if (eVar5 == null) {
                return;
            }
            i iVar3 = this.f37783d;
            eVar5.f37758q = iVar3;
            eVar5.f37759r = this.f37780a;
            i iVar4 = this.f37784e;
            if (iVar4 == null) {
                eVar5.f37752k.c(262, new n0.c(this.f37782c, iVar3), this.f37781b);
            } else {
                eVar5.f37752k.c(264, new n0.c(iVar4, iVar3), this.f37781b);
            }
            eVar5.f37762u.clear();
            eVar5.i();
            eVar5.n();
            List<h.b.C0229b> list = this.f37785f;
            if (list != null) {
                eVar5.f37758q.o(list);
            }
        }
    }

    public static final class h {

        public final p2.h f37790a;

        public final List<i> f37791b = new ArrayList();

        public final h.d f37792c;

        public j f37793d;

        public h(p2.h hVar) {
            this.f37790a = hVar;
            this.f37792c = hVar.f37665b;
        }

        public i a(String str) {
            int size = this.f37791b.size();
            for (int i10 = 0; i10 < size; i10++) {
                if (this.f37791b.get(i10).f37795b.equals(str)) {
                    return this.f37791b.get(i10);
                }
            }
            return null;
        }

        public List<i> b() {
            l.b();
            return Collections.unmodifiableList(this.f37791b);
        }

        public String toString() {
            StringBuilder a10 = android.support.v4.media.b.a("MediaRouter.RouteProviderInfo{ packageName=");
            a10.append(this.f37792c.f37687a.getPackageName());
            a10.append(" }");
            return a10.toString();
        }
    }

    public static class i {

        public final h f37794a;

        public final String f37795b;

        public final String f37796c;

        public String f37797d;

        public String f37798e;

        public Uri f37799f;

        public boolean f37800g;

        public int f37801h;

        public boolean f37802i;

        public int f37804k;

        public int f37805l;

        public int f37806m;

        public int f37807n;

        public int f37808o;

        public int f37809p;

        public Bundle f37811r;

        public IntentSender f37812s;

        public p2.f f37813t;

        public Map<String, h.b.C0229b> f37815v;

        public final ArrayList<IntentFilter> f37803j = new ArrayList<>();

        public int f37810q = -1;

        public List<i> f37814u = new ArrayList();

        public static final class a {

            public final h.b.C0229b f37816a;

            public a(h.b.C0229b c0229b) {
                this.f37816a = c0229b;
            }

            public boolean a() {
                h.b.C0229b c0229b = this.f37816a;
                return c0229b != null && c0229b.f37684d;
            }
        }

        public i(h hVar, String str, String str2) {
            this.f37794a = hVar;
            this.f37795b = str;
            this.f37796c = str2;
        }

        public h.b a() {
            h.e eVar = l.f37735d.f37759r;
            if (eVar instanceof h.b) {
                return (h.b) eVar;
            }
            return null;
        }

        public a b(i iVar) {
            Map<String, h.b.C0229b> map = this.f37815v;
            if (map == null || !map.containsKey(iVar.f37796c)) {
                return null;
            }
            return new a(this.f37815v.get(iVar.f37796c));
        }

        public List<i> c() {
            return Collections.unmodifiableList(this.f37814u);
        }

        public p2.h d() {
            h hVar = this.f37794a;
            Objects.requireNonNull(hVar);
            l.b();
            return hVar.f37790a;
        }

        public boolean e() {
            l.b();
            if ((l.f37735d.f() == this) || this.f37806m == 3) {
                return true;
            }
            return TextUtils.equals(d().f37665b.f37687a.getPackageName(), Constants.ANDROID_PLATFORM) && n("android.media.intent.category.LIVE_AUDIO") && !n("android.media.intent.category.LIVE_VIDEO");
        }

        public boolean f() {
            return c().size() >= 1;
        }

        public boolean g() {
            return this.f37813t != null && this.f37800g;
        }

        public boolean h() {
            l.b();
            return l.f37735d.g() == this;
        }

        public boolean i(k kVar) {
            if (kVar == null) {
                throw new IllegalArgumentException("selector must not be null");
            }
            l.b();
            ArrayList<IntentFilter> arrayList = this.f37803j;
            if (arrayList == null) {
                return false;
            }
            kVar.a();
            int size = kVar.f37715b.size();
            if (size == 0) {
                return false;
            }
            int size2 = arrayList.size();
            for (int i10 = 0; i10 < size2; i10++) {
                IntentFilter intentFilter = arrayList.get(i10);
                if (intentFilter != null) {
                    for (int i11 = 0; i11 < size; i11++) {
                        if (intentFilter.hasCategory(kVar.f37715b.get(i11))) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }

        public int j(p2.f fVar) {
            int i10;
            boolean z10;
            boolean z11;
            i iVar;
            boolean z12;
            int countActions;
            if (this.f37813t == fVar) {
                return 0;
            }
            this.f37813t = fVar;
            if (fVar == null) {
                return 0;
            }
            if (Objects.equals(this.f37797d, fVar.j())) {
                i10 = 0;
            } else {
                this.f37797d = fVar.j();
                i10 = 1;
            }
            if (!Objects.equals(this.f37798e, fVar.d())) {
                this.f37798e = fVar.d();
                i10 |= 1;
            }
            if (!Objects.equals(this.f37799f, fVar.h())) {
                this.f37799f = fVar.h();
                i10 |= 1;
            }
            if (this.f37800g != fVar.q()) {
                this.f37800g = fVar.q();
                i10 |= 1;
            }
            if (this.f37801h != fVar.c()) {
                this.f37801h = fVar.c();
                i10 |= 1;
            }
            ArrayList<IntentFilter> arrayList = this.f37803j;
            fVar.a();
            List<IntentFilter> list = fVar.f37619c;
            if (arrayList != list) {
                if (arrayList != null && list != null) {
                    ListIterator<IntentFilter> listIterator = arrayList.listIterator();
                    ListIterator<IntentFilter> listIterator2 = list.listIterator();
                    while (listIterator.hasNext() && listIterator2.hasNext()) {
                        IntentFilter next = listIterator.next();
                        IntentFilter next2 = listIterator2.next();
                        if (next != next2) {
                            if (next != null && next2 != null && (countActions = next.countActions()) == next2.countActions()) {
                                int i11 = 0;
                                while (true) {
                                    if (i11 >= countActions) {
                                        int countCategories = next.countCategories();
                                        if (countCategories == next2.countCategories()) {
                                            for (int i12 = 0; i12 < countCategories; i12++) {
                                                if (next.getCategory(i12).equals(next2.getCategory(i12))) {
                                                }
                                            }
                                        }
                                    } else {
                                        if (!next.getAction(i11).equals(next2.getAction(i11))) {
                                            break;
                                        }
                                        i11++;
                                    }
                                }
                            }
                            z12 = false;
                            if (z12) {
                                break;
                            }
                        }
                        z12 = true;
                        if (z12) {
                        }
                    }
                    if (!listIterator.hasNext()) {
                    }
                }
                z10 = false;
                if (!z10) {
                    this.f37803j.clear();
                    ArrayList<IntentFilter> arrayList2 = this.f37803j;
                    fVar.a();
                    arrayList2.addAll(fVar.f37619c);
                    i10 |= 1;
                }
                if (this.f37804k != fVar.l()) {
                    this.f37804k = fVar.l();
                    i10 |= 1;
                }
                if (this.f37805l != fVar.k()) {
                    this.f37805l = fVar.k();
                    i10 |= 1;
                }
                if (this.f37806m != fVar.e()) {
                    this.f37806m = fVar.e();
                    i10 |= 1;
                }
                if (this.f37807n != fVar.o()) {
                    this.f37807n = fVar.o();
                    i10 |= 3;
                }
                if (this.f37808o != fVar.n()) {
                    this.f37808o = fVar.n();
                    i10 |= 3;
                }
                if (this.f37809p != fVar.p()) {
                    this.f37809p = fVar.p();
                    i10 |= 3;
                }
                if (this.f37810q != fVar.m()) {
                    this.f37810q = fVar.m();
                    i10 |= 5;
                }
                if (!Objects.equals(this.f37811r, fVar.f())) {
                    this.f37811r = fVar.f();
                    i10 |= 1;
                }
                if (!Objects.equals(this.f37812s, (IntentSender) fVar.f37617a.getParcelable("settingsIntent"))) {
                    this.f37812s = (IntentSender) fVar.f37617a.getParcelable("settingsIntent");
                    i10 |= 1;
                }
                if (this.f37802i != fVar.f37617a.getBoolean("canDisconnect", false)) {
                    this.f37802i = fVar.f37617a.getBoolean("canDisconnect", false);
                    i10 |= 5;
                }
                List<String> g10 = fVar.g();
                ArrayList arrayList3 = new ArrayList();
                z11 = g10.size() != this.f37814u.size();
                for (String str : g10) {
                    e eVar = l.f37735d;
                    h hVar = this.f37794a;
                    Objects.requireNonNull(eVar);
                    String str2 = eVar.f37747f.get(new n0.c(hVar.f37792c.f37687a.flattenToShortString(), str));
                    Iterator<i> it = l.f37735d.f37746e.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            iVar = null;
                            break;
                        }
                        iVar = it.next();
                        if (iVar.f37796c.equals(str2)) {
                            break;
                        }
                    }
                    if (iVar != null) {
                        arrayList3.add(iVar);
                        if (!z11 && !this.f37814u.contains(iVar)) {
                            z11 = true;
                        }
                    }
                }
                if (z11) {
                    return i10;
                }
                this.f37814u = arrayList3;
                return i10 | 1;
            }
            z10 = true;
            if (!z10) {
            }
            if (this.f37804k != fVar.l()) {
            }
            if (this.f37805l != fVar.k()) {
            }
            if (this.f37806m != fVar.e()) {
            }
            if (this.f37807n != fVar.o()) {
            }
            if (this.f37808o != fVar.n()) {
            }
            if (this.f37809p != fVar.p()) {
            }
            if (this.f37810q != fVar.m()) {
            }
            if (!Objects.equals(this.f37811r, fVar.f())) {
            }
            if (!Objects.equals(this.f37812s, (IntentSender) fVar.f37617a.getParcelable("settingsIntent"))) {
            }
            if (this.f37802i != fVar.f37617a.getBoolean("canDisconnect", false)) {
            }
            List<String> g102 = fVar.g();
            ArrayList arrayList32 = new ArrayList();
            if (g102.size() != this.f37814u.size()) {
            }
            while (r12.hasNext()) {
            }
            if (z11) {
            }
        }

        public void k(int i10) {
            h.e eVar;
            h.e eVar2;
            l.b();
            e eVar3 = l.f37735d;
            int min = Math.min(this.f37809p, Math.max(0, i10));
            if (this == eVar3.f37758q && (eVar2 = eVar3.f37759r) != null) {
                eVar2.f(min);
            } else {
                if (eVar3.f37762u.isEmpty() || (eVar = eVar3.f37762u.get(this.f37796c)) == null) {
                    return;
                }
                eVar.f(min);
            }
        }

        public void l(int i10) {
            h.e eVar;
            h.e eVar2;
            l.b();
            if (i10 != 0) {
                e eVar3 = l.f37735d;
                if (this == eVar3.f37758q && (eVar2 = eVar3.f37759r) != null) {
                    eVar2.i(i10);
                } else {
                    if (eVar3.f37762u.isEmpty() || (eVar = eVar3.f37762u.get(this.f37796c)) == null) {
                        return;
                    }
                    eVar.i(i10);
                }
            }
        }

        public void m() {
            l.b();
            l.f37735d.k(this, 3);
        }

        public boolean n(String str) {
            l.b();
            int size = this.f37803j.size();
            for (int i10 = 0; i10 < size; i10++) {
                if (this.f37803j.get(i10).hasCategory(str)) {
                    return true;
                }
            }
            return false;
        }

        public void o(Collection<h.b.C0229b> collection) {
            this.f37814u.clear();
            if (this.f37815v == null) {
                this.f37815v = new s.a();
            }
            this.f37815v.clear();
            for (h.b.C0229b c0229b : collection) {
                i a10 = this.f37794a.a(c0229b.f37681a.i());
                if (a10 != null) {
                    this.f37815v.put(a10.f37796c, c0229b);
                    int i10 = c0229b.f37682b;
                    if (i10 == 2 || i10 == 3) {
                        this.f37814u.add(a10);
                    }
                }
            }
            l.f37735d.f37752k.b(259, this);
        }

        public String toString() {
            StringBuilder sb2 = new StringBuilder();
            StringBuilder a10 = android.support.v4.media.b.a("MediaRouter.RouteInfo{ uniqueId=");
            a10.append(this.f37796c);
            a10.append(", name=");
            a10.append(this.f37797d);
            a10.append(", description=");
            a10.append(this.f37798e);
            a10.append(", iconUri=");
            a10.append(this.f37799f);
            a10.append(", enabled=");
            a10.append(this.f37800g);
            a10.append(", connectionState=");
            a10.append(this.f37801h);
            a10.append(", canDisconnect=");
            a10.append(this.f37802i);
            a10.append(", playbackType=");
            a10.append(this.f37804k);
            a10.append(", playbackStream=");
            a10.append(this.f37805l);
            a10.append(", deviceType=");
            a10.append(this.f37806m);
            a10.append(", volumeHandling=");
            a10.append(this.f37807n);
            a10.append(", volume=");
            a10.append(this.f37808o);
            a10.append(", volumeMax=");
            a10.append(this.f37809p);
            a10.append(", presentationDisplayId=");
            a10.append(this.f37810q);
            a10.append(", extras=");
            a10.append(this.f37811r);
            a10.append(", settingsIntent=");
            a10.append(this.f37812s);
            a10.append(", providerPackageName=");
            a10.append(this.f37794a.f37792c.f37687a.getPackageName());
            sb2.append(a10.toString());
            if (f()) {
                sb2.append(", members=[");
                int size = this.f37814u.size();
                for (int i10 = 0; i10 < size; i10++) {
                    if (i10 > 0) {
                        sb2.append(", ");
                    }
                    if (this.f37814u.get(i10) != this) {
                        sb2.append(this.f37814u.get(i10).f37796c);
                    }
                }
                sb2.append(']');
            }
            sb2.append(" }");
            return sb2.toString();
        }
    }

    public l(Context context) {
        this.f37736a = context;
    }

    public static void b() {
        if (Looper.myLooper() != Looper.getMainLooper()) {
            throw new IllegalStateException("The media router service must only be accessed on the application's main thread.");
        }
    }

    public static l d(Context context) {
        if (context == null) {
            throw new IllegalArgumentException("context must not be null");
        }
        b();
        if (f37735d == null) {
            e eVar = new e(context.getApplicationContext());
            f37735d = eVar;
            eVar.a(eVar.f37753l);
            p2.e eVar2 = eVar.f37744c;
            if (eVar2 != null) {
                eVar.a(eVar2);
            }
            i0 i0Var = new i0(eVar.f37742a, eVar);
            if (!i0Var.f37700f) {
                i0Var.f37700f = true;
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
                intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
                intentFilter.addAction("android.intent.action.PACKAGE_CHANGED");
                intentFilter.addAction("android.intent.action.PACKAGE_REPLACED");
                intentFilter.addAction("android.intent.action.PACKAGE_RESTARTED");
                intentFilter.addDataScheme("package");
                i0Var.f37695a.registerReceiver(i0Var.f37701g, intentFilter, null, i0Var.f37697c);
                i0Var.f37697c.post(i0Var.f37702h);
            }
        }
        e eVar3 = f37735d;
        int size = eVar3.f37745d.size();
        while (true) {
            size--;
            if (size < 0) {
                l lVar = new l(context);
                eVar3.f37745d.add(new WeakReference<>(lVar));
                return lVar;
            }
            l lVar2 = eVar3.f37745d.get(size).get();
            if (lVar2 == null) {
                eVar3.f37745d.remove(size);
            } else if (lVar2.f37736a == context) {
                return lVar2;
            }
        }
    }

    public void a(k kVar, b bVar, int i10) {
        c cVar;
        k kVar2;
        if (kVar == null) {
            throw new IllegalArgumentException("selector must not be null");
        }
        if (bVar == null) {
            throw new IllegalArgumentException("callback must not be null");
        }
        b();
        if (f37734c) {
            Log.d("MediaRouter", "addCallback: selector=" + kVar + ", callback=" + bVar + ", flags=" + Integer.toHexString(i10));
        }
        int c10 = c(bVar);
        if (c10 < 0) {
            cVar = new c(this, bVar);
            this.f37737b.add(cVar);
        } else {
            cVar = this.f37737b.get(c10);
        }
        boolean z10 = false;
        boolean z11 = true;
        if (i10 != cVar.f37741d) {
            cVar.f37741d = i10;
            z10 = true;
        }
        k kVar3 = cVar.f37740c;
        Objects.requireNonNull(kVar3);
        kVar3.a();
        kVar.a();
        if (kVar3.f37715b.containsAll(kVar.f37715b)) {
            z11 = z10;
        } else {
            k kVar4 = cVar.f37740c;
            if (kVar4 == null) {
                throw new IllegalArgumentException("selector must not be null");
            }
            kVar4.a();
            ArrayList<String> arrayList = kVar4.f37715b.isEmpty() ? null : new ArrayList<>(kVar4.f37715b);
            kVar.a();
            List<String> list = kVar.f37715b;
            if (list == null) {
                throw new IllegalArgumentException("categories must not be null");
            }
            if (!list.isEmpty()) {
                for (String str : list) {
                    if (str == null) {
                        throw new IllegalArgumentException("category must not be null");
                    }
                    if (arrayList == null) {
                        arrayList = new ArrayList<>();
                    }
                    if (!arrayList.contains(str)) {
                        arrayList.add(str);
                    }
                }
            }
            if (arrayList == null) {
                kVar2 = k.f37713c;
            } else {
                Bundle bundle = new Bundle();
                bundle.putStringArrayList("controlCategories", arrayList);
                kVar2 = new k(bundle, arrayList);
            }
            cVar.f37740c = kVar2;
        }
        if (z11) {
            f37735d.m();
        }
    }

    public final int c(b bVar) {
        int size = this.f37737b.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (this.f37737b.get(i10).f37739b == bVar) {
                return i10;
            }
        }
        return -1;
    }

    public MediaSessionCompat.Token e() {
        e eVar = f37735d;
        e.d dVar = eVar.A;
        if (dVar != null) {
            MediaSessionCompat mediaSessionCompat = dVar.f37773a;
            if (mediaSessionCompat != null) {
                return mediaSessionCompat.b();
            }
            return null;
        }
        MediaSessionCompat mediaSessionCompat2 = eVar.B;
        if (mediaSessionCompat2 != null) {
            return mediaSessionCompat2.b();
        }
        return null;
    }

    public List<i> f() {
        b();
        return f37735d.f37746e;
    }

    public i g() {
        b();
        return f37735d.g();
    }

    public boolean h(k kVar, int i10) {
        if (kVar == null) {
            throw new IllegalArgumentException("selector must not be null");
        }
        b();
        e eVar = f37735d;
        Objects.requireNonNull(eVar);
        if (kVar.c()) {
            return false;
        }
        if ((i10 & 2) != 0 || !eVar.f37754m) {
            int size = eVar.f37746e.size();
            for (int i11 = 0; i11 < size; i11++) {
                i iVar = eVar.f37746e.get(i11);
                if (((i10 & 1) != 0 && iVar.e()) || !iVar.i(kVar)) {
                }
            }
            return false;
        }
        return true;
    }

    public void i(b bVar) {
        if (bVar == null) {
            throw new IllegalArgumentException("callback must not be null");
        }
        b();
        if (f37734c) {
            Log.d("MediaRouter", "removeCallback: callback=" + bVar);
        }
        int c10 = c(bVar);
        if (c10 >= 0) {
            this.f37737b.remove(c10);
            f37735d.m();
        }
    }

    public void j(i iVar) {
        if (iVar == null) {
            throw new IllegalArgumentException("route must not be null");
        }
        b();
        if (f37734c) {
            Log.d("MediaRouter", "selectRoute: " + iVar);
        }
        f37735d.k(iVar, 3);
    }

    public void k(int i10) {
        if (i10 < 0 || i10 > 3) {
            throw new IllegalArgumentException("Unsupported reason to unselect route");
        }
        b();
        i c10 = f37735d.c();
        if (f37735d.g() != c10) {
            f37735d.k(c10, i10);
        }
    }
}