discord-jadx/app/src/main/java/b/a/d/h.java

378 lines
15 KiB
Java
Raw Normal View History

2021-12-17 21:59:34 +00:00
package b.a.d;
2021-07-24 02:37:17 +00:00
2021-08-13 06:23:11 +00:00
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.appcompat.widget.ActivityChooserModel;
import androidx.core.content.ContextCompat;
import com.discord.R;
import com.discord.app.AppPermissionsRequests;
import com.discord.stores.StoreStream;
import com.discord.utilities.time.ClockFactory;
2021-11-02 06:38:17 +00:00
import d0.z.d.m;
import d0.z.d.o;
2021-08-13 06:23:11 +00:00
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
2021-07-24 02:37:17 +00:00
import kotlin.Unit;
2021-08-13 06:23:11 +00:00
import kotlin.jvm.functions.Function0;
2021-07-24 02:37:17 +00:00
import kotlin.jvm.functions.Function1;
2021-08-13 06:23:11 +00:00
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: AppPermissions.kt */
public final class h implements AppPermissionsRequests {
@Deprecated
2021-12-02 18:53:44 +00:00
public static final HashMap<Integer, String[]> j;
public static final a k = new a(null);
public Function0<Unit> l;
public Function1<? super Map<String, Boolean>, Unit> m;
public long n;
public final ActivityResultLauncher<String[]> o;
public final ComponentActivity p;
2021-08-13 06:23:11 +00:00
/* 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 */ h a;
public b(h hVar) {
this.a = hVar;
}
/* 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)) {
2021-12-02 18:53:44 +00:00
Function1<? super Map<String, Boolean>, Unit> function1 = this.a.m;
2021-08-13 06:23:11 +00:00
if (function1 != null) {
m.checkNotNullExpressionValue(map2, "grantResults");
function1.invoke(map2);
}
} else {
2021-12-02 18:53:44 +00:00
Function0<Unit> function0 = this.a.l;
2021-08-13 06:23:11 +00:00
if (function0 != null) {
2021-11-02 06:38:17 +00:00
function0.mo1invoke();
2021-08-13 06:23:11 +00:00
}
}
h hVar = this.a;
2021-12-02 18:53:44 +00:00
hVar.m = null;
2021-08-13 06:23:11 +00:00
hVar.l = null;
2021-12-02 18:53:44 +00:00
hVar.n = 0;
2021-08-13 06:23:11 +00:00
}
}
/* 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 */ h this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public c(h hVar, Function0 function0) {
super(1);
this.this$0 = hVar;
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;
2021-11-02 06:38:17 +00:00
if (function0 == null || ((Unit) function0.mo1invoke()) == null) {
2021-08-13 06:23:11 +00:00
h.a(this.this$0, R.string.permission_qr_scanner_denied);
}
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");
2021-11-02 06:38:17 +00:00
this.$onFailure.mo1invoke();
2021-08-13 06:23:11 +00:00
return Unit.a;
}
}
/* compiled from: AppPermissions.kt */
public static final class e extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
public final /* synthetic */ h this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public e(h hVar) {
super(1);
this.this$0 = hVar;
}
/* 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");
h.a(this.this$0, R.string.permission_media_denied);
return Unit.a;
}
}
/* compiled from: AppPermissions.kt */
public static final class f extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
public final /* synthetic */ h this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public f(h hVar) {
super(1);
this.this$0 = hVar;
}
/* 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");
h.a(this.this$0, R.string.permission_media_download_denied);
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 */
2021-11-02 06:38:17 +00:00
public Unit mo1invoke() {
2021-08-13 06:23:11 +00:00
if (!this.$hadPermissions) {
StoreStream.Companion.getMediaEngine().handleMicrophonePermissionGranted();
}
StoreStream.Companion.getMediaEngine().setAudioInputEnabled(true);
2021-11-02 06:38:17 +00:00
this.$onSuccess.mo1invoke();
2021-08-13 06:23:11 +00:00
return Unit.a;
}
}
/* compiled from: AppPermissions.kt */
2021-12-17 21:59:34 +00:00
/* renamed from: b.a.d.h$h reason: collision with other inner class name */
2022-02-02 08:50:56 +00:00
public static final class C0022h extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
2021-08-13 06:23:11 +00:00
public final /* synthetic */ Function0 $onFailure;
public final /* synthetic */ h this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
2022-02-02 08:50:56 +00:00
public C0022h(h hVar, Function0 function0) {
2021-08-13 06:23:11 +00:00
super(1);
this.this$0 = hVar;
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;
2021-11-02 06:38:17 +00:00
if (function0 == null || ((Unit) function0.mo1invoke()) == null) {
2021-08-13 06:23:11 +00:00
h.a(this.this$0, R.string.permission_microphone_denied);
}
return Unit.a;
}
}
/* compiled from: AppPermissions.kt */
public static final class i extends o implements Function1<Map<String, ? extends Boolean>, Unit> {
public final /* synthetic */ h this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public i(h hVar) {
super(1);
this.this$0 = hVar;
}
/* 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()) {
h.a(this.this$0, R.string.permission_microphone_denied);
} else {
Object obj2 = map2.get("android.permission.CAMERA");
if (obj2 == null) {
obj2 = Boolean.FALSE;
}
if (!((Boolean) obj2).booleanValue()) {
h.a(this.this$0, R.string.no_camera_access);
} else {
h.a(this.this$0, R.string.no_camera_access);
}
}
return Unit.a;
}
}
static {
HashMap<Integer, String[]> hashMap = new HashMap<>();
2021-12-02 18:53:44 +00:00
j = hashMap;
2021-08-13 06:23:11 +00:00
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 h(ComponentActivity componentActivity) {
m.checkNotNullParameter(componentActivity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
2021-12-02 18:53:44 +00:00
this.p = componentActivity;
2021-08-13 06:23:11 +00:00
ActivityResultLauncher<String[]> registerForActivityResult = componentActivity.registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new b(this));
m.checkNotNullExpressionValue(registerForActivityResult, "activity.registerForActi…rtTimeMillis = 0L\n }");
2021-12-02 18:53:44 +00:00
this.o = registerForActivityResult;
2021-08-13 06:23:11 +00:00
}
public static final void a(h hVar, int i2) {
2021-12-02 18:53:44 +00:00
m.g(hVar.p, i2, 0, null, 12);
2021-08-13 06:23:11 +00:00
}
public final boolean b(int i2) {
2021-12-02 18:53:44 +00:00
String[] strArr = j.get(Integer.valueOf(i2));
2021-08-13 06:23:11 +00:00
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++;
}
}
2021-12-02 18:53:44 +00:00
if (ContextCompat.checkSelfPermission(this.p, str) != 0) {
2021-08-13 06:23:11 +00:00
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) {
2021-12-02 18:53:44 +00:00
String[] strArr = j.get(Integer.valueOf(i2));
2021-08-13 06:23:11 +00:00
if (strArr != null) {
m.checkNotNullExpressionValue(strArr, "PERMISSION_GROUPS[requestCode] ?: return");
if (b(i2)) {
2021-11-02 06:38:17 +00:00
function0.mo1invoke();
2021-08-13 06:23:11 +00:00
return;
}
2021-12-02 18:53:44 +00:00
if (!(ClockFactory.get().currentTimeMillis() - this.n < 350)) {
this.l = function0;
this.m = function1;
this.n = ClockFactory.get().currentTimeMillis();
this.o.launch(strArr);
2021-08-13 06:23:11 +00:00
}
}
}
@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");
2022-02-02 08:50:56 +00:00
c(211, new g(b(211), function02), new C0022h(this, function0));
2021-08-13 06:23:11 +00:00
}
@Override // com.discord.app.AppPermissionsRequests
@MainThread
public void requestVideoCallPermissions(Function0<Unit> function0) {
m.checkNotNullParameter(function0, "onSuccess");
c(210, function0, new i(this));
2021-07-24 02:37:17 +00:00
}
}