package com.benq.platform.test;

import F1.AbstractC0121g;
import F1.AbstractC0125i;
import F1.H;
import F1.I;
import F1.W;
import F1.y0;
import android.net.Uri;
import android.util.Log;
import android.widget.TextView;
import com.benq.platform.AudioRecordController;
import com.benq.platform.BenQApi;
import com.benq.platform.BenqServiceManager;
import com.benq.platform.CameraController;
import com.benq.platform.IBenqRecorderService;
import com.benq.platform.IBenqService;
import com.benq.platform.ICtsStateCallback;
import com.benq.platform.IRecordEventCallback;
import com.benq.platform.NetworkController;
import com.benq.platform.RecorderController;
import com.benq.platform.ScreenControl;
import com.benq.platform.app.App;
import com.benq.platform.test.ApiInvoker;
import com.mstar.android.tv.TvLanguage;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.jvm.internal.v;
import n1.l;
import o1.AbstractC0668d;
import okhttp3.HttpUrl;
import r1.AbstractC0707b;

/* JADX INFO: loaded from: classes.dex */
public final class ApiInvoker {
    public static final ApiInvoker INSTANCE = new ApiInvoker();
    private static final Map<Class<?>, Object> registeredCallbacks = new LinkedHashMap();
    private static final Object UNADAPTABLE = new Object();

