正在查看: 漫天星 v3.0.2 应用的 DownloadService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 漫天星 v3.0.2 应用的 DownloadService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.azhon.appupdate.service;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.azhon.appupdate.R$string;
import f.c.a.d.b;
import f.c.a.f.d;
import f.c.a.f.e;
import f.c.a.f.f;
import java.io.File;
import java.util.Iterator;
import java.util.List;
public final class DownloadService extends Service implements b {
public int n;
public String o;
public String p;
public String q;
public List<b> r;
public boolean s;
public boolean t;
public boolean u;
public int v;
public f.c.a.e.a w;
@SuppressLint({"HandlerLeak"})
public Handler x = new a();
public class a extends Handler {
public a() {
}
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == 0) {
Toast.makeText(DownloadService.this, R$string.background_downloading, 0).show();
return;
}
if (i == 1) {
Iterator it = DownloadService.this.r.iterator();
while (it.hasNext()) {
((b) it.next()).start();
}
return;
}
if (i == 2) {
Iterator it2 = DownloadService.this.r.iterator();
while (it2.hasNext()) {
((b) it2.next()).n(message.arg1, message.arg2);
}
return;
}
if (i == 3) {
Iterator it3 = DownloadService.this.r.iterator();
while (it3.hasNext()) {
((b) it3.next()).j((File) message.obj);
}
DownloadService.this.g();
return;
}
if (i == 4) {
Iterator it4 = DownloadService.this.r.iterator();
while (it4.hasNext()) {
((b) it4.next()).cancel();
}
} else {
if (i != 5) {
return;
}
Iterator it5 = DownloadService.this.r.iterator();
while (it5.hasNext()) {
((b) it5.next()).a((Exception) message.obj);
}
}
}
}
@Override
public void a(Exception exc) {
e.b("AppUpdate.DownloadService", "error: " + exc);
this.w.v(false);
if (this.s) {
f.h(this, this.n, getResources().getString(R$string.download_error), getResources().getString(R$string.continue_downloading));
}
this.x.obtainMessage(5, exc).sendToTarget();
}
@Override
public void cancel() {
this.w.v(false);
if (this.s) {
f.c(this);
}
this.x.sendEmptyMessage(4);
}
public final boolean d() {
if (d.c(this.q, this.p)) {
return d.d(d.b(this.q, this.p)).equalsIgnoreCase(this.w.e());
}
return false;
}
public final synchronized void e(f.c.a.b.a aVar) {
if (this.w.o()) {
e.b("AppUpdate.DownloadService", "download: 当前正在下载,请务重复下载!");
return;
}
f.c.a.a.a e = aVar.e();
if (e == null) {
e = new f.c.a.e.b(this.q);
aVar.n(e);
}
e.a(this.o, this.p, this);
this.w.v(true);
}
public final void f() {
f.c.a.e.a l = f.c.a.e.a.l();
this.w = l;
if (l == null) {
e.a("AppUpdate.DownloadService", "init DownloadManager.getInstance() = null ,请先调用 getInstance(Context context) !");
return;
}
this.o = l.h();
this.p = this.w.f();
this.q = this.w.k();
this.n = this.w.n();
d.a(this.q);
f.c.a.b.a j = this.w.j();
this.r = j.i();
this.s = j.m();
this.t = j.l();
this.u = j.k();
e.a("AppUpdate.DownloadService", f.e(this) ? "应用的通知栏开关状态:已打开" : "应用的通知栏开关状态:已关闭");
if (d()) {
e.a("AppUpdate.DownloadService", "文件已经存在直接进行安装");
j(d.b(this.q, this.p));
} else {
e.a("AppUpdate.DownloadService", "文件不存在开始下载");
e(j);
}
}
public final void g() {
Handler handler = this.x;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
stopSelf();
this.w.p();
}
@Override
public void j(File file) {
e.a("AppUpdate.DownloadService", "done: 文件已下载至" + file.toString());
this.w.v(false);
if (this.s || Build.VERSION.SDK_INT >= 29) {
f.g(this, this.n, getResources().getString(R$string.download_completed), getResources().getString(R$string.click_hint), f.c.a.f.b.a, file);
}
if (this.u) {
f.c.a.f.a.b(this, f.c.a.f.b.a, file);
}
this.x.obtainMessage(3, file).sendToTarget();
}
@Override
public void n(int i, int i2) {
int i3;
String str;
e.c("AppUpdate.DownloadService", "max: " + i + " --- progress: " + i2);
if (this.s && (i3 = (int) ((i2 / i) * 100.0d)) != this.v) {
this.v = i3;
String string = getResources().getString(R$string.start_downloading);
if (i3 < 0) {
str = "";
} else {
str = i3 + "%";
}
f.j(this, this.n, string, str, i != -1 ? 100 : -1, i3);
}
this.x.obtainMessage(2, i, i2).sendToTarget();
}
@Override
@Nullable
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (intent == null) {
return 1;
}
f();
return super.onStartCommand(intent, i, i2);
}
@Override
public void start() {
if (this.s) {
if (this.t) {
this.x.sendEmptyMessage(0);
}
f.i(this, this.n, getResources().getString(R$string.start_download), getResources().getString(R$string.start_download_hint));
}
this.x.sendEmptyMessage(1);
}
}