导航菜单

页面标题

页面副标题

管控平台 v5.2.3.0. - WorkService.java 源代码

正在查看: 管控平台 v5.2.3.0. 应用的 WorkService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.iflytek.mdmservice.policy.service;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentProviderClient;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.RemoteException;
import android.provider.MediaStore;
import androidx.annotation.Nullable;
import com.iflytek.mdmcommon.LogUtil;
import com.iflytek.mdmservice.MDMApp;
import com.iflytek.mdmservice.R$drawable;
import com.iflytek.mdmservice.db.entity.DeviceInfo;
import com.iflytek.mdmservice.m.b;
import com.iflytek.mdmservice.o.c.d;
import com.iflytek.mdmservice.o.c.e;
import com.iflytek.mdmservice.o.c.f;
import com.iflytek.mdmservice.o.c.g;
import com.iflytek.mdmservice.o.c.h;
import com.iflytek.mdmservice.o.c.i;
import com.iflytek.mdmservice.o.c.j;
import com.iflytek.mdmservice.policy.receiver.AppReceiver;
import com.iflytek.mdmservice.policy.receiver.SimReceiver;
import com.iflytek.mdmservice.policy.receiver.TimeReceiver;
import com.iflytek.mdmservice.policy.receiver.UsbReceiver;
import com.iflytek.mdmservice.receiver.BluetoothStateReceiver;
import com.iflytek.mdmservice.receiver.ClearDataReceiver;
import com.iflytek.mdmservice.receiver.DeployReceiver;
import com.iflytek.mdmservice.receiver.DetectionEndReceiver;
import com.iflytek.mdmservice.receiver.HomeKeyBroadCastReceiver;
import com.iflytek.mdmservice.receiver.NetChangedReceiver;
import com.iflytek.mdmservice.receiver.UserLoginReceiver;
import com.iflytek.mdmservice.ui.EmptyActivity;
import com.iflytek.mdmservice.ui.MainActivity;
import com.iflytek.user.stu.StuLogin;
import com.igexin.assist.sdk.AssistPushConsts;
import com.igexin.sdk.PushConsts;
import com.igexin.sdk.PushManager;
import java.io.File;
import net.sqlcipher.database.SQLiteDatabase;
import org.greenrobot.eventbus.c;
import org.greenrobot.eventbus.l;

public class WorkService extends IntentService {
    private static final String t = WorkService.class.getSimpleName();
    static final HandlerThread u;
    static final Handler z;

    private boolean f310a;

    private f f311b;

    private i f312c;
    private e d;
    private d e;
    private h f;
    private g g;
    private j h;
    private AppReceiver i;
    private UsbReceiver j;
    private TimeReceiver k;
    private SimReceiver l;
    private UserLoginReceiver m;
    private BluetoothStateReceiver n;
    private ClearDataReceiver o;
    private HomeKeyBroadCastReceiver p;
    private NetChangedReceiver q;
    private DetectionEndReceiver r;
    private DeployReceiver s;

    static {
        HandlerThread handlerThread = new HandlerThread("workerThread");
        u = handlerThread;
        handlerThread.start();
        z = new Handler(u.getLooper());
        String str = Environment.getExternalStorageDirectory() + File.separator + "iFlytekMDM";
    }

    public WorkService() {
        this("WorkService");
    }

    @l
    public void onAppPolicy(com.iflytek.mdmservice.o.b.a aVar) {
        if (this.i != null) {
            this.i.b(aVar.b(), aVar.a());
        }
    }

