翰林优商.apk(点击下载) / ExChangeVideoBroadcast.java
package com.mbridge.msdk.system;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.text.TextUtils;
import com.mbridge.msdk.foundation.aidl.VideoBinderInterface;
import com.mbridge.msdk.foundation.aidl.VideoBinderListener;
import com.mbridge.msdk.foundation.controller.a;
import com.mbridge.msdk.foundation.download.DownloadResourceType;
import com.mbridge.msdk.foundation.download.core.GlobalComponent;
import com.mbridge.msdk.foundation.download.database.DownloadModel;
import com.mbridge.msdk.foundation.same.b.c;
import com.mbridge.msdk.foundation.same.b.e;
import com.mbridge.msdk.foundation.same.f.b;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ExChangeVideoBroadcast extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String str;
if (context != null && intent != null) {
String str2 = null;
try {
str = intent.getAction();
} catch (Exception unused) {
str = null;
}
if (!TextUtils.isEmpty(str) && TextUtils.equals(str, "mbridge_action_exchange_pm_receiver")) {
try {
str2 = intent.getExtras().getString("pm-receiver");
} catch (Exception unused2) {
}
if (!TextUtils.isEmpty(str2) && !TextUtils.equals(str2, context.getPackageName())) {
try {
abortBroadcast();
} catch (Exception unused3) {
}
b.a().execute(new ExChangeVideoRunnable(str2));
}
}
}
}
private static class ExChangeVideoRunnable implements Runnable {
private String pn;
private VideoBinderInterface videoBinderInterface;
public ExChangeVideoRunnable(String str) {
this.pn = str;
}
public void run() {
List<DownloadModel> list;
if (!(a.f().j() == null || TextUtils.isEmpty(this.pn))) {
try {
list = GlobalComponent.getInstance().getDatabaseHelper().findAll();
} catch (Exception unused) {
list = null;
}
ArrayList arrayList = new ArrayList();
final ArrayList arrayList2 = new ArrayList();
if (list != null && list.size() > 0) {
for (DownloadModel downloadModel : list) {
if (downloadModel != null && downloadModel.getDownloadedBytes() == downloadModel.getTotalBytes()) {
arrayList.add(downloadModel);
arrayList2.add(downloadModel.getResourceUrl());
}
}
}
Intent intent = new Intent("com.mbridge.msdk.foundation.aidl.VideoRequestService");
intent.setClassName(this.pn, "com.mbridge.msdk.foundation.aidl.VideoRequestService");
a.f().j().bindService(intent, new ServiceConnection() {
/* class com.mbridge.msdk.system.ExChangeVideoBroadcast.ExChangeVideoRunnable.AnonymousClass1 */
public final void onServiceDisconnected(ComponentName componentName) {
}
public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
if (iBinder != null) {
try {
ExChangeVideoRunnable.this.videoBinderInterface = VideoBinderInterface.Stub.asInterface(iBinder);
} catch (Exception unused) {
}
}
if (ExChangeVideoRunnable.this.videoBinderInterface != null) {
try {
ExChangeVideoRunnable.this.videoBinderInterface.registerListener(new VideoBinderListener.a() {
/* class com.mbridge.msdk.system.ExChangeVideoBroadcast.ExChangeVideoRunnable.AnonymousClass1.AnonymousClass1 */
@Override // com.mbridge.msdk.foundation.aidl.VideoBinderListener
public final void onVideo(final String str, final long j, final String str2, final String str3, final String str4, final ParcelFileDescriptor parcelFileDescriptor) throws RemoteException {
b.a().execute(new Runnable() {
/* class com.mbridge.msdk.system.ExChangeVideoBroadcast.ExChangeVideoRunnable.AnonymousClass1.AnonymousClass1.AnonymousClass1 */
/* JADX WARNING: Can't wrap try/catch for region: R(9:18|19|20|21|22|23|24|25|52) */
/* JADX WARNING: Code restructure failed: missing block: B:51:?, code lost:
return;
*/
/* JADX WARNING: Failed to process nested try/catch */
/* JADX WARNING: Missing exception handler attribute for start block: B:22:0x0082 */
/* JADX WARNING: Missing exception handler attribute for start block: B:24:0x0085 */
/* JADX WARNING: Removed duplicated region for block: B:37:0x00a5 A[SYNTHETIC, Splitter:B:37:0x00a5] */
/* JADX WARNING: Removed duplicated region for block: B:41:0x00ac A[SYNTHETIC, Splitter:B:41:0x00ac] */
/* JADX WARNING: Removed duplicated region for block: B:45:0x00b3 A[SYNTHETIC, Splitter:B:45:0x00b3] */
public final void run() {
FileOutputStream fileOutputStream;
ByteArrayOutputStream byteArrayOutputStream;
Throwable th;
FileOutputStream fileOutputStream2;
String str;
String str2;
String str3;
String str4;
long j;
FileInputStream fileInputStream = null;
try {
String str5 = e.b(c.MBRIDGE_VC) + File.separator;
FileInputStream fileInputStream2 = new FileInputStream(parcelFileDescriptor.getFileDescriptor());
try {
fileOutputStream2 = new FileOutputStream(new File(str5, str4));
} catch (Throwable th2) {
th = th2;
byteArrayOutputStream = null;
fileOutputStream = null;
fileInputStream = fileInputStream2;
if (fileInputStream != null) {
}
if (fileOutputStream != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
try {
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[4096];
while (true) {
int read = fileInputStream2.read(bArr, 0, 4096);
if (read == -1) {
break;
}
try {
byteArrayOutputStream2.write(bArr, 0, read);
} catch (Throwable th3) {
th = th3;
fileInputStream = fileInputStream2;
byteArrayOutputStream = byteArrayOutputStream2;
fileOutputStream = fileOutputStream2;
}
}
fileOutputStream2.write(byteArrayOutputStream2.toByteArray());
fileOutputStream2.flush();
str = str2;
str2 = str;
str3 = str3;
str4 = str4;
j = j;
byteArrayOutputStream = byteArrayOutputStream2;
fileOutputStream = fileOutputStream2;
} catch (Throwable th4) {
th = th4;
byteArrayOutputStream = byteArrayOutputStream2;
fileOutputStream = fileOutputStream2;
fileInputStream = fileInputStream2;
if (fileInputStream != null) {
}
if (fileOutputStream != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
} catch (Throwable th5) {
th = th5;
fileOutputStream = fileOutputStream2;
byteArrayOutputStream = null;
fileInputStream = fileInputStream2;
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException unused) {
}
}
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException unused2) {
}
}
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
} catch (IOException unused3) {
}
}
throw th;
}
try {
GlobalComponent.getInstance().getDatabaseHelper().insert(DownloadModel.create(str, str2, str2, str3, str5, str4, j, j, 100, 0, DownloadResourceType.DOWNLOAD_RESOURCE_TYPE_VIDEO, 1));
fileInputStream2.close();
fileOutputStream.close();
byteArrayOutputStream.close();
} catch (Throwable th6) {
th = th6;
fileInputStream = fileInputStream2;
if (fileInputStream != null) {
}
if (fileOutputStream != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
} catch (Throwable th7) {
th = th7;
byteArrayOutputStream = null;
fileOutputStream = null;
if (fileInputStream != null) {
}
if (fileOutputStream != null) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
}
});
}
});
List list = arrayList2;
if (list == null || list.size() <= 0) {
ExChangeVideoRunnable.this.videoBinderInterface.requestVideo(null);
return;
}
String[] strArr = new String[arrayList2.size()];
for (int i = 0; i < arrayList2.size(); i++) {
strArr[i] = (String) arrayList2.get(i);
}
try {
ExChangeVideoRunnable.this.videoBinderInterface.requestVideo(strArr);
} catch (RemoteException unused2) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}, 1);
}
}
}
}