导航菜单

页面标题

页面副标题

安讯通-企业级安全协同工具 v1.0.50 - CactusHelp.java 源代码

正在查看: 安讯通-企业级安全协同工具 v1.0.50 应用的 CactusHelp.java JAVA 源代码文件

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


package com.gyf.xtfcactus;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import androidx.work.Configuration;
import androidx.work.Data;
import androidx.work.ListenableWorker;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
import com.alibaba.fastjson.JSON;
import com.getui.gtc.a.f$$ExternalSyntheticApiModelOutline0;
import com.gyf.cactus.CactusTimer;
import com.gyf.xtfcactus.callback.CactusBackgroundCallback;
import com.gyf.xtfcactus.entity.Constant;
import com.gyf.xtfcactus.pix.OnePixActivity;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

public class CactusHelp {
    private static final String TAG = "CactusHelp";
    static Context context = null;
    private static boolean haveExecTimer = false;
    static MediaPlayer mediaPlayer = null;
    static boolean sHaveInit = false;
    AlarmManager alarmManager;
    private long curPoccess;
    boolean isUIniRuntime;
    OnAleraTaskExecListener onAleraTaskExecListener;
    OnBackgroundListener onBackgroundListener;
    OnCTimerListener onCTimerListener;
    OnNotificationClickListener onNotificationClickListener;
    OnScrrenListener onScrrenListener;
    PendingIntent pendingIntent;
    private Timer timer;
    public static long cactusBeginTime = System.currentTimeMillis();
    static boolean haveInitWorkManger = false;
    private static Map<Long, Integer> timerTotalMap = new ConcurrentHashMap();
    private static Map<Long, Integer> timerCountMap = new ConcurrentHashMap();
    private static Map<Long, OnTimerCountListener> timerListenerMap = new ConcurrentHashMap();
    Cactus cactus = Cactus.getInstance();
    MyBroadcastReceiver myBroadcastReceiver = new MyBroadcastReceiver();
    private boolean isExecInterval = false;
    private long interval = 0;

    public interface OnAleraTaskExecListener {
        void onAleraTaskExec();
    }

    public interface OnBackgroundListener {
        void onBackground(boolean z);
    }

    public interface OnCTimerListener {
        void onCExec();
    }

    public interface OnNotificationClickListener {
        void onNotificationClick();
    }

    public interface OnScrrenListener {
        void onScrrenListener(boolean z);
    }

    public interface OnTimerCountListener {
        void onTimerCount();
    }

    public void on(Context context2) {
    }

    public CactusHelp(Context context2) {
        this.curPoccess = (long) (Math.random() * 2.0E7d);
        this.isUIniRuntime = true;
        try {
            Class.forName("io.dcloud.uts.UTSAndroid");
            this.isUIniRuntime = true;
        } catch (Exception e) {
            e.printStackTrace();
            this.isUIniRuntime = false;
        }
        this.cactus.isDebug(false);
        Cactus.context = context2;
        context = context2;
        this.alarmManager = (AlarmManager) context2.getSystemService(NotificationCompat.CATEGORY_ALARM);
        this.curPoccess = (long) (Math.random() * 2.0E7d);
        this.cactus.setSmallIcon(R.drawable.notification_big);
        this.cactus.setChannelName(Constant.CACTUS_TAG);
        this.cactus.setServiceId(6234542);
        this.cactus.setMusicId(R.raw.cactus);
        this.cactus.setOnePixEnabled(false);
        this.cactus.setChannelId(Constant.CACTUS_TAG);
        if (sHaveInit) {
            return;
        }
        this.cactus.addBackgroundCallback(new CactusBackgroundCallback() {
            @Override
            public void onBackground(boolean z) {
                if (CactusHelp.this.onBackgroundListener != null) {
                    CactusHelp.this.onBackgroundListener.onBackground(z);
                }
            }
        });
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.keeplive.keeplive");
        intentFilter.addAction("com.keeplive.screenoff");
        intentFilter.addAction("com.keeplive.screenon");
        intentFilter.addAction("com.keeplive.alera");
        intentFilter.addAction("com.xtf.keeplive.notfation");
        if (Build.VERSION.SDK_INT >= 26) {
            context2.registerReceiver(this.myBroadcastReceiver, intentFilter, 2);
        } else {
            context2.registerReceiver(this.myBroadcastReceiver, intentFilter);
        }
        sHaveInit = true;
    }

    public void setDebug(boolean z) {
        this.cactus.isDebug(z);
    }

