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 m { /* renamed from: c reason: collision with root package name */ private static m f6989c; private Context a = null; /* 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) { 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 WARNING: Removed duplicated region for block: B:43:0x00e6 */ private synchronized void h() { Throwable th; BufferedInputStream bufferedInputStream = null; try { File i2 = i(); if (i2 == null) { TbsLog.e("TbsCommonConfig", "Config file is null, default values will be applied"); return; } BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(i2)); 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; } try { bufferedInputStream2.close(); } catch (IOException e2) { e2.printStackTrace(); } } catch (Throwable th2) { th = th2; bufferedInputStream = bufferedInputStream2; try { StringWriter stringWriter = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter)); TbsLog.e("TbsCommonConfig", "exceptions occurred1:" + stringWriter.toString()); if (bufferedInputStream != null) { bufferedInputStream.close(); } } catch (Throwable th3) { if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e3) { e3.printStackTrace(); } } throw th3; } } } catch (Throwable th4) { th = th4; StringWriter stringWriter2 = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter2)); TbsLog.e("TbsCommonConfig", "exceptions occurred1:" + stringWriter2.toString()); if (bufferedInputStream != null) { } } } private File i() { File file; Throwable th; File file2; try { if (this.f6990b == 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) { 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)); } else { file2 = new File(FileUtil.a(this.a, 8)); } this.f6990b = file2; if (this.f6990b == null || !this.f6990b.isDirectory()) { return null; } } file = new File(this.f6990b, "tbsnet.conf"); if (!file.exists()) { TbsLog.e("TbsCommonConfig", "Get file(" + file.getCanonicalPath() + ") failed!"); return null; } try { TbsLog.w("TbsCommonConfig", "pathc:" + file.getCanonicalPath()); } catch (Throwable th2) { th = th2; } return file; } catch (Throwable th3) { file = null; th = th3; StringWriter stringWriter = new StringWriter(); th.printStackTrace(new PrintWriter(stringWriter)); TbsLog.e("TbsCommonConfig", "exceptions occurred2:" + stringWriter.toString()); 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; } }