375 lines
14 KiB
Java
375 lines
14 KiB
Java
package c.a.d;
|
|
|
|
import android.os.Build;
|
|
import androidx.activity.ComponentActivity;
|
|
import androidx.activity.result.ActivityResultCallback;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.core.content.ContextCompat;
|
|
import com.discord.app.AppPermissionsRequests;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: AppPermissions.kt */
|
|
public final class j implements AppPermissionsRequests {
|
|
@Deprecated
|
|
public static final HashMap<Integer, String[]> i;
|
|
public static final a j = new a(null);
|
|
public Function0<Unit> k;
|
|
public Function1<? super Map<String, Boolean>, Unit> l;
|
|
public long m;
|
|
public final ActivityResultLauncher<String[]> n;
|
|
public final ComponentActivity o;
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class b<O> implements ActivityResultCallback<Map<String, Boolean>> {
|
|
public final /* synthetic */ j a;
|
|
|
|
public b(j jVar) {
|
|
this.a = jVar;
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // androidx.activity.result.ActivityResultCallback
|
|
public void onActivityResult(Map<String, Boolean> map) {
|
|
Map<String, Boolean> map2 = map;
|
|
if (map2.containsValue(Boolean.FALSE)) {
|
|
Function1<? super Map<String, Boolean>, Unit> function1 = this.a.l;
|
|
if (function1 != null) {
|
|
m.checkNotNullExpressionValue(map2, "grantResults");
|
|
function1.invoke(map2);
|
|
}
|
|
} else {
|
|
Function0<Unit> function0 = this.a.k;
|
|
if (function0 != null) {
|
|
function0.mo1invoke();
|
|
}
|
|
}
|
|
j jVar = this.a;
|
|
jVar.l = null;
|
|
jVar.k = null;
|
|
jVar.m = 0;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class c extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ Function0 $onFailure;
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(j jVar, Function0 function0) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
this.$onFailure = function0;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
m.checkNotNullParameter(map, "it");
|
|
Function0 function0 = this.$onFailure;
|
|
if (function0 == null || ((Unit) function0.mo1invoke()) == null) {
|
|
j.a(this.this$0, 2131891860);
|
|
}
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class d extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ Function0 $onFailure;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public d(Function0 function0) {
|
|
super(1);
|
|
this.$onFailure = function0;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
m.checkNotNullParameter(map, "it");
|
|
this.$onFailure.mo1invoke();
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class e extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public e(j jVar) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
m.checkNotNullParameter(map, "it");
|
|
j.a(this.this$0, 2131891853);
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class f extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public f(j jVar) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
m.checkNotNullParameter(map, "it");
|
|
j.a(this.this$0, 2131891854);
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class g extends o implements Function0<Unit> {
|
|
public final /* synthetic */ boolean $hadPermissions;
|
|
public final /* synthetic */ Function0 $onSuccess;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public g(boolean z2, Function0 function0) {
|
|
super(0);
|
|
this.$hadPermissions = z2;
|
|
this.$onSuccess = function0;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public Unit mo1invoke() {
|
|
if (!this.$hadPermissions) {
|
|
StoreStream.Companion.getMediaEngine().handleMicrophonePermissionGranted();
|
|
}
|
|
StoreStream.Companion.getMediaEngine().setAudioInputEnabled(true);
|
|
this.$onSuccess.mo1invoke();
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class h extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ Function0 $onFailure;
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public h(j jVar, Function0 function0) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
this.$onFailure = function0;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
m.checkNotNullParameter(map, "it");
|
|
Function0 function0 = this.$onFailure;
|
|
if (function0 == null || ((Unit) function0.mo1invoke()) == null) {
|
|
j.a(this.this$0, 2131891855);
|
|
}
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: AppPermissions.kt */
|
|
public static final class i extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public i(j jVar) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Map<String, ? extends Boolean> map) {
|
|
Map<String, ? extends Boolean> map2 = map;
|
|
m.checkNotNullParameter(map2, "grantResults");
|
|
Object obj = map2.get("android.permission.RECORD_AUDIO");
|
|
if (obj == null) {
|
|
obj = Boolean.FALSE;
|
|
}
|
|
if (!((Boolean) obj).booleanValue()) {
|
|
j.a(this.this$0, 2131891855);
|
|
} else {
|
|
Object obj2 = map2.get("android.permission.CAMERA");
|
|
if (obj2 == null) {
|
|
obj2 = Boolean.FALSE;
|
|
}
|
|
if (!((Boolean) obj2).booleanValue()) {
|
|
j.a(this.this$0, 2131891373);
|
|
} else {
|
|
j.a(this.this$0, 2131891373);
|
|
}
|
|
}
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
static {
|
|
HashMap<Integer, String[]> hashMap = new HashMap<>();
|
|
i = hashMap;
|
|
hashMap.put(211, new String[]{"android.permission.RECORD_AUDIO"});
|
|
hashMap.put(210, new String[]{"android.permission.RECORD_AUDIO", "android.permission.CAMERA"});
|
|
hashMap.put(222, new String[]{"android.permission.CAMERA", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"});
|
|
hashMap.put(213, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"});
|
|
hashMap.put(214, new String[]{"android.permission.CAMERA"});
|
|
hashMap.put(215, new String[]{"android.permission.READ_CONTACTS"});
|
|
}
|
|
|
|
public j(ComponentActivity componentActivity) {
|
|
m.checkNotNullParameter(componentActivity, "activity");
|
|
this.o = componentActivity;
|
|
ActivityResultLauncher<String[]> registerForActivityResult = componentActivity.registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new b(this));
|
|
m.checkNotNullExpressionValue(registerForActivityResult, "activity.registerForActi…rtTimeMillis = 0L\n }");
|
|
this.n = registerForActivityResult;
|
|
}
|
|
|
|
public static final void a(j jVar, int i2) {
|
|
o.g(jVar.o, i2, 0, null, 12);
|
|
}
|
|
|
|
public final boolean b(int i2) {
|
|
String[] strArr = i.get(Integer.valueOf(i2));
|
|
if (strArr == null) {
|
|
return false;
|
|
}
|
|
m.checkNotNullExpressionValue(strArr, "PERMISSION_GROUPS[requestCode] ?: return false");
|
|
ArrayList<Boolean> arrayList = new ArrayList(strArr.length);
|
|
int length = strArr.length;
|
|
int i3 = 0;
|
|
while (true) {
|
|
boolean z2 = true;
|
|
if (i3 >= length) {
|
|
break;
|
|
}
|
|
String str = strArr[i3];
|
|
if (m.areEqual(str, "android.permission.WRITE_EXTERNAL_STORAGE")) {
|
|
if (!(Build.VERSION.SDK_INT < 29)) {
|
|
arrayList.add(Boolean.valueOf(z2));
|
|
i3++;
|
|
}
|
|
}
|
|
if (ContextCompat.checkSelfPermission(this.o, str) != 0) {
|
|
z2 = false;
|
|
}
|
|
arrayList.add(Boolean.valueOf(z2));
|
|
i3++;
|
|
}
|
|
if (!arrayList.isEmpty()) {
|
|
for (Boolean bool : arrayList) {
|
|
if (!bool.booleanValue()) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final void c(int i2, Function0<Unit> function0, Function1<? super Map<String, Boolean>, Unit> function1) {
|
|
String[] strArr = i.get(Integer.valueOf(i2));
|
|
if (strArr != null) {
|
|
m.checkNotNullExpressionValue(strArr, "PERMISSION_GROUPS[requestCode] ?: return");
|
|
if (b(i2)) {
|
|
function0.mo1invoke();
|
|
return;
|
|
}
|
|
if (!(ClockFactory.get().currentTimeMillis() - this.m < 350)) {
|
|
this.k = function0;
|
|
this.l = function1;
|
|
this.m = ClockFactory.get().currentTimeMillis();
|
|
this.n.launch(strArr);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public boolean hasMedia() {
|
|
return b(222);
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestCameraQRScanner(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
requestCameraQRScanner(function0, null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestCameraQRScanner(Function0<Unit> function0, Function0<Unit> function02) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
c(214, function0, new c(this, function02));
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestContacts(Function0<Unit> function0, Function0<Unit> function02) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
m.checkNotNullParameter(function02, "onFailure");
|
|
c(215, function0, new d(function02));
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestMedia(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
c(222, function0, new e(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestMediaDownload(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
c(213, function0, new f(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestMicrophone(Function0<Unit> function0, Function0<Unit> function02) {
|
|
m.checkNotNullParameter(function02, "onSuccess");
|
|
c(211, new g(b(211), function02), new h(this, function0));
|
|
}
|
|
|
|
@Override // com.discord.app.AppPermissionsRequests
|
|
@MainThread
|
|
public void requestVideoCallPermissions(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "onSuccess");
|
|
c(210, function0, new i(this));
|
|
}
|
|
}
|