正在查看: 大众借. v4.1.2 应用的 FZGB0Service.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 大众借. v4.1.2 应用的 FZGB0Service.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.shiliuj.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.base.commonlibrary.utils.LogUtil;
import com.base.commonlibrary.utils.ToastUtil;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.dtf.face.ui.FaceBaseActivity;
import com.shiliuj.mjyp.BMAG01ACT;
import com.shiliuj.mjyp.app.api.AppConfig;
import com.shiliuj.mjyp.app.fragment.AppUpdateFragmentDialog;
import com.shiliuj.ui.bean.AppVersion;
import face.security.device.api.FaceSecCode;
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 {
private static final String ACTION = "STATUS_BAR_COVER_CLICK_ACTION";
private static final String CHANNEL_ID = "default";
private static final int DOWN_EXCEPTION = -1;
private static final int DOWN_INIT = 1;
private static final int DOWN_OVER = 0;
private static final int DOWN_UPDATE = 2;
private static AppUpdateFragmentDialog fragmentByTag;
private File apkFile;
private AppVersion appVersion;
private String downloadUrl;
private int downloadedSize;
private long length;
private int progress;
private boolean isDownload = true;
private boolean isDownloading = false;
private boolean isDownloadSucess = false;
private int notificationId = 9998;
private boolean isClick = false;
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(FZGB0Service.ACTION)) {
if (FZGB0Service.this.isDownloading || !FZGB0Service.this.isDownloadSucess) {
if (FZGB0Service.this.isDownloading || FZGB0Service.this.isDownloadSucess) {
return;
}
FZGB0Service.this.isDownloading = false;
FZGB0Service.this.isDownloadSucess = false;
FZGB0Service.this.new DownloadThread().start();
FZGB0Service fZGB0Service = FZGB0Service.this;
fZGB0Service.updateData(fZGB0Service.getResources().getString(2131689883), FZGB0Service.this.getResources().getString(2131689768) + FZGB0Service.this.progress + "%");
return;
}
FZGB0Service.this.install();
}
}
};
private Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == -1) {
FZGB0Service.this.isDownloading = false;
FZGB0Service.this.isDownloadSucess = false;
FZGB0Service fZGB0Service = FZGB0Service.this;
fZGB0Service.updateData(fZGB0Service.getResources().getString(2131689641), FZGB0Service.this.getResources().getString(2131689768) + FZGB0Service.this.progress + "%");
return;
}
if (i == 0) {
FZGB0Service.this.isDownloading = false;
FZGB0Service.this.isDownloadSucess = true;
FZGB0Service fZGB0Service2 = FZGB0Service.this;
fZGB0Service2.updateData(fZGB0Service2.getString(2131689536), FZGB0Service.this.getResources().getString(2131689638));
FZGB0Service.this.install();
return;
}
if (i == 1) {
FZGB0Service.this.isDownloading = false;
FZGB0Service.this.isDownloadSucess = false;
FZGB0Service fZGB0Service3 = FZGB0Service.this;
fZGB0Service3.updateData(fZGB0Service3.getResources().getString(2131689640), FZGB0Service.this.getResources().getString(2131689639));
return;
}
if (i == 2) {
FZGB0Service.this.isDownloading = true;
FZGB0Service.this.isDownloadSucess = false;
FZGB0Service fZGB0Service4 = FZGB0Service.this;
fZGB0Service4.updateData(fZGB0Service4.getResources().getString(2131689883), FZGB0Service.this.getResources().getString(2131689768) + FZGB0Service.this.progress + "%");
return;
}
FZGB0Service.this.stopSelf();
}
};
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
startUpdate(intent.getStringExtra("apkUrl"));
return 2;
}
public void startUpdate(String str) {
this.downloadUrl = str;
if ("mounted".equals(Environment.getExternalStorageState())) {
File file = new File(AppConfig.DOWNLOAD_PATH);
if (!file.exists()) {
file.mkdirs();
}
this.apkFile = new File(file, "byj.apk");
LogUtil.d("apkFile", this.apkFile + "");
} else {
new ToastUtil().showShort(this, getResources().getString(2131689818));
}
updateData(getResources().getString(2131690112), getResources().getString(2131689944));
new DownloadThread().start();
}
class DownloadThread extends Thread {
DownloadThread() {
}
@Override
public void run() {
InputStream inputStream;
FileOutputStream fileOutputStream;
Throwable th;
HttpURLConnection httpURLConnection;
FileOutputStream fileOutputStream2;
Exception e;
try {
try {
try {
httpURLConnection = (HttpURLConnection) new URL(FZGB0Service.this.downloadUrl).openConnection();
try {
httpURLConnection.setConnectTimeout(FaceSecCode.SC_SUCCESS);
httpURLConnection.setReadTimeout(FaceSecCode.SC_SUCCESS);
httpURLConnection.connect();
inputStream = httpURLConnection.getInputStream();
try {
fileOutputStream2 = new FileOutputStream(FZGB0Service.this.apkFile);
try {
FZGB0Service.this.length = httpURLConnection.getContentLength();
if (FZGB0Service.this.length <= 0) {
FZGB0Service.this.handler.sendEmptyMessage(0);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
return;
}
}
fileOutputStream2.close();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
return;
}
return;
}
byte[] bArr = new byte[FaceBaseActivity.TOYGER_PERMISSION_REQUEST_CODE];
int i = 0;
int i2 = 0;
while (true) {
int read = inputStream.read(bArr);
if (read <= 0) {
break;
}
fileOutputStream2.write(bArr, 0, read);
if (FZGB0Service.this.length > 0) {
i += read;
FZGB0Service.this.progress = (int) ((i / FZGB0Service.this.length) * 100.0f);
FZGB0Service.this.downloadedSize = i;
if (FZGB0Service.this.progress - i2 >= 1) {
i2 = FZGB0Service.this.progress;
FZGB0Service.this.handler.sendEmptyMessage(2);
}
}
}
if (FZGB0Service.this.downloadedSize == FZGB0Service.this.length) {
FZGB0Service.this.handler.sendEmptyMessage(0);
}
if (inputStream != null) {
inputStream.close();
}
fileOutputStream2.close();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
} catch (Exception e3) {
e = e3;
e.printStackTrace();
FZGB0Service.this.handler.sendEmptyMessage(-1);
if (inputStream != null) {
inputStream.close();
}
if (fileOutputStream2 != null) {
fileOutputStream2.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
} catch (Exception e4) {
fileOutputStream2 = null;
e = e4;
} catch (Throwable th2) {
fileOutputStream = null;
th = th2;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
throw th;
}
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
} catch (Exception e6) {
fileOutputStream2 = null;
e = e6;
inputStream = null;
} catch (Throwable th3) {
fileOutputStream = null;
th = th3;
inputStream = null;
}
} catch (Throwable th4) {
th = th4;
}
} catch (Exception e7) {
inputStream = null;
fileOutputStream2 = null;
e = e7;
httpURLConnection = null;
} catch (Throwable th5) {
inputStream = null;
fileOutputStream = null;
th = th5;
httpURLConnection = null;
}
} catch (IOException e8) {
e8.printStackTrace();
}
}
}
public void updateData(String str, String str2) {
AppUpdateFragmentDialog appUpdateFragmentDialog = fragmentByTag;
if (appUpdateFragmentDialog == null || appUpdateFragmentDialog.isRemoving() || fragmentByTag.getDialog() == null || !fragmentByTag.getDialog().isShowing()) {
return;
}
fragmentByTag.setBtnText(str2);
}
public void install() {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setFlags(268435456);
Uri fromFile = Uri.fromFile(this.apkFile);
if (Build.VERSION.SDK_INT >= 24) {
fromFile = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", this.apkFile);
}
if (Build.VERSION.SDK_INT >= 26) {
if (!getPackageManager().canRequestPackageInstalls()) {
Toast.makeText(this, getResources().getString(2131690132), 0).show();
startInstallPermissionSettingActivity();
}
intent.addFlags(1);
fromFile = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", this.apkFile);
}
intent.setDataAndType(fromFile, "application/vnd.android.package-archive");
Iterator<ResolveInfo> it = getPackageManager().queryIntentActivities(intent, ArrayPool.STANDARD_BUFFER_SIZE_BYTES).iterator();
while (it.hasNext()) {
grantUriPermission(it.next().activityInfo.packageName, fromFile, 3);
}
startActivity(intent);
}
private void startInstallPermissionSettingActivity() {
Intent intent = new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES");
intent.addFlags(268435456);
startActivity(intent);
}
public static void startDownloadAPK(Context context, String str, int i) {
LogUtil.d("startDownloadAPK", "startDownloadAPK:" + str);
Toast.makeText(context, context.getResources().getString(2131689887), 0).show();
Intent intent = new Intent(context, (Class<?>) FZGB0Service.class);
intent.setAction(context.getPackageName() + ".action_update");
intent.putExtra("apkUrl", str);
intent.putExtra("isUpdate", i);
fragmentByTag = ((BMAG01ACT) context).getSupportFragmentManager().findFragmentByTag("AppUpdateFragmentDialog");
context.startService(intent);
}
}