package com.alivc.player; import android.content.Context; import android.support.v4.media.session.PlaybackStateCompat; import android.text.TextUtils; import com.alibaba.sdk.android.oss.ClientException; import com.alibaba.sdk.android.oss.OSSClient; import com.alibaba.sdk.android.oss.ServiceException; import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider; import com.alibaba.sdk.android.oss.model.PutObjectRequest; import java.io.File; import org.json.JSONException; import org.json.JSONObject; public class LogOssUploader { private static final String TAG = "LogOssUploader"; private static JSONObject getCredential() throws JSONException { String doGet = HttpClientUtil.doGet("http://demo-vod.cn-shanghai.aliyuncs.com/voddemo/CreateSecurityToken?BusinessType=vodai&TerminalType=pc&DeviceModel=iPhone9,2&UUID=59ECA-4193-4695-94DD-7E1247288&AppVersion=1.0.0&UploadType=oss"); if (doGet == null) { return null; } return new JSONObject(doGet); } /* access modifiers changed from: private */ public static void uploadActural(Context context, String str) throws JSONException { JSONObject jSONObject; String str2; String str3; String str4; String str5; String str6; String str7; try { jSONObject = getCredential(); } catch (JSONException e2) { e2.printStackTrace(); jSONObject = null; } if (jSONObject != null) { JSONObject jSONObject2 = jSONObject.getJSONObject("UploadAddress"); if (jSONObject2 != null) { str4 = jSONObject2.getString("Prefix"); String string = jSONObject2.getString("Endpoint"); str2 = jSONObject2.getString("Bucket"); str3 = string; } else { str4 = null; str3 = null; str2 = null; } JSONObject jSONObject3 = jSONObject.getJSONObject("SecurityTokenInfo"); if (jSONObject3 != null) { String string2 = jSONObject3.getString("AccessKeyId"); String string3 = jSONObject3.getString("AccessKeySecret"); str7 = string2; str5 = jSONObject3.getString("SecurityToken"); str6 = string3; } else { str7 = null; str6 = null; str5 = null; } if (!TextUtils.isEmpty(str4) && !TextUtils.isEmpty(str3) && !TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str7) && !TextUtils.isEmpty(str6) && !TextUtils.isEmpty(str5)) { uploadToOss(context, str7, str6, str5, str, "player-logs", str3, str2); } } } static void uploadLogFile(Context context, final String str) { final Context applicationContext = context.getApplicationContext(); try { new Thread(new Runnable() { /* class com.alivc.player.LogOssUploader.AnonymousClass1 */ public void run() { try { LogOssUploader.uploadActural(applicationContext, str); } catch (JSONException e2) { e2.printStackTrace(); } } }).start(); } catch (Exception unused) { VcPlayerLog.e(TAG, " thread start ocure exception .."); } } /* JADX WARNING: Removed duplicated region for block: B:26:0x00fa */ /* JADX WARNING: Removed duplicated region for block: B:28:? A[RETURN, SYNTHETIC] */ private static void uploadToOss(Context context, String str, String str2, String str3, String str4, String str5, String str6, String str7) { File file; File file2 = new File(str4); if (file2.exists() && !file2.isDirectory()) { String name = file2.getName(); String str8 = name.substring(0, name.length() - 4) + ".zip"; String str9 = file2.getParentFile().getAbsolutePath() + "/" + str8; try { new ZipCompress(str9, str4).zip(); file = new File(str9); if (file.exists() && !file.isDirectory()) { long length = file.length(); if ((length / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID > 10) { VcPlayerLog.e(TAG, "zipFile len > 10M = return ... totalSpace = " + length); } else { try { new OSSClient(context, str6, new OSSStsTokenCredentialProvider(str, str2, str3)).putObject(new PutObjectRequest(str7, str5 + "/" + str8, str9)); file2.delete(); } catch (ClientException e2) { VcPlayerLog.e(TAG, e2.getMessage()); } catch (ServiceException unused) { } } } } catch (Exception e3) { if (e3.getCause() instanceof OutOfMemoryError) { VcPlayerLog.e(TAG, "oom, means file too large ,delete it: " + file2.getAbsolutePath()); file2.delete(); } } if (file == null) { file.delete(); return; } return; } file = null; if (file == null) { } } }