正在查看: 多多分期 v4.1.2 应用的 FZGB0Service.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 多多分期 v4.1.2 应用的 FZGB0Service.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.duoduofenqi.gzd;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import com.duoduofenqi.mjyp.BMAG01ACT;
import com.duoduofenqi.mjyp.app.fragment.AppUpdateFragmentDialog;
import d.b.a.l;
import d.b.a.r.d;
import d.b.a.r.n;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
public class FZGB0Service extends Service {
public static AppUpdateFragmentDialog f3802k;
public File f3803c;
public String f3804d;
public long f3805e;
public int f3806f;
public int f3807g;
public boolean f3808h = false;
public boolean f3809i = false;
public Handler f3810j;
public class a extends BroadcastReceiver {
public a() {
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("STATUS_BAR_COVER_CLICK_ACTION")) {
if (!FZGB0Service.this.f3808h && FZGB0Service.this.f3809i) {
FZGB0Service.this.p();
return;
}
if (FZGB0Service.this.f3808h || FZGB0Service.this.f3809i) {
return;
}
FZGB0Service.this.f3808h = false;
FZGB0Service.this.f3809i = false;
FZGB0Service.this.new c().start();
FZGB0Service fZGB0Service = FZGB0Service.this;
fZGB0Service.t(fZGB0Service.getResources().getString(l.now_down), FZGB0Service.this.getResources().getString(l.has_down) + FZGB0Service.this.f3806f + "%");
}
}
}
public class b extends Handler {
public b() {
}
@Override
public void handleMessage(Message message) {
int i2 = message.what;
if (i2 == -1) {
FZGB0Service.this.f3808h = false;
FZGB0Service.this.f3809i = false;
FZGB0Service fZGB0Service = FZGB0Service.this;
fZGB0Service.t(fZGB0Service.getResources().getString(l.down_failure_retry), FZGB0Service.this.getResources().getString(l.has_down) + FZGB0Service.this.f3806f + "%");
return;
}
if (i2 == 0) {
FZGB0Service.this.f3808h = false;
FZGB0Service.this.f3809i = true;
FZGB0Service fZGB0Service2 = FZGB0Service.this;
fZGB0Service2.t(fZGB0Service2.getString(2131755072), FZGB0Service.this.getResources().getString(l.down_complete));
FZGB0Service.this.p();
return;
}
if (i2 == 1) {
FZGB0Service.this.f3808h = false;
FZGB0Service.this.f3809i = false;
FZGB0Service fZGB0Service3 = FZGB0Service.this;
fZGB0Service3.t(fZGB0Service3.getResources().getString(l.down_failure), FZGB0Service.this.getResources().getString(l.down_error));
return;
}
if (i2 != 2) {
FZGB0Service.this.stopSelf();
return;
}
FZGB0Service.this.f3808h = true;
FZGB0Service.this.f3809i = false;
FZGB0Service fZGB0Service4 = FZGB0Service.this;
fZGB0Service4.t(fZGB0Service4.getResources().getString(l.now_down), FZGB0Service.this.getResources().getString(l.has_down) + FZGB0Service.this.f3806f + "%");
}
}
public class c extends Thread {
public c() {
}
@Override
public void run() {
InputStream inputStream;
FileOutputStream fileOutputStream;
Throwable th;
HttpURLConnection httpURLConnection;
FileOutputStream fileOutputStream2;
Exception e2;
try {
try {
try {
httpURLConnection = (HttpURLConnection) new URL(FZGB0Service.this.f3804d).openConnection();
try {
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.connect();
inputStream = httpURLConnection.getInputStream();
try {
fileOutputStream2 = new FileOutputStream(FZGB0Service.this.f3803c);
try {
FZGB0Service.this.f3805e = httpURLConnection.getContentLength();
if (FZGB0Service.this.f3805e <= 0) {
FZGB0Service.this.f3810j.sendEmptyMessage(0);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
return;
}
}
fileOutputStream2.close();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
return;
}
return;
}
byte[] bArr = new byte[1024];
int i2 = 0;
int i3 = 0;
while (true) {
int read = inputStream.read(bArr);
if (read <= 0) {
break;
}
fileOutputStream2.write(bArr, 0, read);
if (FZGB0Service.this.f3805e > 0) {
i2 += read;
FZGB0Service.this.f3806f = (int) ((i2 / FZGB0Service.this.f3805e) * 100.0f);
FZGB0Service.this.f3807g = i2;
if (FZGB0Service.this.f3806f - i3 >= 1) {
i3 = FZGB0Service.this.f3806f;
FZGB0Service.this.f3810j.sendEmptyMessage(2);
}
}
}
if (FZGB0Service.this.f3807g == FZGB0Service.this.f3805e) {
FZGB0Service.this.f3810j.sendEmptyMessage(0);
}
if (inputStream != null) {
inputStream.close();
}
fileOutputStream2.close();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
} catch (Exception e4) {
e2 = e4;
e2.printStackTrace();
FZGB0Service.this.f3810j.sendEmptyMessage(-1);
if (inputStream != null) {
inputStream.close();
}
if (fileOutputStream2 != null) {
fileOutputStream2.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
} catch (Exception e5) {
fileOutputStream2 = null;
e2 = e5;
} catch (Throwable th2) {
fileOutputStream = null;
th = th2;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
throw th;
}
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
} catch (Exception e7) {
fileOutputStream2 = null;
e2 = e7;
inputStream = null;
} catch (Throwable th3) {
fileOutputStream = null;
th = th3;
inputStream = null;
}
} catch (Throwable th4) {
th = th4;
}
} catch (Exception e8) {
inputStream = null;
fileOutputStream2 = null;
e2 = e8;
httpURLConnection = null;
} catch (Throwable th5) {
inputStream = null;
fileOutputStream = null;
th = th5;
httpURLConnection = null;
}
} catch (IOException e9) {
e9.printStackTrace();
}
}
}
public FZGB0Service() {
new a();
this.f3810j = new b();
}
public static void q(Context context, String str, int i2) {
d.a("startDownloadAPK", "startDownloadAPK:" + str);
Toast.makeText(context, context.getResources().getString(l.now_prepare_down_new), 0).show();
Intent intent = new Intent(context, (Class<?>) FZGB0Service.class);
intent.setAction(context.getPackageName() + ".action_update");
intent.putExtra("apkUrl", str);
intent.putExtra("isUpdate", i2);
f3802k = (AppUpdateFragmentDialog) ((BMAG01ACT) context).m().e("AppUpdateFragmentDialog");
context.startService(intent);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int i2, int i3) {
s(intent.getStringExtra("apkUrl"));
return 2;
}
public final void p() {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setFlags(268435456);
Uri fromFile = Uri.fromFile(this.f3803c);
if (Build.VERSION.SDK_INT >= 24) {
fromFile = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", this.f3803c);
}
if (Build.VERSION.SDK_INT >= 26) {
if (!getPackageManager().canRequestPackageInstalls()) {
Toast.makeText(this, getResources().getString(l.to_setting), 0).show();
r();
}
intent.addFlags(1);
fromFile = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", this.f3803c);
}
intent.setDataAndType(fromFile, "application/vnd.android.package-archive");
Iterator<ResolveInfo> it = getPackageManager().queryIntentActivities(intent, k.a.TIMEOUT_WRITE_SIZE).iterator();
while (it.hasNext()) {
grantUriPermission(it.next().activityInfo.packageName, fromFile, 3);
}
startActivity(intent);
}
public final void r() {
Intent intent = new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES");
intent.addFlags(268435456);
startActivity(intent);
}
public void s(String str) {
this.f3804d = str;
if ("mounted".equals(Environment.getExternalStorageState())) {
File file = new File(d.i.b.d.a.d.f6825b);
if (!file.exists()) {
file.mkdirs();
}
this.f3803c = new File(file, "byj.apk");
d.a("apkFile", this.f3803c + "");
} else {
new n().d(this, getResources().getString(l.memory_error));
}
t(getResources().getString(l.start_down_new), getResources().getString(l.prepare_down));
new c().start();
}
public final void t(String str, String str2) {
AppUpdateFragmentDialog appUpdateFragmentDialog = f3802k;
if (appUpdateFragmentDialog == null || appUpdateFragmentDialog.isRemoving() || f3802k.h() == null || !f3802k.h().isShowing()) {
return;
}
f3802k.v(str2);
}
}