    @l
    public void onCloseLock(b bVar) {
        LogUtil.c(t, "onCloseLock清理锁屏策略");
        Uri parse = Uri.parse("content://com.iflytek.mdmservice.provider.PolicyTempProvider/policy");
        ContentProviderClient acquireContentProviderClient = MDMApp.j().getContentResolver().acquireContentProviderClient(parse);
        try {
            if (acquireContentProviderClient != null) {
                try {
                    acquireContentProviderClient.delete(parse, "type=?", new String[]{AssistPushConsts.PUSHMESSAGE_ACTION_MULTI_BRAND_RECEIVE_XM});
                    LogUtil.c(t, "onCloseLock");
                    if (acquireContentProviderClient == null) {
                        return;
                    }
                } catch (RemoteException e) {
                    LogUtil.ce(t, "onCloseLock:" + e.getMessage());
                    if (acquireContentProviderClient == null) {
                        return;
                    }
                }
                acquireContentProviderClient.release();
            }
        } catch (Throwable th) {
            if (acquireContentProviderClient != null) {
                acquireContentProviderClient.release();
            }
            throw th;
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LogUtil.i(t, "onCreate");
        c.c().o(this);
        if (Build.VERSION.SDK_INT >= 26) {
            String packageName = getPackageName();
            NotificationManager notificationManager = (NotificationManager) getSystemService(com.igexin.push.core.b.l);
            NotificationChannel notificationChannel = new NotificationChannel(packageName, "主服务", 4);
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(-65536);
            notificationChannel.setShowBadge(true);
            notificationChannel.setDescription("管控平台正在后台运行,请勿停用此服务!");
            notificationChannel.setLockscreenVisibility(-1);
            notificationManager.createNotificationChannel(notificationChannel);
            startForeground(1111, new Notification.Builder(this, packageName).setContentTitle("正在进行设备管控1").setContentText("管控平台正在后台运行,请勿停用此服务!").setWhen(System.currentTimeMillis()).setSmallIcon(R$drawable.ic_notification_mdm).build());
        }
        PushManager.getInstance().initialize(getApplicationContext());
        this.f311b = new f(this, z);
        getContentResolver().registerContentObserver(Uri.parse("content://com.iflytek.mdmservice.provider.PolicyHelperProvider/policy"), true, this.f311b);
        this.f312c = new i(this, z);
        getContentResolver().registerContentObserver(Uri.parse("content://com.iflytek.mdmservice.provider.PolicyTempProvider/policy"), true, this.f312c);
        this.d = new e(z);
        getContentResolver().registerContentObserver(Uri.parse(StuLogin.stuUriStr), true, this.d);
        try {
            this.e = new d(this, z);
            getContentResolver().registerContentObserver(Uri.parse("content://com.iflytek.mdmadmin.provider.PolicyCacheProvider/policy"), true, this.e);
        } catch (Exception e) {
            LogUtil.e(e.getMessage());
        }
        this.f = new h(this, z);
        Uri parse = Uri.parse("content://com.iflytek.mdmservice.provider.PolicyProvider/policy");
        getContentResolver().registerContentObserver(parse, true, this.f);
        getContentResolver().notifyChange(parse, null);
        this.g = new g(z);
        getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, this.g);
        this.h = new j(z);
        getContentResolver().registerContentObserver(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, true, this.h);
        this.i = new AppReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
        intentFilter.addAction("android.intent.action.PACKAGE_CHANGED");
        intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
        intentFilter.addAction("android.intent.action.PACKAGE_REPLACED");
        intentFilter.addDataScheme("package");
        registerReceiver(this.i, intentFilter);
        this.k = new TimeReceiver();
        registerReceiver(this.k, new IntentFilter("com.iflytek.mdm.intent.TIME_TICK"));
        this.j = new UsbReceiver();
        registerReceiver(this.j, new IntentFilter("android.hardware.usb.action.USB_STATE"));
        this.l = new SimReceiver();
        registerReceiver(this.l, new IntentFilter("android.intent.action.SIM_STATE_CHANGED"));
        this.m = new UserLoginReceiver();
        IntentFilter intentFilter2 = new IntentFilter();
        intentFilter2.setPriority(1000);
        intentFilter2.addAction("com.android.laucher3.mdm.LOGIN_APK_FINISH");
        intentFilter2.addAction("com.iflytek.mdm.intent.ACTION_USER_LOGIN");
        registerReceiver(this.m, intentFilter2);
        this.n = new BluetoothStateReceiver();
        IntentFilter intentFilter3 = new IntentFilter();
        intentFilter3.addAction("android.bluetooth.adapter.action.STATE_CHANGED");
        intentFilter3.addAction("android.bluetooth.device.action.ACL_CONNECTED");
        intentFilter3.addAction("android.bluetooth.device.action.ACL_DISCONNECTED");
        registerReceiver(this.n, intentFilter3);
        this.o = new ClearDataReceiver();
        registerReceiver(this.o, new IntentFilter("com.iflytek.mdm.intent.ACTION_CLEAR_DATA"));
        this.p = new HomeKeyBroadCastReceiver();
        registerReceiver(this.p, new IntentFilter("android.intent.action.CLOSE_SYSTEM_DIALOGS"));
        this.q = new NetChangedReceiver();
        IntentFilter intentFilter4 = new IntentFilter(PushConsts.ACTION_BROADCAST_NETWORK_CHANGE);
        intentFilter4.addAction("com.iflytek.mdmservice.NET_WORK_CHANGE_DELAY");
        registerReceiver(this.q, intentFilter4);
        this.r = new DetectionEndReceiver();
        registerReceiver(this.r, new IntentFilter("com.iflytek.mdmdetection.MDM_DETECTION_END_ACTION"));
        this.s = new DeployReceiver();
        registerReceiver(this.s, new IntentFilter("com.iflytek.mdmservice.MDM_START_DEPLOY_ACTIVITY_ACTION"));
    }

