正在查看: 管控平台 v5.2.3.0. 应用的 FirewallService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 管控平台 v5.2.3.0. 应用的 FirewallService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.iflytek.mdmservice.service;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.Nullable;
import com.iflytek.mdmcommon.LogUtil;
import com.iflytek.mdmlibrary.MdmSdk;
import com.iflytek.mdmservice.MDMApp;
import com.iflytek.mdmservice.db.dao.AppInfoDao;
import com.iflytek.mdmservice.db.dao.WhiteAppDao;
import com.iflytek.mdmservice.db.entity.AppInfo;
import com.iflytek.mdmservice.db.entity.WhiteApp;
import com.iflytek.mdmservice.db.impl.WhiteAppDaoImpl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class FirewallService extends IntentService {
private WhiteAppDao f479a;
private WhiteAppDaoImpl f480b;
private AlarmManager f481c;
public FirewallService() {
this("FirewallService");
}
private void a() {
org.greenrobot.greendao.i.g<WhiteApp> queryBuilder = this.f479a.queryBuilder();
queryBuilder.m(WhiteAppDao.Properties.End);
queryBuilder.k(1);
List<WhiteApp> l = queryBuilder.l();
if (l == null || l.size() != 1) {
return;
}
WhiteApp whiteApp = l.get(0);
long start = whiteApp.getStart();
long end = whiteApp.getEnd();
String pkgName = whiteApp.getPkgName();
Intent intent = new Intent(this, (Class<?>) FirewallService.class);
intent.setAction("com.iflytek.mdm.action.ACTION_FIREWALL_END_TASK");
intent.putExtra("pkg", pkgName);
intent.putExtra("start", start);
intent.putExtra("end", end);
PendingIntent service = PendingIntent.getService(this, 1, intent, 134217728);
if (Build.VERSION.SDK_INT < 19) {
this.f481c.set(0, end, service);
} else {
this.f481c.setExact(0, end, service);
}
}
private void b() {
org.greenrobot.greendao.i.g<WhiteApp> queryBuilder = this.f479a.queryBuilder();
queryBuilder.r(WhiteAppDao.Properties.Flag.a(0), new org.greenrobot.greendao.i.i[0]);
queryBuilder.m(WhiteAppDao.Properties.Start);
queryBuilder.k(1);
List<WhiteApp> l = queryBuilder.l();
if (l == null || l.size() != 1) {
return;
}
WhiteApp whiteApp = l.get(0);
long start = whiteApp.getStart();
long end = whiteApp.getEnd();
String pkgName = whiteApp.getPkgName();
Intent intent = new Intent(this, (Class<?>) FirewallService.class);
intent.setAction("com.iflytek.mdm.action.ACTION_FIREWALL_START_TASK");
intent.putExtra("pkg", pkgName);
intent.putExtra("start", start);
intent.putExtra("end", end);
PendingIntent service = PendingIntent.getService(this, 0, intent, 134217728);
if (Build.VERSION.SDK_INT < 19) {
this.f481c.set(0, start, service);
} else {
this.f481c.setExact(0, start, service);
}
}
private void c() {
org.greenrobot.greendao.i.g<AppInfo> queryBuilder = MDMApp.k().getAppInfoDao().queryBuilder();
queryBuilder.r(AppInfoDao.Properties.Firewall.a(0), new org.greenrobot.greendao.i.i[0]);
List<AppInfo> h = queryBuilder.c().h();
if (h == null || h.isEmpty()) {
return;
}
ArrayList arrayList = new ArrayList();
Iterator<AppInfo> it = h.iterator();
while (it.hasNext()) {
arrayList.add(it.next().getPackageName());
}
MdmSdk.setNetworkAccessAppWhiteList(arrayList);
}
private void d() {
org.greenrobot.greendao.i.g<WhiteApp> queryBuilder = this.f479a.queryBuilder();
queryBuilder.r(WhiteAppDao.Properties.Flag.a(1), new org.greenrobot.greendao.i.i[0]);
List<WhiteApp> h = queryBuilder.c().h();
if (h == null || h.isEmpty()) {
return;
}
ArrayList arrayList = new ArrayList();
for (WhiteApp whiteApp : h) {
LogUtil.i("MDMApi", "PendingIntentRcv authorSingleEnd { loadWhiteApp: " + whiteApp.getPkgName() + "}");
arrayList.add(whiteApp.getPkgName());
}
MdmSdk.setNetworkAccessAppWhiteList(arrayList);
}
@Override
public void onCreate() {
super.onCreate();
this.f479a = MDMApp.k().getWhiteAppDao();
this.f480b = new WhiteAppDaoImpl(this);
this.f481c = (AlarmManager) getSystemService("alarm");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
String stringExtra = intent.getStringExtra("pkg");
long longExtra = intent.getLongExtra("start", 0L);
long longExtra2 = intent.getLongExtra("end", 0L);
long currentTimeMillis = System.currentTimeMillis() + 1000;
String action = intent.getAction();
LogUtil.i("MDMApi", "action: " + action);
LogUtil.i("MDMApi", "intent data: { pkg: " + stringExtra + ", start: " + longExtra + ", end: " + longExtra2 + ", now: " + currentTimeMillis + " }");
org.greenrobot.greendao.i.g<WhiteApp> queryBuilder = this.f479a.queryBuilder();
queryBuilder.r(WhiteAppDao.Properties.PkgName.a(stringExtra), WhiteAppDao.Properties.Start.a(Long.valueOf(longExtra)), WhiteAppDao.Properties.End.a(Long.valueOf(longExtra2)));
List<WhiteApp> h = queryBuilder.c().h();
if (!"com.iflytek.mdm.action.FIREWALL_GET_DATA".equals(action)) {
if ("com.iflytek.mdm.action.ACTION_FIREWALL_START_TASK".equals(action)) {
if (h == null || h.size() <= 0) {
return;
}
WhiteApp whiteApp = h.get(0);
MdmSdk.setNetworkAccessAppWhiteList(whiteApp.getPkgName());
whiteApp.setFlag(1);
this.f479a.update(whiteApp);
b();
return;
}
if (!"com.iflytek.mdm.action.ACTION_FIREWALL_END_TASK".equals(action) || h == null || h.size() <= 0) {
return;
}
this.f479a.deleteInTx(h);
MdmSdk.cleanNetworkAccessAppWhiteList();
d();
c();
a();
return;
}
if (currentTimeMillis < longExtra) {
if (h == null || h.isEmpty()) {
WhiteApp whiteApp2 = new WhiteApp();
whiteApp2.setPkgName(stringExtra);
whiteApp2.setStart(longExtra);
whiteApp2.setEnd(longExtra2);
whiteApp2.setFlag(0);
this.f479a.insertOrReplace(whiteApp2);
}
b();
a();
return;
}
if (longExtra > currentTimeMillis || currentTimeMillis >= longExtra2) {
if (longExtra2 <= currentTimeMillis) {
this.f480b.deleteWhiteApp(stringExtra);
MdmSdk.cleanNetworkAccessAppWhiteList();
d();
c();
return;
}
return;
}
if (h == null || h.isEmpty()) {
WhiteApp whiteApp3 = new WhiteApp();
whiteApp3.setPkgName(stringExtra);
whiteApp3.setStart(longExtra);
whiteApp3.setEnd(longExtra2);
whiteApp3.setFlag(1);
this.f479a.insertOrReplace(whiteApp3);
}
MdmSdk.setNetworkAccessAppWhiteList(stringExtra);
a();
}
public FirewallService(String str) {
super(str);
}
}