    /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$invokeApiMethod$1, reason: invalid class name */
    @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$invokeApiMethod$1", f = "ApiInvoker.kt", l = {TvLanguage.CRIMEANTATAR, 144}, m = "invokeSuspend")
    static final class AnonymousClass1 extends kotlin.coroutines.jvm.internal.l implements y1.p {
        final /* synthetic */ y1.l $callback;
        final /* synthetic */ Method $method;
        final /* synthetic */ String[] $paramStrings;
        int label;

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$invokeApiMethod$1$1, reason: invalid class name and collision with other inner class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$invokeApiMethod$1$1", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class C00631 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ v $result;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C00631(y1.l lVar, v vVar, q1.d dVar) {
                super(2, dVar);
                this.$callback = lVar;
                this.$result = vVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new C00631(this.$callback, this.$result, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((C00631) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                y1.l lVar = this.$callback;
                l.a aVar = n1.l.f5861g;
                lVar.invoke(n1.l.a(n1.l.b(this.$result.f5103b)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$invokeApiMethod$1$2, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$invokeApiMethod$1$2", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass2 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ Exception $e;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass2(y1.l lVar, Exception exc, q1.d dVar) {
                super(2, dVar);
                this.$callback = lVar;
                this.$e = exc;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass2(this.$callback, this.$e, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass2) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                y1.l lVar = this.$callback;
                l.a aVar = n1.l.f5861g;
                lVar.invoke(n1.l.a(n1.l.b(n1.m.a(this.$e))));
                return n1.s.f5871a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        AnonymousClass1(Method method, String[] strArr, y1.l lVar, q1.d dVar) {
            super(2, dVar);
            this.$method = method;
            this.$paramStrings = strArr;
            this.$callback = lVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final q1.d create(Object obj, q1.d dVar) {
            return new AnonymousClass1(this.$method, this.$paramStrings, this.$callback, dVar);
        }

        @Override // y1.p
        public final Object invoke(H h2, q1.d dVar) {
            return ((AnonymousClass1) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            String str;
            String strY;
            Object objD = AbstractC0707b.d();
            int i2 = this.label;
            try {
                if (i2 == 0) {
                    n1.m.b(obj);
                    Class<?> declaringClass = this.$method.getDeclaringClass();
                    Class<?>[] parameterTypes = this.$method.getParameterTypes();
                    kotlin.jvm.internal.l.d(parameterTypes, "getParameterTypes(...)");
                    String[] strArr = this.$paramStrings;
                    ArrayList arrayList = new ArrayList(parameterTypes.length);
                    int length = parameterTypes.length;
                    int i3 = 0;
                    int i4 = 0;
                    while (i3 < length) {
                        Class<?> cls = parameterTypes[i3];
                        int i5 = i4 + 1;
                        ApiInvoker apiInvoker = ApiInvoker.INSTANCE;
                        String str2 = (i4 < 0 || i4 > AbstractC0668d.r(strArr)) ? HttpUrl.FRAGMENT_ENCODE_SET : strArr[i4];
                        kotlin.jvm.internal.l.b(cls);
                        arrayList.add(apiInvoker.convertStringToObject(str2, cls));
                        i3++;
                        i4 = i5;
                    }
                    Object[] array = arrayList.toArray(new Object[0]);
                    v vVar = new v();
                    if (kotlin.jvm.internal.l.a(declaringClass, IBenqRecorderService.class)) {
                        RecorderController recorderController = RecorderController.getInstance();
                        ApiInvoker apiInvoker2 = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(recorderController);
                        String name = this.$method.getName();
                        kotlin.jvm.internal.l.d(name, "getName(...)");
                        n1.o oVarTryInvokeOnController = apiInvoker2.tryInvokeOnController(recorderController, name, array);
                        boolean zBooleanValue = ((Boolean) oVarTryInvokeOnController.a()).booleanValue();
                        Object objB = oVarTryInvokeOnController.b();
                        str = (String) oVarTryInvokeOnController.c();
                        if (zBooleanValue) {
                            vVar.f5103b = objB;
                        } else {
                            IBenqRecorderService recordService = BenqServiceManager.getRecordService();
                            if (recordService == null) {
                                throw new IllegalStateException("Record service not available for method: " + this.$method.getName());
                            }
                            vVar.f5103b = this.$method.invoke(recordService, Arrays.copyOf(array, array.length));
                            str = "com.benq.platform.BenqServiceManager.getRecordService() -> " + this.$method.getName();
                        }
                    } else if (kotlin.jvm.internal.l.a(declaringClass, IBenqService.class)) {
                        BenQApi benQApi = BenQApi.getInstance();
                        ApiInvoker apiInvoker3 = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(benQApi);
                        String name2 = this.$method.getName();
                        kotlin.jvm.internal.l.d(name2, "getName(...)");
                        n1.o oVarTryInvokeOnController2 = apiInvoker3.tryInvokeOnController(benQApi, name2, array);
                        boolean zBooleanValue2 = ((Boolean) oVarTryInvokeOnController2.a()).booleanValue();
                        Object objB2 = oVarTryInvokeOnController2.b();
                        str = (String) oVarTryInvokeOnController2.c();
                        if (zBooleanValue2) {
                            vVar.f5103b = objB2;
                        } else {
                            NetworkController networkController = NetworkController.getInstance();
                            kotlin.jvm.internal.l.b(networkController);
                            String name3 = this.$method.getName();
                            kotlin.jvm.internal.l.d(name3, "getName(...)");
                            n1.o oVarTryInvokeOnController3 = apiInvoker3.tryInvokeOnController(networkController, name3, array);
                            if (((Boolean) oVarTryInvokeOnController3.d()).booleanValue()) {
                                vVar.f5103b = oVarTryInvokeOnController3.e();
                                str = (String) oVarTryInvokeOnController3.f();
                            } else {
                                String name4 = this.$method.getName();
                                kotlin.jvm.internal.l.d(name4, "getName(...)");
                                n1.o oVarTryInvokeOnController4 = apiInvoker3.tryInvokeOnController(ScreenControl.class, name4, array);
                                if (((Boolean) oVarTryInvokeOnController4.d()).booleanValue()) {
                                    vVar.f5103b = oVarTryInvokeOnController4.e();
                                    str = (String) oVarTryInvokeOnController4.f();
                                } else {
                                    IBenqService benqApiService = BenqServiceManager.getBenqApiService();
                                    if (benqApiService == null) {
                                        throw new IllegalStateException("Benq API service not available for method: " + this.$method.getName());
                                    }
                                    vVar.f5103b = this.$method.invoke(benqApiService, Arrays.copyOf(array, array.length));
                                    str = "com.benq.platform.BenqServiceManager.getBenqApiService() -> " + this.$method.getName();
                                }
                            }
                        }
                    } else if (kotlin.jvm.internal.l.a(declaringClass, CameraController.class)) {
                        CameraController cameraController = CameraController.getInstance();
                        ApiInvoker apiInvoker4 = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(cameraController);
                        String name5 = this.$method.getName();
                        kotlin.jvm.internal.l.d(name5, "getName(...)");
                        n1.o oVarTryInvokeOnController5 = apiInvoker4.tryInvokeOnController(cameraController, name5, array);
                        boolean zBooleanValue3 = ((Boolean) oVarTryInvokeOnController5.a()).booleanValue();
                        Object objB3 = oVarTryInvokeOnController5.b();
                        str = (String) oVarTryInvokeOnController5.c();
                        if (!zBooleanValue3) {
                            throw new IllegalStateException("Camera controller method not available: " + this.$method.getName());
                        }
                        vVar.f5103b = objB3;
                    } else if (kotlin.jvm.internal.l.a(declaringClass, AudioRecordController.class)) {
                        AudioRecordController audioRecordController = AudioRecordController.getInstance();
                        ApiInvoker apiInvoker5 = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(audioRecordController);
                        String name6 = this.$method.getName();
                        kotlin.jvm.internal.l.d(name6, "getName(...)");
                        n1.o oVarTryInvokeOnController6 = apiInvoker5.tryInvokeOnController(audioRecordController, name6, array);
                        boolean zBooleanValue4 = ((Boolean) oVarTryInvokeOnController6.a()).booleanValue();
                        Object objB4 = oVarTryInvokeOnController6.b();
                        str = (String) oVarTryInvokeOnController6.c();
                        if (!zBooleanValue4) {
                            throw new IllegalStateException("AudioRecord controller method not available: " + this.$method.getName());
                        }
                        if (kotlin.jvm.internal.l.a(this.$method.getName(), "read")) {
                            if (!(array.length == 0)) {
                                Object obj2 = array[0];
                                if (obj2 instanceof byte[]) {
                                    kotlin.jvm.internal.l.c(obj2, "null cannot be cast to non-null type kotlin.ByteArray");
                                    byte[] bArr = (byte[]) obj2;
                                    Integer num = objB4 instanceof Integer ? (Integer) objB4 : null;
                                    int iIntValue = num != null ? num.intValue() : -1;
                                    int iMin = iIntValue > 0 ? Math.min(iIntValue, 32) : 0;
                                    if (iMin > 0) {
                                        byte[] bArrCopyOf = Arrays.copyOf(bArr, iMin);
                                        kotlin.jvm.internal.l.d(bArrCopyOf, "copyOf(...)");
                                        strY = AbstractC0668d.y(bArrCopyOf, null, "[", "]", 0, null, null, 57, null);
                                    } else {
                                        strY = HttpUrl.PATH_SEGMENT_ENCODE_SET_URI;
                                    }
                                    objB4 = "bytesRead=" + iIntValue + ", bufferPreview=" + strY + ", bufferSize=" + bArr.length;
                                }
                            }
                        }
                        vVar.f5103b = objB4;
                    } else {
                        IBenqService benqApiService2 = kotlin.jvm.internal.l.a(declaringClass, IBenqService.class) ? BenqServiceManager.getBenqApiService() : BenqServiceManager.getRecordService();
                        if (benqApiService2 == null) {
                            throw new IllegalStateException("Service not available for method: " + this.$method.getName());
                        }
                        vVar.f5103b = this.$method.invoke(benqApiService2, Arrays.copyOf(array, array.length));
                        str = declaringClass.getName() + " (binder service)";
                    }
                    Log.d("ApiInvoker", "✅ Invoked: " + str);
                    y0 y0VarC = W.c();
                    C00631 c00631 = new C00631(this.$callback, vVar, null);
                    this.label = 1;
                    if (AbstractC0121g.g(y0VarC, c00631, this) == objD) {
                        return objD;
                    }
                } else {
                    if (i2 != 1 && i2 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    n1.m.b(obj);
                }
            } catch (Exception e2) {
                Log.e("ApiInvoker", "Method invocation failed for " + this.$method.getName(), e2);
                y0 y0VarC2 = W.c();
                AnonymousClass2 anonymousClass2 = new AnonymousClass2(this.$callback, e2, null);
                this.label = 2;
                if (AbstractC0121g.g(y0VarC2, anonymousClass2, this) == objD) {
                    return objD;
                }
            }
            return n1.s.f5871a;
        }
    }

    /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1, reason: invalid class name and case insensitive filesystem */
    @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$registerCallbackMethod$1", f = "ApiInvoker.kt", l = {TvLanguage.KUTENAI, TvLanguage.ERZYA, TvLanguage.NAVAJO, TvLanguage.NIGERKORDOFANIAN}, m = "invokeSuspend")
    static final class C04121 extends kotlin.coroutines.jvm.internal.l implements y1.p {
        final /* synthetic */ y1.l $callback;
        final /* synthetic */ TextView $callbackResultTextView;
        final /* synthetic */ Method $method;
        int label;

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$1, reason: invalid class name and collision with other inner class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$1", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class C00641 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ Method $method;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C00641(TextView textView, Method method, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new C00641(this.$callbackResultTextView, this.$method, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((C00641) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nRegistered callback for " + this.$method.getName() + " via RecorderController");
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$2, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$2", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass2 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ Method $method;
            final /* synthetic */ String $path;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass2(TextView textView, Method method, String str, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$path = str;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass2(this.$callbackResultTextView, this.$method, this.$path, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass2) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nRegistered callback for " + this.$method.getName() + " via " + this.$path);
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$3, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$3", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass3 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ String $fallbackPath;
            final /* synthetic */ Method $method;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass3(TextView textView, Method method, String str, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$fallbackPath = str;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass3(this.$callbackResultTextView, this.$method, this.$fallbackPath, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass3) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nRegistered callback for " + this.$method.getName() + " via binder service (" + this.$fallbackPath + ")");
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$4, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$4", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass4 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ Exception $e;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass4(y1.l lVar, Exception exc, q1.d dVar) {
                super(2, dVar);
                this.$callback = lVar;
                this.$e = exc;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass4(this.$callback, this.$e, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass4) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                y1.l lVar = this.$callback;
                l.a aVar = n1.l.f5861g;
                lVar.invoke(n1.l.a(n1.l.b(n1.m.a(this.$e))));
                return n1.s.f5871a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        C04121(Method method, TextView textView, y1.l lVar, q1.d dVar) {
            super(2, dVar);
            this.$method = method;
            this.$callbackResultTextView = textView;
            this.$callback = lVar;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void invokeSuspend$lambda$0(TextView textView, int i2) {
            AbstractC0125i.d(I.a(W.c()), null, null, new ApiInvoker$registerCallbackMethod$1$listener$1$1(textView, i2, null), 3, null);
            Log.d("ApiInvoker", "IRecordEventCallback: onStateChange(" + i2 + ")");
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final q1.d create(Object obj, q1.d dVar) {
            return new C04121(this.$method, this.$callbackResultTextView, this.$callback, dVar);
        }

        @Override // y1.p
        public final Object invoke(H h2, q1.d dVar) {
            return ((C04121) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            IRecordEventCallback.Stub stub;
            Object objD = AbstractC0707b.d();
            int i2 = this.label;
            try {
                if (i2 == 0) {
                    n1.m.b(obj);
                    Class<?> cls = this.$method.getParameterTypes()[0];
                    if (kotlin.jvm.internal.l.a(cls, IRecordEventCallback.class) && kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), IBenqRecorderService.class)) {
                        final TextView textView = this.$callbackResultTextView;
                        RecorderController.OnRecordingListener onRecordingListener = new RecorderController.OnRecordingListener() { // from class: com.benq.platform.test.a
                            public final void onStateChange(int i3) {
                                ApiInvoker.C04121.invokeSuspend$lambda$0(textView, i3);
                            }
                        };
                        RecorderController.getInstance().addRecordingListener(onRecordingListener);
                        Map map = ApiInvoker.registeredCallbacks;
                        kotlin.jvm.internal.l.b(cls);
                        map.put(cls, onRecordingListener);
                        y0 y0VarC = W.c();
                        C00641 c00641 = new C00641(this.$callbackResultTextView, this.$method, this.$callback, null);
                        this.label = 1;
                        if (AbstractC0121g.g(y0VarC, c00641, this) == objD) {
                            return objD;
                        }
                    } else {
                        if (kotlin.jvm.internal.l.a(cls, IRecordEventCallback.class)) {
                            final TextView textView2 = this.$callbackResultTextView;
                            stub = new IRecordEventCallback.Stub() { // from class: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$callbackStub$1
                                public void onStateChange(int i3) {
                                    AbstractC0125i.d(I.a(W.c()), null, null, new ApiInvoker$registerCallbackMethod$1$callbackStub$1$onStateChange$1(textView2, i3, null), 3, null);
                                    Log.d("ApiInvoker", "IRecordEventCallback: onStateChange(" + i3 + ")");
                                }
                            };
                        } else if (kotlin.jvm.internal.l.a(cls, ICtsStateCallback.class)) {
                            final TextView textView3 = this.$callbackResultTextView;
                            stub = new ICtsStateCallback.Stub() { // from class: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$callbackStub$2
                                public void onStateChange(boolean z2) {
                                    AbstractC0125i.d(I.a(W.c()), null, null, new ApiInvoker$registerCallbackMethod$1$callbackStub$2$onStateChange$1(textView3, z2, null), 3, null);
                                    Log.d("ApiInvoker", "ICtsStateCallback: onStateChange(" + z2 + ")");
                                }
                            };
                        } else {
                            if (!kotlin.jvm.internal.l.a(cls, CameraController.ICameraSelectionCallback.class)) {
                                throw new IllegalArgumentException("Unsupported callback interface: " + cls.getName());
                            }
                            final TextView textView4 = this.$callbackResultTextView;
                            stub = new CameraController.ICameraSelectionCallback() { // from class: com.benq.platform.test.ApiInvoker$registerCallbackMethod$1$callbackStub$3
                                public void onCameraSelectionChanged(String str) {
                                    AbstractC0125i.d(I.a(W.c()), null, null, new ApiInvoker$registerCallbackMethod$1$callbackStub$3$onCameraSelectionChanged$1(textView4, str, null), 3, null);
                                    Log.d("ApiInvoker", "CameraSelectionCallback: onCameraSelectionChanged(" + str + ")");
                                }
                            };
                        }
                        CameraController cameraController = kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), CameraController.class) ? CameraController.getInstance() : BenQApi.getInstance();
                        ApiInvoker apiInvoker = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(cameraController);
                        String name = this.$method.getName();
                        kotlin.jvm.internal.l.d(name, "getName(...)");
                        n1.o oVarTryInvokeOnController = apiInvoker.tryInvokeOnController(cameraController, name, new Object[]{stub});
                        boolean zBooleanValue = ((Boolean) oVarTryInvokeOnController.a()).booleanValue();
                        String str = (String) oVarTryInvokeOnController.c();
                        if (zBooleanValue) {
                            Map map2 = ApiInvoker.registeredCallbacks;
                            kotlin.jvm.internal.l.b(cls);
                            map2.put(cls, stub);
                            Log.d("ApiInvoker", "✅ Registered callback via: " + str);
                            y0 y0VarC2 = W.c();
                            AnonymousClass2 anonymousClass2 = new AnonymousClass2(this.$callbackResultTextView, this.$method, str, this.$callback, null);
                            this.label = 2;
                            if (AbstractC0121g.g(y0VarC2, anonymousClass2, this) == objD) {
                                return objD;
                            }
                        } else {
                            if (kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), CameraController.class)) {
                                throw new IllegalStateException("Camera controller callback registration failed for " + this.$method.getName());
                            }
                            IBenqService benqApiService = kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), IBenqService.class) ? BenqServiceManager.getBenqApiService() : BenqServiceManager.getRecordService();
                            if (benqApiService == null) {
                                throw new IllegalStateException("Service not available for method: " + this.$method.getName());
                            }
                            this.$method.invoke(benqApiService, stub);
                            Map map3 = ApiInvoker.registeredCallbacks;
                            kotlin.jvm.internal.l.b(cls);
                            map3.put(cls, stub);
                            String str2 = "com.benq.platform.BenqServiceManager -> " + this.$method.getName();
                            Log.d("ApiInvoker", "✅ Registered callback via (fallback): " + str2);
                            y0 y0VarC3 = W.c();
                            AnonymousClass3 anonymousClass3 = new AnonymousClass3(this.$callbackResultTextView, this.$method, str2, this.$callback, null);
                            this.label = 3;
                            if (AbstractC0121g.g(y0VarC3, anonymousClass3, this) == objD) {
                                return objD;
                            }
                        }
                    }
                } else {
                    if (i2 != 1 && i2 != 2 && i2 != 3 && i2 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    n1.m.b(obj);
                }
            } catch (Exception e2) {
                Log.e("ApiInvoker", "Callback registration failed for " + this.$method.getName(), e2);
                y0 y0VarC4 = W.c();
                AnonymousClass4 anonymousClass4 = new AnonymousClass4(this.$callback, e2, null);
                this.label = 4;
                if (AbstractC0121g.g(y0VarC4, anonymousClass4, this) == objD) {
                    return objD;
                }
            }
            return n1.s.f5871a;
        }
    }

    /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1, reason: invalid class name and case insensitive filesystem */
    @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1", f = "ApiInvoker.kt", l = {TvLanguage.PALAUAN, TvLanguage.PROVENCALOLD, TvLanguage.SAMINORTHERN, TvLanguage.SANGO, TvLanguage.SELKUP}, m = "invokeSuspend")
    static final class C04131 extends kotlin.coroutines.jvm.internal.l implements y1.p {
        final /* synthetic */ y1.l $callback;
        final /* synthetic */ TextView $callbackResultTextView;
        final /* synthetic */ Method $method;
        int label;

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$1, reason: invalid class name and collision with other inner class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$1", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class C00651 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ Method $method;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C00651(TextView textView, Method method, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new C00651(this.$callbackResultTextView, this.$method, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((C00651) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nUnregistered recorder callback via RecorderController for " + this.$method.getName());
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$2, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$2", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass2 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ Method $method;
            final /* synthetic */ String $path;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass2(TextView textView, Method method, String str, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$path = str;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass2(this.$callbackResultTextView, this.$method, this.$path, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass2) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nUnregistered callback for " + this.$method.getName() + " via " + this.$path);
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$3, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$3", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass3 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ String $fallbackPath;
            final /* synthetic */ Method $method;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass3(TextView textView, Method method, String str, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$fallbackPath = str;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass3(this.$callbackResultTextView, this.$method, this.$fallbackPath, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass3) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nUnregistered callback for " + this.$method.getName() + " via binder service (" + this.$fallbackPath + ")");
                this.$callback.invoke(n1.l.a(n1.l.b(null)));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$4, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$4", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass4 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ TextView $callbackResultTextView;
            final /* synthetic */ Method $method;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass4(TextView textView, Method method, y1.l lVar, q1.d dVar) {
                super(2, dVar);
                this.$callbackResultTextView = textView;
                this.$method = method;
                this.$callback = lVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass4(this.$callbackResultTextView, this.$method, this.$callback, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass4) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                this.$callbackResultTextView.append("\nNo callback registered for " + this.$method.getName());
                y1.l lVar = this.$callback;
                l.a aVar = n1.l.f5861g;
                lVar.invoke(n1.l.a(n1.l.b(n1.m.a(new IllegalStateException("No callback registered")))));
                return n1.s.f5871a;
            }
        }

        /* JADX INFO: renamed from: com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$5, reason: invalid class name */
        @kotlin.coroutines.jvm.internal.f(c = "com.benq.platform.test.ApiInvoker$unregisterCallbackMethod$1$5", f = "ApiInvoker.kt", l = {}, m = "invokeSuspend")
        static final class AnonymousClass5 extends kotlin.coroutines.jvm.internal.l implements y1.p {
            final /* synthetic */ y1.l $callback;
            final /* synthetic */ Exception $e;
            int label;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass5(y1.l lVar, Exception exc, q1.d dVar) {
                super(2, dVar);
                this.$callback = lVar;
                this.$e = exc;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final q1.d create(Object obj, q1.d dVar) {
                return new AnonymousClass5(this.$callback, this.$e, dVar);
            }

            @Override // y1.p
            public final Object invoke(H h2, q1.d dVar) {
                return ((AnonymousClass5) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                AbstractC0707b.d();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                n1.m.b(obj);
                y1.l lVar = this.$callback;
                l.a aVar = n1.l.f5861g;
                lVar.invoke(n1.l.a(n1.l.b(n1.m.a(this.$e))));
                return n1.s.f5871a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        C04131(Method method, TextView textView, y1.l lVar, q1.d dVar) {
            super(2, dVar);
            this.$method = method;
            this.$callbackResultTextView = textView;
            this.$callback = lVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final q1.d create(Object obj, q1.d dVar) {
            return new C04131(this.$method, this.$callbackResultTextView, this.$callback, dVar);
        }

        @Override // y1.p
        public final Object invoke(H h2, q1.d dVar) {
            return ((C04131) create(h2, dVar)).invokeSuspend(n1.s.f5871a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object objD = AbstractC0707b.d();
            int i2 = this.label;
            try {
                if (i2 == 0) {
                    n1.m.b(obj);
                    Class<?> cls = this.$method.getParameterTypes()[0];
                    Object objRemove = ApiInvoker.registeredCallbacks.remove(cls);
                    if (objRemove == null) {
                        y0 y0VarC = W.c();
                        AnonymousClass4 anonymousClass4 = new AnonymousClass4(this.$callbackResultTextView, this.$method, this.$callback, null);
                        this.label = 4;
                        if (AbstractC0121g.g(y0VarC, anonymousClass4, this) == objD) {
                            return objD;
                        }
                    } else if (kotlin.jvm.internal.l.a(cls, IRecordEventCallback.class) && kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), IBenqRecorderService.class)) {
                        RecorderController.getInstance().clearRecordingListeners();
                        y0 y0VarC2 = W.c();
                        C00651 c00651 = new C00651(this.$callbackResultTextView, this.$method, this.$callback, null);
                        this.label = 1;
                        if (AbstractC0121g.g(y0VarC2, c00651, this) == objD) {
                            return objD;
                        }
                    } else {
                        CameraController cameraController = kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), CameraController.class) ? CameraController.getInstance() : BenQApi.getInstance();
                        ApiInvoker apiInvoker = ApiInvoker.INSTANCE;
                        kotlin.jvm.internal.l.b(cameraController);
                        String name = this.$method.getName();
                        kotlin.jvm.internal.l.d(name, "getName(...)");
                        n1.o oVarTryInvokeOnController = apiInvoker.tryInvokeOnController(cameraController, name, new Object[]{objRemove});
                        boolean zBooleanValue = ((Boolean) oVarTryInvokeOnController.a()).booleanValue();
                        String str = (String) oVarTryInvokeOnController.c();
                        if (zBooleanValue) {
                            Log.d("ApiInvoker", "✅ Unregistered callback via: " + str);
                            y0 y0VarC3 = W.c();
                            AnonymousClass2 anonymousClass2 = new AnonymousClass2(this.$callbackResultTextView, this.$method, str, this.$callback, null);
                            this.label = 2;
                            if (AbstractC0121g.g(y0VarC3, anonymousClass2, this) == objD) {
                                return objD;
                            }
                        } else {
                            if (kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), CameraController.class)) {
                                throw new IllegalStateException("Camera controller callback unregistration failed for " + this.$method.getName());
                            }
                            IBenqService benqApiService = kotlin.jvm.internal.l.a(this.$method.getDeclaringClass(), IBenqService.class) ? BenqServiceManager.getBenqApiService() : BenqServiceManager.getRecordService();
                            if (benqApiService == null) {
                                throw new IllegalStateException("Service not available for method: " + this.$method.getName());
                            }
                            this.$method.invoke(benqApiService, objRemove);
                            String str2 = "com.benq.platform.BenqServiceManager -> " + this.$method.getName();
                            Log.d("ApiInvoker", "✅ Unregistered callback via (fallback): " + str2);
                            y0 y0VarC4 = W.c();
                            AnonymousClass3 anonymousClass3 = new AnonymousClass3(this.$callbackResultTextView, this.$method, str2, this.$callback, null);
                            this.label = 3;
                            if (AbstractC0121g.g(y0VarC4, anonymousClass3, this) == objD) {
                                return objD;
                            }
                        }
                    }
                } else {
                    if (i2 != 1 && i2 != 2 && i2 != 3 && i2 != 4 && i2 != 5) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    n1.m.b(obj);
                }
            } catch (Exception e2) {
                Log.e("ApiInvoker", "Callback unregistration failed for " + this.$method.getName(), e2);
                y0 y0VarC5 = W.c();
                AnonymousClass5 anonymousClass5 = new AnonymousClass5(this.$callback, e2, null);
                this.label = 5;
                if (AbstractC0121g.g(y0VarC5, anonymousClass5, this) == objD) {
                    return objD;
                }
            }
            return n1.s.f5871a;
        }
    }

    private ApiInvoker() {
    }

    private final Object adaptParam(Object obj, Class<?> cls) {
        if (obj == null) {
            return null;
        }
        try {
            if (kotlin.jvm.internal.l.a(cls, Uri.class)) {
                if (obj instanceof String) {
                    obj = Uri.parse((String) obj);
                } else if (!(obj instanceof Uri)) {
                    obj = UNADAPTABLE;
                }
            } else if (kotlin.jvm.internal.l.a(cls, String.class)) {
                obj = obj.toString();
            } else {
                Class cls2 = Integer.TYPE;
                if (kotlin.jvm.internal.l.a(cls, cls2) || kotlin.jvm.internal.l.a(cls, cls2)) {
                    obj = Integer.valueOf(((Number) obj).intValue());
                } else {
                    Class cls3 = Long.TYPE;
                    if (kotlin.jvm.internal.l.a(cls, cls3) || kotlin.jvm.internal.l.a(cls, cls3)) {
                        obj = Long.valueOf(((Number) obj).longValue());
                    } else {
                        Class cls4 = Float.TYPE;
                        if (kotlin.jvm.internal.l.a(cls, cls4) || kotlin.jvm.internal.l.a(cls, cls4)) {
                            obj = Float.valueOf(((Number) obj).floatValue());
                        } else {
                            Class cls5 = Double.TYPE;
                            if (kotlin.jvm.internal.l.a(cls, cls5) || kotlin.jvm.internal.l.a(cls, cls5)) {
                                obj = Double.valueOf(((Number) obj).doubleValue());
                            } else {
                                Class cls6 = Boolean.TYPE;
                                if (kotlin.jvm.internal.l.a(cls, cls6) || kotlin.jvm.internal.l.a(cls, cls6)) {
                                    if (!(obj instanceof Boolean)) {
                                        obj = obj instanceof String ? Boolean.valueOf(Boolean.parseBoolean((String) obj)) : UNADAPTABLE;
                                    }
                                } else if (obj instanceof String) {
                                    Object objConvertStringToObject = ParameterConverter.INSTANCE.convertStringToObject((String) obj, cls);
                                    if (objConvertStringToObject != null) {
                                        obj = objConvertStringToObject;
                                    } else if (!cls.isInstance(obj)) {
                                        obj = UNADAPTABLE;
                                    }
                                } else if (!cls.isInstance(obj)) {
                                    obj = UNADAPTABLE;
                                }
                            }
                        }
                    }
                }
            }
            return obj;
        } catch (Exception e2) {
            Log.w("ApiInvoker", "Failed to adapt value to type " + cls.getName(), e2);
            return UNADAPTABLE;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Object convertStringToObject(String str, Class<?> cls) {
        return ParameterConverter.INSTANCE.convertStringToObject(str, cls);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final n1.o tryInvokeOnController(Object obj, String str, Object[] objArr) {
        Class<?> cls;
        try {
            if (obj instanceof Class) {
                kotlin.jvm.internal.l.c(obj, "null cannot be cast to non-null type java.lang.Class<*>");
                cls = (Class) obj;
            } else {
                cls = obj.getClass();
            }
            Method[] methods = cls.getMethods();
            kotlin.jvm.internal.l.d(methods, "getMethods(...)");
            ArrayList<Method> arrayList = new ArrayList();
            for (Method method : methods) {
                if (kotlin.jvm.internal.l.a(method.getName(), str)) {
                    arrayList.add(method);
                }
            }
            for (Method method2 : arrayList) {
                Class<?>[] parameterTypes = method2.getParameterTypes();
                if (parameterTypes.length == objArr.length) {
                    int length = objArr.length;
                    Object[] objArr2 = new Object[length];
                    for (int i2 = 0; i2 < length; i2++) {
                        objArr2[i2] = null;
                    }
                    int length2 = parameterTypes.length;
                    for (int i3 = 0; i3 < length2; i3++) {
                        Class<?> cls2 = parameterTypes[i3];
                        Object obj2 = objArr[i3];
                        kotlin.jvm.internal.l.b(cls2);
                        Object objAdaptParam = adaptParam(obj2, cls2);
                        if (kotlin.jvm.internal.l.a(objAdaptParam, UNADAPTABLE)) {
                            break;
                        }
                        objArr2[i3] = objAdaptParam;
                    }
                    return new n1.o(Boolean.TRUE, obj instanceof Class ? method2.invoke(null, Arrays.copyOf(objArr2, length)) : method2.invoke(obj, Arrays.copyOf(objArr2, length)), cls.getName() + "." + method2.getName());
                }
                kotlin.jvm.internal.l.b(parameterTypes);
                if (!(parameterTypes.length == 0) && kotlin.jvm.internal.l.a(parameterTypes[0].getName(), "android.content.Context") && parameterTypes.length == objArr.length + 1) {
                    int length3 = parameterTypes.length;
                    Object[] objArr3 = new Object[length3];
                    for (int i4 = 0; i4 < length3; i4++) {
                        objArr3[i4] = null;
                    }
                    objArr3[0] = App.Companion.getI();
                    int length4 = parameterTypes.length;
                    for (int i5 = 1; i5 < length4; i5++) {
                        Class<?> cls3 = parameterTypes[i5];
                        Object obj3 = objArr[i5 - 1];
                        kotlin.jvm.internal.l.b(cls3);
                        Object objAdaptParam2 = adaptParam(obj3, cls3);
                        if (kotlin.jvm.internal.l.a(objAdaptParam2, UNADAPTABLE)) {
                            break;
                        }
                        objArr3[i5] = objAdaptParam2;
                    }
                    return new n1.o(Boolean.TRUE, obj instanceof Class ? method2.invoke(null, Arrays.copyOf(objArr3, length3)) : method2.invoke(obj, Arrays.copyOf(objArr3, length3)), cls.getName() + "." + method2.getName());
                }
            }
        } catch (Exception e2) {
            Log.w("ApiInvoker", "Controller invocation failed for " + str, e2);
        }
        return new n1.o(Boolean.FALSE, null, HttpUrl.FRAGMENT_ENCODE_SET);
    }

    public final void invokeApiMethod(Method method, String[] paramStrings, IBenqService iBenqService, IBenqRecorderService iBenqRecorderService, y1.l callback) {
        kotlin.jvm.internal.l.e(method, "method");
        kotlin.jvm.internal.l.e(paramStrings, "paramStrings");
        kotlin.jvm.internal.l.e(callback, "callback");
        AbstractC0125i.d(I.a(W.b()), null, null, new AnonymousClass1(method, paramStrings, callback, null), 3, null);
    }

    public final void registerCallbackMethod(Method method, IBenqService iBenqService, IBenqRecorderService iBenqRecorderService, TextView callbackResultTextView, y1.l callback) {
        kotlin.jvm.internal.l.e(method, "method");
        kotlin.jvm.internal.l.e(callbackResultTextView, "callbackResultTextView");
        kotlin.jvm.internal.l.e(callback, "callback");
        AbstractC0125i.d(I.a(W.b()), null, null, new C04121(method, callbackResultTextView, callback, null), 3, null);
    }

    public final void unregisterCallbackMethod(Method method, IBenqService iBenqService, IBenqRecorderService iBenqRecorderService, TextView callbackResultTextView, y1.l callback) {
        kotlin.jvm.internal.l.e(method, "method");
        kotlin.jvm.internal.l.e(callbackResultTextView, "callbackResultTextView");
        kotlin.jvm.internal.l.e(callback, "callback");
        AbstractC0125i.d(I.a(W.b()), null, null, new C04131(method, callbackResultTextView, callback, null), 3, null);
    }
}
