TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c
以下内容为反编译后的 QvipSpecialSoundManager.java 源代码,内容仅作参考
package com.tencent.mobileqq.activity.specialcare;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.tencent.common.app.AppInterface;
import com.tencent.commonsdk.pool.ByteArrayPool;
import com.tencent.mobileqq.app.AppConstants;
import com.tencent.mobileqq.app.ThreadManager;
import com.tencent.mobileqq.msf.sdk.MsfSdkUtils;
import com.tencent.mobileqq.utils.NetworkUtil;
import com.tencent.mobileqq.vip.DownloadTask;
import com.tencent.mobileqq.vip.DownloaderFactory;
import com.tencent.qphone.base.util.BaseApplication;
import com.tencent.qphone.base.util.QLog;
import com.tencent.tim.R;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
public class QvipSpecialSoundManager {
public static final int f86907a = 1000277;
public static final String f16900a = "http://i.gtimg.cn/club/moblie/special_sound/new_config.json";
public static final String f86908b = "specialcare_config";
public static final String f86909c = "key_special_sound_list";
private static final String d = "QvipSpecialSoundManager";
private Context f16903a;
private AppInterface f16905a;
public static HashMap f16901a = new HashMap();
public static HashMap f16902b = new HashMap();
private ByteArrayPool f16906a = new ByteArrayPool(4096);
private Handler f16904a = new Handler(Looper.getMainLooper());
public interface CallBack {
void a(boolean z);
}
public QvipSpecialSoundManager(Context context, AppInterface appInterface) {
this.f16903a = context;
this.f16905a = appInterface;
}
public void m4079a() {
String str;
int i;
String str2 = null;
SharedPreferences sharedPreferences = this.f16905a.getApp().getSharedPreferences(AppConstants.Preferences.bX, 4);
File file = new File(this.f16903a.getFilesDir(), f16900a);
try {
} catch (Exception e) {
m4083b("download error:" + e.toString());
e.printStackTrace();
}
if (file.exists()) {
str = a(file);
DownloadTask downloadTask = new DownloadTask(sharedPreferences.getString(f86908b, ""), file);
downloadTask.f34328a = (byte) 1;
downloadTask.f34367l = true;
i = DownloaderFactory.a(downloadTask, this.f16905a);
if (i == 0) {
try {
String a2 = a(file);
a(file != null ? file.length() : 0L);
str2 = a2;
} catch (Exception e2) {
m4083b("decodeTextFile is exception.");
e2.printStackTrace();
} catch (OutOfMemoryError e3) {
m4083b("decodeTextFile is OutOfMemoryError.");
e3.printStackTrace();
}
}
if (!TextUtils.isEmpty(str2)) {
m4083b("new Config is Empty");
return;
} else if (!TextUtils.isEmpty(str) && str.equals(str2)) {
m4083b("Config is Same");
return;
} else {
a(str, str2);
return;
}
}
str = null;
DownloadTask downloadTask2 = new DownloadTask(sharedPreferences.getString(f86908b, ""), file);
downloadTask2.f34328a = (byte) 1;
downloadTask2.f34367l = true;
i = DownloaderFactory.a(downloadTask2, this.f16905a);
if (i == 0) {
}
if (!TextUtils.isEmpty(str2)) {
}
}
public void b() {
c();
m4080a(a());
}
private void c() {
SharedPreferences sharedPreferences = this.f16905a.getApp().getSharedPreferences(AppConstants.Preferences.bX, 4);
if (!sharedPreferences.contains("defaulut_special_sound_source1")) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putInt("defaulut_special_sound_source1", R.raw.f58400name_res_0x7f07001a);
edit.commit();
}
}
public String a() {
int i;
boolean z;
File file = new File(this.f16903a.getFilesDir(), f16900a);
if (file.exists()) {
z = true;
} else {
try {
DownloadTask downloadTask = new DownloadTask(this.f16905a.getApp().getSharedPreferences(AppConstants.Preferences.bX, 4).getString(f86908b, ""), file);
downloadTask.f34328a = (byte) 1;
downloadTask.f34367l = true;
i = DownloaderFactory.a(downloadTask, this.f16905a);
} catch (Exception e) {
e.printStackTrace();
i = -1;
}
if (i != 0) {
z = false;
} else {
a(file != null ? file.length() : 0L);
z = true;
}
}
if (!z) {
m4083b("downLoad Special Sound Config failed.");
return "";
}
try {
return a(file);
} catch (IOException e2) {
m4083b("decodeTextFile is IOException.");
e2.printStackTrace();
return "";
} catch (Exception e3) {
m4083b("decodeTextFile is exception.");
e3.printStackTrace();
return "";
} catch (OutOfMemoryError e4) {
m4083b("decodeTextFile is OutOfMemoryError.");
e4.printStackTrace();
return "";
}
}
public void m4080a(String str) {
if (str != null && !TextUtils.isEmpty(str)) {
try {
QvipSpecialSoundConfig a2 = QvipSpecialSoundConfig.a(new JSONObject(str));
if (a2 != null) {
a(a2.f86906a);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private String a(File file) {
try {
FileInputStream fileInputStream = new FileInputStream(file);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buf = this.f16906a.getBuf(4096);
while (true) {
try {
try {
int read = fileInputStream.read(buf, 0, 4096);
if (read == -1) {
break;
}
byteArrayOutputStream.write(buf, 0, read);
} catch (IOException e) {
e.printStackTrace();
if (fileInputStream != null) {
fileInputStream.close();
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
this.f16906a.returnBuf(buf);
return "";
} catch (Exception e2) {
e2.printStackTrace();
if (fileInputStream != null) {
fileInputStream.close();
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
this.f16906a.returnBuf(buf);
return "";
}
} catch (Throwable th) {
if (fileInputStream != null) {
fileInputStream.close();
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
this.f16906a.returnBuf(buf);
throw th;
}
}
String str = new String(byteArrayOutputStream.toByteArray(), "utf-8");
if (fileInputStream != null) {
fileInputStream.close();
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
this.f16906a.returnBuf(buf);
return str;
} catch (FileNotFoundException e3) {
e3.printStackTrace();
return "";
}
}
private void a(String str, String str2) {
if (str != null) {
try {
if (!TextUtils.isEmpty(str) && str2 != null && !TextUtils.isEmpty(str2)) {
QvipSpecialSoundConfig a2 = QvipSpecialSoundConfig.a(new JSONObject(str2));
QvipSpecialSoundConfig a3 = QvipSpecialSoundConfig.a(new JSONObject(str));
List list = a2.f86906a;
List list2 = a3.f86906a;
if (list == null || list2 == null || list.isEmpty() || list2.isEmpty() || list.size() < list2.size()) {
m4083b("updateSpecialSound return.");
return;
}
int size = list2.size();
for (int i = 0; i < size; i++) {
ojf ojfVar = (ojf) list.get(i);
ojf ojfVar2 = (ojf) list2.get(i);
if (ojfVar.f105490a == ojfVar2.f105490a && !ojfVar.f75108b.equals(ojfVar2.f75108b)) {
ThreadManager.a(new ojg(this, ojfVar), 5, null, true);
}
}
}
} catch (Exception e) {
m4083b("updateSpecialSound exception");
e.printStackTrace();
}
}
}
public boolean m4082a(String str) {
int i;
if (str == null || TextUtils.isEmpty(str)) {
return false;
}
try {
DownloadTask downloadTask = new DownloadTask(MsfSdkUtils.insertMtype("lingyin", str), new File(this.f16903a.getFilesDir(), str));
downloadTask.f34328a = (byte) 1;
i = DownloaderFactory.a(downloadTask, this.f16905a);
} catch (Exception e) {
e.printStackTrace();
i = -1;
}
return i == 0;
}
public void a(long j) {
String[] strArr;
if (j <= 0) {
m4083b("reportFlowData is Empty flowSize = " + j);
return;
}
if (NetworkUtil.b((Context) BaseApplication.getContext()) == 1) {
m4083b("reportFlowData int wifi state");
strArr = new String[]{AppConstants.FlowStatPram.aA, "param_WIFIFlow", "param_Flow"};
} else {
m4083b("reportFlowData int 2G/3G state");
strArr = new String[]{AppConstants.FlowStatPram.aB, "param_XGFlow", "param_Flow"};
}
m4083b("sendAppDataIncerment flowSize = " + j);
this.f16905a.sendAppDataIncerment(this.f16905a.getAccount(), strArr, j);
}
private void a(List list) {
if (list == null || list.isEmpty()) {
m4083b("SpecialSoundList is empty, donot need sort.");
return;
}
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
int size = list.size();
SharedPreferences.Editor edit = this.f16905a.getApp().getSharedPreferences(AppConstants.Preferences.bX, 4).edit();
for (int i = 0; i < size; i++) {
ojf ojfVar = (ojf) list.get(i);
if (!f16902b.containsKey(String.valueOf(ojfVar.f105490a))) {
f16902b.put(String.valueOf(ojfVar.f105490a), ojfVar);
}
edit.putString(AppConstants.Preferences.bZ + ojfVar.f105490a, ojfVar.f75109c);
if (!b(ojfVar.f75110d)) {
m4083b("is white list.");
} else if (ojfVar.f105492c == 1) {
if (ojfVar.f105491b == 1) {
arrayList.add(ojfVar);
} else if (ojfVar.f105491b == 2) {
arrayList2.add(ojfVar);
} else {
arrayList3.add(ojfVar);
}
}
}
edit.commit();
list.clear();
list.addAll(arrayList);
list.addAll(arrayList2);
list.addAll(arrayList3);
if (!f16901a.containsKey(f86909c + this.f16905a.getCurrentAccountUin())) {
f16901a.put(f86909c + this.f16905a.getCurrentAccountUin(), list);
}
}
private boolean b(String str) {
String currentAccountUin = this.f16905a.getCurrentAccountUin();
if (str == null || TextUtils.isEmpty(str)) {
return true;
}
if (str.contains("|")) {
try {
for (String str2 : str.split("\\|")) {
if (str2.trim().equals(currentAccountUin)) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return str.equals(currentAccountUin);
}
public void m4083b(String str) {
if (QLog.isColorLevel()) {
QLog.i(d, 2, str);
}
}
public void a(CallBack callBack) {
ThreadManager.a(new ojh(this, callBack), 5, null, true);
}
public void a(CallBack callBack, boolean z) {
this.f16904a.post(new oji(this, callBack, z));
}
public String a(int i) {
ojf ojfVar;
if (f16902b == null || f16902b.isEmpty() || (ojfVar = (ojf) f16902b.get(String.valueOf(i))) == null) {
return "";
}
return ojfVar.f75107a;
}
public boolean m4081a() {
return f16901a.containsKey(f86909c + this.f16905a.getCurrentAccountUin());
}
public int a(String str) {
List<ojf> list = (List) f16901a.get(f86909c + this.f16905a.getCurrentAccountUin());
if (list == null) {
return -1;
}
for (ojf ojfVar : list) {
if (str.equals(ojfVar.f75109c)) {
return ojfVar.f105490a;
}
}
return -1;
}
public String m4078a(String str) {
List<ojf> list = (List) f16901a.get(f86909c + this.f16905a.getCurrentAccountUin());
if (list == null) {
return null;
}
for (ojf ojfVar : list) {
if (str.equals(ojfVar.f75109c)) {
return ojfVar.f75107a;
}
}
return null;
}
}