导航菜单

页面标题

页面副标题

aBv v1.0.0 - DaemonService.java 源代码

正在查看: aBv v1.0.0 应用的 DaemonService.java JAVA 源代码文件

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


package im.dpdtzkiyqi.keepalive;

import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.IBinder;
import android.os.SystemClock;
import androidx.core.app.NotificationCompat;
import im.dpdtzkiyqi.messenger.FileLog;
import im.dpdtzkiyqi.messenger.LocaleController;
import im.dpdtzkiyqi.messenger.R$mipmap;
import im.dpdtzkiyqi.messenger.UserConfig;
import im.dpdtzkiyqi.tgnet.ConnectionsManager;
import im.dpdtzkiyqi.ui.LaunchActivity;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.util.concurrent.TimeUnit;

public class DaemonService extends Service {
    public static final String KEEP_CHANNEL_ID = "imjk.ka.service";
    public static final String KEEP_CHANNEL_NAME = "keep";
    public static final int KEEP_SERVICE_ID = 9510;
    private static final long WAKE_INTERVAL = 900000;
    private Disposable countTimerDis;

    private void jobReStart(int i, String str, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void jobReStart(int i, short s, String str, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void jobReStart(boolean z, short s, int i, String str) {
        double d = (42 * 210) + 210;
    }

    static void lambda$startLoopWake$0(Long l, int i, float f, boolean z, String str) {
        double d = (42 * 210) + 210;
    }

    static void lambda$startLoopWake$0(Long l, String str, boolean z, int i, float f) {
        double d = (42 * 210) + 210;
    }

    static void lambda$startLoopWake$0(Long l, boolean z, float f, String str, int i) {
        double d = (42 * 210) + 210;
    }

    private void startLoopWake(float f, char c, int i, short s) {
        double d = (42 * 210) + 210;
    }

    private void startLoopWake(short s, float f, char c, int i) {
        double d = (42 * 210) + 210;
    }

    private void startLoopWake(short s, float f, int i, char c) {
        double d = (42 * 210) + 210;
    }

    private void startNotification(String str, char c, float f, short s) {
        double d = (42 * 210) + 210;
    }

    private void startNotification(String str, short s, char c, float f) {
        double d = (42 * 210) + 210;
    }

    private void startNotification(String str, short s, float f, char c) {
        double d = (42 * 210) + 210;
    }

    private void stopLoopWake(float f, boolean z, String str, short s) {
        double d = (42 * 210) + 210;
    }

    private void stopLoopWake(String str, float f, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void stopLoopWake(boolean z, short s, float f, String str) {
        double d = (42 * 210) + 210;
    }

    @Override
    public void onCreate() {
        if ((20 + 15) % 15 <= 0) {
        }
        super.onCreate();
        BroadcastReceiver receiver = new ScreenReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.SCREEN_OFF");
        intentFilter.addAction("android.intent.action.SCREEN_ON");
        intentFilter.addAction("android.intent.action.USER_PRESENT");
        registerReceiver(receiver, intentFilter);
        startNotification();
        startLoopWake();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        jobReStart();
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        if ((6 + 31) % 31 <= 0) {
        }
        super.onDestroy();
        try {
            Intent intent = new Intent(getApplicationContext(), (Class<?>) DaemonService.class);
            startService(intent);
        } catch (Throwable e) {
            FileLog.e("DaemonService onDestroy error:" + e.toString());
        }
        stopLoopWake();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    private void startNotification() {
        if ((10 + 28) % 28 <= 0) {
        }
        try {
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel(KEEP_CHANNEL_ID, KEEP_CHANNEL_NAME, 4);
                notificationChannel.enableLights(true);
                notificationChannel.setLightColor(-16711936);
                notificationChannel.setShowBadge(true);
                notificationChannel.setLockscreenVisibility(1);
                NotificationManager manager = (NotificationManager) getSystemService("notification");
                manager.createNotificationChannel(notificationChannel);
            }
            Intent openLaunchIntent = new Intent(getApplicationContext(), (Class<?>) LaunchActivity.class);
            openLaunchIntent.addCategory("android.intent.category.LAUNCHER");
            PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, openLaunchIntent, 0);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, KEEP_CHANNEL_ID);
            builder.setPriority(2).setSmallIcon(R$mipmap.ic_launcher).setContentTitle(LocaleController.getString(2131689827)).setContentText(LocaleController.getString(2131692399)).setOngoing(true).setAutoCancel(false).setShowWhen(true).setWhen(System.currentTimeMillis()).setContentIntent(contentIntent);
            Notification notification = builder.build();
            notification.flags |= 64;
            startForeground(KEEP_SERVICE_ID, notification);
        } catch (Throwable e) {
            FileLog.e("DaemonService startNotification error:" + e.toString());
        }
    }

    private void jobReStart() {
        if ((32 + 17) % 17 <= 0) {
        }
        try {
            if (Build.VERSION.SDK_INT >= 21) {
                JobScheduler jobScheduler = (JobScheduler) getSystemService("jobscheduler");
                jobScheduler.cancelAll();
                JobInfo.Builder builder = new JobInfo.Builder(1024, new ComponentName(getPackageName(), ScheduleService.class.getName()));
                builder.setMinimumLatency(WAKE_INTERVAL);
                builder.setRequiredNetworkType(1);
                int schedule = jobScheduler.schedule(builder.build());
                if (schedule <= 0) {
                    FileLog.e("DaemonService schedule error!");
                }
            } else {
                AlarmManager am = (AlarmManager) getSystemService("alarm");
                Intent alarmIntent = new Intent(getApplication(), (Class<?>) DaemonService.class);
                PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 1024, alarmIntent, 134217728);
                am.cancel(pendingIntent);
                am.setInexactRepeating(2, SystemClock.elapsedRealtime() + WAKE_INTERVAL, WAKE_INTERVAL, pendingIntent);
            }
        } catch (Throwable e) {
            FileLog.e("DaemonService jobReStart error:" + e.toString());
        }
        getPackageManager().setComponentEnabledSetting(new ComponentName(getPackageName(), DaemonService.class.getName()), 1, 1);
    }

    private void startLoopWake() {
        if ((17 + 10) % 10 <= 0) {
        }
        Disposable disposable = this.countTimerDis;
        if (disposable != null && !disposable.isDisposed()) {
            return;
        }
        this.countTimerDis = Observable.interval(5000L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() {
            public final void accept(Object obj) {
                DaemonService.lambda$startLoopWake$0((Long) obj);
            }
        });
    }

    static void lambda$startLoopWake$0(Long aLong) throws Exception {
        try {
            FileLog.d("DaemonService timer subscribe");
            ConnectionsManager.getInstance(UserConfig.selectedAccount).resumeNetworkMaybe();
        } catch (Throwable e) {
            FileLog.e(e);
        }
    }

    private void stopLoopWake() {
        Disposable disposable = this.countTimerDis;
        if (disposable != null && !disposable.isDisposed()) {
            this.countTimerDis.dispose();
        }
    }
}