package com.tencent.smtt.utils; import android.annotation.TargetApi; import android.content.Context; import android.text.TextUtils; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Properties; public class o { /* renamed from: c reason: collision with root package name */ private static o f2380c; private Context a = null; private File b = null; private String d = "https://log.tbs.qq.com/ajax?c=pu&v=2&k="; private String e = "https://log.tbs.qq.com/ajax?c=pu&tk="; private String f = "https://log.tbs.qq.com/ajax?c=dl&k="; private String g = "https://cfg.imtt.qq.com/tbs?v=2&mk="; private String h = "https://log.tbs.qq.com/ajax?c=ul&v=2&k="; private String i = "https://mqqad.html5.qq.com/adjs"; private String j = "https://log.tbs.qq.com/ajax?c=ucfu&k="; private String k = ""; private String l = ""; private String m = ""; private String n = "https://tbsrecovery.imtt.qq.com/getconfig"; @TargetApi(11) private o(Context context) { TbsLog.w("TbsCommonConfig", "TbsCommonConfig constructing..."); this.a = context.getApplicationContext(); k(); } public static synchronized o a() { o oVar; synchronized (o.class) { oVar = f2380c; } return oVar; } public static synchronized o a(Context context) { o oVar; synchronized (o.class) { if (f2380c == null) { f2380c = new o(context); } oVar = f2380c; } return oVar; } /* JADX WARNING: Removed duplicated region for block: B:56:0x017e A[SYNTHETIC, Splitter:B:56:0x017e] */ /* JADX WARNING: Removed duplicated region for block: B:63:0x0189 A[SYNTHETIC, Splitter:B:63:0x0189] */ private synchronized void k() { BufferedInputStream bufferedInputStream; Throwable th; Throwable th2; try { File l2 = l(); if (l2 == null) { TbsLog.e("TbsCommonConfig", "Config file is null, default values will be applied"); return; } bufferedInputStream = new BufferedInputStream(new FileInputStream(l2)); try { Properties properties = new Properties(); properties.load(bufferedInputStream); String property = properties.getProperty("pv_post_url", ""); if (!"".equals(property)) { this.d = property; } String property2 = properties.getProperty("tbs_download_stat_post_url", ""); if (!"".equals(property2)) { this.f = property2; } String property3 = properties.getProperty("tbs_downloader_post_url", ""); TbsLog.i("TbsCommonConfig", "KEY_TBS_DOWNLOADER_POST_URL is " + property3); if (!"".equals(property3)) { this.g = property3; } String property4 = properties.getProperty("tbs_downloader_response_query", ""); TbsLog.i("TbsCommonConfig", "KEY_TBS_DOWNLOADER_RESPONSE_QUERY is " + property4); if (!"".equals(property4)) { this.k = property4; } String property5 = properties.getProperty("tbs_downloader_response_update", ""); TbsLog.i("TbsCommonConfig", "KEY_TBS_DOWNLOADER_RESPONSE_UPDATE is " + property5); if (!"".equals(property5)) { this.l = property5; } String property6 = properties.getProperty("tbs_downloader_response_download", ""); TbsLog.i("TbsCommonConfig", "KEY_TBS_DOWNLOADER_RESPONSE_DOWNLOAD is " + property6); if (!"".equals(property6)) { this.m = property6; } String property7 = properties.getProperty("tbs_log_post_url", ""); if (!"".equals(property7)) { this.h = property7; } String property8 = properties.getProperty("tips_url", ""); if (!"".equals(property8)) { this.i = property8; } String property9 = properties.getProperty("tbs_cmd_post_url", ""); if (!"".equals(property9)) { this.j = property9; } String property10 = properties.getProperty("tbs_emergency_post_url", ""); if (!"".equals(property10)) { this.n = property10; } String property11 = properties.getProperty("pv_post_url_tk", ""); if (!"".equals(property11)) { this.e = property11; } try { bufferedInputStream.close(); } catch (IOException e2) { e = e2; } } catch (Throwable th3) { th2 = th3; try { StringWriter stringWriter = new StringWriter(); th2.printStackTrace(new PrintWriter(stringWriter)); TbsLog.e("TbsCommonConfig", "exceptions occurred1:" + stringWriter.toString()); if (bufferedInputStream != null) { } } catch (Throwable th4) { th = th4; if (bufferedInputStream != null) { } throw th; } } } catch (Throwable th5) { bufferedInputStream = null; th = th5; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e3) { e3.printStackTrace(); } } throw th; } e.printStackTrace(); } private File l() { Throwable th; File file; File file2 = null; try { if (this.b == null) { String str = this.a.getApplicationContext().getApplicationInfo().packageName; if (!TextUtils.isEmpty(str)) { boolean z = true; boolean z2 = this.a.getPackageManager().checkPermission("android.permission.READ_EXTERNAL_STORAGE", str) == 0; if (this.a.getPackageManager().checkPermission("android.permission.WRITE_EXTERNAL_STORAGE", str) != 0) { z = false; } if (!z2) { if (!z) { file = new File(FileUtil.a(this.a, 8)); } } TbsLog.i("TbsCommonConfig", "no permission,use sdcard default folder"); file = new File(FileUtil.a(this.a, 5)); } else { file = new File(FileUtil.a(this.a, 8)); } this.b = file; if (this.b == null || !this.b.isDirectory()) { return null; } } TbsLog.i("TbsCommonConfig", "mTbsConfigDir is " + this.b.getAbsolutePath()); File file3 = new File(this.b, "tbsnet.conf"); if (!file3.exists()) { TbsLog.e("TbsCommonConfig", "Get file(" + file3.getCanonicalPath() + ") failed!"); return null; } try { TbsLog.w("TbsCommonConfig", "pathc:" + file3.getCanonicalPath()); return file3; } catch (Throwable th2) { th = th2; file2 = file3; StringWriter stringWriter = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter)); TbsLog.e("TbsCommonConfig", "exceptions occurred2:" + stringWriter.toString()); return file2; } } catch (Throwable th3) { th = th3; StringWriter stringWriter2 = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter2)); TbsLog.e("TbsCommonConfig", "exceptions occurred2:" + stringWriter2.toString()); return file2; } } public String b() { return this.d; } public String c() { return this.f; } public String d() { return this.k; } public String e() { return this.l; } public String f() { return this.m; } public String g() { return this.g; } public String h() { return this.h; } public String i() { return this.e; } public String j() { return this.n; } }