正在查看: 管控平台 v5.2.3.0. 应用的 AppRollBackService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 管控平台 v5.2.3.0. 应用的 AppRollBackService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.iflytek.mdmservice.service;
import a.b.c.a;
import a.b.c.b;
import android.app.IntentService;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import com.iflytek.mdmcommon.AppUtils;
import com.iflytek.mdmcommon.LogUtil;
import com.iflytek.mdmcommon.constant.MDMConstants;
import com.iflytek.mdmlibrary.MdmSdk;
import com.iflytek.mdmservice.MDMApp;
import com.iflytek.mdmservice.db.AppInfoManager;
import com.iflytek.mdmservice.db.RemoteAppInfoManager;
import com.iflytek.mdmservice.db.entity.AppInfo;
import com.iflytek.mdmservice.k.d0;
import com.iflytek.mdmservice.model.MessageBean;
import com.iflytek.mdmstore.model.RemoteAppInfo;
import java.util.List;
import net.sqlcipher.BuildConfig;
import org.json.JSONObject;
public class AppRollBackService extends IntentService {
private static final Object e = new Object();
private boolean f432a;
private a.b.c.a f433b;
private ServiceConnection f434c;
private a.b.c.b d;
class a implements ServiceConnection {
a() {
}
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
LogUtil.c("back_app", "bind AppRollBackRemoteService successfully");
try {
AppRollBackService.this.f433b = a.AbstractBinderC0000a.G(iBinder);
AppRollBackService.this.f433b.a(AppRollBackService.this.d);
} catch (Exception e) {
LogUtil.c("back_app", Log.getStackTraceString(e));
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
LogUtil.c("back_app", "unbind AppRollBackRemoteService service");
try {
AppRollBackService.this.f433b = null;
} catch (Exception e) {
LogUtil.c("back_app", Log.getStackTraceString(e));
}
}
}
class b extends b.a {
class a implements d0.b0 {
final String f437a;
final long f438b;
a(String str, long j) {
this.f437a = str;
this.f438b = j;
}
@Override
public void a(List<AppInfo> list) {
if (list == null) {
LogUtil.c("back_app", "没有备份包,拉取app列表失败");
return;
}
for (AppInfo appInfo : list) {
String str = this.f437a;
if (str != null && str.equals(appInfo.getPackageName())) {
if (appInfo.getVersionCode() == this.f438b) {
LogUtil.c("back_app", "没有备份包,拉取app列表也是错误版本,不下载不安装");
return;
} else {
AppRollBackService.this.i(appInfo);
return;
}
}
}
}
}
b() {
}
@Override
public void E(int i, String str, long j, long j2) throws RemoteException {
LogUtil.c("back_app", "callback: errorCode: " + i + " ,packageName: " + str + " ,errorVersionCode: " + j + " ,taskId: " + j2);
AppRollBackService.this.j(i, j2);
if (i == -2 || i == -6 || i == -3) {
if (!AppRollBackService.this.f432a) {
d0.b0().T(j2, new a(str, j));
return;
}
AppInfo appInfo = AppInfoManager.getInstance().getAppInfo(str);
if (appInfo == null) {
LogUtil.c("back_app", "没有备份包,拉取app列表失败");
} else if (appInfo.getVersionCode() == j) {
LogUtil.c("back_app", "没有备份包,拉取app列表也是错误版本,不下载不安装");
} else {
AppRollBackService.this.i(appInfo);
}
}
}
}
public AppRollBackService() {
super("AppRollBackService");
this.f434c = new a();
this.d = new b();
}
private void g() {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.iflytek.mdmstore", "com.iflytek.mdmstore.service.AppRollBackRemoteService"));
LogUtil.c("back_app", "bind DetectionService result: " + bindService(intent, this.f434c, 1));
}
private void h(String str, long j, long j2, AppInfo appInfo) {
j(-12, j2);
if (AppUtils.getPackageInfo(this, str) == null || r6.versionCode != j || appInfo == null) {
return;
}
if (appInfo.getForceInstall() == 1 && appInfo.getVersionCode() == j && appInfo.getStatus() != 1) {
return;
}
MdmSdk.silentUninstall(str);
}
public void i(AppInfo appInfo) {
RemoteAppInfo remoteAppInfo = new RemoteAppInfo();
remoteAppInfo.setAppId(appInfo.getAppId());
remoteAppInfo.setAppName(appInfo.getName());
remoteAppInfo.setPackageName(appInfo.getPackageName());
remoteAppInfo.setIconUrl(appInfo.getIcon());
remoteAppInfo.setDownloadUrl(appInfo.getDownloadUrl());
remoteAppInfo.setSize(appInfo.getSize());
remoteAppInfo.setVersionCode(appInfo.getVersionCode());
remoteAppInfo.setVersionName(appInfo.getVersionName());
remoteAppInfo.setRating((int) appInfo.getRating());
remoteAppInfo.setAppType(appInfo.getAppType());
remoteAppInfo.setForceInstall(appInfo.getForceInstall());
remoteAppInfo.setForceInstallRank(appInfo.getForceInstallRank());
remoteAppInfo.setType(appInfo.getType());
RemoteAppInfoManager.getInstance().addRemoteAppInfo(remoteAppInfo);
Intent intent = new Intent(MDMApp.j(), (Class<?>) RemoteDownloadService.class);
intent.putExtra("remotedownloadappinfo_now", 1);
MDMApp.j().startService(intent);
LogUtil.c("back_app", "没有备份包,已触发强制下载");
}
public void j(int i, long j) {
String str = i == 200 ? "应用回退成功" : i == -1 ? "参数不合法" : i == -4 ? "应用未安装" : i == -5 ? "应用安装的不是有问题的版本,不需要回退" : i == -2 ? "没有备份数据" : i == -6 ? "本地备份包不存在" : i == -3 ? "应用备份的是错误版本,删除备份数据" : i == -7 ? "卸载超时" : i == -8 ? "静默安装出错" : i == -9 ? "后台错误版本没有被下架" : i == -10 ? "拉取应用列表失败,且本地数据库中是错误的版本" : i == -11 ? "预制应用不支持" : i == -12 ? "MDM版本不支持" : BuildConfig.FLAVOR;
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", i);
jSONObject.put("msg", str);
} catch (Exception e2) {
LogUtil.c("back_app", Log.getStackTraceString(e2));
}
MessageBean messageBean = new MessageBean();
messageBean.setTaskId(Long.valueOf(j));
messageBean.setType(29);
messageBean.setExtInfo(jSONObject.toString());
d0.b0().K(messageBean);
}
public static void k(String str, long j, long j2, boolean z) {
Intent intent = new Intent(MDMApp.j(), (Class<?>) AppRollBackService.class);
intent.putExtra("approllbackpackagename", str);
intent.putExtra("approllbackerrorversioncode", j);
intent.putExtra("approllbacktaskid", j2);
intent.putExtra("approllbackhaspullapps", z);
MDMApp.j().startService(intent);
}
private void l() {
try {
if (this.f433b != null) {
this.f433b.v(this.d);
}
} catch (Exception e2) {
LogUtil.c("back_app", Log.getStackTraceString(e2));
}
ServiceConnection serviceConnection = this.f434c;
if (serviceConnection != null) {
unbindService(serviceConnection);
}
}
@Override
public void onCreate() {
super.onCreate();
g();
}
@Override
public void onDestroy() {
LogUtil.d("back_app", "AppRollBackService onDestroy");
l();
super.onDestroy();
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
String stringExtra = intent.getStringExtra("approllbackpackagename");
long longExtra = intent.getLongExtra("approllbackerrorversioncode", -1L);
long longExtra2 = intent.getLongExtra("approllbacktaskid", -1L);
this.f432a = intent.getBooleanExtra("approllbackhaspullapps", false);
if (TextUtils.isEmpty(stringExtra) || longExtra <= 0) {
j(-1, longExtra2);
return;
}
if (MDMConstants.getMdmApks5().contains(stringExtra)) {
j(-11, longExtra2);
return;
}
AppInfo appInfo = AppInfoManager.getInstance().getAppInfo(stringExtra);
if (appInfo != null && appInfo.getVersionCode() == longExtra) {
LogUtil.c("back_app", this.f432a ? "后台错误版本没有被下架" : "拉取应用失败,且数据库中是错误的版本");
if (appInfo.getForceInstall() == 1 && appInfo.getStatus() != 1) {
j(this.f432a ? -9 : -10, longExtra2);
return;
}
}
long currentTimeMillis = System.currentTimeMillis();
while (this.f433b == null && System.currentTimeMillis() - currentTimeMillis < 3000) {
synchronized (e) {
try {
e.wait(100L);
} catch (InterruptedException e2) {
LogUtil.e(e2.getMessage());
Thread.currentThread().interrupt();
}
}
}
a.b.c.a aVar = this.f433b;
if (aVar == null) {
h(stringExtra, longExtra, longExtra2, appInfo);
return;
}
try {
aVar.C(stringExtra, longExtra, longExtra2);
} catch (Exception e3) {
LogUtil.c("back_app", Log.getStackTraceString(e3));
h(stringExtra, longExtra, longExtra2, appInfo);
}
}
}