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; /* loaded from: classes3.dex */ public class m { /* renamed from: c reason: collision with root package name */ private static m f6989c; private Context a; /* renamed from: b reason: collision with root package name */ private File f6990b = null; /* renamed from: d reason: collision with root package name */ private String f6991d = "https://log.tbs.qq.com/ajax?c=pu&v=2&k="; /* renamed from: e reason: collision with root package name */ private String f6992e = "https://log.tbs.qq.com/ajax?c=pu&tk="; /* renamed from: f reason: collision with root package name */ private String f6993f = "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 = "https://tbsrecovery.imtt.qq.com/getconfig"; @TargetApi(11) private m(Context context) { this.a = null; TbsLog.w("TbsCommonConfig", "TbsCommonConfig constructing..."); this.a = context.getApplicationContext(); h(); } public static synchronized m a() { m mVar; synchronized (m.class) { mVar = f6989c; } return mVar; } public static synchronized m a(Context context) { m mVar; synchronized (m.class) { if (f6989c == null) { f6989c = new m(context); } mVar = f6989c; } return mVar; } /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:46:0x00eb -> B:59:0x00ee). Please submit an issue!!! */ private synchronized void h() { File i; BufferedInputStream bufferedInputStream = null; try { try { i = i(); } catch (IOException e2) { e2.printStackTrace(); } } catch (Throwable th) { th = th; } if (i == null) { TbsLog.e("TbsCommonConfig", "Config file is null, default values will be applied"); return; } BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(i)); try { Properties properties = new Properties(); properties.load(bufferedInputStream2); String property = properties.getProperty("pv_post_url", ""); if (!"".equals(property)) { this.f6991d = property; } String property2 = properties.getProperty("tbs_download_stat_post_url", ""); if (!"".equals(property2)) { this.f6993f = property2; } String property3 = properties.getProperty("tbs_downloader_post_url", ""); if (!"".equals(property3)) { this.g = property3; } String property4 = properties.getProperty("tbs_log_post_url", ""); if (!"".equals(property4)) { this.h = property4; } String property5 = properties.getProperty("tips_url", ""); if (!"".equals(property5)) { this.i = property5; } String property6 = properties.getProperty("tbs_cmd_post_url", ""); if (!"".equals(property6)) { this.j = property6; } String property7 = properties.getProperty("tbs_emergency_post_url", ""); if (!"".equals(property7)) { this.k = property7; } String property8 = properties.getProperty("pv_post_url_tk", ""); if (!"".equals(property8)) { this.f6992e = property8; } bufferedInputStream2.close(); } catch (Throwable th2) { th = th2; bufferedInputStream = bufferedInputStream2; StringWriter stringWriter = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter)); TbsLog.e("TbsCommonConfig", "exceptions occurred1:" + stringWriter.toString()); if (bufferedInputStream != null) { bufferedInputStream.close(); } } } private File i() { File file; Throwable th; StringWriter stringWriter; File file2; try { if (this.f6990b == null) { String str = this.a.getApplicationContext().getApplicationInfo().packageName; if (TextUtils.isEmpty(str)) { file2 = new File(FileUtil.a(this.a, 8)); } else { 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 && !z) { file2 = new File(FileUtil.a(this.a, 8)); } TbsLog.i("TbsCommonConfig", "no permission,use sdcard default folder"); file2 = new File(FileUtil.a(this.a, 5)); } this.f6990b = file2; if (this.f6990b == null || !this.f6990b.isDirectory()) { return null; } } file = new File(this.f6990b, "tbsnet.conf"); } catch (Throwable th2) { file = null; th = th2; } if (!file.exists()) { TbsLog.e("TbsCommonConfig", "Get file(" + file.getCanonicalPath() + ") failed!"); return null; } try { TbsLog.w("TbsCommonConfig", "pathc:" + file.getCanonicalPath()); } catch (Throwable th3) { th = th3; th.printStackTrace(new PrintWriter(new StringWriter())); TbsLog.e("TbsCommonConfig", "exceptions occurred2:" + stringWriter.toString()); return file; } return file; } public String b() { return this.f6991d; } public String c() { return this.f6993f; } public String d() { return this.g; } public String e() { return this.h; } public String f() { return this.f6992e; } public String g() { return this.k; } }