    @Override
    public void onDestroy() {
        this.f310a = false;
        if (this.f311b != null) {
            getContentResolver().unregisterContentObserver(this.f311b);
        }
        if (this.f312c != null) {
            getContentResolver().unregisterContentObserver(this.f312c);
        }
        if (this.d != null) {
            getContentResolver().unregisterContentObserver(this.d);
        }
        if (this.e != null) {
            getContentResolver().unregisterContentObserver(this.e);
        }
        if (this.f != null) {
            getContentResolver().unregisterContentObserver(this.f);
        }
        if (this.g != null) {
            getContentResolver().unregisterContentObserver(this.g);
        }
        if (this.h != null) {
            getContentResolver().unregisterContentObserver(this.h);
        }
        AppReceiver appReceiver = this.i;
        if (appReceiver != null) {
            unregisterReceiver(appReceiver);
        }
        TimeReceiver timeReceiver = this.k;
        if (timeReceiver != null) {
            unregisterReceiver(timeReceiver);
        }
        UsbReceiver usbReceiver = this.j;
        if (usbReceiver != null) {
            unregisterReceiver(usbReceiver);
        }
        SimReceiver simReceiver = this.l;
        if (simReceiver != null) {
            unregisterReceiver(simReceiver);
        }
        UserLoginReceiver userLoginReceiver = this.m;
        if (userLoginReceiver != null) {
            unregisterReceiver(userLoginReceiver);
        }
        BluetoothStateReceiver bluetoothStateReceiver = this.n;
        if (bluetoothStateReceiver != null) {
            unregisterReceiver(bluetoothStateReceiver);
        }
        ClearDataReceiver clearDataReceiver = this.o;
        if (clearDataReceiver != null) {
            unregisterReceiver(clearDataReceiver);
        }
        HomeKeyBroadCastReceiver homeKeyBroadCastReceiver = this.p;
        if (homeKeyBroadCastReceiver != null) {
            unregisterReceiver(homeKeyBroadCastReceiver);
        }
        NetChangedReceiver netChangedReceiver = this.q;
        if (netChangedReceiver != null) {
            unregisterReceiver(netChangedReceiver);
        }
        DetectionEndReceiver detectionEndReceiver = this.r;
        if (detectionEndReceiver != null) {
            unregisterReceiver(detectionEndReceiver);
        }
        DeployReceiver deployReceiver = this.s;
        if (deployReceiver != null) {
            unregisterReceiver(deployReceiver);
        }
        c.c().q(this);
        AlarmManager alarmManager = (AlarmManager) getSystemService("alarm");
        try {
            Intent intent = new Intent("com.iflytek.mdm.intent.ACTION_WAKE_WORKER_SERVICE");
            intent.setFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
            alarmManager.set(1, System.currentTimeMillis() + 15000, PendingIntent.getBroadcast(this, 0, intent, 1073741824));
        } catch (Exception e) {
            LogUtil.e("crash handler:" + e.getMessage());
        }
        super.onDestroy();
    }

