230 lines
6.9 KiB
Java
230 lines
6.9 KiB
Java
package com.baidu.license.download;
|
|
|
|
import android.app.Service;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.IBinder;
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
import com.baidu.license.download.DownloadRequest;
|
|
import com.baidu.license.download.base.DownloadCallback;
|
|
import com.baidu.license.download.exception.DownloadException;
|
|
import com.baidu.license.download.utils.CommonUtils;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class CaptureDownloadService extends Service {
|
|
private DownloadManager a;
|
|
|
|
private void a(String str) {
|
|
this.a.a(str);
|
|
}
|
|
|
|
private void b(String str) {
|
|
this.a.b(str);
|
|
}
|
|
|
|
@Override // android.app.Service
|
|
public IBinder onBind(Intent intent) {
|
|
return null;
|
|
}
|
|
|
|
@Override // android.app.Service
|
|
public void onCreate() {
|
|
super.onCreate();
|
|
this.a = DownloadManager.c();
|
|
}
|
|
|
|
@Override // android.app.Service
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
this.a.b();
|
|
}
|
|
|
|
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
|
/* JADX WARN: Code restructure failed: missing block: B:5:0x0034, code lost:
|
|
|
|
if (r0.equals("com.baidu.cloudar.download.ACTION_DOWNLOAD") != false) goto L22;
|
|
*/
|
|
@Override // android.app.Service
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public int onStartCommand(android.content.Intent r12, int r13, int r14) {
|
|
/*
|
|
r11 = this;
|
|
if (r12 == 0) goto L7e
|
|
java.lang.String r0 = r12.getAction()
|
|
r1 = 0
|
|
java.lang.String r2 = "extra_position"
|
|
int r2 = r12.getIntExtra(r2, r1)
|
|
com.baidu.license.download.nx r3 = new com.baidu.license.download.nx
|
|
r3.<init>()
|
|
java.lang.String r4 = "extra_file_info"
|
|
java.lang.String r4 = r12.getStringExtra(r4)
|
|
r3.a(r4)
|
|
java.lang.String r4 = "extra_tag"
|
|
java.lang.String r4 = r12.getStringExtra(r4)
|
|
r5 = -1
|
|
int r6 = r0.hashCode()
|
|
r7 = 4
|
|
r8 = 3
|
|
r9 = 2
|
|
r10 = 1
|
|
switch(r6) {
|
|
case -1845641145: goto L55;
|
|
case -1229466579: goto L4b;
|
|
case -540402171: goto L41;
|
|
case 1657148651: goto L37;
|
|
case 1915551059: goto L2e;
|
|
default: goto L2d;
|
|
}
|
|
L2d:
|
|
goto L5f
|
|
L2e:
|
|
java.lang.String r6 = "com.baidu.cloudar.download.ACTION_DOWNLOAD"
|
|
boolean r0 = r0.equals(r6)
|
|
if (r0 == 0) goto L5f
|
|
goto L60
|
|
L37:
|
|
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_PAUSE"
|
|
boolean r0 = r0.equals(r1)
|
|
if (r0 == 0) goto L5f
|
|
r1 = 1
|
|
goto L60
|
|
L41:
|
|
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_CANCEL"
|
|
boolean r0 = r0.equals(r1)
|
|
if (r0 == 0) goto L5f
|
|
r1 = 2
|
|
goto L60
|
|
L4b:
|
|
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_PAUSE_ALL"
|
|
boolean r0 = r0.equals(r1)
|
|
if (r0 == 0) goto L5f
|
|
r1 = 3
|
|
goto L60
|
|
L55:
|
|
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_CANCEL_ALL"
|
|
boolean r0 = r0.equals(r1)
|
|
if (r0 == 0) goto L5f
|
|
r1 = 4
|
|
goto L60
|
|
L5f:
|
|
r1 = -1
|
|
L60:
|
|
if (r1 == 0) goto L7b
|
|
if (r1 == r10) goto L77
|
|
if (r1 == r9) goto L73
|
|
if (r1 == r8) goto L6f
|
|
if (r1 == r7) goto L6b
|
|
goto L7e
|
|
L6b:
|
|
r11.a()
|
|
goto L7e
|
|
L6f:
|
|
r11.b()
|
|
goto L7e
|
|
L73:
|
|
r11.a(r4)
|
|
goto L7e
|
|
L77:
|
|
r11.b(r4)
|
|
goto L7e
|
|
L7b:
|
|
r11.a(r2, r3, r4)
|
|
L7e:
|
|
int r12 = super.onStartCommand(r12, r13, r14)
|
|
return r12
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.baidu.license.download.CaptureDownloadService.onStartCommand(android.content.Intent, int, int):int");
|
|
}
|
|
|
|
private void a() {
|
|
this.a.a();
|
|
}
|
|
|
|
private void b() {
|
|
this.a.b();
|
|
}
|
|
|
|
private void a(int i, nx nxVar, String str) {
|
|
DownloadRequest.Builder builder = new DownloadRequest.Builder();
|
|
builder.a(nxVar.b());
|
|
this.a.a(builder.a(), str, new ProgressCallback(i, nxVar, getApplicationContext()));
|
|
}
|
|
|
|
public static class ProgressCallback extends DownloadCallback {
|
|
private int a;
|
|
private nx b;
|
|
private LocalBroadcastManager c;
|
|
private long d;
|
|
private int e;
|
|
|
|
public ProgressCallback(int i, nx nxVar, Context context) {
|
|
this.a = i;
|
|
this.b = nxVar;
|
|
this.c = LocalBroadcastManager.a(context);
|
|
}
|
|
|
|
@Override // com.baidu.license.download.base.DownloadCallback
|
|
public void a(long j, long j2, int i) {
|
|
if (this.d == 0) {
|
|
this.d = System.currentTimeMillis();
|
|
}
|
|
this.b.b(3);
|
|
this.b.a(i);
|
|
this.b.b(CommonUtils.a(j, j2));
|
|
if (a(i)) {
|
|
a(this.b);
|
|
}
|
|
}
|
|
|
|
@Override // com.baidu.license.download.base.DownloadCallback
|
|
public void b() {
|
|
this.b.b(0);
|
|
this.b.a(0);
|
|
this.b.b("");
|
|
a(this.b);
|
|
}
|
|
|
|
@Override // com.baidu.license.download.base.DownloadCallback
|
|
public void c() {
|
|
this.b.b(4);
|
|
a(this.b);
|
|
}
|
|
|
|
@Override // com.baidu.license.download.base.DownloadCallback
|
|
public void a(String str) {
|
|
this.b.b(6);
|
|
this.b.a(100);
|
|
this.b.c(str);
|
|
a(this.b);
|
|
}
|
|
|
|
@Override // com.baidu.license.download.base.DownloadCallback
|
|
public void a(DownloadException downloadException) {
|
|
downloadException.printStackTrace();
|
|
this.b.b(5);
|
|
a(this.b);
|
|
}
|
|
|
|
private void a(nx nxVar) {
|
|
Intent intent = new Intent();
|
|
intent.setAction("com.baidu.cloudar.download.ACTION_BROAD_CAST");
|
|
intent.putExtra("extra_position", this.a);
|
|
intent.putExtra("extra_file_info", nxVar.a().toString());
|
|
this.c.a(intent);
|
|
}
|
|
|
|
private boolean a(int i) {
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
if (currentTimeMillis - this.d <= 300 || i == this.e) {
|
|
return false;
|
|
}
|
|
this.d = currentTimeMillis;
|
|
this.e = i;
|
|
return true;
|
|
}
|
|
}
|
|
}
|