package com.baseflow.permissionhandler;

import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import dd.a0;
import ed.q;
import ed.s;
import ed.t;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class b implements s {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f5536a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final com.google.android.material.shape.f f5537b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final e f5538c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final com.google.android.material.shape.f f5539d;

    public b(Context context, com.google.android.material.shape.f fVar, e eVar, com.google.android.material.shape.f fVar2) {
        this.f5536a = context;
        this.f5537b = fVar;
        this.f5538c = eVar;
        this.f5539d = fVar2;
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v0 */
    /* JADX WARN: Type inference failed for: r6v1 */
    /* JADX WARN: Type inference failed for: r6v2, types: [int] */
    /* JADX WARN: Type inference failed for: r6v4 */
    /* JADX WARN: Type inference failed for: r6v5 */
    /* JADX WARN: Type inference failed for: r7v2, types: [com.baseflow.permissionhandler.a] */
    @Override // ed.s
    public final void onMethodCall(q qVar, t tVar) {
        String str = qVar.f25842a;
        str.getClass();
        ?? IsLocationEnabled = 0;
        IsLocationEnabled = 0;
        byte b10 = -1;
        switch (str.hashCode()) {
            case -1544053025:
                if (str.equals("checkServiceStatus")) {
                    b10 = 0;
                }
                break;
            case -1017315255:
                if (str.equals("shouldShowRequestPermissionRationale")) {
                    b10 = 1;
                }
                break;
            case -576207927:
                if (str.equals("checkPermissionStatus")) {
                    b10 = 2;
                }
                break;
            case 347240634:
                if (str.equals("openAppSettings")) {
                    b10 = 3;
                }
                break;
            case 1669188213:
                if (str.equals("requestPermissions")) {
                    b10 = 4;
                }
                break;
        }
        Context context = this.f5536a;
        Object obj = qVar.f25843b;
        if (b10 != 0) {
            e eVar = this.f5538c;
            if (b10 == 1) {
                a0 a0Var = (a0) tVar;
                eVar.f(Integer.parseInt(obj.toString()), new a(5, a0Var), new a(6, a0Var));
                return;
            }
            if (b10 == 2) {
                new a(2, (a0) tVar).b(eVar.b(Integer.parseInt(obj.toString())));
                return;
            }
            if (b10 != 3) {
                if (b10 != 4) {
                    ((a0) tVar).notImplemented();
                    return;
                } else {
                    a0 a0Var2 = (a0) tVar;
                    eVar.e((List) qVar.arguments(), new a(3, a0Var2), new a(4, a0Var2));
                    return;
                }
            }
            a0 a0Var3 = (a0) tVar;
            a aVar = new a(7, a0Var3);
            a aVar2 = new a(8, a0Var3);
            this.f5537b.getClass();
            if (context == null) {
                aVar2.a("PermissionHandler.AppSettingsManager", "Android context cannot be null.");
                return;
            }
            try {
                Intent intent = new Intent();
                intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                intent.addCategory("android.intent.category.DEFAULT");
                intent.setData(Uri.parse("package:" + context.getPackageName()));
                intent.addFlags(268435456);
                intent.addFlags(1073741824);
                intent.addFlags(8388608);
                context.startActivity(intent);
                aVar.c(true);
                return;
            } catch (Exception unused) {
                aVar.c(false);
                return;
            }
        }
        int i10 = Integer.parseInt(obj.toString());
        a0 a0Var4 = (a0) tVar;
        ?? aVar3 = new a(0, a0Var4);
        a aVar4 = new a(1, a0Var4);
        this.f5539d.getClass();
        if (context == null) {
            aVar4.a("PermissionHandler.ServiceManager", "Android context cannot be null.");
            return;
        }
        if (i10 == 3 || i10 == 4 || i10 == 5) {
            if (Build.VERSION.SDK_INT >= 28) {
                LocationManager locationManager = (LocationManager) context.getSystemService(LocationManager.class);
                if (locationManager != null) {
                    IsLocationEnabled = locationManager.isLocationEnabled();
                }
            } else {
                try {
                    IsLocationEnabled = Settings.Secure.getInt(context.getContentResolver(), "location_mode") != 0;
                } catch (Settings.SettingNotFoundException e10) {
                    e10.printStackTrace();
                }
            }
            aVar3.b(IsLocationEnabled);
            return;
        }
        if (i10 == 21) {
            aVar3.b(((BluetoothManager) context.getSystemService("bluetooth")).getAdapter().isEnabled() ? 1 : 0);
            return;
        }
        if (i10 != 8) {
            if (i10 == 16) {
                aVar3.b(1);
                return;
            } else {
                aVar3.b(2);
                return;
            }
        }
        PackageManager packageManager = context.getPackageManager();
        if (!packageManager.hasSystemFeature("android.hardware.telephony")) {
            aVar3.b(2);
            return;
        }
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        if (telephonyManager == null || telephonyManager.getPhoneType() == 0) {
            aVar3.b(2);
            return;
        }
        Intent intent2 = new Intent("android.intent.action.CALL");
        intent2.setData(Uri.parse("tel:123123"));
        if ((Build.VERSION.SDK_INT >= 33 ? packageManager.queryIntentActivities(intent2, PackageManager.ResolveInfoFlags.of(0L)) : packageManager.queryIntentActivities(intent2, 0)).isEmpty()) {
            aVar3.b(2);
        } else if (telephonyManager.getSimState() != 5) {
            aVar3.b(0);
        } else {
            aVar3.b(1);
        }
    }
}