    public void setMusicEnabled(boolean z) {
        this.cactus.setMusicEnabled(z);
    }

    public void setMusicId(int i) {
        this.cactus.setMusicId(i);
    }

    public void hideRecentTask(boolean z) {
        ComponentName componentName;
        List<ActivityManager.AppTask> appTasks = ((ActivityManager) context.getSystemService("activity")).getAppTasks();
        appTasks.size();
        for (ActivityManager.AppTask appTask : appTasks) {
            if (Build.VERSION.SDK_INT >= 23) {
                componentName = appTask.getTaskInfo().baseActivity;
                if (componentName.getPackageName().equals(context.getPackageName())) {
                    appTask.setExcludeFromRecents(z);
                }
            }
        }
    }

    public void setNotifationId(int i) {
        Log.i(TAG, "setNotifationId: id= " + i);
        this.cactus.setServiceId(i);
    }

    public int getNotifationId() {
        return this.cactus.getServiceId();
    }

    public void cancelNotifation() {
        NotificationManagerCompat.from(context).cancel(this.cactus.getServiceId());
    }

    public void preCreateNotificationChannel() {
        try {
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationManagerCompat from = NotificationManagerCompat.from(context);
                if (from.getNotificationChannel(Cactus.getInstance().getMCactusConfig().getNotificationConfig().getChannelId()) == null) {
                    f$$ExternalSyntheticApiModelOutline0.m262m$2();
                    NotificationChannel m = f$$ExternalSyntheticApiModelOutline0.m(Cactus.getInstance().getMCactusConfig().getNotificationConfig().getChannelId(), Cactus.getInstance().getMCactusConfig().getNotificationConfig().getChannelName(), Cactus.getInstance().getMCactusConfig().getNotificationConfig().getChannelImportance());
                    if (!this.cactus.getMCactusConfig().getNotificationConfig().getEnableSound()) {
                        m.setSound(null, null);
                    }
                    from.createNotificationChannel(m);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setAutoStartEnable(boolean z) {
        this.cactus.setOnePixEnabled(z);
    }

    public boolean checkAppNotification(Context context2) {
        if (Build.VERSION.SDK_INT < 26) {
            return true;
        }
        return NotificationManagerCompat.from(context2).areNotificationsEnabled();
    }

    public void setChannelId(String str) {
        this.cactus.setChannelId(str);
    }

    public void goNotificationSetting(Context context2) {
        try {
            Intent intent = new Intent();
            intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
            intent.putExtra("android.provider.extra.APP_PACKAGE", context2.getPackageName());
            intent.putExtra(NotificationCompat.EXTRA_CHANNEL_ID, context2.getApplicationInfo().uid);
            intent.setFlags(268435456);
            intent.putExtra("app_package", Constant.CACTUS_TAG);
            intent.putExtra("app_uid", context2.getApplicationInfo().uid);
            context2.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            Intent intent2 = new Intent();
            intent2.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent2.setData(Uri.fromParts("package", context2.getPackageName(), null));
            intent2.setFlags(268435456);
            context2.startActivity(intent2);
        }
    }

    public void setPendingIntent(Activity activity) {
        try {
            Intent intent = new Intent(activity, Class.forName(activity.getLocalClassName()));
            intent.setFlags(270532608);
            this.cactus.setPendingIntent(PendingIntent.getActivity(activity, 0, intent, AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setNotificationClick() {
        Intent intent = new Intent();
        intent.setAction("com.keeplive.keeplive");
        this.cactus.setPendingIntent(PendingIntent.getBroadcast(context, 0, intent, Build.VERSION.SDK_INT >= 23 ? 201326592 : 134217728));
    }

    public void doStartApplicationWithPackageName(Context context2, String str) {
        PackageInfo packageInfo;
        try {
            try {
                packageInfo = context2.getPackageManager().getPackageInfo(str, 0);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
                packageInfo = null;
            }
            if (packageInfo == null) {
                return;
            }
            Intent intent = new Intent("android.intent.action.MAIN", (Uri) null);
            intent.addCategory("android.intent.category.LAUNCHER");
            intent.setPackage(packageInfo.packageName);
            ResolveInfo next = context2.getPackageManager().queryIntentActivities(intent, 0).iterator().next();
            if (next != null) {
                String str2 = next.activityInfo.packageName;
                String str3 = next.activityInfo.name;
                Intent intent2 = new Intent("android.intent.action.MAIN");
                intent2.addCategory("android.intent.category.LAUNCHER");
                intent2.setFlags(270532608);
                intent2.setComponent(new ComponentName(str2, str3));
                context2.startActivity(intent2);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void setChannelName(String str) {
        this.cactus.setChannelName(str);
    }

    public void setTitle(String str) {
        this.cactus.setTitle(str);
    }

    public void setContent(String str) {
        this.cactus.setContent(str);
    }

    public void setWorkerEnabled(boolean z) {
        this.cactus.setWorkerEnabled(z);
    }

    public void setSmallIcon(int i) {
        this.cactus.setSmallIcon(i);
    }

    public void setMuiscVol(float f) {
        this.cactus.setMusicVolNum(f);
    }

    public void setLargeIcon(int i) {
        this.cactus.setLargeIcon(i);
    }

    public void setNotifactionPer(int i) {
        this.cactus.setNotifactionPer(i);
    }

    public void setBackgroundMusicEnabled(boolean z) {
        this.cactus.setBackgroundMusicEnabled(z);
    }

    public void setMusicInterval(int i) {
        this.cactus.setMusicInterval(i);
    }

    public void setWorkOnMainThread(boolean z) {
        this.cactus.setWorkOnMainThread(z);
    }

    public void register(Context context2) {
        try {
            if (Cactus.getInstance().getMCactusConfig().getDefaultConfig().getDebug()) {
                if (!haveInitWorkManger) {
                    try {
                        WorkManager.initialize(context.getApplicationContext(), new Configuration.Builder().setMinimumLoggingLevel(3).build());
                    } catch (Exception unused) {
                    }
                    haveInitWorkManger = true;
                }
                if (this.cactus.getMCactusConfig().getDefaultConfig().getOnePixEnabled()) {
                    if (OnePixActivity.INSTANCE.getSThis() == null) {
                        Intent intent = new Intent(context, (Class<?>) OnePixActivity.class);
                        intent.setFlags(268435456);
                        context.startActivity(intent);
                    }
                    WorkManager.getInstance(context2).cancelAllWorkByTag("keeplivetask");
                    WorkManager.getInstance(context).enqueue(new PeriodicWorkRequest.Builder((Class<? extends ListenableWorker>) KeepLiveWork.class, 15L, TimeUnit.MINUTES).setInitialDelay(10L, TimeUnit.SECONDS).addTag("keeplivetask").setInputData(new Data.Builder().putString("keep", "Hello").build()).build());
                    Log.i(TAG, "register: exec task");
                } else {
                    WorkManager.getInstance(context).cancelAllWorkByTag("keeplivetask");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                CactusHelp.this.cactus.register(CactusHelp.context);
            }
        }).start();
    }

    public void unregister(Context context2) {
        this.cactus.unregister(context2);
        try {
            if (OnePixActivity.INSTANCE.getSThis() != null) {
                OnePixActivity.INSTANCE.getSThis().finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNotification(Context context2) {
        this.cactus.updateNotification(context2);
    }

    public boolean isRunning(Context context2) {
        return this.cactus.isRunning(context2);
    }

    public void restart(Context context2) {
        this.cactus.restart(context2);
    }

    public void hideNotification(boolean z) {
        this.cactus.hideNotification(z);
        this.cactus.hideNotificationAfterO(z);
    }

    public void setChannelImportance(int i) {
        this.cactus.setChannelImportance(i);
    }

    public void setShowChannelShowBrage(boolean z) {
        this.cactus.setShowChannelShowBrage(z);
    }

    public void startExeckTask(long j, long j2) {
        Timer timer = this.timer;
        if (timer != null) {
            timer.cancel();
        }
        this.interval = j2;
        if (j2 < 60000) {
            this.timer = new Timer();
            this.timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    if (CactusHelp.this.onAleraTaskExecListener != null) {
                        CactusHelp.this.onAleraTaskExecListener.onAleraTaskExec();
                    }
                }
            }, j, j2);
            return;
        }
        PendingIntent pendingIntent = this.pendingIntent;
        if (pendingIntent != null) {
            this.alarmManager.cancel(pendingIntent);
        }
        this.isExecInterval = true;
        if (j < 60000) {
            this.timer = new Timer();
            this.timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    Intent intent = new Intent("com.keeplive.alera");
                    intent.putExtra("process", CactusHelp.this.curPoccess);
                    CactusHelp.context.sendBroadcast(intent);
                }
            }, j);
            return;
        }
        startExecAlera();
    }

    public void startExecAlera() {
        Intent intent = new Intent();
        intent.setAction("com.keeplive.alera");
        intent.putExtra("process", this.curPoccess);
        this.pendingIntent = PendingIntent.getBroadcast(context, (int) (Math.random() * 100000.0d), intent, Build.VERSION.SDK_INT >= 23 ? 201326592 : 134217728);
        if (Build.VERSION.SDK_INT >= 23) {
            this.alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(System.currentTimeMillis() + this.interval, this.pendingIntent), this.pendingIntent);
        } else {
            this.alarmManager.setExact(0, System.currentTimeMillis() + this.interval, this.pendingIntent);
            this.alarmManager.set(0, System.currentTimeMillis() + this.interval, this.pendingIntent);
        }
    }

    public void cancleTask() {
        try {
            this.isExecInterval = false;
            Timer timer = this.timer;
            if (timer != null) {
                timer.cancel();
            }
            PendingIntent pendingIntent = this.pendingIntent;
            if (pendingIntent != null) {
                this.alarmManager.cancel(pendingIntent);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setSoundEnable(boolean z) {
        this.cactus.setSoundEnable(z);
    }

    public void setOnBackgroundListener(OnBackgroundListener onBackgroundListener) {
        this.onBackgroundListener = onBackgroundListener;
    }

    public void setOnNotificationClickListener(OnNotificationClickListener onNotificationClickListener) {
        this.onNotificationClickListener = onNotificationClickListener;
    }

    public void setCrashRestartUIEnabled(boolean z) {
        Log.i(TAG, "setCrashRestartUIEnabled: " + z);
        this.cactus.setCrashRestartUIEnabled(z);
    }

    public void setOnScrrenListener(OnScrrenListener onScrrenListener) {
        this.onScrrenListener = onScrrenListener;
    }

    public void setOnAleraTaskExecListener(OnAleraTaskExecListener onAleraTaskExecListener) {
        this.onAleraTaskExecListener = onAleraTaskExecListener;
    }

    class MyBroadcastReceiver extends BroadcastReceiver {
        MyBroadcastReceiver() {
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction() == null) {
                return;
            }
            if (Objects.equals(intent.getAction(), "com.keeplive.screenoff")) {
                intent.getLongExtra("process", 0L);
                long unused = CactusHelp.this.curPoccess;
                if (CactusHelp.this.onScrrenListener != null) {
                    CactusHelp.this.onScrrenListener.onScrrenListener(false);
                    return;
                }
                return;
            }
            if (Objects.equals(intent.getAction(), "com.keeplive.screenon")) {
                Log.i("xtf", "onReceive: " + intent.getLongExtra("process", 0L) + "    " + CactusHelp.this.curPoccess);
                intent.getLongExtra("process", 0L);
                long unused2 = CactusHelp.this.curPoccess;
                if (CactusHelp.this.onScrrenListener != null) {
                    CactusHelp.this.onScrrenListener.onScrrenListener(true);
                    return;
                }
                return;
            }
            if (Objects.equals(intent.getAction(), "com.keeplive.keeplive")) {
                if (intent.getLongExtra("process", 0L) != CactusHelp.this.curPoccess || CactusHelp.this.onNotificationClickListener == null) {
                    return;
                }
                CactusHelp.this.onNotificationClickListener.onNotificationClick();
                return;
            }
            if (Objects.equals(intent.getAction(), "com.keeplive.alera")) {
                if (CactusHelp.this.isExecInterval) {
                    try {
                        if (intent.getLongExtra("process", 0L) == CactusHelp.this.curPoccess) {
                            try {
                                if (CactusHelp.this.onAleraTaskExecListener != null) {
                                    CactusHelp.this.onAleraTaskExecListener.onAleraTaskExec();
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            return;
                        }
                        return;
                    } finally {
                        CactusHelp.this.startExecAlera();
                    }
                }
                return;
            }
            if (intent.getAction().equals("com.xtf.keeplive.notfation") && CactusHelp.this.cactus.isRunning(context)) {
                CactusHelp.this.updateNotification(context);
            }
        }
    }

    public void execTime(int i) {
        Log.i(TAG, "execTime: " + i);
        OnCTimerListener onCTimerListener = this.onCTimerListener;
        if (onCTimerListener != null) {
            onCTimerListener.onCExec();
        }
    }

    public void cancelSystemTimer() {
        CactusTimer.get(this.curPoccess).cancelTimer();
    }

    public void startCSystemTimer(int i, OnCTimerListener onCTimerListener) {
        this.onCTimerListener = onCTimerListener;
        CactusTimer.get(this.curPoccess).startTimer(i);
        CactusTimer.get(this.curPoccess).setOnCTimerListener(onCTimerListener);
    }

    public void clearAllCTimer() {
        CactusTimer.get(this.curPoccess).clearAllTask();
    }

    public long getLiveTime() {
        return System.currentTimeMillis() - cactusBeginTime;
    }

    public String millisToHMS(long j) {
        long j2 = j / 1000;
        long j3 = j2 / 60;
        return String.format("%02d:%02d:%02d", Long.valueOf(j3 / 60), Long.valueOf(j3 % 60), Long.valueOf(j2 % 60));
    }

    private static void startTimer(final MediaPlayer.OnCompletionListener onCompletionListener) {
        if (mediaPlayer == null) {
            System.currentTimeMillis();
            MediaPlayer create = MediaPlayer.create(context, R.raw.timer);
            mediaPlayer = create;
            create.setWakeMode(context, 1);
            mediaPlayer.setOnCompletionListener(onCompletionListener);
            mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public boolean onError(MediaPlayer mediaPlayer2, int i, int i2) {
                    try {
                        Log.i(CactusHelp.TAG, "onError: ");
                        mediaPlayer2.reset();
                        mediaPlayer2.release();
                        MediaPlayer create2 = MediaPlayer.create(CactusHelp.context, R.raw.timer);
                        create2.setOnCompletionListener(onCompletionListener);
                        onCompletionListener.onCompletion(create2);
                        return true;
                    } catch (Exception e) {
                        e.printStackTrace();
                        return true;
                    }
                }
            });
        }
    }

    public void startClcokTimer(int i, OnTimerCountListener onTimerCountListener) {
        timerTotalMap.put(Long.valueOf(this.curPoccess), Integer.valueOf(i));
        timerCountMap.put(Long.valueOf(this.curPoccess), 0);
        timerListenerMap.put(Long.valueOf(this.curPoccess), onTimerCountListener);
        startTimer(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer2) {
                Log.i(CactusHelp.TAG, "onCompletion: " + CactusHelp.this.curPoccess + "   " + CactusHelp.timerCountMap.size() + "  " + JSON.toJSONString(CactusHelp.timerCountMap));
                for (Map.Entry entry : CactusHelp.timerTotalMap.entrySet()) {
                    Long l = (Long) entry.getKey();
                    int intValue = ((Integer) entry.getValue()).intValue();
                    Integer num = (Integer) CactusHelp.timerCountMap.get(l);
                    if (num != null) {
                        int intValue2 = num.intValue();
                        if (intValue2 >= intValue) {
                            OnTimerCountListener onTimerCountListener2 = (OnTimerCountListener) CactusHelp.timerListenerMap.get(l);
                            CactusHelp.timerCountMap.put(l, 0);
                            if (onTimerCountListener2 != null) {
                                try {
                                    onTimerCountListener2.onTimerCount();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        } else {
                            CactusHelp.timerCountMap.put(l, Integer.valueOf(intValue2 + 1));
                        }
                    }
                }
                try {
                    mediaPlayer2.start();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        });
        MediaPlayer mediaPlayer2 = mediaPlayer;
        if (mediaPlayer2 == null || mediaPlayer2.isPlaying()) {
            return;
        }
        mediaPlayer.start();
    }

    public void cancelClcokTimer() {
        timerTotalMap.remove(Long.valueOf(this.curPoccess));
        timerCountMap.remove(Long.valueOf(this.curPoccess));
        timerListenerMap.remove(Long.valueOf(this.curPoccess));
        if (timerCountMap.isEmpty()) {
            try {
                MediaPlayer mediaPlayer2 = mediaPlayer;
                if (mediaPlayer2 != null) {
                    mediaPlayer2.stop();
                    mediaPlayer.release();
                    mediaPlayer = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void cancelAllClcokTimer() {
        timerTotalMap.clear();
        timerCountMap.clear();
        timerListenerMap.clear();
        if (timerCountMap.isEmpty()) {
            try {
                MediaPlayer mediaPlayer2 = mediaPlayer;
                if (mediaPlayer2 != null) {
                    mediaPlayer2.stop();
                    mediaPlayer.release();
                    mediaPlayer = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}