正在查看: Pulsar v1.0.0 应用的 o.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Pulsar v1.0.0 应用的 o.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.reactnativecommunity.webview;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Parcelable;
import android.util.Log;
import android.webkit.MimeTypeMap;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.widget.Toast;
import androidx.annotation.p0;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.util.s;
import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;
public class o implements ActivityEventListener {
public static final String g = "RNCWebViewModule";
public static final int i = 1;
public static final int n = 3;
public static final int s = 1;
protected static final d t = new d();
private final ReactApplicationContext a;
private DownloadManager.Request b;
private ValueCallback<Uri> c;
private ValueCallback<Uri[]> d;
private File e;
private File f;
class a implements PermissionListener {
final String a;
final String b;
a(String str, String str2) {
this.a = str;
this.b = str2;
}
public boolean onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
if (i != 1) {
return false;
}
if (iArr.length <= 0 || iArr[0] != 0) {
Toast.makeText((Context) o.this.a, (CharSequence) this.b, 1).show();
} else if (o.this.b != null) {
o.this.downloadFile(this.a);
}
return true;
}
}
static class b {
static final int[] a;
static {
int[] iArr = new int[c.values().length];
a = iArr;
try {
iArr[c.IMAGE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[c.VIDEO.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
private enum c {
DEFAULT("*/*"),
IMAGE("image"),
VIDEO("video");
private final String a;
c(String str) {
this.a = str;
}
}
protected static class d {
private double a = 1.0d;
private final HashMap<Double, AtomicReference<a>> b = new HashMap<>();
protected enum a {
UNDECIDED,
SHOULD_OVERRIDE,
DO_NOT_OVERRIDE
}
protected d() {
}
@p0
public synchronized AtomicReference<a> getLock(Double d) {
return this.b.get(d);
}
public synchronized s<Double, AtomicReference<a>> getNewLock() {
double d;
AtomicReference<a> atomicReference;
d = this.a;
this.a = 1.0d + d;
atomicReference = new AtomicReference<>(a.UNDECIDED);
this.b.put(Double.valueOf(d), atomicReference);
return new s<>(Double.valueOf(d), atomicReference);
}
public synchronized void removeLock(Double d) {
this.b.remove(d);
}
}
public o(ReactApplicationContext reactApplicationContext) {
this.a = reactApplicationContext;
reactApplicationContext.addActivityEventListener(this);
}
private Boolean c(String str) {
if (str.matches("\\.\\w+")) {
str = k(str.replace(".", ""));
}
return Boolean.valueOf(str.isEmpty() || str.toLowerCase().contains(c.IMAGE.a));
}
private Boolean d(String[] strArr) {
String[] h = h(strArr);
return Boolean.valueOf(g(h, c.DEFAULT.a).booleanValue() || g(h, c.IMAGE.a).booleanValue());
}
private Boolean e(String str) {
if (str.matches("\\.\\w+")) {
str = k(str.replace(".", ""));
}
return Boolean.valueOf(str.isEmpty() || str.toLowerCase().contains(c.VIDEO.a));
}
private Boolean f(String[] strArr) {
String[] h = h(strArr);
return Boolean.valueOf(g(h, c.DEFAULT.a).booleanValue() || g(h, c.VIDEO.a).booleanValue());
}
private Boolean g(String[] strArr, String str) {
for (String str2 : strArr) {
if (str2.contains(str)) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
private String[] h(String[] strArr) {
if (o(strArr).booleanValue()) {
return new String[]{c.DEFAULT.a};
}
String[] strArr2 = new String[strArr.length];
for (int i2 = 0; i2 < strArr.length; i2++) {
String str = strArr[i2];
if (str.matches("\\.\\w+")) {
String k = k(str.replace(".", ""));
if (k != null) {
strArr2[i2] = k;
} else {
strArr2[i2] = str;
}
} else {
strArr2[i2] = str;
}
}
return strArr2;
}
private Intent i(String str) {
String str2 = str.isEmpty() ? c.DEFAULT.a : str;
if (str.matches("\\.\\w+")) {
str2 = k(str.replace(".", ""));
}
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType(str2);
return intent;
}
private Intent j(String[] strArr, boolean z) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType(c.DEFAULT.a);
intent.putExtra("android.intent.extra.MIME_TYPES", h(strArr));
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", z);
return intent;
}
private String k(String str) {
if (str != null) {
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(str);
}
return null;
}
private PermissionAwareActivity l() {
PermissionAwareActivity currentActivity = this.a.getCurrentActivity();
if (currentActivity == null) {
throw new IllegalStateException("Tried to use permissions API while not attached to an Activity.");
}
if (currentActivity instanceof PermissionAwareActivity) {
return currentActivity;
}
throw new IllegalStateException("Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity.");
}
private PermissionListener m(String str, String str2) {
return new a(str, str2);
}
private Boolean o(String[] strArr) {
String str;
boolean z = true;
if (strArr.length != 0 && (strArr.length != 1 || (str = strArr[0]) == null || str.length() != 0)) {
z = false;
}
return Boolean.valueOf(z);
}
public void downloadFile(String str) {
try {
((DownloadManager) this.a.getSystemService("download")).enqueue(this.b);
Toast.makeText((Context) this.a, (CharSequence) str, 1).show();
} catch (IllegalArgumentException | SecurityException e) {
Log.w(g, "Unsupported URI, aborting download", e);
}
}
public File getCapturedFile(c cVar) throws IOException {
String str;
String str2;
int i2 = b.a[cVar.ordinal()];
if (i2 == 1) {
String str3 = Environment.DIRECTORY_PICTURES;
str = "image-";
str2 = ".jpg";
} else if (i2 != 2) {
str = "";
str2 = "";
} else {
String str4 = Environment.DIRECTORY_MOVIES;
str = "video-";
str2 = ".mp4";
}
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(String.valueOf(System.currentTimeMillis()));
sb.append(str2);
return File.createTempFile(str, str2, this.a.getExternalFilesDir(null));
}
public Uri getOutputUri(File file) {
String packageName = this.a.getPackageName();
return FileProvider.getUriForFile(this.a, packageName + ".fileprovider", file);
}
public Intent getPhotoIntent() {
Intent intent;
Throwable e;
Uri outputUri;
try {
File capturedFile = getCapturedFile(c.IMAGE);
this.e = capturedFile;
outputUri = getOutputUri(capturedFile);
intent = new Intent("android.media.action.IMAGE_CAPTURE");
} catch (IOException | IllegalArgumentException e2) {
intent = null;
e = e2;
}
try {
intent.putExtra("output", outputUri);
} catch (IOException e3) {
e = e3;
Log.e("CREATE FILE", "Error occurred while creating the File", e);
e.printStackTrace();
return intent;
} catch (IllegalArgumentException e4) {
e = e4;
Log.e("CREATE FILE", "Error occurred while creating the File", e);
e.printStackTrace();
return intent;
}
return intent;
}
public Uri[] getSelectedFiles(Intent intent, int i2) {
if (intent == null) {
return null;
}
if (intent.getClipData() == null) {
if (intent.getData() == null || i2 != -1) {
return null;
}
return WebChromeClient.FileChooserParams.parseResult(i2, intent);
}
int itemCount = intent.getClipData().getItemCount();
Uri[] uriArr = new Uri[itemCount];
for (int i3 = 0; i3 < itemCount; i3++) {
uriArr[i3] = intent.getClipData().getItemAt(i3).getUri();
}
return uriArr;
}
public Intent getVideoIntent() {
Intent intent;
Throwable e;
Uri outputUri;
try {
File capturedFile = getCapturedFile(c.VIDEO);
this.f = capturedFile;
outputUri = getOutputUri(capturedFile);
intent = new Intent("android.media.action.VIDEO_CAPTURE");
} catch (IOException | IllegalArgumentException e2) {
intent = null;
e = e2;
}
try {
intent.putExtra("output", outputUri);
} catch (IOException e3) {
e = e3;
Log.e("CREATE FILE", "Error occurred while creating the File", e);
e.printStackTrace();
return intent;
} catch (IllegalArgumentException e4) {
e = e4;
Log.e("CREATE FILE", "Error occurred while creating the File", e);
e.printStackTrace();
return intent;
}
return intent;
}
public boolean grantFileDownloaderPermissions(String str, String str2) {
Activity currentActivity = this.a.getCurrentActivity();
if (Build.VERSION.SDK_INT > 28) {
return true;
}
boolean z = ContextCompat.checkSelfPermission(currentActivity, "android.permission.WRITE_EXTERNAL_STORAGE") == 0;
if (!z) {
l().requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1, m(str, str2));
}
return z;
}
public boolean isFileUploadSupported() {
return true;
}
protected boolean n() {
Activity currentActivity = this.a.getCurrentActivity();
try {
if (Arrays.asList(currentActivity.getPackageManager().getPackageInfo(currentActivity.getApplicationContext().getPackageName(), 4096).requestedPermissions).contains("android.permission.CAMERA")) {
if (ContextCompat.checkSelfPermission(currentActivity, "android.permission.CAMERA") != 0) {
return true;
}
}
return false;
} catch (PackageManager.NameNotFoundException unused) {
return true;
}
}
public void onActivityResult(android.app.Activity r7, int r8, int r9, android.content.Intent r10) {
throw new UnsupportedOperationException("Method not decompiled: com.reactnativecommunity.webview.o.onActivityResult(android.app.Activity, int, int, android.content.Intent):void");
}
public void onNewIntent(Intent intent) {
}
public void setDownloadRequest(DownloadManager.Request request) {
this.b = request;
}
public void shouldStartLoadWithLockIdentifier(boolean z, double d2) {
AtomicReference<d.a> lock = t.getLock(Double.valueOf(d2));
if (lock != null) {
synchronized (lock) {
try {
lock.set(z ? d.a.DO_NOT_OVERRIDE : d.a.SHOULD_OVERRIDE);
lock.notify();
} finally {
}
}
}
}
public void startPhotoPickerIntent(String str, ValueCallback<Uri> valueCallback) {
Intent videoIntent;
Intent photoIntent;
this.c = valueCallback;
Activity currentActivity = this.a.getCurrentActivity();
Intent createChooser = Intent.createChooser(i(str), "");
ArrayList arrayList = new ArrayList();
if (c(str).booleanValue() && (photoIntent = getPhotoIntent()) != null) {
arrayList.add(photoIntent);
}
if (e(str).booleanValue() && (videoIntent = getVideoIntent()) != null) {
arrayList.add(videoIntent);
}
createChooser.putExtra("android.intent.extra.INITIAL_INTENTS", (Parcelable[]) arrayList.toArray(new Parcelable[0]));
if (createChooser.resolveActivity(currentActivity.getPackageManager()) != null) {
currentActivity.startActivityForResult(createChooser, 3);
} else {
Log.w(g, "there is no Activity to handle this Intent");
}
}
public boolean startPhotoPickerIntent(String[] strArr, boolean z, ValueCallback<Uri[]> valueCallback, boolean z2) {
String str;
Intent videoIntent;
this.d = valueCallback;
Activity currentActivity = this.a.getCurrentActivity();
ArrayList arrayList = new ArrayList();
Intent intent = null;
if (!n()) {
if (d(strArr).booleanValue() && (intent = getPhotoIntent()) != null) {
arrayList.add(intent);
}
if (f(strArr).booleanValue() && (videoIntent = getVideoIntent()) != null) {
arrayList.add(videoIntent);
}
}
Intent intent2 = new Intent("android.intent.action.CHOOSER");
if (!z2) {
intent2.putExtra("android.intent.extra.INTENT", j(strArr, z));
intent2.putExtra("android.intent.extra.INITIAL_INTENTS", (Parcelable[]) arrayList.toArray(new Parcelable[0]));
intent = intent2;
}
if (intent == null) {
str = "there is no Camera permission";
} else {
if (intent.resolveActivity(currentActivity.getPackageManager()) != null) {
currentActivity.startActivityForResult(intent, 1);
return true;
}
str = "there is no Activity to handle this Intent";
}
Log.w(g, str);
return true;
}
}