    @l
    public void onFileObserve(com.iflytek.mdmservice.o.b.b bVar) {
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        LogUtil.i(t, "onHandleIntent");
        MDMApp j = MDMApp.j();
        try {
            Intent intent2 = new Intent(this, (Class<?>) EmptyActivity.class);
            intent2.setFlags(268468224);
            intent2.putExtra("alarm_id", 0);
            j.startActivity(intent2);
        } catch (Exception e) {
            LogUtil.e("BlueBlue", "WorkService.onHandleIntent1: " + e.getMessage());
        }
        try {
            Intent intent3 = new Intent(j, (Class<?>) MainActivity.class);
            intent3.setFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
            j.startActivity(intent3);
        } catch (Throwable th) {
            LogUtil.e("BlueBlue", "WorkService.onHandleIntent2: " + th.getMessage());
        }
        while (this.f310a) {
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e2) {
                LogUtil.e(t, e2.getMessage());
                Thread.currentThread().interrupt();
            }
        }
    }

    @l
    public void onRootPolicy(com.iflytek.mdmservice.o.b.c cVar) {
        String b2 = cVar.b();
        String a2 = cVar.a();
        Intent intent = new Intent(this, (Class<?>) RootService.class);
        intent.putExtra(DeviceInfo.STATUS, b2);
        intent.putExtra("adminDevicePolicy", a2);
        startService(intent);
    }

    @l
    public void onSimPolicy(com.iflytek.mdmservice.o.b.d dVar) {
        if (this.l != null) {
            this.l.c(dVar.b(), dVar.a());
        }
    }

    @Override
    public int onStartCommand(@Nullable Intent intent, int i, int i2) {
        LogUtil.i(t, "onStartCommand");
        if (Build.VERSION.SDK_INT >= 26) {
            String packageName = getPackageName();
            NotificationManager notificationManager = (NotificationManager) getSystemService(com.igexin.push.core.b.l);
            NotificationChannel notificationChannel = new NotificationChannel(packageName, "主服务", 4);
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(-65536);
            notificationChannel.setShowBadge(true);
            notificationChannel.setDescription("管控平台正在后台运行,请勿停用此服务!");
            notificationChannel.setLockscreenVisibility(-1);
            notificationManager.createNotificationChannel(notificationChannel);
            startForeground(1111, new Notification.Builder(this, packageName).setContentTitle("正在进行设备管控1").setContentText("管控平台正在后台运行,请勿停用此服务!").setWhen(System.currentTimeMillis()).setSmallIcon(R$drawable.ic_notification_mdm).build());
        }
        return super.onStartCommand(intent, i, i2);
    }

    @l
    public void onTimePolicy(com.iflytek.mdmservice.o.b.e eVar) {
        if (this.k != null) {
            this.k.d(eVar.b(), eVar.a());
        }
    }

    @l
    public void onUsbPolicy(com.iflytek.mdmservice.o.b.f fVar) {
        if (this.j != null) {
            this.j.a(fVar.b(), fVar.a());
        }
    }

    public WorkService(String str) {
        super(str);
        this.f310a = true;
    }
}