package com.tencent.open.utils; import android.annotation.SuppressLint; import android.app.Activity; import android.content.ComponentName; import android.content.ContentUris; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.provider.DocumentsContract; import android.provider.MediaStore; import android.text.TextUtils; import android.util.Base64; import android.util.DisplayMetrics; import androidx.core.content.FileProvider; import cn.jpush.android.local.JPushConstants; import com.google.android.exoplayer2.source.rtsp.RtspHeaders; import com.huawei.hms.framework.common.ContainerUtils; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import com.mihoyo.hyperion.utils.share.Share; import com.tencent.bugly.Bugly; import com.tencent.connect.common.Constants; import com.tencent.open.log.SLog; import com.tencent.tauth.IUiListener; import com.tencent.tauth.Tencent; import gc.c; import io.rong.common.LibStorageUtils; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Map; import n6.b; import org.json.JSONException; import org.json.JSONObject; import t4.h; /* compiled from: ProGuard */ public class l { /* renamed from: a reason: collision with root package name */ private static String f41827a = ""; /* renamed from: b reason: collision with root package name */ private static String f41828b = ""; /* renamed from: c reason: collision with root package name */ private static String f41829c = ""; /* renamed from: d reason: collision with root package name */ private static String f41830d = ""; /* renamed from: e reason: collision with root package name */ private static int f41831e = -1; /* renamed from: f reason: collision with root package name */ private static String f41832f = "0123456789ABCDEF"; /* compiled from: ProGuard */ public static class a { /* renamed from: a reason: collision with root package name */ public String f41835a; /* renamed from: b reason: collision with root package name */ public long f41836b; /* renamed from: c reason: collision with root package name */ public long f41837c; public a(String str, int i10) { this.f41835a = str; this.f41836b = (long) i10; if (str != null) { this.f41837c = (long) str.length(); } } } private static char a(int i10) { int i11 = i10 & 15; return (char) (i11 < 10 ? i11 + 48 : (i11 - 10) + 97); } public static Bundle a(String str) { Bundle bundle = new Bundle(); if (str == null) { return bundle; } try { for (String str2 : str.split("&")) { String[] split = str2.split(ContainerUtils.KEY_VALUE_DELIMITER); if (split.length == 2) { bundle.putString(URLDecoder.decode(split[0]), URLDecoder.decode(split[1])); } } return bundle; } catch (Exception unused) { return null; } } public static Bundle b(String str) { try { URL url = new URL(str.replace("auth://", JPushConstants.HTTP_PRE)); Bundle a10 = a(url.getQuery()); a10.putAll(a(url.getRef())); return a10; } catch (MalformedURLException unused) { return new Bundle(); } } public static JSONObject c(String str) { try { URL url = new URL(str.replace("auth://", JPushConstants.HTTP_PRE)); JSONObject a10 = a((JSONObject) null, url.getQuery()); a(a10, url.getRef()); return a10; } catch (MalformedURLException unused) { return new JSONObject(); } } public static JSONObject d(String str) throws JSONException { if (str.equals(Bugly.SDK_IS_DEV)) { str = "{value : false}"; } if (str.equals("true")) { str = "{value : true}"; } if (str.contains("allback(")) { str = str.replaceFirst("[\\s\\S]*allback\\(([\\s\\S]*)\\);[^\\)]*\\z", "$1").trim(); } if (str.contains("online[0]=")) { str = "{online:" + str.charAt(str.length() - 2) + h.f134439d; } return new JSONObject(str); } public static boolean e(String str) { return str == null || str.length() == 0; } public static String f(String str) { try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(i(str)); byte[] digest = instance.digest(); if (digest == null) { return str; } StringBuilder sb2 = new StringBuilder(); for (byte b10 : digest) { sb2.append(a(b10 >>> 4)); sb2.append(a(b10)); } return sb2.toString(); } catch (NoSuchAlgorithmException e10) { SLog.e("openSDK_LOG.Util", "encrypt has exception: " + e10.getMessage()); return str; } } private static boolean g(Context context) { Signature[] signatureArr; try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo("com.tencent.mtt", 64); String str = packageInfo.versionName; if (i.a(str, "4.3") >= 0 && !str.startsWith("4.4") && (signatureArr = packageInfo.signatures) != null) { try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(signatureArr[0].toByteArray()); String a10 = a(instance.digest()); instance.reset(); if (a10.equals("d8391a394d4a179e6fe7bdb8a301258b")) { return true; } } catch (NoSuchAlgorithmException e10) { SLog.e("openSDK_LOG.Util", "isQQBrowerAvailable has exception: " + e10.getMessage()); } } } catch (PackageManager.NameNotFoundException unused) { } return false; } public static boolean h(String str) { if (str != null && new File(str).exists()) { return true; } return false; } public static byte[] i(String str) { try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException unused) { return null; } } /* JADX WARNING: Removed duplicated region for block: B:19:0x0025 A[SYNTHETIC, Splitter:B:19:0x0025] */ /* JADX WARNING: Removed duplicated region for block: B:25:0x002b A[SYNTHETIC, Splitter:B:25:0x002b] */ public static long j(String str) { Throwable th2; FileInputStream fileInputStream = null; try { File file = new File(str); if (!file.exists()) { return 0; } FileInputStream fileInputStream2 = new FileInputStream(file); try { long available = (long) fileInputStream2.available(); try { fileInputStream2.close(); } catch (IOException unused) { } return available; } catch (Exception unused2) { fileInputStream = fileInputStream2; if (fileInputStream != null) { } return 0; } catch (Throwable th3) { th2 = th3; fileInputStream = fileInputStream2; if (fileInputStream != null) { } throw th2; } } catch (Exception unused3) { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException unused4) { } } return 0; } catch (Throwable th4) { th2 = th4; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException unused5) { } } throw th2; } } public static String k(String str) { if (str == null) { return null; } return Base64.encodeToString(a(str.getBytes(), "JCPTZXEZ"), 3); } public static String l(String str) { if (!TextUtils.isEmpty(str)) { try { return Base64.encodeToString(str.getBytes("UTF-8"), 2); } catch (UnsupportedEncodingException e10) { SLog.e("openSDK_LOG.Util", "convert2Base64String exception: " + e10.getMessage()); } } return ""; } public static File m(String str) throws IOException { File file = new File(str); if (!file.exists()) { if (file.getParentFile() == null || file.getParentFile().exists()) { file.createNewFile(); } else if (file.getParentFile().mkdirs()) { file.createNewFile(); } else { SLog.d("openSDK_LOG.Util", "createFile failed" + str); } } return file; } public static boolean n(String str) { String b10 = b(); return !TextUtils.isEmpty(str) && !TextUtils.isEmpty(b10) && str.contains(b10); } public static String e(Context context, String str) { if (context == null) { return ""; } String d10 = d(context, str); f41829c = d10; return d10; } public static boolean e(Context context) { return i.c(context, "8.1.8") >= 0; } public static File h(Context context, String str) { if (context == null) { return null; } if (Build.VERSION.SDK_INT < 19) { return context.getExternalFilesDir(str); } File[] externalFilesDirs = context.getExternalFilesDirs(str); if (externalFilesDirs == null || externalFilesDirs.length <= 0) { return null; } return externalFilesDirs[0]; } public static boolean b(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity"); if (connectivityManager == null) { return true; } NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo(); if (allNetworkInfo != null) { for (NetworkInfo networkInfo : allNetworkInfo) { if (networkInfo.isConnectedOrConnecting()) { return true; } } } return false; } public static String c(Context context, String str) { if (context == null) { return ""; } b(context, str); return f41828b; } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x0031 */ public static JSONObject a(JSONObject jSONObject, String str) { if (jSONObject == null) { jSONObject = new JSONObject(); } if (str != null) { for (String str2 : str.split("&")) { String[] split = str2.split(ContainerUtils.KEY_VALUE_DELIMITER); if (split.length == 2) { split[0] = URLDecoder.decode(split[0]); split[1] = URLDecoder.decode(split[1]); try { jSONObject.put(split[0], split[1]); } catch (JSONException e10) { SLog.e("openSDK_LOG.Util", "decodeUrlToJson has exception: " + e10.getMessage()); } } } } return jSONObject; } public static boolean c(Context context) { double d10; try { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); d10 = Math.sqrt(Math.pow((double) (((float) displayMetrics.widthPixels) / displayMetrics.xdpi), 2.0d) + Math.pow((double) (((float) displayMetrics.heightPixels) / displayMetrics.ydpi), 2.0d)); } catch (Throwable unused) { d10 = 0.0d; } return d10 > 6.5d; } public static String d(Context context, String str) { if (context == null) { return ""; } b(context, str); return f41827a; } public static void b(Context context, String str) { if (context != null) { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 0); String str2 = packageInfo.versionName; f41828b = str2; f41827a = str2.substring(0, str2.lastIndexOf(46)); String str3 = f41828b; f41830d = str3.substring(str3.lastIndexOf(46) + 1, f41828b.length()); f41831e = packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e10) { SLog.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e10.getMessage()); } catch (Exception e11) { SLog.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e11.getMessage()); } } } public static boolean f(Context context, String str) { boolean z10 = true; boolean z11 = !c(context) || i.a(context, Constants.PACKAGE_QQ_PAD) == null; if (z11 && i.a(context, Constants.PACKAGE_TIM) != null) { z11 = false; } if (z11 && i.a(context, Constants.PACKAGE_QQ_SPEED) != null) { z11 = false; } if (!z11) { return z11; } if (i.c(context, str) >= 0) { z10 = false; } return z10; } public static boolean d(Context context) { return i.c(context, "8.1.5") >= 0; } public static final boolean g(String str) { if (str == null) { return false; } return str.startsWith(JPushConstants.HTTP_PRE) || str.startsWith(JPushConstants.HTTPS_PRE); } public static boolean g(Context context, String str) { boolean z10 = true; boolean z11 = !c(context) || i.a(context, Constants.PACKAGE_QQ_PAD) == null; if (z11 && i.a(context, Constants.PACKAGE_QQ_SPEED) != null) { z11 = false; } if (!z11) { return z11; } if (i.c(context, str) >= 0) { z10 = false; } return z10; } public static boolean c() { Context a10 = f.a(); if (a10 == null || a10.getPackageManager().checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", a10.getPackageName()) != 0) { return false; } return true; } public static boolean f(Context context) { return i.c(context, "5.9.5") >= 0 || i.a(context, Constants.PACKAGE_QQ_SPEED) != null; } /* JADX WARNING: Can't wrap try/catch for region: R(7:13|14|15|16|17|18|32) */ /* JADX WARNING: Code restructure failed: missing block: B:19:0x002c, code lost: return false; */ /* JADX WARNING: Code restructure failed: missing block: B:30:?, code lost: return true; */ /* JADX WARNING: Code restructure failed: missing block: B:31:?, code lost: return true; */ /* JADX WARNING: Code restructure failed: missing block: B:33:?, code lost: return true; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x0024 */ /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x0028 */ /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0031 */ /* JADX WARNING: Removed duplicated region for block: B:13:0x0020 A[SYNTHETIC, Splitter:B:13:0x0020] */ /* JADX WARNING: Removed duplicated region for block: B:21:0x002d A[SYNTHETIC, Splitter:B:21:0x002d] */ public static boolean a(Context context, String str) { boolean z10; try { z10 = g(context); if (z10) { try { a(context, "com.tencent.mtt", "com.tencent.mtt.MainActivity", str); return true; } catch (Exception unused) { if (!z10) { a(context, "com.android.browser", "com.android.browser.BrowserActivity", str); a(context, "com.google.android.browser", "com.android.browser.BrowserActivity", str); a(context, "com.android.chrome", "com.google.android.apps.chrome.Main", str); return true; } a(context, "com.google.android.browser", "com.android.browser.BrowserActivity", str); try { a(context, "com.android.chrome", "com.google.android.apps.chrome.Main", str); return true; } catch (Exception unused2) { return false; } } } else { a(context, "com.android.browser", "com.android.browser.BrowserActivity", str); return true; } } catch (Exception unused3) { z10 = false; if (!z10) { } } } /* JADX WARNING: Removed duplicated region for block: B:101:0x01e2 A[SYNTHETIC, Splitter:B:101:0x01e2] */ /* JADX WARNING: Removed duplicated region for block: B:106:0x01ff A[SYNTHETIC, Splitter:B:106:0x01ff] */ /* JADX WARNING: Removed duplicated region for block: B:14:0x004a */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0068 A[Catch:{ Exception -> 0x013d, all -> 0x0139 }] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x00a4 */ /* JADX WARNING: Removed duplicated region for block: B:78:0x016b A[SYNTHETIC, Splitter:B:78:0x016b] */ /* JADX WARNING: Removed duplicated region for block: B:83:0x0188 A[SYNTHETIC, Splitter:B:83:0x0188] */ /* JADX WARNING: Removed duplicated region for block: B:88:0x01a5 A[SYNTHETIC, Splitter:B:88:0x01a5] */ /* JADX WARNING: Removed duplicated region for block: B:96:0x01c5 A[SYNTHETIC, Splitter:B:96:0x01c5] */ public static String b(Context context, Uri uri) { Cursor cursor; Exception e10; FileOutputStream fileOutputStream; Throwable th2; ParcelFileDescriptor parcelFileDescriptor; FileInputStream fileInputStream; Exception e11; File h10; FileInputStream fileInputStream2 = null; try { cursor = context.getContentResolver().query(uri, new String[]{"_data"}, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { return cursor.getString(cursor.getColumnIndexOrThrow("_data")); } } catch (Exception e12) { e10 = e12; SLog.e("openSDK_LOG.Util", "queryAbsolutePath error : " + e10.getMessage()); if (cursor != null) { } try { parcelFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r"); try { fileInputStream = new FileInputStream(parcelFileDescriptor.getFileDescriptor()); } catch (Exception e13) { e11 = e13; fileOutputStream = null; fileInputStream = null; try { SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e11.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th3) { th2 = th3; fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { try { fileInputStream2.close(); } catch (IOException e14) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e14.getMessage()); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e15) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e15.getMessage()); } } if (parcelFileDescriptor != null) { try { parcelFileDescriptor.close(); } catch (IOException e16) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e16.getMessage()); } } throw th2; } } catch (Throwable th4) { th2 = th4; fileOutputStream = null; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th2; } } catch (Exception e17) { e11 = e17; fileOutputStream = null; parcelFileDescriptor = null; fileInputStream = null; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e11.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th5) { th2 = th5; fileOutputStream = null; parcelFileDescriptor = null; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th2; } try { h10 = h(context, "Images"); if (h10 != null) { } } catch (Exception e18) { e11 = e18; fileOutputStream = null; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e11.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th6) { th2 = th6; fileOutputStream = null; fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th2; } } } return null; } catch (Exception e19) { e10 = e19; cursor = null; SLog.e("openSDK_LOG.Util", "queryAbsolutePath error : " + e10.getMessage()); if (cursor != null) { cursor.close(); } parcelFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r"); fileInputStream = new FileInputStream(parcelFileDescriptor.getFileDescriptor()); h10 = h(context, "Images"); if (h10 != null) { SLog.e("openSDK_LOG.Util", "getExternalFilesDir return null"); try { fileInputStream.close(); } catch (IOException e20) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e20.getMessage()); } try { parcelFileDescriptor.close(); } catch (IOException e21) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e21.getMessage()); } return null; } if (!h10.exists()) { h10.mkdirs(); } File file = new File(h10, uri.getLastPathSegment()); if (!file.exists()) { file.createNewFile(); } FileOutputStream fileOutputStream2 = new FileOutputStream(file); try { byte[] bArr = new byte[2048]; while (true) { int read = fileInputStream.read(bArr); if (read == -1) { break; } fileOutputStream2.write(bArr, 0, read); } fileOutputStream2.flush(); String absolutePath = file.getAbsolutePath(); try { fileInputStream.close(); } catch (IOException e22) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e22.getMessage()); } try { fileOutputStream2.close(); } catch (IOException e23) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e23.getMessage()); } try { parcelFileDescriptor.close(); } catch (IOException e24) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e24.getMessage()); } return absolutePath; } catch (Exception e25) { fileOutputStream = fileOutputStream2; e11 = e25; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e11.getMessage()); if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e26) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e26.getMessage()); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e27) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e27.getMessage()); } } if (parcelFileDescriptor != null) { try { parcelFileDescriptor.close(); } catch (IOException e28) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e28.getMessage()); } } return null; } catch (Throwable th7) { fileInputStream2 = fileInputStream; fileOutputStream = fileOutputStream2; th2 = th7; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th2; } } } private static void a(Context context, String str, String str2, String str3) { Intent intent = new Intent(); intent.setComponent(new ComponentName(str, str2)); intent.setAction("android.intent.action.VIEW"); intent.addFlags(1073741824); intent.addFlags(268435456); intent.setData(Uri.parse(str3)); context.startActivity(intent); } public static void a(final Context context, String str, long j10, String str2) { final Bundle bundle = new Bundle(); bundle.putString("appid_for_getting_config", str2); bundle.putString("strValue", str2); bundle.putString("nValue", str); bundle.putString("qver", Constants.SDK_VERSION); if (j10 != 0) { bundle.putLong("elt", j10); } new Thread() { /* class com.tencent.open.utils.l.AnonymousClass1 */ public void run() { try { HttpUtils.openUrl2(context, "https://cgi.qplus.com/report/report", "GET", bundle); } catch (Exception e10) { SLog.e("openSDK_LOG.Util", "reportBernoulli has exception: " + e10.getMessage()); } } }.start(); } public static boolean a() { return (Environment.getExternalStorageState().equals("mounted") ? Environment.getExternalStorageDirectory() : null) != null; } public static String a(byte[] bArr) { if (bArr == null) { return null; } StringBuilder sb2 = new StringBuilder(bArr.length * 2); for (byte b10 : bArr) { String num = Integer.toString(b10 & 255, 16); if (num.length() == 1) { num = "0" + num; } sb2.append(num); } return sb2.toString(); } public static final String a(Context context) { CharSequence applicationLabel; if (context == null || (applicationLabel = context.getPackageManager().getApplicationLabel(context.getApplicationInfo())) == null) { return null; } return applicationLabel.toString(); } public static final String a(String str, int i10, String str2, String str3) { if (TextUtils.isEmpty(str)) { return ""; } if (TextUtils.isEmpty(str2)) { str2 = "UTF-8"; } try { if (str.getBytes(str2).length <= i10) { return str; } int i11 = 0; int i12 = 0; while (i11 < str.length()) { int i13 = i11 + 1; i12 += str.substring(i11, i13).getBytes(str2).length; if (i12 > i10) { String substring = str.substring(0, i11); if (TextUtils.isEmpty(str3)) { return substring; } return substring + str3; } i11 = i13; } return str; } catch (Exception e10) { SLog.e("openSDK_LOG.Util", "Util.subString has exception: " + e10.getMessage()); return str; } } public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6) { return a(str, str3, str4, str2, str5, str6, "", "", "", "", "", ""); } public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, String str12) { Bundle bundle = new Bundle(); bundle.putString("openid", str); bundle.putString("report_type", str2); bundle.putString("act_type", str3); bundle.putString(RtspHeaders.VIA, str4); bundle.putString("app_id", str5); bundle.putString("result", str6); bundle.putString("type", str7); bundle.putString("login_status", str8); bundle.putString("need_user_auth", str9); bundle.putString("to_uin", str10); bundle.putString("call_source", str11); bundle.putString("to_type", str12); bundle.putString("platform", "1"); return bundle; } public static String b() { File e10 = f.e(); if (e10 == null) { return null; } if (!e10.exists()) { e10.mkdirs(); } return e10.toString(); } public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) { Bundle bundle = new Bundle(); bundle.putString("platform", "1"); bundle.putString("result", str); bundle.putString("code", str2); bundle.putString("tmcost", str3); bundle.putString("rate", str4); bundle.putString("cmd", str5); bundle.putString("uin", str6); bundle.putString("appid", str7); bundle.putString(Share.Receive.SHARE_TYPE, str8); bundle.putString("detail", str9); bundle.putString("os_ver", Build.VERSION.RELEASE); bundle.putString(b.a.f93291r, com.tencent.open.a.a.a(f.a())); bundle.putString("apn", com.tencent.open.a.a.b(f.a())); bundle.putString("model_name", Build.MODEL); bundle.putString(HiAnalyticsConstant.BI_KEY_SDK_VER, Constants.SDK_VERSION); bundle.putString("packagename", f.b()); bundle.putString("app_ver", d(f.a(), f.b())); return bundle; } public static boolean a(Context context, boolean z10) { if ((!c(context) || i.a(context, Constants.PACKAGE_QQ_PAD) == null) && i.c(context, "4.1") < 0 && i.a(context, Constants.PACKAGE_TIM) == null && i.a(context, Constants.PACKAGE_QQ_SPEED) == null) { return false; } return true; } @SuppressLint({"NewApi"}) public static String a(Context context, Uri uri) { Uri uri2; if (uri == null) { return null; } if (!(Build.VERSION.SDK_INT >= 19) || !DocumentsContract.isDocumentUri(context, uri)) { String scheme = uri.getScheme(); if ("content".equals(scheme)) { return b(context, uri); } if (LibStorageUtils.FILE.equals(scheme)) { return uri.getPath(); } return null; } String authority = uri.getAuthority(); if ("com.android.externalstorage.documents".equals(authority)) { String[] split = DocumentsContract.getDocumentId(uri).split(com.xiaomi.mipush.sdk.Constants.COLON_SEPARATOR); String str = split[0]; if ("primary".equals(str)) { return Environment.getExternalStorageDirectory().getAbsolutePath().concat("/").concat(split[1]); } return "/storage/".concat(str).concat("/").concat(split[1]); } else if ("com.android.providers.downloads.documents".equals(authority)) { String documentId = DocumentsContract.getDocumentId(uri); if (documentId.startsWith("raw:")) { return documentId.replaceFirst("raw:", ""); } return b(context, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.parseLong(documentId))); } else { if ("com.android.providers.media.documents".equals(authority)) { String[] split2 = DocumentsContract.getDocumentId(uri).split(com.xiaomi.mipush.sdk.Constants.COLON_SEPARATOR); String str2 = split2[0]; if ("image".equals(str2)) { uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(str2)) { uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(str2)) { uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } return b(context, ContentUris.withAppendedId(uri2, Long.parseLong(split2[1]))); } return null; } } private static byte[] a(byte[] bArr, String str) { if (bArr != null) { try { char[] charArray = str.toCharArray(); int length = bArr.length; byte[] bArr2 = new byte[length]; for (int i10 = 0; i10 < length; i10++) { bArr2[i10] = (byte) (bArr[i10] ^ charArray[i10 % charArray.length]); } return bArr2; } catch (Throwable th2) { SLog.e("Util", "xor Exception! ", th2); } } return bArr; } public static Drawable a(String str, Context context) { Throwable th2; InputStream inputStream; IOException e10; StringBuilder sb2; InputStream inputStream2 = null; r1 = null; Drawable drawable = null; if (context == null) { SLog.e("openSDK_LOG.Util", "context null!"); return null; } try { inputStream = context.getAssets().open(str); try { drawable = Drawable.createFromStream(inputStream, str); try { inputStream.close(); } catch (Exception e11) { e = e11; sb2 = new StringBuilder(); } } catch (IOException e12) { e10 = e12; try { SLog.e("openSDK_LOG.Util", "getDrawable exception: " + e10.getMessage()); try { inputStream.close(); } catch (Exception e13) { e = e13; sb2 = new StringBuilder(); } return drawable; } catch (Throwable th3) { th2 = th3; inputStream2 = inputStream; try { inputStream2.close(); } catch (Exception e14) { SLog.e("openSDK_LOG.Util", "inputStream close exception: " + e14.getMessage()); } throw th2; } } } catch (IOException e15) { e10 = e15; inputStream = null; SLog.e("openSDK_LOG.Util", "getDrawable exception: " + e10.getMessage()); inputStream.close(); return drawable; } catch (Throwable th4) { th2 = th4; inputStream2.close(); throw th2; } return drawable; sb2.append("inputStream close exception: "); sb2.append(e.getMessage()); SLog.e("openSDK_LOG.Util", sb2.toString()); return drawable; } public static boolean a(String str, String str2) { File file = new File(str); if (file.exists()) { try { return a(file, m(str2)); } catch (IOException e10) { SLog.d("openSDK_LOG.Util", "copy fail from " + str + " to " + str2 + c.f66526t, e10); } } return false; } /* JADX WARNING: Removed duplicated region for block: B:47:0x0076 A[SYNTHETIC, Splitter:B:47:0x0076] */ /* JADX WARNING: Removed duplicated region for block: B:52:0x0080 */ /* JADX WARNING: Removed duplicated region for block: B:57:0x008b A[SYNTHETIC, Splitter:B:57:0x008b] */ /* JADX WARNING: Removed duplicated region for block: B:62:0x0095 */ /* JADX WARNING: Removed duplicated region for block: B:66:0x009c A[SYNTHETIC, Splitter:B:66:0x009c] */ /* JADX WARNING: Removed duplicated region for block: B:71:0x00a6 A[SYNTHETIC, Splitter:B:71:0x00a6] */ public static boolean a(File file, File file2) { BufferedInputStream bufferedInputStream; Throwable th2; IOException e10; OutOfMemoryError e11; boolean z10 = false; FileOutputStream fileOutputStream = null; try { if (file2.exists()) { file2.delete(); } if (file2.getParentFile() != null && !file2.getParentFile().exists()) { file2.getParentFile().mkdirs(); } FileOutputStream fileOutputStream2 = new FileOutputStream(file2); try { bufferedInputStream = new BufferedInputStream(new FileInputStream(file)); } catch (IOException e12) { e10 = e12; bufferedInputStream = null; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e10); if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e13) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e13); } } if (bufferedInputStream != null) { bufferedInputStream.close(); } return z10; } catch (OutOfMemoryError e14) { e11 = e14; bufferedInputStream = null; fileOutputStream = fileOutputStream2; try { SLog.e("openSDK_LOG.Util", "copyFile error, ", e11); if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e15) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e15); } } if (bufferedInputStream != null) { bufferedInputStream.close(); } return z10; } catch (Throwable th3) { th2 = th3; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th2; } } catch (Throwable th4) { th2 = th4; bufferedInputStream = null; fileOutputStream = fileOutputStream2; if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e16) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e16); } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e17) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e17); } } throw th2; } try { byte[] bArr = new byte[102400]; while (true) { int read = bufferedInputStream.read(bArr); if (read == -1) { break; } fileOutputStream2.write(bArr, 0, read); fileOutputStream2.flush(); } z10 = true; try { fileOutputStream2.close(); } catch (IOException e18) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e18); } try { bufferedInputStream.close(); } catch (IOException e19) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e19); } } catch (IOException e20) { e10 = e20; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e10); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z10; } catch (OutOfMemoryError e21) { e11 = e21; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e11); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z10; } catch (Throwable th5) { th2 = th5; fileOutputStream = fileOutputStream2; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th2; } } catch (IOException e22) { e10 = e22; bufferedInputStream = null; SLog.e("openSDK_LOG.Util", "copyFile error, ", e10); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z10; } catch (OutOfMemoryError e23) { e11 = e23; bufferedInputStream = null; SLog.e("openSDK_LOG.Util", "copyFile error, ", e11); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z10; } catch (Throwable th6) { th2 = th6; bufferedInputStream = null; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th2; } return z10; } public static boolean a(Context context, String str, String str2) { boolean z10; if (Build.VERSION.SDK_INT < 19) { z10 = context.getPackageManager().checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", context.getPackageName()) == 0 ? a(str, str2) : false; } else { z10 = a(str, str2); } SLog.i("openSDK_LOG.Util", "copyFileByCheckPermission() copy success:" + z10); return z10; } public static String a(String str, Activity activity, String str2, IUiListener iUiListener) { String str3; try { boolean n10 = n(str2); SLog.i("openSDK_LOG.Util", "doPublishMood() check file: isAppSpecificDir=" + n10 + ",hasSDPermission=" + c()); if (!n10) { File a10 = f.a("Images"); if (a10 != null) { str3 = a10.getAbsolutePath() + File.separator + Constants.QQ_SHARE_TEMP_DIR; } else { File cacheDir = f.a().getCacheDir(); if (cacheDir == null) { SLog.e("openSDK_LOG.Util", "getMediaFileUri error, cacheDir is null"); return null; } str3 = cacheDir.getAbsolutePath() + File.separator + Constants.QQ_SHARE_TEMP_DIR; } File file = new File(str2); String absolutePath = file.getAbsolutePath(); String str4 = str3 + File.separator + file.getName(); str2 = a(absolutePath, str4) ? str4 : null; } if (!TextUtils.isEmpty(str2)) { File file2 = new File(str2); String authorities = Tencent.getAuthorities(str); if (TextUtils.isEmpty(authorities)) { SLog.e("openSDK_LOG.Util", "getMediaFileUri error, authorities is null"); if (iUiListener != null) { iUiListener.onWarning(-19); } return null; } Uri uriForFile = FileProvider.getUriForFile(activity, authorities, file2); activity.grantUriPermission("com.tencent.mobileqq", uriForFile, 3); return uriForFile.toString(); } SLog.e("openSDK_LOG.Util", "getMediaFileUri error, destAppSpecific is null"); return null; } catch (Exception e10) { SLog.e("openSDK_LOG.Util", "getMediaFileUri error", e10); return null; } } public static boolean a(Map<String, Object> map, String str, boolean z10) { if (map == null) { SLog.e("openSDK_LOG.Util", "getBoolean error, params==null"); return z10; } else if (!map.containsKey(str)) { SLog.e("openSDK_LOG.Util", "getBoolean error, not comtain : " + str); return z10; } else { Object obj = map.get(str); return obj instanceof Boolean ? ((Boolean) obj).booleanValue() : z10; } } public static String a(Map<String, Object> map, String str, String str2) { if (map == null) { SLog.e("openSDK_LOG.Util", "getString error, params==null"); return str2; } else if (!map.containsKey(str)) { SLog.e("openSDK_LOG.Util", "getString error, not comtain : " + str); return str2; } else { Object obj = map.get(str); return obj instanceof String ? (String) obj : str2; } } }