197 lines
8.0 KiB
Java
197 lines
8.0 KiB
Java
package o;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageItemInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Point;
|
|
import android.media.MediaScannerConnection;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Environment;
|
|
import android.view.WindowManager;
|
|
import com.huawei.hms.support.api.entity.common.CommonConstant;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import o.cXH;
|
|
|
|
/* renamed from: o.cXO, reason: case insensitive filesystem */
|
|
/* loaded from: classes4.dex */
|
|
public final class C6582cXO {
|
|
public static Uri VN_(Bitmap bitmap, String str, Context context) throws IOException {
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
return VM_(context.getContentResolver(), bitmap, str, context);
|
|
}
|
|
File file = new File(Environment.getExternalStorageDirectory(), b(context));
|
|
if (!file.exists()) {
|
|
guQ.c("%s created %s", file.getAbsolutePath(), Boolean.valueOf(file.mkdir()));
|
|
}
|
|
((WindowManager) context.getSystemService("window")).getDefaultDisplay().getSize(new Point());
|
|
if (str != null) {
|
|
str = str.replace(":", ".");
|
|
}
|
|
File file2 = new File(file, str);
|
|
if (!file2.exists()) {
|
|
FileOutputStream fileOutputStream = new FileOutputStream(file2, false);
|
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fileOutputStream);
|
|
fileOutputStream.close();
|
|
}
|
|
bitmap.recycle();
|
|
Uri fromFile = Uri.fromFile(file2);
|
|
Uri uriForFile = C9257dgM.getUriForFile(context, cXH.RVV.e, file2);
|
|
VP_(context, fromFile);
|
|
return uriForFile;
|
|
}
|
|
|
|
public static boolean a(String str, Context context) {
|
|
File file;
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
file = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), b(context));
|
|
} else {
|
|
file = new File(Environment.getExternalStorageDirectory(), b(context));
|
|
}
|
|
try {
|
|
if (!file.exists()) {
|
|
return false;
|
|
}
|
|
if (str != null) {
|
|
str = str.replace(":", ".");
|
|
}
|
|
File file2 = new File(file, str);
|
|
if (file2.exists()) {
|
|
return file2.delete();
|
|
}
|
|
return false;
|
|
} catch (SecurityException e) {
|
|
guQ.e(e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static Uri VO_(Bitmap bitmap, Context context, String str) throws IOException {
|
|
File file = new File(context.getFilesDir(), "images");
|
|
if (!file.exists()) {
|
|
guQ.c("%s created %s", file.getAbsolutePath(), Boolean.valueOf(file.mkdir()));
|
|
}
|
|
((WindowManager) context.getSystemService("window")).getDefaultDisplay().getSize(new Point());
|
|
if (str != null) {
|
|
str = str.replace(":", ".");
|
|
}
|
|
File file2 = new File(file, str);
|
|
FileOutputStream fileOutputStream = new FileOutputStream(file2, false);
|
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fileOutputStream);
|
|
fileOutputStream.close();
|
|
bitmap.recycle();
|
|
Uri uriForFile = C9257dgM.getUriForFile(context, cXH.RVV.b, file2);
|
|
context.grantUriPermission("com.scb.phone.domain", uriForFile, 1);
|
|
VP_(context, uriForFile);
|
|
return uriForFile;
|
|
}
|
|
|
|
public static String b(Context context) {
|
|
ApplicationInfo applicationInfo;
|
|
PackageManager packageManager = context.getPackageManager();
|
|
try {
|
|
applicationInfo = packageManager.getApplicationInfo((String) PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(context.getApplicationInfo()), 0);
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
guQ.a(e);
|
|
applicationInfo = null;
|
|
}
|
|
return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown");
|
|
}
|
|
|
|
private static void VP_(Context context, Uri uri) {
|
|
MediaScannerConnection.scanFile(context, new String[]{uri != null ? uri.getPath() : ""}, null, new MediaScannerConnection.OnScanCompletedListener() { // from class: o.cXN
|
|
@Override // android.media.MediaScannerConnection.OnScanCompletedListener
|
|
public final void onScanCompleted(String str, Uri uri2) {
|
|
guQ.e("media scan succeed", new Object[0]);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:9:0x008f */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static android.net.Uri VM_(android.content.ContentResolver r4, android.graphics.Bitmap r5, java.lang.String r6, android.content.Context r7) {
|
|
/*
|
|
if (r6 == 0) goto La
|
|
java.lang.String r0 = ":"
|
|
java.lang.String r1 = "."
|
|
java.lang.String r6 = r6.replace(r0, r1)
|
|
La:
|
|
java.lang.String r0 = b(r7)
|
|
android.content.ContentValues r1 = new android.content.ContentValues
|
|
r1.<init>()
|
|
java.lang.StringBuilder r2 = new java.lang.StringBuilder
|
|
r2.<init>()
|
|
java.lang.String r3 = android.os.Environment.DIRECTORY_PICTURES
|
|
r2.append(r3)
|
|
java.lang.String r3 = java.io.File.separator
|
|
r2.append(r3)
|
|
r2.append(r0)
|
|
java.lang.String r0 = r2.toString()
|
|
java.lang.String r2 = "relative_path"
|
|
r1.put(r2, r0)
|
|
java.lang.String r0 = "title"
|
|
r1.put(r0, r6)
|
|
java.lang.String r0 = "_display_name"
|
|
r1.put(r0, r6)
|
|
java.lang.String r6 = "mime_type"
|
|
java.lang.String r0 = "image/jpeg"
|
|
r1.put(r6, r0)
|
|
long r2 = java.lang.System.currentTimeMillis()
|
|
java.lang.Long r6 = java.lang.Long.valueOf(r2)
|
|
java.lang.String r0 = "date_added"
|
|
r1.put(r0, r6)
|
|
long r2 = java.lang.System.currentTimeMillis()
|
|
java.lang.Long r6 = java.lang.Long.valueOf(r2)
|
|
java.lang.String r0 = "datetaken"
|
|
r1.put(r0, r6)
|
|
r6 = 0
|
|
android.net.Uri r0 = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI // Catch: java.lang.Exception -> L87
|
|
android.net.Uri r0 = r4.insert(r0, r1) // Catch: java.lang.Exception -> L87
|
|
if (r0 == 0) goto L85
|
|
if (r5 == 0) goto L81
|
|
java.io.OutputStream r1 = r4.openOutputStream(r0) // Catch: java.lang.Exception -> L88
|
|
android.graphics.Bitmap$CompressFormat r2 = android.graphics.Bitmap.CompressFormat.JPEG // Catch: java.lang.Throwable -> L75
|
|
r3 = 70
|
|
r5.compress(r2, r3, r1) // Catch: java.lang.Throwable -> L75
|
|
if (r1 == 0) goto L85
|
|
r1.close() // Catch: java.lang.Exception -> L88
|
|
goto L85
|
|
L75:
|
|
r2 = move-exception
|
|
if (r1 == 0) goto L80
|
|
r1.close() // Catch: java.lang.Throwable -> L7c
|
|
goto L80
|
|
L7c:
|
|
r1 = move-exception
|
|
r2.addSuppressed(r1) // Catch: java.lang.Exception -> L88
|
|
L80:
|
|
throw r2 // Catch: java.lang.Exception -> L88
|
|
L81:
|
|
r4.delete(r0, r6, r6) // Catch: java.lang.Exception -> L88
|
|
goto L8d
|
|
L85:
|
|
r6 = r0
|
|
goto L8d
|
|
L87:
|
|
r0 = r6
|
|
L88:
|
|
if (r0 == 0) goto L85
|
|
r4.delete(r0, r6, r6)
|
|
L8d:
|
|
if (r5 == 0) goto L92
|
|
r5.recycle()
|
|
L92:
|
|
VP_(r7, r6)
|
|
return r6
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: o.C6582cXO.VM_(android.content.ContentResolver, android.graphics.Bitmap, java.lang.String, android.content.Context):android.net.Uri");
|
|
}
|
|
}
|