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.adjust.sdk.Constants; import com.alipay.sdk.util.f; import com.huawei.hms.support.api.entity.common.CommonConstant; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import com.tencent.open.log.SLog; import com.tencent.smtt.sdk.TbsConfig; import com.tencent.tauth.IUiListener; import com.tencent.tauth.Tencent; import com.tencent.wcdb.database.SQLiteDatabase; 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 n02.d; import org.cybergarage.upnp.std.av.server.object.SearchCriteria; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ public class l { /* renamed from: a reason: collision with root package name */ private static String f34084a = ""; /* renamed from: b reason: collision with root package name */ private static String f34085b = ""; /* renamed from: c reason: collision with root package name */ private static String f34086c = ""; /* renamed from: d reason: collision with root package name */ private static String f34087d = ""; /* renamed from: e reason: collision with root package name */ private static int f34088e = -1; /* renamed from: f reason: collision with root package name */ private static String f34089f = "0123456789ABCDEF"; /* compiled from: ProGuard */ public static class a { /* renamed from: a reason: collision with root package name */ public String f34092a; /* renamed from: b reason: collision with root package name */ public long f34093b; /* renamed from: c reason: collision with root package name */ public long f34094c; public a(String str, int i10) { this.f34092a = str; this.f34093b = (long) i10; if (str != null) { this.f34094c = (long) str.length(); } } } private static char a(int i10) { int i14 = i10 & 15; return (char) (i14 < 10 ? i14 + 48 : (i14 - 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("="); 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 a14 = a(url.getQuery()); a14.putAll(a(url.getRef())); return a14; } catch (MalformedURLException unused) { return new Bundle(); } } public static JSONObject c(String str) { try { URL url = new URL(str.replace("auth://", JPushConstants.HTTP_PRE)); JSONObject a14 = a((JSONObject) null, url.getQuery()); a(a14, url.getRef()); return a14; } catch (MalformedURLException unused) { return new JSONObject(); } } public static JSONObject d(String str) throws JSONException { if (str.equals(SearchCriteria.FALSE)) { 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) + f.f18326d; } 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(Constants.MD5); instance.update(i(str)); byte[] digest = instance.digest(); if (digest == null) { return str; } StringBuilder sb3 = new StringBuilder(); for (byte b14 : digest) { sb3.append(a(b14 >>> 4)); sb3.append(a(b14)); } return sb3.toString(); } catch (NoSuchAlgorithmException e14) { SLog.e("openSDK_LOG.Util", "encrypt has exception: " + e14.getMessage()); return str; } } private static boolean g(Context context) { Signature[] signatureArr; try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(TbsConfig.APP_QB, 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(Constants.MD5); instance.update(signatureArr[0].toByteArray()); String a14 = a(instance.digest()); instance.reset(); if (a14.equals("d8391a394d4a179e6fe7bdb8a301258b")) { return true; } } catch (NoSuchAlgorithmException e14) { SLog.e("openSDK_LOG.Util", "isQQBrowerAvailable has exception: " + e14.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:0x002c A[SYNTHETIC, Splitter:B:25:0x002c] */ public static long j(String str) { Throwable th3; 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 th4) { th3 = th4; fileInputStream = fileInputStream2; if (fileInputStream != null) { } throw th3; } } catch (Exception unused3) { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException unused4) { } } return 0; } catch (Throwable th5) { th3 = th5; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException unused5) { } } throw th3; } } 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 e14) { SLog.e("openSDK_LOG.Util", "convert2Base64String exception: " + e14.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 b14 = b(); return !TextUtils.isEmpty(str) && !TextUtils.isEmpty(b14) && str.contains(b14); } public static String e(Context context, String str) { if (context == null) { return ""; } String d14 = d(context, str); f34086c = d14; return d14; } 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 f34085b; } /* 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("="); 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 e14) { SLog.e("openSDK_LOG.Util", "decodeUrlToJson has exception: " + e14.getMessage()); } } } } return jSONObject; } public static boolean c(Context context) { double d14; try { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); d14 = 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) { d14 = 0.0d; } return d14 > 6.5d; } public static String d(Context context, String str) { if (context == null) { return ""; } b(context, str); return f34084a; } public static void b(Context context, String str) { if (context != null) { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 0); String str2 = packageInfo.versionName; f34085b = str2; f34084a = str2.substring(0, str2.lastIndexOf(46)); String str3 = f34085b; f34087d = str3.substring(str3.lastIndexOf(46) + 1, f34085b.length()); f34088e = packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e14) { SLog.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e14.getMessage()); } catch (Exception e15) { SLog.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e15.getMessage()); } } } public static boolean f(Context context, String str) { boolean z14 = true; boolean z15 = !c(context) || i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_PAD) == null; if (z15 && i.a(context, com.tencent.connect.common.Constants.PACKAGE_TIM) != null) { z15 = false; } if (z15 && i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_SPEED) != null) { z15 = false; } if (!z15) { return z15; } if (i.c(context, str) >= 0) { z14 = false; } return z14; } 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 z14 = true; boolean z15 = !c(context) || i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_PAD) == null; if (z15 && i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_SPEED) != null) { z15 = false; } if (!z15) { return z15; } if (i.c(context, str) >= 0) { z14 = false; } return z14; } public static boolean c() { Context a14 = f.a(); if (a14 == null || a14.getPackageManager().checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", a14.getPackageName()) != 0) { return false; } return true; } public static boolean f(Context context) { return i.c(context, "5.9.5") >= 0 || i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_SPEED) != null; } /* JADX WARNING: Can't wrap try/catch for region: R(5:22|23|24|25|28) */ /* JADX WARNING: Can't wrap try/catch for region: R(7:14|15|16|17|18|19|33) */ /* JADX WARNING: Code restructure failed: missing block: B:20:0x002e, code lost: return false; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x0038, code lost: return false; */ /* JADX WARNING: Code restructure failed: missing block: B:31:?, code lost: return true; */ /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost: return true; */ /* JADX WARNING: Code restructure failed: missing block: B:34:?, code lost: return true; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:16:0x0026 */ /* JADX WARNING: Missing exception handler attribute for start block: B:18:0x002a */ /* JADX WARNING: Missing exception handler attribute for start block: B:24:0x0033 */ /* JADX WARNING: Removed duplicated region for block: B:14:0x0022 A[SYNTHETIC, Splitter:B:14:0x0022] */ /* JADX WARNING: Removed duplicated region for block: B:22:0x002f A[SYNTHETIC, Splitter:B:22:0x002f] */ public static boolean a(Context context, String str) { boolean z14; try { z14 = g(context); if (z14) { try { a(context, TbsConfig.APP_QB, "com.tencent.mtt.MainActivity", str); return true; } catch (Exception unused) { if (!z14) { } } } else { a(context, "com.android.browser", "com.android.browser.BrowserActivity", str); return true; } } catch (Exception unused2) { z14 = false; if (!z14) { 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); a(context, "com.android.chrome", "com.google.android.apps.chrome.Main", str); return true; } } /* 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 e14; FileOutputStream fileOutputStream; Throwable th3; ParcelFileDescriptor parcelFileDescriptor; FileInputStream fileInputStream; Exception e15; File h10; FileInputStream fileInputStream2 = null; try { cursor = d.z(context.getContentResolver(), uri, new String[]{"_data"}, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { return cursor.getString(cursor.getColumnIndexOrThrow("_data")); } } catch (Exception e16) { e14 = e16; SLog.e("openSDK_LOG.Util", "queryAbsolutePath error : " + e14.getMessage()); if (cursor != null) { } try { parcelFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r"); try { fileInputStream = new FileInputStream(parcelFileDescriptor.getFileDescriptor()); } catch (Exception e17) { e15 = e17; fileOutputStream = null; fileInputStream = null; try { SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e15.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th4) { th3 = th4; fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { try { fileInputStream2.close(); } catch (IOException e18) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e18.getMessage()); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e19) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e19.getMessage()); } } if (parcelFileDescriptor != null) { try { parcelFileDescriptor.close(); } catch (IOException e24) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e24.getMessage()); } } throw th3; } } catch (Throwable th5) { th3 = th5; fileOutputStream = null; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th3; } } catch (Exception e25) { e15 = e25; fileOutputStream = null; parcelFileDescriptor = null; fileInputStream = null; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e15.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th6) { th3 = th6; fileOutputStream = null; parcelFileDescriptor = null; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th3; } try { h10 = h(context, "Images"); if (h10 != null) { } } catch (Exception e26) { e15 = e26; fileOutputStream = null; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e15.getMessage()); if (fileInputStream != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } return null; } catch (Throwable th7) { th3 = th7; fileOutputStream = null; fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th3; } } } return null; } catch (Exception e27) { e14 = e27; cursor = null; SLog.e("openSDK_LOG.Util", "queryAbsolutePath error : " + e14.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 e28) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e28.getMessage()); } try { parcelFileDescriptor.close(); } catch (IOException e29) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e29.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 e33) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e33.getMessage()); } try { fileOutputStream2.close(); } catch (IOException e34) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e34.getMessage()); } try { parcelFileDescriptor.close(); } catch (IOException e35) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e35.getMessage()); } return absolutePath; } catch (Exception e36) { fileOutputStream = fileOutputStream2; e15 = e36; SLog.e("openSDK_LOG.Util", "copy file from uri error : " + e15.getMessage()); if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e37) { SLog.e("openSDK_LOG.Util", "close fileIuputStream error" + e37.getMessage()); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e38) { SLog.e("openSDK_LOG.Util", "close fileOutputStream error" + e38.getMessage()); } } if (parcelFileDescriptor != null) { try { parcelFileDescriptor.close(); } catch (IOException e39) { SLog.e("openSDK_LOG.Util", "close ParcelFileDescriptor error" + e39.getMessage()); } } return null; } catch (Throwable th8) { fileInputStream2 = fileInputStream; fileOutputStream = fileOutputStream2; th3 = th8; if (fileInputStream2 != null) { } if (fileOutputStream != null) { } if (parcelFileDescriptor != null) { } throw th3; } } } private static void a(Context context, String str, String str2, String str3) { Intent intent = new Intent(); intent.setComponent(new ComponentName(str, str2)); intent.setAction(CommonConstant.ACTION.HWID_SCHEME_URL); intent.addFlags(1073741824); intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY); intent.setData(Uri.parse(str3)); context.startActivity(intent); } public static void a(final Context context, String str, long j14, 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", com.tencent.connect.common.Constants.SDK_VERSION); if (j14 != 0) { bundle.putLong("elt", j14); } 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 e14) { SLog.e("openSDK_LOG.Util", "reportBernoulli has exception: " + e14.getMessage()); } } }.start(); } public static boolean a() { return (Environment.getExternalStorageState().equals("mounted") ? n02.f.d() : null) != null; } public static String a(byte[] bArr) { if (bArr == null) { return null; } StringBuilder sb3 = new StringBuilder(bArr.length * 2); for (byte b14 : bArr) { String num = Integer.toString(b14 & 255, 16); if (num.length() == 1) { num = "0" + num; } sb3.append(num); } return sb3.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 i14 = 0; int i15 = 0; while (i14 < str.length()) { int i16 = i14 + 1; i15 += str.substring(i14, i16).getBytes(str2).length; if (i15 > i10) { String substring = str.substring(0, i14); if (TextUtils.isEmpty(str3)) { return substring; } return substring + str3; } i14 = i16; } return str; } catch (Exception e14) { SLog.e("openSDK_LOG.Util", "Util.subString has exception: " + e14.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("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 e14 = f.e(); if (e14 == null) { return null; } if (!e14.exists()) { e14.mkdirs(); } return e14.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_type", str8); bundle.putString("detail", str9); bundle.putString("os_ver", Build.VERSION.RELEASE); bundle.putString("network", 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, com.tencent.connect.common.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 z14) { if ((!c(context) || i.a(context, com.tencent.connect.common.Constants.PACKAGE_QQ_PAD) == null) && i.c(context, "4.1") < 0 && i.a(context, com.tencent.connect.common.Constants.PACKAGE_TIM) == null && i.a(context, com.tencent.connect.common.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 ("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(":"); String str = split[0]; if ("primary".equals(str)) { return n02.f.d().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(":"); 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 th3) { SLog.e("Util", "xor Exception! ", th3); } } return bArr; } public static Drawable a(String str, Context context) { Throwable th3; InputStream inputStream; IOException e14; StringBuilder sb3; 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 e15) { e = e15; sb3 = new StringBuilder(); } } catch (IOException e16) { e14 = e16; try { SLog.e("openSDK_LOG.Util", "getDrawable exception: " + e14.getMessage()); try { inputStream.close(); } catch (Exception e17) { e = e17; sb3 = new StringBuilder(); } return drawable; } catch (Throwable th4) { th3 = th4; inputStream2 = inputStream; try { inputStream2.close(); } catch (Exception e18) { SLog.e("openSDK_LOG.Util", "inputStream close exception: " + e18.getMessage()); } throw th3; } } } catch (IOException e19) { e14 = e19; inputStream = null; SLog.e("openSDK_LOG.Util", "getDrawable exception: " + e14.getMessage()); inputStream.close(); return drawable; } catch (Throwable th5) { th3 = th5; inputStream2.close(); throw th3; } return drawable; sb3.append("inputStream close exception: "); sb3.append(e.getMessage()); SLog.e("openSDK_LOG.Util", sb3.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 e14) { SLog.d("openSDK_LOG.Util", "copy fail from " + str + " to " + str2 + " ", e14); } } 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 th3; IOException e14; OutOfMemoryError e15; boolean z14 = 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 e16) { e14 = e16; bufferedInputStream = null; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e14); if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e17) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e17); } } if (bufferedInputStream != null) { bufferedInputStream.close(); } return z14; } catch (OutOfMemoryError e18) { e15 = e18; bufferedInputStream = null; fileOutputStream = fileOutputStream2; try { SLog.e("openSDK_LOG.Util", "copyFile error, ", e15); if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e19) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e19); } } if (bufferedInputStream != null) { bufferedInputStream.close(); } return z14; } catch (Throwable th4) { th3 = th4; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th3; } } catch (Throwable th5) { th3 = th5; bufferedInputStream = null; fileOutputStream = fileOutputStream2; if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e24) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e24); } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e25) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e25); } } throw th3; } try { byte[] bArr = new byte[102400]; while (true) { int read = bufferedInputStream.read(bArr); if (read == -1) { break; } fileOutputStream2.write(bArr, 0, read); fileOutputStream2.flush(); } z14 = true; try { fileOutputStream2.close(); } catch (IOException e26) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e26); } try { bufferedInputStream.close(); } catch (IOException e27) { SLog.e("openSDK_LOG.Util", "copyFile error, ", e27); } } catch (IOException e28) { e14 = e28; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e14); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z14; } catch (OutOfMemoryError e29) { e15 = e29; fileOutputStream = fileOutputStream2; SLog.e("openSDK_LOG.Util", "copyFile error, ", e15); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z14; } catch (Throwable th6) { th3 = th6; fileOutputStream = fileOutputStream2; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th3; } } catch (IOException e33) { e14 = e33; bufferedInputStream = null; SLog.e("openSDK_LOG.Util", "copyFile error, ", e14); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z14; } catch (OutOfMemoryError e34) { e15 = e34; bufferedInputStream = null; SLog.e("openSDK_LOG.Util", "copyFile error, ", e15); if (fileOutputStream != null) { } if (bufferedInputStream != null) { } return z14; } catch (Throwable th7) { th3 = th7; bufferedInputStream = null; if (fileOutputStream != null) { } if (bufferedInputStream != null) { } throw th3; } return z14; } public static boolean a(Context context, String str, String str2) { boolean z14; if (Build.VERSION.SDK_INT < 19) { z14 = context.getPackageManager().checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", context.getPackageName()) == 0 ? a(str, str2) : false; } else { z14 = a(str, str2); } SLog.i("openSDK_LOG.Util", "copyFileByCheckPermission() copy success:" + z14); return z14; } public static String a(String str, Activity activity, String str2, IUiListener iUiListener) { String str3; try { boolean n14 = n(str2); SLog.i("openSDK_LOG.Util", "doPublishMood() check file: isAppSpecificDir=" + n14 + ",hasSDPermission=" + c()); if (!n14) { File a14 = f.a("Images"); if (a14 != null) { str3 = a14.getAbsolutePath() + File.separator + com.tencent.connect.common.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 + com.tencent.connect.common.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 e14) { SLog.e("openSDK_LOG.Util", "getMediaFileUri error", e14); return null; } } public static boolean a(Map<String, Object> map, String str, boolean z14) { if (map == null) { SLog.e("openSDK_LOG.Util", "getBoolean error, params==null"); return z14; } else if (!map.containsKey(str)) { SLog.e("openSDK_LOG.Util", "getBoolean error, not comtain : " + str); return z14; } else { Object obj = map.get(str); return obj instanceof Boolean ? ((Boolean) obj).booleanValue() : z14; } } 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; } } }