package permissions.dispatcher.ktx; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import androidx.fragment.app.Fragment; import java.util.Arrays; import java.util.Random; import o.AbstractC13482fbE; import o.C14875gap; import o.C14957gcv; import o.C15581guh; import o.C15589gup; import o.VKL; import o.VLM; import o.gur; import o.yRS; /* loaded from: classes6.dex */ public abstract class PermissionRequestFragment extends Fragment { private final int c; private C15589gup e; private PermissionRequestFragment() { this.c = new Random().nextInt(1000); } protected final C15589gup a() { C15589gup c15589gup = this.e; if (c15589gup != null) { return c15589gup; } C14957gcv.a(""); throw null; } @Override // androidx.fragment.app.Fragment public void onAttach(Context context) { super.onAttach(context); setRetainInstance(true); VKL b = new VLM(requireActivity()).b(C15589gup.class); C14957gcv.c(b, ""); C15589gup c15589gup = (C15589gup) b; C14957gcv.e(c15589gup, ""); this.e = c15589gup; } protected final Integer d() { AbstractC13482fbE e; yRS fragmentManager = getFragmentManager(); if (fragmentManager == null || (e = fragmentManager.a().e(this)) == null) { return null; } return Integer.valueOf(e.a()); } /* loaded from: classes6.dex */ public static final class NormalRequestPermissionFragment extends PermissionRequestFragment { public static final IeS b = new IeS(0); public NormalRequestPermissionFragment() { super((byte) 0); } @Override // androidx.fragment.app.Fragment public final void onCreate(Bundle bundle) { super.onCreate(bundle); Bundle arguments = getArguments(); String[] stringArray = arguments == null ? null : arguments.getStringArray("key:permissions"); if (stringArray == null) { return; } requestPermissions(stringArray, e()); } @Override // androidx.fragment.app.Fragment public final void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) { C14957gcv.e(strArr, ""); C14957gcv.e(iArr, ""); super.onRequestPermissionsResult(i, strArr, iArr); if (i == e()) { String arrays = Arrays.toString(C14875gap.a(strArr)); C14957gcv.c((Object) arrays, ""); if (C15581guh.d(Arrays.copyOf(iArr, iArr.length))) { a().c(arrays, gur.GRANTED); } else if (!C15581guh.e(this, (String[]) Arrays.copyOf(strArr, strArr.length))) { a().c(arrays, gur.DENIED_AND_DISABLED); } else { a().c(arrays, gur.DENIED); } } d(); } /* loaded from: classes6.dex */ public static final class IeS { private IeS() { } public /* synthetic */ IeS(byte b) { this(); } } } /* loaded from: classes6.dex */ public static final class SpecialRequestPermissionFragment extends PermissionRequestFragment { private String c; public SpecialRequestPermissionFragment() { super((byte) 0); } @Override // androidx.fragment.app.Fragment public final void onCreate(Bundle bundle) { super.onCreate(bundle); Bundle arguments = getArguments(); String string = arguments == null ? null : arguments.getString("key:action"); if (string == null) { return; } this.c = string; Context context = getContext(); String packageName = context == null ? null : context.getPackageName(); if (packageName == null) { return; } Uri parse = Uri.parse(C14957gcv.c("package:", (Object) packageName)); String str = this.c; if (str != null) { startActivityForResult(new Intent(str, parse), e()); } else { C14957gcv.a(""); throw null; } } @Override // androidx.fragment.app.Fragment public final void onActivityResult(int i, int i2, Intent intent) { if (i == e()) { try { if (((Boolean) Class.forName("android.provider.Settings").getMethod("canDrawOverlays", Context.class).invoke(null, getActivity())).booleanValue()) { C15589gup a = a(); String str = this.c; if (str == null) { C14957gcv.a(""); throw null; } a.c(str, gur.GRANTED); } else { C15589gup a2 = a(); String str2 = this.c; if (str2 == null) { C14957gcv.a(""); throw null; } a2.c(str2, gur.DENIED); } } catch (Throwable th) { Throwable cause = th.getCause(); if (cause == null) { throw th; } throw cause; } } d(); } /* loaded from: classes6.dex */ public static final class IeS { private IeS() { } public /* synthetic */ IeS(byte b) { this(); } } static { new IeS((byte) 0); } } protected final int e() { return this.c; } public /* synthetic */ PermissionRequestFragment(byte b) { this(); } }