TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c
以下内容为反编译后的 QzoneUploadInterface.java 源代码,内容仅作参考
package cooperation.qzone.webviewplugin;
import android.content.Context;
import android.os.Environment;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.Base64;
import com.tencent.common.app.AppInterface;
import com.tencent.mobileqq.webview.utils.WebViewConstant;
import com.tencent.qphone.base.util.QLog;
import com.tencent.upload.uinterface.data.UpsImageUploadTask;
import cooperation.qzone.remote.logic.RemoteHandleManager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.UUID;
import mqq.app.MobileQQ;
import mqq.manager.TicketManager;
public class QzoneUploadInterface {
public static final int f98847a = 5;
public static final String f71003a = "js-upload: ";
public static final String f98848b = "uploader";
public static final String f98849c = ".qtmp";
private static final String d = "js-upload: QzoneWebUploadInterface";
private static final String e = "data:image/jpg;base64,";
private static final String f = "data:image/png;base64,";
private static final String g = "data:image/jpeg;base64,";
public static String a(Context context, String str) {
String replace = str.replace(e, "").replace(g, "").replace(f, "");
String b2 = b(context, UUID.randomUUID().toString());
if (TextUtils.isEmpty(b2)) {
QLog.e(d, 1, "getTempFilePath return null !");
return null;
}
try {
boolean a2 = a(Base64.decode(replace.getBytes(), 2), b2);
QLog.d(d, 1, "saveByteBufferToLocalFile ret:" + a2);
if (!a2) {
b2 = null;
}
return b2;
} catch (Exception e2) {
QLog.d(d, 1, "Base64.decode Exception: " + e2.toString());
return null;
}
}
protected static boolean a(byte[] bArr, String str) {
FileOutputStream fileOutputStream;
boolean z = true;
if (TextUtils.isEmpty(str)) {
return false;
}
FileOutputStream fileOutputStream2 = null;
try {
try {
File file = new File(str);
if (!file.exists()) {
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
} catch (IOException e2) {
e = e2;
}
} catch (Throwable th) {
th = th;
}
try {
fileOutputStream.write(bArr);
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (Exception e3) {
QLog.d(d, 1, "fos close " + e3);
}
}
} catch (IOException e4) {
e = e4;
fileOutputStream2 = fileOutputStream;
QLog.d(d, 1, "save bytes to local file " + e);
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
z = false;
} catch (Exception e5) {
QLog.d(d, 1, "fos close " + e5);
z = false;
}
} else {
z = false;
}
return z;
} catch (Throwable th2) {
th = th2;
fileOutputStream2 = fileOutputStream;
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (Exception e6) {
QLog.d(d, 1, "fos close " + e6);
}
}
throw th;
}
return z;
}
public static boolean m11135a(String str, String str2) {
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
QLog.w(d, 1, "localPath: " + str + " bid:" + str2);
return false;
} else if (!new File(str).exists()) {
QLog.w(d, 1, "upload file not exist! localPath:" + str);
return false;
} else {
new UpsImageUploadTask(false).uploadFilePath = str;
AppInterface appInterface = (AppInterface) MobileQQ.sMobileQQ.waitAppRuntime(null).getAppRuntime(WebViewConstant.h);
if (appInterface == null) {
QLog.w(d, 1, "app == null");
return false;
}
TicketManager ticketManager = (TicketManager) appInterface.getManager(2);
String account = appInterface.getAccount();
String skey = ticketManager.getSkey(account);
String a2 = ticketManager.getA2(account);
if (TextUtils.isEmpty(skey) || TextUtils.isEmpty(a2)) {
QLog.w(d, 1, "mSkey == null || mA2 == null, mSkey=" + skey + " mA2=" + a2);
return false;
}
RemoteHandleManager.a().m11010a().a(str, str2);
return true;
}
}
public static boolean a(String str, int i, int i2, byte[] bArr) {
if (TextUtils.isEmpty(str)) {
QLog.w(d, 1, "localPath is empty : " + str);
return false;
} else if (!new File(str).exists()) {
QLog.w(d, 1, "upload file not exist! localPath : " + str);
return false;
} else {
RemoteHandleManager.a().m11010a().a(str, i, i2, bArr);
return true;
}
}
public static final String a(String str, String str2) {
return new StringBuilder(8).append(str).append(File.separator).append(str2).append(f98849c).toString();
}
public static String b(Context context, String str) {
File dir;
File a2;
if (str == null) {
return null;
}
if ("mounted".equals(Environment.getExternalStorageState()) && a() > 5 && (a2 = a(context)) != null) {
return a(a2.getAbsolutePath(), str);
}
if (b() <= 5 || (dir = context.getDir(f98848b, 0)) == null) {
return null;
}
return a(dir.getAbsolutePath(), str);
}
private static File a(Context context) {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
if (externalStorageDirectory == null || !externalStorageDirectory.exists() || context == null) {
return null;
}
StringBuilder sb = new StringBuilder(11);
sb.append(externalStorageDirectory.getAbsolutePath());
sb.append(File.separator);
sb.append("Android");
sb.append(File.separator);
sb.append("data");
sb.append(File.separator);
sb.append(context.getPackageName());
sb.append(File.separator);
sb.append("files");
sb.append(File.separator);
sb.append(f98848b);
File file = new File(sb.toString());
if (file.isDirectory() || file.mkdirs()) {
return file;
}
return null;
}
public static int a() {
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
return (int) (((statFs.getBlockSize() * (1.0d * statFs.getAvailableBlocks())) / 1024.0d) / 1024.0d);
}
public static int b() {
StatFs statFs = new StatFs(Environment.getRootDirectory().getPath());
return (int) (((statFs.getBlockSize() * (1.0d * statFs.getAvailableBlocks())) / 1024.0d) / 1024.0d);
}
}