正在查看: Tasker v6.5.11 应用的 MonitorService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.5.11 应用的 MonitorService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package net.dinglisch.android.taskerm;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.UiModeManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SyncStatusObserver;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.BadParcelableException;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcel;
import android.os.PowerManager;
import android.provider.CallLog;
import android.provider.Settings;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.widget.RemoteViews;
import com.joaomgcd.taskerm.helper.HelperMonitorService;
import com.joaomgcd.taskerm.securesettings.AccessibilitySettingObservable;
import com.joaomgcd.taskerm.spawn.RFactory;
import com.joaomgcd.taskerm.util.ExtensionsContextKt;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import cyanogenmod.alarmclock.ClockContract;
import cyanogenmod.app.ProfileManager;
import cyanogenmod.os.Build;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import net.dinglisch.android.tasker.PluginResultReceiver;
import net.dinglisch.android.taskerm.MonitorService;
import net.dinglisch.android.taskerm.RunLog;
import net.dinglisch.android.taskerm.g6;
import net.dinglisch.android.taskerm.pp;
import net.dinglisch.android.taskerm.ri;
import net.dinglisch.android.taskerm.tn;
import net.dinglisch.android.taskerm.vo;
import net.dinglisch.android.taskerm.wo;
import net.dinglisch.android.taskerm.yd;
import nf.h;
public class MonitorService extends MyService {
private static long R1;
private static long S1;
private static volatile Boolean T1;
private static volatile long U1;
private static Map<String, ScanResult> V1;
private static Map<String, Long> W1;
private static long X1;
private static long Y1;
private static volatile Boolean Z1;
private static Map<String, i1> a2;
private static Map<String, i1> b2;
private static String[][] c2;
private static String d2;
private static String e2;
private static boolean f2;
private static Map<Integer, Long> g2;
private static float h2;
private static float i2;
private static float j2;
private static float k2;
private static final LinkedList<Integer> l2;
private static boolean m2;
private static boolean n2;
private static boolean o2;
private static hg.l1 p2;
private static hg.l1 q2;
private static final String[] w1;
private static final long[] x1;
private static final String[] y1;
private static final int z1;
private List<String> A;
private SharedPreferences A0;
private String B;
public to B0;
private String C;
private Set<Integer> C0;
private Set<ComponentName> D;
private PendingIntent D0;
private long E;
private long E0;
private Location F;
private Object F0;
private long G;
private PendingIntent G0;
private int H;
private long H0;
private long I;
private PendingIntent[] I0;
private long J;
private Object J0;
private ClipboardManager.OnPrimaryClipChangedListener K;
private long[] K0;
private x1 L;
private PendingIntent L0;
private x1 M;
private Object M0;
private Object N;
private long N0;
private PhoneStateListenerCommon O;
private Set<Integer> O0;
private boolean P;
private Map<Integer, kp> P0;
private PendingIntent Q;
private Map<Integer, w1> Q0;
private boolean R;
private Map<Integer, g1> R0;
private boolean S;
private Map<Integer, q7> S0;
private int T;
private Map<Integer, a0> T0;
private int U;
private Map<Integer, e0> U0;
private boolean V;
public Map<Integer, List<Integer>> V0;
private BroadcastReceiver W;
public Map<Integer, List<Integer>> W0;
private int X;
private List<ih> X0;
private WifiManager.WifiLock Y;
private com.joaomgcd.taskerm.util.e Y0;
private int Z;
private HashMap<Integer, List<pn>> Z0;
private long a0;
public List<ReceiverDynamicUser> a1;
private long b0;
private List<ReceiverDynamic> b1;
private Map<String, Object> c0;
private Set<String> c1;
private int d0;
private Map<Integer, net.dinglisch.android.taskerm.c> d1;
private BroadcastReceiver e0;
private final Object e1;
private Handler f0;
private Map<Integer, Integer> f1;
private long g0;
public ConcurrentLinkedDeque<Intent> g1;
private long h0;
private boolean h1;
private int i0;
private long i1;
private BluetoothProfile.ServiceListener j0;
private long j1;
private int[] k0;
private long k1;
private Handler l0;
private long l1;
private boolean[] m0;
private long m1;
private bh[] n0;
private rg.q n1;
private SensorEventListener[] o0;
private AccessibilitySettingObservable o1;
private Sensor[] p0;
public HelperMonitorService p1;
private long q0;
private ji.b q1;
private long r0;
private final Object r1;
private final boolean[] s;
private Handler s0;
private final Object s1;
private final boolean[] t;
private SensorManager t0;
private List<z> u;
private ActivityManager u0;
private String v;
private AlarmManager v0;
private long w;
private ContentResolver w0;
private long x;
private LocationManager x0;
private List<String> y;
private WifiManager y0;
private List<String> z;
private Resources z0;
private static final Object t1 = new Object();
private static final int[] u1 = {0, -16777216, -10066330, -5592406, -1, -3407872, -30720, -10053376, -16737844, -8947849};
private static final int[] v1 = {-1, 110, 30, 30, 150, 100, 80, 80, 50, 10, 10, 140, 160, 105, 105, 105, 105, 105, 105, 120, 40, 107, 145, 125, 103, 104, 122, 123, 142, 143, 40, 106, 2, 10, 175, 180, 80, 12, 185, 161, 10, 195, 154, 14, 135, 182, 141, 16, 148, 149, 136};
private static final String[] A1 = {"WIFI-EN", "BT-EN", "BT-PAIR", "BT-LE-PAIR", "BT-UNKNOWN", "BT-LE-UNKNOWN", "APP-SERV", "APP-FORE", "MEDIA-HELD"};
private static final Object B1 = new Object();
private static final int[] C1 = {22, 0, 15, 12, 13, 16, 19, 24, 21, 17};
private static final String[] D1 = {"stepsWhenOff", "accelWhenOff", "accelWhenOff", "proxWhenOff", "lightWhenOff", "pressureWhenOff", "tempWhenOff", "heartWhenOff", "humidityWhenOff", "magnetWhenOff"};
private static final int[] E1 = {2, 1, 1, 1, 1, 1, 2, 2, 2, 2};
private static final String[] F1 = {"STEP", "ACCEL", "SHAKE", "PROX", "LIGHT", "PRESSURE", "TEMP", "HEART", "HUMIDITY", "MAGNET"};
private static Map<String, Integer> G1 = new HashMap();
private static String H1 = "";
private static long I1 = -1;
private static boolean J1 = false;
private static volatile int K1 = -1;
private static volatile String L1 = null;
private static String M1 = "";
private static volatile int N1 = -1;
private static volatile Map<Long, String> O1 = new HashMap();
private static Map<Integer, Location> P1 = new ConcurrentHashMap();
private static Map<String, LocationListener> Q1 = new HashMap();
class a implements SensorEventListener {
a() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - MonitorService.this.k1 > 5000) {
if (MonitorService.this.M2(sensorEvent, 8, 1)) {
try {
float f = sensorEvent.values[0];
if (MonitorService.this.x5(185)) {
MonitorService.this.D7(38, (int) f, true);
}
kq.S1(MonitorService.this, 44, String.valueOf(f));
} catch (Exception e) {
r7.H("M", "onSensorChanged (humidity)", e);
}
}
MonitorService.this.k1 = currentTimeMillis;
}
}
}
private class a0 {
float[] a;
float[] b;
float[] c;
int d;
boolean e;
float g;
float h;
float i;
long j;
float l;
int m;
int f = 0;
long k = Long.MAX_VALUE;
private boolean n = false;
public a0(int i, float f, long j, String str, String str2) {
this.e = false;
this.l = f;
this.j = j;
this.d = i;
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
boolean a0 = j2.a0(str2, arrayList, arrayList2, arrayList3);
this.e = !a0;
if (!a0) {
r7.G("M", "bad data for gesture " + str);
return;
}
int size = arrayList.size();
this.m = size;
this.a = new float[size];
this.b = new float[size];
this.c = new float[size];
for (int i2 = 0; i2 < this.m; i2++) {
this.a[i2] = ((Float) arrayList.get(i2)).floatValue();
this.b[i2] = ((Float) arrayList2.get(i2)).floatValue();
this.c[i2] = ((Float) arrayList3.get(i2)).floatValue();
}
this.g = this.a[0];
this.h = this.b[0];
this.i = this.c[0];
}
private void d() {
this.f = 0;
this.g = this.a[0];
this.h = this.b[0];
this.i = this.c[0];
}
public boolean a(float f, float f2, float f3, long j) {
if (Math.abs(this.g - f) >= this.l || Math.abs(this.h - f2) >= this.l || Math.abs(this.i - f3) >= this.l) {
if (this.f <= 0) {
return false;
}
if (this.k == Long.MAX_VALUE) {
this.k = j;
}
if (j - this.k <= this.j) {
return false;
}
d();
this.k = Long.MAX_VALUE;
return false;
}
this.k = Long.MAX_VALUE;
int i = this.f + 1;
this.f = i;
if (i == this.m) {
d();
return true;
}
this.g = this.a[i];
this.h = this.b[i];
this.i = this.c[i];
return false;
}
public int b() {
return this.f;
}
public boolean c() {
return this.n;
}
public void e(boolean z) {
if (this.n && !z) {
d();
}
this.n = z;
}
}
class b implements SensorEventListener {
b() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - MonitorService.this.l1 > 5000) {
if (MonitorService.this.M2(sensorEvent, 5, 1)) {
try {
float f = sensorEvent.values[0];
if (MonitorService.this.x5(104)) {
MonitorService.this.D7(25, (int) f, true);
}
kq.S1(MonitorService.this, 65, String.valueOf(f));
} catch (Exception e) {
r7.H("M", "onSensorChanged (pressure)", e);
}
}
MonitorService.this.l1 = currentTimeMillis;
}
}
}
static class b0 extends Handler {
WeakReference<MonitorService> a;
b0(MonitorService monitorService) {
this.a = new WeakReference<>(monitorService);
}
public static void b(MonitorService monitorService) {
try {
monitorService.z2(true, "MSHandler");
zq.k(monitorService.getApplicationContext(), "SmsObserver");
} catch (NullPointerException e) {
r7.l("M", "SMSobserver", e);
}
}
@Override
public void handleMessage(Message message) {
final MonitorService monitorService = this.a.get();
monitorService.s3(new Runnable() {
@Override
public final void run() {
MonitorService.b0.b(MonitorService.this);
}
}, "MSHandler");
}
}
class c implements SensorEventListener {
c() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - MonitorService.this.m1 > 1000) {
if (MonitorService.this.M2(sensorEvent, 9, 3)) {
try {
float[] fArr = sensorEvent.values;
float f = fArr[0];
float f2 = fArr[1];
float f3 = fArr[2];
float abs = Math.abs(f);
float abs2 = Math.abs(f2);
float abs3 = Math.abs(f3);
float f4 = abs + abs2 + abs3;
r7.f("M", "x: " + f + " y: " + f2 + " x: " + f3 + " tot: " + f4);
if (MonitorService.this.x5(106)) {
MonitorService.this.K7(31, new float[]{abs, abs2, abs3}, true);
}
kq.S1(MonitorService.this, 59, String.valueOf(f4));
} catch (Exception e) {
r7.H("M", "onSensorChanged (magnet)", e);
}
}
MonitorService.this.m1 = currentTimeMillis;
}
}
}
static class c0 extends Handler {
WeakReference<MonitorService> a;
c0(MonitorService monitorService) {
this.a = new WeakReference<>(monitorService);
}
public static void b(int i, int i2, MonitorService monitorService) {
if (i == 0) {
try {
r7.f("M", "got ss " + i2 + " last " + MonitorService.N1);
if (i2 != MonitorService.N1) {
monitorService.D7(22, i2, true);
MonitorService.N1 = i2;
if (kq.e1(18)) {
kq.F1(monitorService, 18);
return;
}
return;
}
return;
} catch (NullPointerException e) {
r7.l("M", "phoneStateListenerSig", e);
return;
}
}
if (i != 1) {
if (i == 2) {
r7.f("M", "-- got service state");
try {
if (i2 == 0) {
if (MonitorService.K1 != i2) {
oi.m();
}
monitorService.R2();
} else if (i2 == 1 || i2 == 2 || i2 == 3) {
r7.f("M", "no service, clear cell data");
MonitorService.N1 = -1;
MonitorService.L8(null);
if (kq.e1(17)) {
kq.C1(monitorService, 17);
}
if (kq.e1(18)) {
kq.F1(monitorService, 18);
}
if (kq.e1(78)) {
kq.C(monitorService, 78);
}
} else {
r7.k("M", "unknown service state: " + i2);
}
if (MonitorService.K1 != i2 && kq.e1(19)) {
kq.F1(monitorService, 19);
}
MonitorService.K1 = i2;
return;
} catch (NullPointerException e2) {
r7.l("M", "phoneStateListenerServ", e2);
return;
}
}
if (i != 3) {
return;
}
}
try {
if (monitorService.U9(8)) {
r7.f("M", "ignore cell update, in final wakelock stages");
return;
}
if (monitorService.O == null) {
r7.f("M", "ignore cell info, listener is null");
return;
}
if (i == 3) {
r7.f("M", "-- got cell info update");
MonitorService.r2(monitorService, true);
} else {
r7.f("M", "-- got cell loc update");
monitorService.t7(monitorService.O.getLastLocation());
}
monitorService.D2(7, true);
if (MonitorService.n2) {
return;
}
monitorService.M9();
} catch (NullPointerException e3) {
r7.l("M", "phoneStateListenerLoc", e3);
}
}
@Override
public void handleMessage(Message message) {
final MonitorService monitorService = this.a.get();
if (monitorService == null) {
return;
}
final int i = message.what;
final int i2 = message.arg1;
monitorService.w3(new Runnable() {
@Override
public final void run() {
MonitorService.c0.b(i, i2, monitorService);
}
}, "PhoneStateHandler handleMessage");
}
}
class d implements BluetoothProfile.ServiceListener {
d() {
}
@Override
public void onServiceConnected(int i, BluetoothProfile bluetoothProfile) {
for (BluetoothDevice bluetoothDevice : bluetoothProfile.getConnectedDevices()) {
MonitorService monitorService = MonitorService.this;
monitorService.r4(monitorService, bluetoothDevice, true, "onServiceConnected", false);
}
}
@Override
public void onServiceDisconnected(int i) {
}
}
static class d0 extends Handler {
WeakReference<MonitorService> a;
d0(MonitorService monitorService) {
this.a = new WeakReference<>(monitorService);
}
public void c(MonitorService monitorService, float f, int i) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("proxbuffer: level: ");
stringBuffer.append(f);
stringBuffer.append(" acc: ");
stringBuffer.append(i);
if (f < MonitorService.j2) {
r7.f("M", "new prox min: " + f);
MonitorService.j2 = f;
monitorService.u7("pmi", f);
}
if (f > MonitorService.k2) {
r7.f("M", "new prox max: " + f);
MonitorService.k2 = f;
monitorService.u7("pma", f);
}
if (MonitorService.k2 <= MonitorService.j2) {
r7.f("M", "ignoring prox reading " + f + ", max <= min " + MonitorService.k2 + " < " + MonitorService.j2);
} else {
monitorService.J7(23, f >= MonitorService.j2 && f < MonitorService.k2, true);
}
r7.f("M", stringBuffer.toString());
}
@Override
public void handleMessage(Message message) {
final MonitorService monitorService = this.a.get();
if (monitorService == null) {
return;
}
final float f = message.arg1;
final int i = message.arg2;
monitorService.w3(new Runnable() {
@Override
public final void run() {
MonitorService.d0.this.c(monitorService, f, i);
}
}, "ProxHandler handleMessageSync");
}
}
class e extends BroadcastReceiver {
e() {
}
@Override
public void onReceive(Context context, Intent intent) {
try {
com.joaomgcd.taskerm.util.e5 g0 = com.joaomgcd.taskerm.util.e5.g0(context);
if (!g0.B()) {
MonitorService.this.p1.Q(g0.j0());
return;
}
long currentTimeMillis = System.currentTimeMillis();
MonitorService.this.X++;
List<ScanResult> scanResults = MonitorService.this.y0.getScanResults();
if (dq.F(scanResults)) {
r7.f("M", "got empty scan results after : " + (currentTimeMillis - MonitorService.this.a0) + "ms");
} else {
r7.f("M", "got scan results after : " + (currentTimeMillis - MonitorService.this.a0) + "ms");
MonitorService.this.b0 = currentTimeMillis;
for (ScanResult scanResult : scanResults) {
r7.f("M", "new result for " + scanResult.BSSID + " / " + scanResult.SSID);
MonitorService.V1.put(scanResult.BSSID, scanResult);
MonitorService.W1.put(scanResult.BSSID, Long.valueOf(currentTimeMillis));
}
}
MonitorService.this.D2(170, true);
MonitorService monitorService = MonitorService.this;
if (monitorService.b2(170, monitorService.a0)) {
MonitorService.this.O9(true);
}
} catch (Throwable th2) {
r7.l("M", "wifiScanResultsReceiver", th2);
}
}
}
private class e0 {
private final float[] a;
private float[] b;
private int c;
private int d;
private int e;
private int f;
private boolean g = false;
private int h;
private float i;
private long j;
private long k;
public e0(int i, k2 k2Var, float f) {
float[] fArr = {45.0f, 33.0f, 25.0f, 10.0f, 1.5f};
this.a = fArr;
int i2 = 0;
this.c = i;
this.d = k2Var.x(1).v();
this.e = k2Var.x(0).v();
this.f = k2Var.x(2).v();
this.b = new float[fArr.length];
while (true) {
float[] fArr2 = this.a;
if (i2 >= fArr2.length) {
d();
return;
} else {
this.b[i2] = (fArr2[i2] / 100.0f) * f;
i2++;
}
}
}
private void d() {
this.h = 0;
this.k = 0L;
this.i = Float.MAX_VALUE;
this.j = Long.MAX_VALUE;
}
public boolean b(float f, float f2, float f3, long j, long j2) {
int i = this.d;
float[] fArr = this.b;
if (fArr == null || fArr.length < i || j - this.k <= 1000000000) {
return false;
}
int i2 = this.e;
if (i2 != 0) {
f = i2 == 1 ? f3 : f2;
}
if (Math.abs(f) <= fArr[i]) {
if (j - this.j <= 1000000000) {
return false;
}
d();
return false;
}
float f4 = this.i;
if (f4 == Float.MAX_VALUE || ((f4 >= 0.0f && f < 0.0f) || (f4 < 0.0f && f >= 0.0f))) {
this.h++;
this.i = f;
this.j = j;
}
if (this.h <= this.f) {
return false;
}
d();
this.k = j;
return true;
}
public boolean c() {
return this.g;
}
public void e(boolean z) {
if (this.g && !z) {
d();
}
this.g = z;
}
}
class f extends Handler {
f() {
}
@Override
public void handleMessage(Message message) {
MonitorService.this.p1.I0((BluetoothDevice) message.getData().getParcelable("android.bluetooth.device.extra.DEVICE"));
}
}
private static class f0 extends Handler {
WeakReference<MonitorService> a;
f0(MonitorService monitorService) {
this.a = new WeakReference<>(monitorService);
}
@Override
public void handleMessage(Message message) {
MonitorService monitorService = this.a.get();
if (monitorService != null) {
monitorService.Z4(message.what);
}
}
}
class g extends BroadcastReceiver {
g() {
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("android.bluetooth.adapter.action.DISCOVERY_STARTED")) {
r7.f("M", "BT discovery started");
return;
}
if (action.equals("android.bluetooth.adapter.action.DISCOVERY_FINISHED")) {
r7.f("M", "BT discovery finished");
if (MonitorService.this.i0 == 2) {
MonitorService.this.g9();
return;
}
return;
}
if (action.equals("android.bluetooth.device.action.FOUND") || action.equals("android.bluetooth.device.action.ACL_CONNECTED")) {
BluetoothDevice bluetoothDevice = (BluetoothDevice) intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE");
r7.f("M", action + " for " + bluetoothDevice);
MonitorService monitorService = MonitorService.this;
monitorService.p1.Y(monitorService.t4(bluetoothDevice, 0, "scanResultReceiver," + action));
}
}
}
class h implements Comparator<wo> {
h() {
}
@Override
public int compare(wo woVar, wo woVar2) {
return Long.compare(woVar.d(), woVar2.d());
}
}
class i extends BroadcastReceiver {
final int a;
final String b;
final pn c;
i(int i, String str, pn pnVar) {
this.a = i;
this.b = str;
this.c = pnVar;
}
@Override
public void onReceive(Context context, Intent intent) {
boolean H0;
wo c = MonitorService.this.B0.c(this.a);
boolean z = false;
if (intent.hasExtra("net.dinglisch.android.tasker.EXTRA_NSR_DEPRECATED") && c != null) {
r7.f("M", "plugin requested settings restore cancel for pid " + this.a);
c.D1(false);
}
int resultCode = getResultCode();
switch (resultCode) {
case 16:
case 17:
break;
case 18:
MonitorService monitorService = MonitorService.this;
monitorService.M6(monitorService, "UNKNOWN", this.b, this.c);
if (!this.c.D1()) {
r7.f("M", this.b + ": no cached query result, do nothing");
return;
}
resultCode = this.c.r1();
r7.f("M", this.b + ": retrieved cached query result: " + resultCode);
z = true;
break;
default:
r7.k("M", this.b + ": unexpected state result code " + resultCode);
return;
}
if (resultCode == 16) {
MonitorService monitorService2 = MonitorService.this;
monitorService2.M6(monitorService2, "SATISFIED", this.b, this.c);
H0 = !this.c.H0();
if (!z) {
Bundle o = ri.o(this.b, getResultExtras(true));
r7.v(this.b + "vars", o);
MonitorService monitorService3 = MonitorService.this;
com.joaomgcd.taskerm.util.x2.t(monitorService3.B0, monitorService3, c, o, "queryStatePluginonReceive");
com.joaomgcd.taskerm.structuredoutput.c.a(o, this.c);
this.c.c1(this.b, o);
}
} else {
MonitorService monitorService4 = MonitorService.this;
monitorService4.M6(monitorService4, "UNSATISFIED", this.b, this.c);
H0 = this.c.H0();
}
if (this.c.G0() != H0) {
StringBuilder sb = new StringBuilder();
sb.append(this.b);
sb.append(": change state status ");
sb.append(H0 ? "inactive -> active" : "active -> inactive");
r7.f("M", sb.toString());
this.c.M0(H0);
if (MonitorService.this.B0.V(this.a)) {
HashSet hashSet = new HashSet();
hashSet.add(Integer.valueOf(this.a));
MonitorService.this.O4(hashSet, null, null, "queryStatePluginBroadcast", false);
} else {
r7.G("M", "not handling changes for unknown profile ID " + this.a + ", from plugin code " + this.c.j());
}
}
if (z) {
return;
}
this.c.b1(resultCode);
r7.f("M", this.b + ": cache query result code " + resultCode);
}
}
class j extends BroadcastReceiver {
final int a;
final k2 b;
final String c;
j(int i, k2 k2Var, String str) {
this.a = i;
this.b = k2Var;
this.c = str;
}
@Override
public void onReceive(Context context, Intent intent) {
MonitorService.this.R4(getResultCode(), this.a, this.b, this.c, getResultExtras(true), getAbortBroadcast());
}
}
class k implements Comparator<wo> {
k() {
}
@Override
public int compare(wo woVar, wo woVar2) {
if (!woVar.Z0(1) || !woVar2.Z0(1)) {
if (woVar.Z0(3) && woVar2.Z0(3)) {
return Float.valueOf(((q7) woVar.T0(3)).i1()).compareTo(Float.valueOf(((q7) woVar2.T0(3)).i1()));
}
return 0;
}
kp kpVar = (kp) woVar.T0(1);
kp kpVar2 = (kp) woVar2.T0(1);
MonitorService monitorService = MonitorService.this;
Bundle t = com.joaomgcd.taskerm.util.x2.t(monitorService.B0, monitorService, woVar, null, "enlistActiveProfiles1");
MonitorService monitorService2 = MonitorService.this;
return Integer.valueOf(kpVar.s1() ? kpVar.d1(MonitorService.this, t) : 0).compareTo(Integer.valueOf(kpVar2.s1() ? kpVar2.d1(MonitorService.this, com.joaomgcd.taskerm.util.x2.t(monitorService2.B0, monitorService2, woVar2, null, "enlistActiveProfiles2")) : 0));
}
}
class l extends Handler {
final Set a;
final boolean b;
l(Set set, boolean z) {
this.a = set;
this.b = z;
}
@Override
public void handleMessage(Message message) {
if (MonitorService.J1) {
this.a.add(8);
}
USBHandler.f(MonitorService.this, this.a);
MonitorService.this.I7(4, this.a, this.b);
}
}
class m extends Handler {
m() {
}
public void b(BluetoothDevice bluetoothDevice) {
MonitorService monitorService = MonitorService.this;
monitorService.p1.Y(monitorService.t4(bluetoothDevice, 2, "gatt ocsc"));
}
@Override
public void handleMessage(Message message) {
final BluetoothDevice bluetoothDevice = (BluetoothDevice) message.getData().getParcelable("android.bluetooth.device.extra.DEVICE");
MonitorService.this.w3(new Runnable() {
@Override
public final void run() {
MonitorService.m.this.b(bluetoothDevice);
}
}, "pingMatchingPairedBTDevices");
}
}
class n implements SyncStatusObserver {
n() {
}
@Override
public void onStatusChanged(int i) {
r7.f("M", "sync change " + i);
MonitorService.this.s7(true);
}
}
class o implements pp.a {
o() {
}
@Override
public void a() {
long currentTimeMillis = System.currentTimeMillis() - MonitorService.this.E;
long l4 = MonitorService.this.l4();
r7.f("M", "sm triggered checkPeriod " + l4 + "ms elapsedSinceLastCheckMS " + currentTimeMillis + "ms");
if (currentTimeMillis >= l4) {
r7.f("M", "past initial period, start check");
MonitorService.this.o5(false);
return;
}
long j = l4 - currentTimeMillis;
r7.f("M", "within initial period, set alarm for remaining " + j + "ms");
if (j >= 3000) {
MonitorService.this.w9(j, false);
} else {
r7.f("M", "< 3s remaining, check immediately");
MonitorService.this.o5(false);
}
}
}
class p implements LocationListener {
final String i;
p(String str) {
this.i = str;
}
@Override
public void onLocationChanged(Location location) {
double d;
float f;
float accuracy = location.getAccuracy();
double latitude = location.getLatitude();
double longitude = location.getLongitude();
r7.f("M", "FIX: " + this.i + " A:" + ((int) accuracy));
for (Map.Entry entry : MonitorService.this.S0.entrySet()) {
Integer num = (Integer) entry.getKey();
int intValue = num.intValue();
q7 q7Var = (q7) entry.getValue();
Location location2 = (Location) MonitorService.P1.get(num);
if (location2 != null && latitude == location2.getLatitude() && longitude == location2.getLongitude() && accuracy == location2.getAccuracy()) {
f = accuracy;
d = latitude;
} else {
d = latitude;
f = accuracy;
if (q7Var.X0(latitude, longitude, accuracy, this.i, q7.o1(MonitorService.this.x0, "gps"))) {
HashSet hashSet = new HashSet();
hashSet.add(num);
MonitorService.this.P4(hashSet, null, "locationChanged");
MonitorService.P1.put(num, location);
MonitorService.this.q8(intValue, location);
MonitorService.this.a9(intValue, q7Var, "locListener");
}
}
accuracy = f;
latitude = d;
}
long currentTimeMillis = System.currentTimeMillis();
if (!this.i.equals("gps")) {
MonitorService.this.I9("network");
q7.C1(MonitorService.this, location);
kq.r(MonitorService.this);
return;
}
kq.K1(System.currentTimeMillis() - location.getTime());
location.setTime(currentTimeMillis);
if (q7.V0(MonitorService.this.F, location)) {
MonitorService.this.H++;
if (MonitorService.this.H > 1) {
MonitorService.this.I9("gps");
if (MonitorService.n2 && MonitorService.this.s[1]) {
MonitorService.this.m8(1);
}
}
} else {
MonitorService.this.H = 0;
}
MonitorService.this.F = location;
q7.B1(MonitorService.this, location);
kq.q(MonitorService.this);
}
@Override
public void onProviderDisabled(String str) {
}
@Override
public void onProviderEnabled(String str) {
}
@Override
public void onStatusChanged(String str, int i, Bundle bundle) {
}
}
class q implements SensorEventListener {
float i = Float.MAX_VALUE;
float q = Float.MAX_VALUE;
float r = Float.MAX_VALUE;
private long s = 0;
q() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (MonitorService.this.M2(sensorEvent, 2, 3)) {
float[] fArr = sensorEvent.values;
float f = fArr[0];
float f2 = fArr[1];
float f3 = fArr[2];
long j = sensorEvent.timestamp;
long j2 = this.s;
float f4 = j - j2;
float f5 = ((f - this.i) / f4) * 1.0E7f;
float f6 = ((f2 - this.q) / f4) * 1.0E7f;
float f7 = ((f3 - this.r) / f4) * 1.0E7f;
if (j2 != 0) {
for (e0 e0Var : MonitorService.this.U0.values()) {
if (e0Var.c() && e0Var.b(f5, f6, f7, sensorEvent.timestamp, this.s)) {
MonitorService.this.H5("net.dinglisch.android.tasker.SHAKUM", e0Var.c);
}
}
}
this.i = f;
this.q = f2;
this.r = f3;
this.s = sensorEvent.timestamp;
}
}
}
class r implements SensorEventListener {
private long i = -1;
private int q = -1;
private long r = 0;
r() {
}
public void b(SensorEvent sensorEvent) {
int i;
if (MonitorService.this.M2(sensorEvent, 1, 3)) {
float[] fArr = sensorEvent.values;
float f = fArr[0];
float f2 = fArr[1];
float f3 = fArr[2];
if (sensorEvent.timestamp - this.r >= MonitorService.this.r0) {
long currentTimeMillis = System.currentTimeMillis();
try {
if (MonitorService.this.x5(120) && currentTimeMillis - this.i > 500) {
int W3 = MonitorService.this.W3(f, f2, f3, r10.A0.getInt("oss", 0));
r7.f("M", String.valueOf(f) + "," + f2 + "," + f + " ori: " + W3 + " last ori: " + this.q);
if (W3 == this.q) {
boolean z5 = MonitorService.this.z5(19);
if (z5) {
Integer E3 = dq.E3(MonitorService.this.k4(19, 0));
if (E3 == null) {
r7.G("M", "bad recorded state");
i = -2;
} else {
i = E3.intValue();
}
} else {
i = -1;
}
if (!z5 || (i != -2 && W3 != i)) {
r7.f("M", "record ori: " + W3);
MonitorService.this.E7(19, W3, true, true);
}
} else {
this.q = W3;
}
this.i = currentTimeMillis;
}
} catch (Exception e) {
r7.H("M", "onSensorChanged (ori)", e);
}
try {
if (MonitorService.this.T0.size() > 0) {
boolean z = false;
for (a0 a0Var : MonitorService.this.T0.values()) {
if (a0Var.c()) {
if (a0Var.a(f, f2, f3, sensorEvent.timestamp)) {
MonitorService.this.H5("net.dinglisch.android.tasker.GESTRUM", a0Var.d);
} else if (a0Var.b() != 0) {
z = true;
}
}
}
if (z) {
if (MonitorService.this.r0 != 20000000) {
MonitorService.this.t0.unregisterListener(this);
if (MonitorService.this.t0.registerListener(this, MonitorService.this.p0[1], 2)) {
MonitorService.this.r0 = 20000000L;
} else {
MonitorService.this.O8(0, false);
r7.k("M", "failed to re-register with sensor manager (UI rate)");
}
}
} else if (MonitorService.this.r0 != MonitorService.this.q0) {
MonitorService.this.t0.unregisterListener(this);
if (MonitorService.this.t0.registerListener(this, MonitorService.this.p0[1], 3)) {
MonitorService monitorService = MonitorService.this;
monitorService.r0 = monitorService.q0;
} else {
MonitorService.this.O8(0, false);
r7.k("M", "failed to re-register with sensor manager (initial rate)");
}
}
}
} catch (Exception e2) {
r7.H("M", "onSensorChanged (gesture)", e2);
}
this.r = sensorEvent.timestamp;
}
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(final SensorEvent sensorEvent) {
MonitorService.this.p1.s(new Runnable() {
@Override
public final void run() {
MonitorService.r.this.b(sensorEvent);
}
});
}
}
class s implements SensorEventListener {
s() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (MonitorService.this.M2(sensorEvent, 3, 1)) {
try {
Sensor sensor = sensorEvent.sensor;
r7.f("M", "prox: level: " + sensorEvent.values[0] + " acc " + sensorEvent.accuracy + " max: " + (sensor != null ? sensor.getMaximumRange() : -1.0f));
if (MonitorService.this.s0 == null) {
r7.f("M", "ignore, prox buffer null");
return;
}
Message obtainMessage = MonitorService.this.s0.obtainMessage(0, (int) sensorEvent.values[0], sensorEvent.accuracy);
MonitorService.this.s0.removeMessages(0);
MonitorService.this.s0.sendMessageDelayed(obtainMessage, 150L);
} catch (Exception e) {
r7.H("M", "onSensorChanged (prox)", e);
}
}
}
}
class t implements SensorEventListener {
private float i = -1.0f;
t() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
int i = 0;
float f = sensorEvent.values[0];
float f2 = this.i;
long j = (long) (f2 == -1.0f ? 1.0f : f - f2);
r7.f("M", "step " + f + " last " + this.i + " elapsed " + j);
int i2 = 309;
List<Integer> list = MonitorService.this.V0.get(309);
if (list == null) {
return;
}
for (Integer num : list) {
wo c = MonitorService.this.B0.c(num.intValue());
if (c != null && c.h1() && c.t0() == c.I0() - 1) {
int O0 = c.O0(3);
k2 k2Var = (k2) c.T0(7);
int v = k2Var.x(i).v();
r7.f("M", "step: pid " + num + ": steps wanted: " + v + " pcount " + O0);
if (j > 0) {
long j2 = j;
while (true) {
O0++;
j2--;
if (v == 0 || O0 % v == 0) {
k2 k2Var2 = new k2(i2);
k2Var2.x1(i, O0);
k2Var.M0(true);
if (MonitorService.this.w2(c, k2Var2, null)) {
MonitorService.g2.put(num, Long.valueOf(System.currentTimeMillis()));
}
k2Var.s0();
r7.f("M", "step event " + O0);
}
if (j2 <= 0) {
break;
}
i = 0;
i2 = 309;
}
c.I1(3, O0);
}
}
i = 0;
i2 = 309;
}
this.i = f;
}
}
class u implements SensorEventListener {
u() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (MonitorService.this.M2(sensorEvent, 4, 1)) {
MonitorService.this.p1.q1(sensorEvent);
}
}
}
class v implements SensorEventListener {
v() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - MonitorService.this.i1 > 5000) {
if (MonitorService.this.M2(sensorEvent, 6, 1)) {
try {
float f = sensorEvent.values[0];
if (MonitorService.this.x5(180)) {
MonitorService.this.D7(35, (int) f, true);
}
kq.S1(MonitorService.this, 85, String.valueOf(f));
} catch (Exception e) {
r7.H("M", "onSensorChanged (temp)", e);
}
}
MonitorService.this.i1 = currentTimeMillis;
}
}
}
class w implements SensorEventListener {
w() {
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - MonitorService.this.j1 > 500) {
int i = sensorEvent.accuracy;
int i2 = -1;
if (i != -1) {
if (i == 0) {
i2 = -2;
} else {
if (MonitorService.this.M2(sensorEvent, 7, 1)) {
try {
i2 = (int) sensorEvent.values[0];
} catch (Exception e) {
r7.H("M", "onSensorChanged (" + MonitorService.F1[7] + ")", e);
}
}
i2 = -3;
}
}
r7.f("M", "record level: " + i2);
if (MonitorService.this.x5(182)) {
MonitorService.this.D7(45, i2, true);
}
kq.S1(MonitorService.this, 40, String.valueOf(i2));
MonitorService.this.j1 = currentTimeMillis;
}
}
}
private static class x extends Handler {
WeakReference<MonitorService> a;
int b;
x(MonitorService monitorService, int i) {
this.a = new WeakReference<>(monitorService);
this.b = i;
}
@Override
public void handleMessage(Message message) {
MonitorService monitorService = this.a.get();
try {
r7.f("M", "received calendar observer update: " + bh.k(this.b));
monitorService.u4(this.b);
zq.k(monitorService.getApplicationContext(), bh.L(this.b));
} catch (NullPointerException e) {
r7.l("M", "calobserver", e);
}
}
}
static class y extends Handler {
WeakReference<MonitorService> a;
y(MonitorService monitorService) {
this.a = new WeakReference<>(monitorService);
}
public static void b(MonitorService monitorService) {
try {
monitorService.x7(true);
monitorService.z7(true);
zq.k(monitorService.getApplicationContext(), "CallLogObserver");
} catch (NullPointerException e) {
r7.l("M", "callLogObserver", e);
}
}
@Override
public void handleMessage(Message message) {
final MonitorService monitorService = this.a.get();
monitorService.s3(new Runnable() {
@Override
public final void run() {
MonitorService.y.b(MonitorService.this);
}
}, "CallLogHandler");
}
}
public interface z {
void a(int i, int i2, boolean z, boolean z2);
void b(int i, boolean z, boolean z2, boolean z3);
}
static {
String[] strArr = {"APP", "LOC-GPS", "LOC-NET", "WIFI-CHECK", "USER-ABSENT-WAKE", "WIFI-ENABLE", "GPS-TIMEOUT", "WIFI-TIMEOUT", "USER-ABSENT-WAKE-FINAL", "LOC-CELL", "PQ", "BT", "BT-ENABLE", "BT-TIMEOUT"};
w1 = strArr;
x1 = new long[strArr.length];
String[] strArr2 = {"ACC", "LOC-GPS", "LOC-NET", "WIFI", "TIME", "APP", "CAL", "FOBS", "MBUT", "CLOG", "PSTATE", "ACCESS", "PROX", "LIGHT", "SMS", "SHAKE", "PRESSURE", "MAGNET", "CLIP", "TEMP", "BT", "HUMIDITY", "STEPC", "SYNC", "HEART", "CUSTOM-SETTINGS", "ACCESSIBILITY_SERVICES"};
y1 = strArr2;
z1 = strArr2.length;
Boolean bool = Boolean.FALSE;
T1 = bool;
U1 = 0L;
V1 = new ConcurrentHashMap();
W1 = new HashMap();
Z1 = bool;
a2 = new ConcurrentHashMap();
b2 = new HashMap();
c2 = new String[51][];
d2 = null;
e2 = null;
f2 = false;
g2 = new ConcurrentHashMap();
l2 = new LinkedList<>();
m2 = true;
n2 = true;
o2 = false;
}
public MonitorService() {
int i3 = z1;
this.s = new boolean[i3];
this.t = new boolean[i3];
this.u = new ArrayList();
this.v = null;
this.w = -2L;
this.x = -2L;
this.B = "";
this.C = "";
this.D = null;
this.F = null;
this.H = 0;
this.I = 0L;
this.J = 0L;
this.K = null;
this.L = null;
this.M = null;
this.N = null;
this.O = null;
this.P = false;
this.Q = null;
this.R = false;
this.S = false;
this.V = false;
this.W = null;
this.X = 0;
this.Y = null;
this.Z = 0;
this.c0 = null;
this.d0 = 0;
this.e0 = null;
this.f0 = null;
this.i0 = 0;
this.j0 = null;
this.k0 = new int[]{5, 1, 2, 3, 20};
this.m0 = new boolean[A1.length];
this.n0 = new bh[bh.D()];
this.o0 = new SensorEventListener[10];
this.p0 = new Sensor[10];
this.q0 = -1L;
this.s0 = null;
this.t0 = null;
this.u0 = null;
this.v0 = null;
this.w0 = null;
this.x0 = null;
this.y0 = null;
this.B0 = null;
this.C0 = null;
this.D0 = null;
this.E0 = 0L;
this.F0 = new Object();
this.G0 = null;
this.I0 = new PendingIntent[bh.D()];
this.J0 = new Object();
this.K0 = new long[bh.D()];
this.L0 = null;
this.M0 = new Object();
this.d1 = null;
this.e1 = new Object();
this.f1 = null;
this.h1 = false;
this.i1 = 0L;
this.j1 = 0L;
this.k1 = 0L;
this.l1 = 0L;
this.m1 = 0L;
this.n1 = new rg.q(this);
this.o1 = new AccessibilitySettingObservable(this);
this.p1 = new HelperMonitorService(this);
this.r1 = new Object();
this.s1 = new Object();
}
private boolean A2(String str) {
boolean z2 = false;
for (Map.Entry<Integer, g1> entry : this.R0.entrySet()) {
g1 value = entry.getValue();
if (value.V0(this, str, this.D)) {
a9(entry.getKey().intValue(), value, "checkMatchApp");
z2 = true;
}
}
return z2;
}
private void A3(boolean z2) {
if (x5(105)) {
th.R(this, WebSearchHandler.class.getName(), !z2 && u5(105) && R6(8));
}
}
private void A4(Bundle bundle, boolean z2) {
int i3 = bundle.getInt("state", -1);
int i4 = bundle.getInt("microphone");
r7.f("M", "HEADSET: state: " + i3 + " mic: " + i4);
if (i3 == 0) {
J7(3, false, z2);
J7(2, false, z2);
} else if (i4 == 1) {
J7(3, true, z2);
} else {
J7(2, true, z2);
}
}
private void A5(boolean z2) {
if (dq.z(this, "android.permission.BODY_SENSORS", "MheartRateStartStop")) {
q9(7, z2, 3, new w());
}
}
public void A6() {
if (this.f0 == null) {
this.f0 = new f();
}
}
private void A7(boolean z2) {
boolean z3;
if (yd.i0.b()) {
z3 = yd.i0.h(yd.i0.c(getApplicationContext()));
} else {
r7.k("M", "recordPowerSaveState: no API");
z3 = false;
}
J7(43, z3, z2);
}
public static void A8(Context context, int i3, String str, String str2, String str3) {
Intent intent = new Intent("net.dinglisch.android.tasker.SMSUM");
intent.setPackage(context.getPackageName());
intent.putExtra("num", str).putExtra("bdy", str2).putExtra("mmsbdy", str3).putExtra("acct", i3);
context.sendBroadcast(intent);
}
private void A9() {
boolean z2;
if (this.y0.getWifiState() == 3 || g2(this.y0)) {
if (!this.y0.pingSupplicant()) {
r7.f("M", "startWifiScan II: supplicant not responding, continuing anyway");
}
try {
z2 = this.y0.startScan();
} catch (Exception e3) {
r7.H("M", "swfsp2: start scan", e3);
z2 = false;
}
if (z2) {
this.Z = 2;
this.a0 = System.currentTimeMillis();
this.b0 = -1L;
r7.f("M", "started scan at " + this.a0);
u9(7);
} else {
r7.f("M", "wifi reports failed to start scan");
}
} else {
r7.f("M", "start wifi scan II: wifi not enabled and Always Scan not available");
}
if (this.Z != 2) {
O9(true);
}
}
private void B2(int i3) {
if (this.x0 != null) {
for (Map.Entry<Integer, Location> entry : P1.entrySet()) {
Location value = entry.getValue();
Integer key = entry.getKey();
int intValue = key.intValue();
if (i3 == -1 || i3 == intValue) {
q7 q7Var = this.S0.get(key);
if (q7Var.X0(value.getLatitude(), value.getLongitude(), value.getAccuracy(), value.getProvider(), q7.o1(this.x0, "gps"))) {
a9(intValue, q7Var, "checkMatchLocs");
}
}
}
}
}
private List<tn> B3(Set<Integer> set, List<wo> list, long j3) {
ArrayList arrayList;
synchronized (this.s1) {
try {
Iterator<Integer> it = set.iterator();
ArrayList arrayList2 = new ArrayList();
while (it.hasNext()) {
wo c3 = this.B0.c(it.next().intValue());
if (f2(c3)) {
arrayList2.add(c3);
}
}
arrayList = new ArrayList();
Collections.sort(arrayList2, new k());
for (int i3 = 0; i3 < arrayList2.size(); i3++) {
wo woVar = (wo) arrayList2.get(i3);
boolean z2 = list != null && g7(woVar, list);
if (!z2) {
g2.put(Integer.valueOf(woVar.C0()), Long.valueOf(j3));
}
this.Y0.add(woVar);
if (!z2) {
r7.f("M", "profile -> active: " + woVar.H0());
RunLog.K0(this, this.A0, wo.a.Active, woVar);
b9(woVar, false, "enlist");
int Q0 = woVar.Q0(0);
if (Q0 != -1) {
tn R = this.B0.R(Q0);
if (R == null) {
r7.k("M", "enlistActiveProfiles: bad enter task ID " + Q0);
} else {
tn r0 = R.r0();
r0.D2(woVar.L0());
if (woVar.q1()) {
s8(this.B0.R(Q0));
}
if (woVar.s0()) {
r0.z2(woVar.C0());
}
r0.I(woVar.F0());
r0.B2(woVar.k1("enter"));
arrayList.add(r0);
}
}
if (!woVar.c1(1) && woVar.f0()) {
this.B0.q4(false);
v3(woVar);
}
}
}
} catch (Throwable th2) {
throw th2;
}
}
return arrayList;
}
private void B4(boolean z2) {
int i3 = getResources().getConfiguration().hardKeyboardHidden;
if (i3 == 2) {
J7(8, false, z2);
} else if (i3 == 1) {
J7(8, true, z2);
}
}
private void B5(boolean z2) {
q9(8, z2, 3, new a());
}
public void B6(List list) {
this.p1.S1(list);
}
private void B7() {
LinkedList linkedList = new LinkedList();
if (this.Y0 != null) {
Iterator it = new LinkedList(this.Y0).iterator();
while (it.hasNext()) {
wo woVar = (wo) it.next();
if (woVar != null && woVar.e1() && woVar.u() && !linkedList.contains(woVar.getName())) {
linkedList.add(woVar.getName());
}
}
}
try {
P9(66, linkedList);
} catch (StackOverflowError unused) {
r7.G("M", "recordProfilesActive: caught infinite recursion setting %PACTIVE");
}
try {
I7(28, linkedList, true);
} catch (StackOverflowError unused2) {
r7.G("M", "recordProfilesActive: caught infinite recursion recording active profiles");
}
}
public static void B8(Context context, boolean z2) {
Intent intent = new Intent(context, (Class<?>) MonitorService.class);
intent.putExtra("eventType", 9995);
intent.putExtra("sreamo", z2);
J6(context, intent);
}
public static void B9(Context context, Intent intent, int i3) {
C9(context, intent, i3, false);
}
private void C3(wo woVar, int i3, Bundle bundle) {
int Q0 = woVar.Q0(i3);
if (Q0 != -1) {
tn R = this.B0.R(Q0);
if (R != null) {
R.D2((i3 == 0 ? 1 : 0) + woVar.L0());
ExecuteService.d6(this, R, 0, -1, -1, woVar.s0() ? woVar.C0() : -1, null, null, woVar.k1("enter"), bundle);
} else {
r7.G("M", "exeTaskByType: bad task ID: " + Q0);
}
}
}
private void C5(boolean z2, int i3, int i4, int i5) {
if (z2 && this.p0[i3] == null) {
r7.f("M", "setup " + F1[i3] + " sensor");
this.p0[i3] = this.t0.getDefaultSensor(i4);
if (this.p0[i3] == null) {
if (this.s[C1[i3]]) {
if (i3 == 6 || i3 == 8) {
r7.f("M", "no temp sensor for temp or humidity var");
return;
} else {
dq.a0(this, 2131887856, vh.g(this, i5, new Object[0]).toLowerCase());
return;
}
}
return;
}
if (i4 == 1) {
if (this.q0 == -1) {
this.q0 = this.A0.getLong("acMSr", 300L) * 1000000;
return;
}
return;
}
if (i3 == 4 && x5(103)) {
h2 = N3("lmi", Float.MAX_VALUE);
i2 = N3("lma", Float.MIN_VALUE);
r7.f("M", "initialized light range to " + h2 + ConstantsCommonTaskerServer.ID_SEPARATOR + i2);
return;
}
if (i3 == 3 && x5(125)) {
j2 = N3("pmi", Float.MAX_VALUE);
k2 = N3("pma", Float.MIN_VALUE);
r7.f("M", "initialized prox range to " + j2 + ConstantsCommonTaskerServer.ID_SEPARATOR + k2);
}
}
}
public void C6(bh bhVar, int i3) {
if (bhVar.V()) {
return;
}
bhVar.S(new x(this, i3), this, new com.joaomgcd.taskerm.util.c() {
@Override
public final void a(Object obj) {
MonitorService.this.B6((List) obj);
}
}, this.B0.U2(2102));
}
private void C7() {
LinkedList linkedList = new LinkedList();
List<wo> M12 = this.B0.M1();
Collections.sort(M12, new h());
for (wo woVar : M12) {
if (woVar.u() && !linkedList.contains(woVar.getName())) {
linkedList.add(woVar.getName());
}
}
P9(67, linkedList);
}
public static void C8(Context context) {
Intent intent = new Intent("net.dinglisch.android.tasker.MSC");
intent.setPackage(context.getPackageName());
context.sendBroadcast(intent);
}
public static void C9(Context context, Intent intent, int i3, boolean z2) {
if (z2) {
com.joaomgcd.taskerm.util.f1.g(intent);
}
J6(context, I5(context, intent, i3));
}
private List<tn> D3(Set<Integer> set) {
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList(this.Y0);
int size = arrayList2.size();
for (int i3 = 0; i3 < size; i3++) {
wo woVar = (wo) arrayList2.get(i3);
int Q0 = woVar.Q0(0);
if (Q0 != -1) {
tn R = this.B0.R(Q0);
if (R == null) {
r7.k("M", "gacm: unknown task id " + Q0 + " in profile " + woVar.H0());
} else {
tn r0 = R.r0();
tn X12 = to.X1();
X12.D2(woVar.L0() + 2002);
for (net.dinglisch.android.taskerm.c cVar : r0.D0()) {
if (set.contains(Integer.valueOf(cVar.j()))) {
X12.a0(cVar);
}
}
arrayList.add(X12);
}
}
}
return arrayList;
}
private void D4(java.util.Set<java.lang.Integer> r6, java.util.List<net.dinglisch.android.taskerm.wo> r7, java.lang.String r8) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.D4(java.util.Set, java.util.List, java.lang.String):void");
}
private boolean D5() {
this.v0 = (AlarmManager) oi.d(this, "alarm", "M", "initManagers");
this.y0 = (WifiManager) oi.d(this, "wifi", "M", "initManagers");
if (this.v0 == null) {
r7.k("M", "no alarm manager, exiting");
return false;
}
ContentResolver contentResolver = getContentResolver();
this.w0 = contentResolver;
if (contentResolver == null) {
r7.G("M", "no content resolver, can't change system settings");
}
if (getPackageManager() != null) {
return true;
}
r7.k("M", "no package manager, exiting");
return false;
}
public void D6(boolean z2) {
for (final int i3 = 0; i3 < bh.D(); i3++) {
final bh bhVar = this.n0[i3];
if (bhVar != null) {
if (!z2) {
r7.f("M", "stopCal: " + bh.k(i3) + ": " + z2);
h2(i3);
bhVar.T();
} else {
if (!this.p1.f0(com.joaomgcd.taskerm.util.e5.u(this))) {
return;
}
r7.f("M", "startCal: " + bh.k(i3) + ": " + z2);
E8(i3);
try {
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.C6(bhVar, i3);
}
});
} catch (Throwable th2) {
r7.l("M", "stopCal: couldn't start updates", th2);
}
}
}
}
}
public void D7(int i3, int i4, boolean z2) {
H7(i3, Integer.toString(i4), z2, false);
}
public static void D8(Context context) {
J6(context, new Intent(context, (Class<?>) MonitorService.class).putExtra("eventType", 9983));
}
public static void D9(Context context, Intent intent, int i3) {
intent.setComponent(new ComponentName(context, MonitorService.class.getName()));
intent.putExtra("UserIntentPIDExtra", i3);
J6(context, intent);
}
private void E2(int i3, int[] iArr, boolean z2) {
HashSet hashSet = new HashSet();
if (i3 == -1) {
for (Integer num : this.W0.keySet()) {
if (!on.O(num.intValue())) {
hashSet.add(num);
}
}
} else if (on.O(i3)) {
r7.G("M", "checkMatchStates: ignoring plugin state " + i3);
} else {
hashSet.add(Integer.valueOf(i3));
}
if (iArr != null) {
for (int i4 : iArr) {
hashSet.remove(Integer.valueOf(i4));
}
}
F2(hashSet, z2);
}
public static int[] E3() {
int[] iArr;
LinkedList<Integer> linkedList = l2;
synchronized (linkedList) {
try {
int size = linkedList.size();
iArr = new int[size];
for (int i3 = 0; i3 < size; i3++) {
iArr[i3] = l2.get(i3).intValue();
}
} catch (Throwable th2) {
throw th2;
}
}
return iArr;
}
private void E5() {
R8(((PowerManager) oi.d(getApplicationContext(), "power", "M", "initSS")).isScreenOn());
n2 = y8(this) && !kh.d(this);
}
public void E6() {
r7.f("M", "Clipboard changed. Broadcasting variable change");
kq.F1(this, 20);
this.p1.T1(oe.c.m(this));
}
public void E7(int i3, int i4, boolean z2, boolean z3) {
H7(i3, Integer.toString(i4), z2, z3);
}
private void E8(int i3) {
if (com.joaomgcd.taskerm.util.e5.u(this).A()) {
h2(i3);
synchronized (this.J0) {
try {
bh bhVar = this.n0[i3];
if (bhVar == null) {
r7.k("M", "setCalendarAlarm: no calendar for " + bh.k(i3));
} else {
long C = bhVar.C(this);
if (C == -1) {
r7.f("M", "...no next time");
} else if (C == -2) {
dq.a0(this, 2131887899, new Object[0]);
} else {
F8(i3, C);
}
}
} catch (Throwable th2) {
throw th2;
}
}
}
}
private void E9(boolean z2) {
r9(0, z2, 3, new t(), true);
}
private void F2(java.util.Set<java.lang.Integer> r41, boolean r42) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.F2(java.util.Set, boolean):void");
}
private long F3() {
return this.A0.getLong("btpiod", 120L) * 1000;
}
private void F4() {
Log.d("M", "not starting, no config");
W7();
}
private void F5(boolean z2, boolean z3) {
long[] jArr = x1;
jArr[0] = this.A0.getLong("lperiod", 1500L);
jArr[1] = this.A0.getLong("guped", 120L) * 1000;
jArr[2] = this.A0.getLong("luped", 30L) * 1000;
jArr[3] = this.A0.getLong("wfpiod", 120L) * 1000;
jArr[4] = this.A0.getLong("sows", 60L) * 1000;
jArr[5] = 1000;
jArr[12] = 750;
jArr[11] = this.A0.getLong("btpiod", 120L) * 1000;
jArr[6] = this.A0.getLong("gupt", 90L) * 1000;
if (z2) {
jArr[7] = S3();
r7.f("M", "set initial wifi timeout to " + S3() + "ms (max)");
}
if (z3) {
jArr[13] = R3();
r7.f("M", "set initial BT timeout to " + R3() + "ms (max)");
}
jArr[8] = 2000;
jArr[9] = 2000;
jArr[10] = 200;
}
public void F6(int i3) {
J9(i3, "tidyUp");
}
private void F7(int i3, long j3, boolean z2) {
H7(i3, Long.toString(j3), z2, false);
}
private void F8(int i3, long j3) {
h2(i3);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(j3);
r7.f("M", "nextcal: " + bh.k(i3) + ": " + bh.r(calendar, true) + " " + bh.i(this, calendar));
long currentTimeMillis = j3 - System.currentTimeMillis();
if (currentTimeMillis < 0) {
r7.k("M", "bug: trying to set cal alarm in the past, diff " + currentTimeMillis);
this.K0[i3] = 0;
return;
}
Intent intent = new Intent(this, (Class<?>) ReceiverStaticInternal.class);
intent.setAction("net.dinglisch.android.tasker.CALARUM");
intent.putExtra("csrc", i3);
this.I0[i3] = PendingIntent.getBroadcast(this, i3, intent, com.joaomgcd.taskerm.util.k8.g(268435456, intent));
this.K0[i3] = j3;
O7(i3, "setCalendarAlarmAux");
}
private boolean F9() {
boolean z2;
synchronized (Q1) {
try {
z2 = this.Z != 0 || this.i0 != 0 || Q1.size() > 0 || this.P;
} finally {
}
}
return z2;
}
private void G2() {
for (Map.Entry<Integer, w1> entry : this.Q0.entrySet()) {
w1 value = entry.getValue();
if (value.V0()) {
a9(entry.getKey().intValue(), value, "checkMatchTDD");
}
}
for (Map.Entry<Integer, kp> entry2 : this.P0.entrySet()) {
kp value2 = entry2.getValue();
Integer key = entry2.getKey();
int intValue = key.intValue();
wo c3 = this.B0.c(intValue);
Bundle t2 = com.joaomgcd.taskerm.util.x2.t(this.B0, this, c3, null, "checkMatchTimesDays");
boolean W0 = value2.W0(this, t2);
if (value2.w1(this, t2)) {
if (c3 != null && c3.h1()) {
if (g2.containsKey(key) && System.currentTimeMillis() - g2.get(key).longValue() <= 60000) {
r7.f("M", "skip instant check, less than a minute since last");
} else if (w2(c3, null, null)) {
long H = bh.H(System.currentTimeMillis());
long currentTimeMillis = System.currentTimeMillis();
if (H > currentTimeMillis) {
r7.k("M", "startOfMinute " + H + " > curtime " + currentTimeMillis);
}
g2.put(key, Long.valueOf(H));
}
}
value2.s0();
} else if (W0) {
a9(intValue, value2, "checkMatchTDT");
}
}
}
private Bundle G3() {
Intent i1 = this.p1.i1(new IntentFilter("android.intent.action.BATTERY_CHANGED"));
if (i1 == null) {
return null;
}
return i1.getExtras();
}
private boolean G5(boolean z2) {
ig.a.a(this);
this.B0 = to.u1(this);
boolean z3 = false;
if (this.B0 != null) {
com.joaomgcd.taskerm.util.z6.j(this);
r7.f("M", "struct");
c3(z2);
r7.f("M", "scan data");
w8();
HelperMonitorService.F1(this.V0);
HelperMonitorService.G1(this.W0.keySet());
this.G = 0L;
f8();
r7.f("M", "done cals");
this.u0 = (ActivityManager) oi.d(this, "activity", "M", "init");
r7.f("M", "rescan vars");
i8(false);
b3();
r7.f("M", "recalc action set");
this.B0.q4(false);
r7.f("M", "receivers");
try {
k3(true);
this.p1.P0();
df.c.d(this.p1);
this.p1.M0();
dq.V2(this, false, "M.initialize");
X8();
this.p1.O1();
j3();
z3(false);
x3(false);
} catch (Exception e3) {
r7.k("M", "init: exception from component toggle: " + e3.toString());
}
r7.f("M", "loc setup");
try {
if (this.S0.size() > 0) {
LocationManager locationManager = (LocationManager) oi.d(this, "location", "M", "init");
this.x0 = locationManager;
if (locationManager == null) {
r7.k("M", vh.g(this, 2131887712, new Object[0]));
} else {
g8();
}
r7.f("M", "got locs");
}
} catch (Exception e4) {
r7.k("M", "init: exception from loc setup: " + e4.toString());
}
r7.f("M", "sensor");
N2();
r7.f("M", "pen var");
C7();
z3 = true;
} else {
r7.G("M", "not starting due to failed config read");
W7();
}
r7.f("M", "done init: " + z3);
return z3;
}
public void G6(Bundle bundle, vg.b bVar, vg.b bVar2, wo woVar, HashSet hashSet, pe.c cVar, b5 b5Var) {
if (cVar.H() == null) {
return;
}
vg.c G = cVar.G(this, b5Var, bundle);
if (bVar.a() && !bVar.c(G)) {
cVar.J(false);
cVar.M(this, woVar, b5Var);
} else {
if (bVar2.d(G)) {
cVar.J(false);
cVar.M(this, woVar, b5Var);
return;
}
if (!((ho) b5Var).G0()) {
bVar2.e(G);
}
hashSet.add(cVar.H());
cVar.J(true);
cVar.I(this, woVar, b5Var, bundle);
}
}
private void G8(long j3) {
i2();
r7.f("M", "set cooldown alarm for " + j3 + "ms");
Intent intent = new Intent(this, (Class<?>) ReceiverStaticInternal.class);
intent.setAction("net.dinglisch.android.tasker.COOLORUM");
this.G0 = PendingIntent.getBroadcast(this, 0, intent, com.joaomgcd.taskerm.util.k8.g(268435456, intent));
this.H0 = System.currentTimeMillis() + j3;
P7("set");
}
private void G9(boolean z2) {
r7.f("M", "stop BT scan");
K9(12);
K9(13);
this.i0 = 0;
if (j1.q()) {
j1.t(this);
}
if (z2) {
i3();
}
N9();
}
private void H2(to toVar, to toVar2) {
for (wo woVar : toVar2.q2(-2)) {
if (!woVar.h1()) {
v3(woVar);
}
}
}
private boolean H3(int i3) throws Settings.SettingNotFoundException {
int N0 = dq.N0(this.w0, i3);
if (N0 != -1) {
return N0 != 0;
}
throw new Settings.SettingNotFoundException("no setting for action code " + i3);
}
public void H5(String str, int i3) {
Intent intent = new Intent();
intent.putExtra("eventType", 9996);
intent.putExtra("eventAct", str);
intent.putExtra("eventConID", i3);
Q1(intent, -1, true);
}
public static long H6() {
long currentTimeMillis;
synchronized (T1) {
currentTimeMillis = System.currentTimeMillis() - U1;
r7.f("M", "lastWifiDisableAgoMS: " + currentTimeMillis);
}
return currentTimeMillis;
}
private void H7(int i3, String str, boolean z2, boolean z3) {
if (!z3) {
try {
if (z5(i3) && k4(i3, 0).equals(str)) {
return;
}
} catch (Throwable th2) {
r7.l("M", "recordState", th2);
return;
}
}
L7(i3, new String[]{str}, z2);
}
public static void H8(Context context, boolean z2) {
dq.S0(context).edit().putBoolean(ClockContract.AlarmsColumns.ENABLED, z2).commit();
}
private void H9() {
try {
stopForeground(true);
} catch (Exception e3) {
r7.f("M", "stopForeground: " + e3.getMessage());
}
}
private int I2(Bundle bundle, boolean z2) {
return J2(bundle, z2, false, false);
}
public static String I3() {
return L1;
}
private static Intent I5(Context context, Intent intent, int i3) {
Bundle bundle;
Intent intent2 = new Intent(context, (Class<?>) MonitorService.class);
intent2.putExtra("eventType", 9996);
String action = intent.getAction();
try {
bundle = intent.getExtras();
} catch (Throwable th2) {
r7.l("M", "Error getting system event intent extras", th2);
bundle = null;
}
if (bundle != null) {
intent2.putExtra("eventExt", bundle);
}
intent2.putExtra("eventAct", action);
String dataString = intent.getDataString();
if (dataString != null) {
intent2.putExtra("eventDt", dataString);
}
if (i3 != -1) {
intent2.putExtra("eventConID", i3);
}
if ("android.provider.Telephony.SMS_RECEIVED".equals(action) || "android.intent.action.DATA_SMS_RECEIVED".equals(action)) {
intent2.putExtra("eventOrigIntent", intent.toUri(1).toString());
}
return intent2;
}
private void I6(boolean z2) {
r9(4, z2, 3, new u(), true);
}
public void I7(int i3, Collection<?> collection, boolean z2) {
String[] strArr;
if (collection != null) {
strArr = new String[collection.size()];
int i4 = 0;
for (Object obj : collection) {
if (obj == null) {
obj = "";
}
strArr[i4] = obj.toString();
i4++;
}
} else {
strArr = null;
}
L7(i3, strArr, z2);
}
private void I8(boolean z2) {
if (Settings.R3(this, this.A0)) {
Notification Z9 = Z9(true, z2);
if (Z9 == null) {
r7.G("M", "setForegroundState: null notification");
return;
}
try {
com.joaomgcd.taskerm.util.p.p(this, Integer.MAX_VALUE, Z9);
} catch (IllegalArgumentException e3) {
r7.H("M", "startForeground: id 2147483647", e3);
}
}
}
public void I9(String str) {
if (this.x0 != null) {
synchronized (Q1) {
if (Q1.containsKey(str)) {
try {
this.x0.removeUpdates(Q1.get(str));
} catch (Exception e3) {
r7.k("M", "removing " + str + " listener: " + e3.toString());
}
Q1.remove(str);
}
}
}
if (str.equals("gps")) {
K9(6);
}
N9();
}
private int J2(Bundle bundle, boolean z2, boolean z3, boolean z4) {
if (bundle == null) {
bundle = G3();
}
int d22 = d2(bundle);
if (z3 && d22 <= 0) {
r7.f("M", "cps: plugged battery extras not updated yet. Setting to 1");
d22 = 1;
}
if (z4) {
r7.f("M", "cps: plugged came from disconnected event so set to 0");
d22 = 0;
}
r7.f("M", "cps: plugged: " + d22);
if (d22 == 1) {
J7(9, true, z2);
} else if (d22 == 2) {
J7(10, true, z2);
} else if (d22 == 4) {
J7(33, true, z2);
} else if (d22 > 0) {
J7(40, true, z2);
} else {
J7(40, false, z2);
J7(9, false, z2);
J7(10, false, z2);
J7(33, false, z2);
}
int s2 = dq.s(bundle);
D7(11, s2, z2);
D7(46, bundle.getInt("temperature", -1), z2);
return s2;
}
public static int J3() {
return K1;
}
private void J4(Bundle bundle, boolean z2) {
J7(48, !bundle.getBoolean("penInsert"), z2);
}
public static int J5(Object obj, Object obj2) {
return ((Long) obj2).compareTo((Long) obj);
}
public static void J6(Context context, Intent intent) {
pg.w0.z1(K6(context, intent), context);
}
public void J7(int i3, boolean z2, boolean z3) {
H7(i3, Boolean.toString(z2), z3, false);
}
public static void J8() {
synchronized (Z1) {
Z1 = Boolean.FALSE;
}
}
private void J9(int i3, String str) {
if (Q6(i3)) {
r7.f("M", y1[i3] + ": " + str + ": monitor stop");
switch (i3) {
case 0:
N1(false);
break;
case 1:
I9("gps");
K9(1);
break;
case 2:
K9(2);
I9("network");
break;
case 3:
K9(3);
O9(true);
break;
case 4:
l2();
break;
case 5:
K9(0);
break;
case ClockContract.InstancesColumns.MISSED_STATE:
i9(false);
break;
case 7:
l9(false);
this.X0.clear();
break;
case 8:
dq.r1(this, false, false);
break;
case 9:
j9(false);
break;
case 10:
p9(false);
break;
case 11:
MyAccessibilityService.s(0);
break;
case 12:
h7(false);
break;
case 13:
I6(false);
break;
case 14:
m9(false);
break;
case 15:
Z8(false);
break;
case 16:
b7(false);
break;
case 17:
O6(false);
break;
case 18:
k9(false);
break;
case 19:
Q9(false);
break;
case 20:
K9(11);
G9(true);
break;
case 21:
B5(false);
break;
case 22:
E9(false);
break;
case 23:
s9(false);
break;
case 24:
A5(false);
break;
case 25:
this.n1.e();
break;
case 26:
this.p1.J0();
break;
default:
r7.k("M", "bad monitor: " + i3);
break;
}
O8(i3, false);
}
}
private void K2(String str, Bundle bundle, List<k2> list) {
int i3 = 0;
while (true) {
String[] strArr = g6.l.a;
if (i3 >= strArr.length) {
return;
}
if (str.equals(strArr[i3])) {
k2 k2Var = new k2(447);
k2Var.x1(0, i3);
String str2 = g6.l.b[i3];
if (bundle.containsKey(str2)) {
k2Var.x1(1, bundle.getInt(str2));
} else {
r7.G("M", str + ": no extra: " + str2);
}
String str3 = g6.l.c[i3];
if (str3 != null && bundle.containsKey(str3)) {
ArrayList<String> stringArrayList = bundle.getStringArrayList(str3);
if (dq.F(stringArrayList)) {
r7.G("M", str + ": no extra " + str3);
} else {
StringBuilder sb = new StringBuilder();
Iterator<String> it = stringArrayList.iterator();
while (it.hasNext()) {
String next = it.next();
if (sb.length() > 0) {
sb.append("\n");
}
sb.append(next);
}
k2Var.k0(2, sb.toString());
}
}
list.add(k2Var);
return;
}
i3++;
}
}
private int K3() {
return this.A0.getInt("sbl", 0);
}
private void K4(Bundle bundle, boolean z2) {
J7(49, bundle.getBoolean("isShow"), true);
}
public void K5(BluetoothDevice bluetoothDevice, String str, int i3) {
long currentTimeMillis = System.currentTimeMillis();
int b3 = yd.g.d() ? yd.g.b(bluetoothDevice) : 1;
r7.f("M", str + ": result: " + bluetoothDevice.getName() + ", " + bluetoothDevice.getAddress() + " defaultType: " + i3 + " detectedType " + b3);
this.d0 = this.d0 + 1;
this.h0 = currentTimeMillis;
StringBuilder sb = new StringBuilder();
sb.append("got scan result after : ");
sb.append(currentTimeMillis - this.g0);
sb.append("ms");
r7.f("M", sb.toString());
String address = bluetoothDevice.getAddress();
if (a2.containsKey(address)) {
a2.get(address).u(currentTimeMillis);
} else {
i1 i1Var = new i1(bluetoothDevice, false);
if (b3 == 0) {
r7.f("M", "handleScanResult: correcting unknown device type to default " + i3);
i1Var.w(i3);
}
a2.put(address, i1Var);
}
D2(4, true);
if (b2(4, this.g0)) {
G9(true);
}
}
public static ji.b K6(final Context context, final Intent intent) {
return pg.w0.U(ExtensionsContextKt.Y1(context).h().getValue(), new Runnable() {
@Override
public final void run() {
MonitorService.T5(context, intent);
}
}).q(new oi.d() {
@Override
public final void accept(Object obj) {
r7.l("M", "Couldn't lockAndStartService", (Throwable) obj);
}
}).v();
}
public void K7(int i3, float[] fArr, boolean z2) {
String[] strArr = new String[fArr.length];
for (int i4 = 0; i4 < fArr.length; i4++) {
strArr[i4] = String.valueOf(fArr[i4]);
}
L7(i3, strArr, z2);
}
public static void K8(String str) {
synchronized (T1) {
r7.f("M", "setKeepWifiOn: " + str);
T1 = Boolean.FALSE;
}
}
private boolean K9(int i3) {
Handler handler = this.l0;
if (handler == null || !U9(i3)) {
return false;
}
r7.f("M", "stop timer: " + w1[i3]);
handler.removeMessages(i3);
return true;
}
private void L2(boolean z2) {
Cursor cursor;
r7.f("M", "update: " + z2 + " lastSeenTime: " + g4(this.w));
if (dq.z(this, "android.permission.READ_SMS", "McheckMS")) {
try {
cursor = this.w0.query(Uri.parse("content://sms/inbox"), new String[]{"date", "address", "body"}, "read=0", null, "_id");
} catch (Exception e3) {
r7.H("M", "query SMS inbox", e3);
cursor = null;
}
if (cursor == null) {
r7.G("M", "checkSMS: null cursor");
return;
}
while (cursor.moveToNext()) {
long j3 = cursor.getLong(0);
String string = cursor.getString(1);
String string2 = cursor.getString(2);
r7.f("M", "THIS STAMP: " + j3 + " THIS TIME: " + g4(j3));
if (j3 > this.w) {
this.w = j3;
if (z2 && dq.g() < 19) {
A8(this, 2, string, string2, null);
}
}
M7(2, string, string2, j3);
}
cursor.close();
}
}
private RemoteViews L3(String str, int i3, int i4) {
RemoteViews remoteViews = new RemoteViews(getPackageName(), dq.g() >= 16 ? 2131494245 : 2131494244);
remoteViews.setImageViewResource(2131296972, i4);
int i5 = u1[i3];
remoteViews.setTextColor(2131297638, i3 == 9 ? -16777216 : i5);
remoteViews.setTextColor(2131297000, i5);
remoteViews.setTextViewText(2131297638, th.s(this));
remoteViews.setTextViewText(2131297000, str);
remoteViews.setTextViewText(2131297630, DateFormat.getTimeFormat(this).format(bh.x().getTime()));
return remoteViews;
}
private void L6(String str) {
String str2 = "";
int i3 = 0;
for (int i4 = 0; i4 < z1; i4++) {
if (this.s[i4]) {
str2 = str2 + y1[i4] + " ";
}
}
if (str2.length() == 0) {
str2 = "none";
}
r7.f("M", str + ": needed monitors: " + str2);
StringBuilder sb = new StringBuilder();
sb.append("needed flags:");
while (true) {
String[] strArr = A1;
if (i3 >= strArr.length) {
r7.f("M", sb.toString());
r7.f("M", "needed pstate-types: " + this.T + " access-types: " + this.U);
return;
}
if (R6(i3)) {
sb.append(' ');
sb.append(strArr[i3]);
}
i3++;
}
}
private void L7(int i3, String[] strArr, boolean z2) {
c2[i3] = strArr;
if (z2) {
D2(v1[i3], z2);
}
}
public static void L8(String str) {
r7.f("M", "set lastCellID: " + str);
L1 = str;
}
private void L9() {
I9("gps");
I9("network");
if (this.Z != 0) {
O9(true);
}
if (this.i0 != 0) {
G9(true);
}
M9();
}
public boolean M2(SensorEvent sensorEvent, int i3, int i4) {
if (sensorEvent == null) {
r7.f("M", "sensor event: " + F1[i3] + ": null");
} else {
float[] fArr = sensorEvent.values;
if (fArr == null) {
r7.f("M", "sensor event: " + F1[i3] + ": null values");
} else {
if (fArr.length >= i4) {
return true;
}
r7.f("M", "sensor event: " + F1[i3] + ": vals = " + sensorEvent.values.length);
}
}
return false;
}
public static String M3(Context context) {
return Kid.b(context) ? to.u1(context).w(0).getIcon().getName() : "cust_notification";
}
private void M4(int i3, k2 k2Var, Bundle bundle) {
if (!this.B0.V(i3)) {
r7.G("M", "handlePluginEvent: unknown profile ID " + i3);
return;
}
wo c3 = this.B0.c(i3);
if (!c3.h1()) {
r7.f("M", "handlePluginEvent: profile disabled");
return;
}
k2Var.M0(true);
if (w2(c3, null, bundle)) {
g2.put(Integer.valueOf(i3), Long.valueOf(System.currentTimeMillis()));
}
k2Var.s0();
}
public void M6(Context context, String str, String str2, ho hoVar) {
r7.f("M", "received " + str + " from plugin " + str2 + " / " + hoVar.d(context));
}
private void M7(int i3, String str, String str2, long j3) {
if (x5(147)) {
try {
Calendar t2 = bh.t(j3);
String g3 = t2 != null ? bh.g(t2) : null;
if (g3 == null) {
g3 = Build.UNKNOWN;
}
r7.f("M", "record ms from " + str + " date " + g3 + " flags " + i3);
} catch (Exception e3) {
r7.H("M", "getDateString", e3);
}
this.y.add(str);
this.z.add(str2);
this.A.add(String.valueOf(i3));
}
}
private void M8(String str, String str2) {
this.B = str;
r7.f("M", "handleTimerApp set last new package accessibility from " + str2 + ": " + str);
}
public void M9() {
r7.f("M", "stop user-absent cell check");
c8();
this.P = false;
K9(9);
N9();
}
private void N1(boolean z2) {
r9(1, z2, 3, new r(), true);
}
private void N2() {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.N2():void");
}
private float N3(String str, float f3) {
return dq.S0(this).getFloat(str, f3);
}
public void M5(Intent intent) {
String stringExtra = intent.getStringExtra("title");
boolean z2 = false;
for (int i3 = 0; i3 < 10; i3++) {
if (D1[i3].equals(stringExtra)) {
T4(i3, stringExtra);
z2 = true;
}
}
if (z2) {
return;
}
if (stringExtra.equals("appcheckMethod")) {
Y9("handlePrefsIntent");
if (g1.s1(this)) {
N8(wp.a(this, 600000L), "handlePrefsIntent");
}
if (this.s[5]) {
f9(5);
return;
} else {
J9(5, "hpi");
return;
}
}
if (stringExtra.equals("mFn")) {
if (Settings.R3(this, this.A0)) {
I8(true);
return;
} else {
H9();
j2();
return;
}
}
if (!stringExtra.equals("lfdd")) {
F5(stringExtra.equals("wfpiod") || stringExtra.equals("wip") || stringExtra.equals("lfdd"), stringExtra.equals("btpiod") || stringExtra.equals("bttp") || stringExtra.equals("lfdd"));
return;
}
synchronized (this.M0) {
try {
if (this.L0 != null && !zq.j("Tasker.UserAbsentWakelock")) {
n2();
x9();
}
} finally {
}
}
}
public void N5(String str) {
r7.f("M", "handle time alarm: " + str);
G2();
P4(this.O0, null, "timeAlarm");
if (Q6(4)) {
o8(4, "handleTimeAlarm");
}
}
private void N6(Intent intent, Bundle bundle, String str) {
if (bundle != null) {
r7.f("M", "QUERY PLUGIN: " + str + " / " + intent.getAction() + " " + bundle.size() + " bundle keys");
} else {
r7.f("M", "QUERY EVENT PLUGIN: " + str + " / " + intent.getAction() + ": no extras");
}
ComponentName component = intent.getComponent();
if (component == null) {
r7.k("M", str + ": null component name");
return;
}
r7.f("M", str + ": plugin comp: " + component.getPackageName() + "/" + component.getClassName());
}
private void N7(final boolean z2, final long j3) {
final HashSet hashSet = new HashSet();
if (j3 > 0) {
this.p1.r(new Runnable() {
@Override
public final void run() {
MonitorService.this.q6(hashSet, z2, j3);
}
});
return;
}
if (J1) {
hashSet.add(8);
}
USBHandler.f(this, hashSet);
I7(4, hashSet, z2);
}
private void N8(String str, String str2) {
this.C = str;
r7.f("M", "handleTimerApp set last new package appusage from " + str2 + ": " + str);
}
private void N9() {
if (n2 || F9() || !K9(4)) {
return;
}
u9(8);
}
private void O1() {
if (zq.j("Sensor")) {
return;
}
zq.f(this, "Sensor", false, true);
}
private void O2(wo woVar) {
if (woVar.Z0(3)) {
q7 q7Var = (q7) woVar.T0(3);
if ((Q6(1) && q7Var.k1()) || (Q6(2) && q7Var.l1())) {
B2(woVar.C0());
}
}
if (woVar.Z0(1)) {
kp kpVar = (kp) woVar.T0(1);
if (kpVar.W0(this, com.joaomgcd.taskerm.util.x2.t(this.B0, this, woVar, null, "checkSingleProfileMatches"))) {
a9(woVar.C0(), kpVar, "checkSingeMatchTime");
}
}
if (woVar.Z0(2)) {
w1 w1Var = (w1) woVar.T0(2);
if (w1Var.V0()) {
a9(woVar.C0(), w1Var, "checkSingeMatchDate");
}
}
if (woVar.Z0(0) && Q6(5)) {
g1 g1Var = (g1) woVar.T0(0);
if (g1Var.V0(this, this.B, this.D)) {
a9(woVar.C0(), g1Var, "checkSingeMatchApp");
}
}
HashSet hashSet = new HashSet();
for (int i3 = 4; i3 <= 6; i3++) {
if (woVar.Z0(i3)) {
pn pnVar = (pn) woVar.T0(i3);
int j3 = pnVar.j();
if (j3 == 170 || j3 == 4 || j3 == 5) {
hashSet.add(Integer.valueOf(pnVar.j()));
} else if (on.O(j3)) {
q7(woVar, woVar.C0(), pnVar);
}
}
}
Iterator it = hashSet.iterator();
while (it.hasNext()) {
E2(((Integer) it.next()).intValue(), null, false);
}
}
private String O3(byte[] bArr) {
String str = null;
try {
Parcel obtain = Parcel.obtain();
obtain.unmarshall(bArr, 0, bArr.length);
obtain.setDataPosition(0);
for (int i3 = 0; i3 < 5; i3++) {
obtain.readInt();
}
obtain.readLong();
obtain.readInt();
str = obtain.readString();
obtain.recycle();
return str;
} catch (Exception e3) {
r7.k("M", "getLabelFromRawAlarm: " + e3.toString());
return str;
}
}
public void O4(Set<Integer> set, List<wo> list, Bundle bundle, String str, boolean z2) {
r7.f("M", "handleProfileChanges (" + str + ")");
long currentTimeMillis = System.currentTimeMillis();
d3(set);
HashSet hashSet = new HashSet();
LinkedList linkedList = new LinkedList();
List<tn> f3 = f3(this.B0, this.Y0, hashSet, false, linkedList);
if (z2) {
f3.addAll(e3(this.B0, this.p1.T0()));
}
List<tn> D3 = D3(hashSet);
List<tn> B3 = B3(set, list, currentTimeMillis);
tn f4 = f4(false);
if (f4 != null) {
r7.f("M", "RESTORE: " + f4.u1(this.z0));
if (linkedList.size() == 1) {
int intValue = linkedList.get(0).intValue();
if (this.B0.V(intValue) && this.B0.c(intValue).s0()) {
f4.z2(intValue);
}
}
D3.add(f4);
}
boolean z3 = false;
for (int i3 = 0; i3 < f3.size(); i3++) {
tn tnVar = f3.get(i3);
if (bundle != null) {
tnVar.I(null);
z3 = true;
}
D3.add(tnVar);
}
boolean z4 = false;
for (int i4 = 0; i4 < B3.size(); i4++) {
tn tnVar2 = B3.get(i4);
if (bundle != null) {
tnVar2.s((Bundle) bundle.clone());
z4 = true;
}
D3.add(tnVar2);
}
B7();
P6(D3, false, false);
Z9(false, true);
Y2();
D4(set, list, str + ":handleProfileChanges");
if (z4) {
Iterator<tn> it = B3.iterator();
while (it.hasNext()) {
it.next().I(null);
}
}
if (z3) {
Iterator<tn> it2 = f3.iterator();
while (it2.hasNext()) {
it2.next().I(null);
}
}
r7.f("M", "handleProfileChanges: done");
}
public void O5() {
if (e7(-1) && !U9(10)) {
zq.k(this, "M");
}
}
private void O6(boolean z2) {
q9(9, z2, 3, new c());
}
private void O7(int i3, String str) {
r7.f("M", "AC refresh cal: src " + i3 + " / " + str);
synchronized (this.J0) {
try {
if (this.I0[i3] != null) {
if (this.K0[i3] == 0) {
r7.f("M", "refresh next time: skipping, it's zero");
} else {
r7.f("M", "refresh cal alarm: " + bh.k(i3) + ": " + bh.m(this.K0[i3]) + " " + bh.h(this, this.K0[i3]));
kp.y1(this.v0, 0, this.K0[i3], this.I0[i3], kp.G1(this, y8(this)), "M/refreshCal");
}
}
} catch (Throwable th2) {
throw th2;
}
}
}
public void O8(int i3, boolean z2) {
this.t[i3] = z2;
}
public void O9(boolean z2) {
r7.f("M", "stop wifi scan");
K9(5);
K9(7);
this.Z = 0;
Y7();
if (z2) {
m3();
}
N9();
}
private void P2(int i3, String str, int i4, boolean z2) {
if (this.s[i3]) {
r7.f("M", "checkStartStop: " + y1[i3] + ": needMonitor: " + this.s[i3] + " want when off: " + aa(str, i4, z2) + " plugged: " + z2);
if (z2) {
if (Q6(i3) || aa(str, i4, true) <= 0) {
return;
}
f9(i3);
return;
}
if (Q6(i3) && aa(str, i4, false) == 0) {
J9(i3, "powerChange");
}
}
}
private LocationManager P3() {
LocationManager locationManager = this.x0;
if (locationManager == null) {
locationManager = (LocationManager) oi.d(this, "location", "M", "getLocalLocMan");
}
if (locationManager == null) {
r7.f("M", vh.g(this, 2131887712, new Object[0]));
}
return locationManager;
}
public void P4(Set<Integer> set, List<wo> list, String str) {
O4(set, list, null, str, false);
}
public void P5(String str, String str2) {
wl.J(this, str, str2);
}
private void P6(List<tn> list, boolean z2, boolean z3) {
Collections.sort(list, new tn.d());
for (int i3 = 0; i3 < list.size(); i3++) {
tn tnVar = list.get(i3);
tn r0 = tnVar.r0();
for (int c1 = r0.c1() - 1; c1 >= 0; c1--) {
int j3 = r0.A0(c1).j();
if (a1.g(j3)) {
int i4 = i3 + 1;
while (i4 < list.size()) {
tn tnVar2 = list.get(i4);
int i5 = 0;
while (true) {
if (i5 >= tnVar2.c1()) {
break;
}
net.dinglisch.android.taskerm.c A0 = tnVar2.A0(i5);
if (A0 != null && A0.j() == j3 && A0.L()) {
r0.s0(c1);
i4 = list.size();
break;
}
i5++;
}
i4++;
}
}
}
if (r0.c1() > 0 && !z3) {
ExecuteService.d6(this, r0, z2 ? 1 : 0, -1, -1, r0.Y0(), null, null, tnVar.H1() ? tnVar.i1() : null, tnVar.o() ? tnVar.m() : null);
}
}
}
private void P7(String str) {
r7.f("M", "AC refresh cooldown alarm: " + str);
PendingIntent pendingIntent = this.G0;
if (pendingIntent != null) {
kp.y1(this.v0, 0, this.H0, pendingIntent, kp.G1(this, y8(this)), "M/cooldown/" + str);
}
}
private static void P8(boolean z2) {
synchronized (Z1) {
Z1 = Boolean.valueOf(z2);
}
}
private void P9(int i3, Collection<String> collection) {
StringBuilder sb = new StringBuilder();
if (collection.size() > 0) {
sb.append(",");
}
Iterator<String> it = collection.iterator();
while (it.hasNext()) {
sb.append(it.next());
sb.append(",");
}
String sb2 = sb.toString();
if (kq.w0(this, kq.I0(i3)).equals(sb2)) {
return;
}
kq.S1(this, i3, sb2);
}
private void Q1(Intent intent, int i3, boolean z2) {
this.p1.E0(intent, i3, z2);
}
private void Q2(boolean z2) {
for (int i3 = 0; i3 < 10; i3++) {
P2(C1[i3], D1[i3], E1[i3], z2);
}
}
private void Q4(java.lang.String r11, int r12) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.Q4(java.lang.String, int):void");
}
public void Q5(String str, String str2) {
wl.K(this, str, str2, null);
}
private boolean Q6(int i3) {
return this.t[i3];
}
private void Q7(String str) {
synchronized (this.F0) {
try {
if (this.D0 != null) {
if (this.E0 == 0) {
r7.f("M", "refresh next time: skipping, it's zero");
} else {
r7.f("M", "refresh next time: " + bh.m(this.E0));
kp.y1(this.v0, 0, this.E0, this.D0, kp.G1(this, y8(this)), "M/refreshTime/" + str);
}
}
} catch (Throwable th2) {
throw th2;
}
}
}
private static void Q8(boolean z2, String str) {
synchronized (T1) {
r7.f("M", "setNeedDisable: " + str + " -> " + z2);
T1 = Boolean.valueOf(z2);
}
}
private void Q9(boolean z2) {
q9(6, z2, 3, new v());
}
private boolean R1(String str, boolean z2) {
if (str == null) {
return false;
}
Intent intent = new Intent();
intent.putExtra("eventType", 9997);
intent.putExtra("pkg", str);
Q1(intent, -1, z2);
return true;
}
public void R2() {
TelephonyManager telephonyManager;
if (!kq.e1(78) || (telephonyManager = (TelephonyManager) oi.d(this, "phone", "M", "checkTelChange")) == null) {
return;
}
String networkOperatorName = telephonyManager.getNetworkOperatorName();
if (networkOperatorName.equals(kq.A0(this, 78))) {
return;
}
kq.S1(this, 78, networkOperatorName);
}
private long R3() {
return Math.min(Math.min(l4() - 15000, F3() - 15000), 45000L);
}
public void R4(int i3, int i4, k2 k2Var, String str, Bundle bundle, boolean z2) {
switch (i3) {
case 16:
M6(this, "SATISFIED", str, k2Var);
Bundle o3 = ri.o(str, bundle);
if (o3 == null) {
o3 = new Bundle();
}
com.joaomgcd.taskerm.structuredoutput.c.a(o3, k2Var);
M4(i4, k2Var, o3);
break;
case 17:
M6(this, "UNSATISFIED", str, k2Var);
break;
case 18:
M6(this, "UNKNOWN", str, k2Var);
break;
default:
r7.k("M", "pid: " + i4 + ": unexpected plugin event result code " + i3 + " abort: " + z2 + " from " + str);
M6(this, "UNEXPECTED", str, k2Var);
r7.v("intentExtras", bundle);
break;
}
}
public static void R5() throws Exception {
}
private void R7(String str) {
Q7(str);
for (int i3 = 0; i3 < bh.D(); i3++) {
O7(i3, str);
}
}
private void R8(boolean z2) {
m2 = z2;
o2 = true;
}
private void R9() {
S9(false);
}
private void S2(String str, String[] strArr, int i3, List<k2> list) {
for (int i4 = 0; i4 < strArr.length; i4++) {
if (str.equals(strArr[i4])) {
k2 k2Var = new k2(i3);
k2Var.x1(0, i4);
list.add(k2Var);
return;
}
}
}
private long S3() {
return Math.min(Math.min(l4() - 15000, o4() - 15000), 20000L);
}
private k2 S4(int i3, String str, String str2, int i4, String str3) {
Calendar x2 = bh.x();
kq.S1(this, 79, str);
kq.S1(this, 82, bh.i(this, x2));
kq.S1(this, 84, bh.o(x2));
if (i3 == 2) {
kq.S1(this, 81, str2);
kq.C(this, 83);
} else {
kq.S1(this, 83, str2);
if (str3 != null) {
kq.S1(this, 81, str3);
} else {
kq.C(this, 81);
}
}
String r2 = TextUtils.isEmpty(str) ? null : eh.r(this, str, "display_name");
if (TextUtils.isEmpty(r2)) {
r2 = str;
}
kq.S1(this, 80, r2);
String b3 = new h.a.C0258a(this).b(i4);
k2 k2Var = new k2(7);
k2Var.x1(0, i3);
k2Var.k0(1, str);
k2Var.k0(2, str2);
k2Var.k0(3, b3);
k2Var.k0(4, str3);
return k2Var;
}
private boolean S6() {
return (this.T & 16) > 0 || T6();
}
private void S7(String str) {
synchronized (this.M0) {
try {
PendingIntent pendingIntent = this.L0;
if (pendingIntent != null) {
kp.y1(this.v0, 0, this.N0, pendingIntent, kp.G1(this, y8(this)), "M/userAbsentRefresh");
}
} catch (Throwable th2) {
throw th2;
}
}
}
public static void S8(Context context, String str) {
Intent intent = new Intent("net.dinglisch.android.tasker.ICOMUM");
intent.putExtra("title", str);
intent.setComponent(new ComponentName(context, MonitorService.class.getName()));
J6(context, intent);
}
private void S9(boolean z2) {
r7.f("M", "tidyup");
z3(true);
x3(true);
A3(true);
l3();
k3(false);
this.p1.Q0(false);
this.p1.N0(false);
r7.f("M", "rewrite rec");
dq.V2(this, true, "M.tidyUp");
h8();
b8();
a8();
Z7();
i2();
n2();
if (!o2 || !n2) {
r7.f("M", "user-absent activities");
L9();
}
this.j0 = null;
r7.f("M", "stop monitors");
for (final int i3 = 0; i3 < z1; i3++) {
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.F6(i3);
}
});
}
if (!z2) {
vg.j.b().B(this);
ze.h.b().B(this);
}
this.p1.V1(new String[0]);
r7.f("M", "unreg internal receivers");
List<ReceiverDynamic> c4 = c4();
if (c4 != null) {
Iterator<ReceiverDynamic> it = c4.iterator();
while (it.hasNext()) {
X9(it.next(), "dynamic");
}
c4.clear();
}
com.joaomgcd.taskerm.util.z6.m(this);
this.p1.X1();
df.c.g();
this.p1.A1();
this.c1.clear();
r7.f("M", "destroy cals");
h3();
this.V = false;
r7.f("M", "tidy up done");
}
private void T1(wo woVar, int i3) {
for (int i4 = 4; i4 <= 6; i4++) {
if (woVar.Z0(i4) && ((pn) woVar.T0(i4)).j() == i3) {
List<pn> list = this.Z0.get(Integer.valueOf(i3));
if (list == null) {
list = Collections.synchronizedList(new LinkedList());
this.Z0.put(Integer.valueOf(i3), list);
}
list.add((pn) woVar.T0(i4));
}
}
}
private boolean T2(String str) {
boolean z2;
Iterator<kp> it = this.P0.values().iterator();
while (true) {
if (!it.hasNext()) {
z2 = false;
break;
}
if (it.next().v1(str)) {
z2 = true;
break;
}
}
if (z2) {
Y4("varchange: " + str);
}
return z2;
}
private long T3() {
return this.A0.getLong("bttp", 15L) * 1000;
}
private void T4(int i3, String str) {
int i4 = E1[i3];
if (!y8(this)) {
P2(C1[i3], str, i4, o2());
}
if (aa(str, i4, false) == 2) {
O1();
} else {
X7();
}
}
public static void T5(Context context, Intent intent) {
int i3;
if (c2(context)) {
HelperMonitorService.y1(context);
} else {
HelperMonitorService.p1(context).y(new oi.a() {
@Override
public final void run() {
MonitorService.R5();
}
}, new oi.d() {
@Override
public final void accept(Object obj) {
r7.g("M", "Couldn't create tasker stopped notification on event", (Throwable) obj);
}
});
Bundle extras = intent.getExtras();
boolean z2 = false;
if (extras == null || !extras.containsKey("eventType")) {
i3 = -1;
} else {
i3 = extras.getInt("eventType");
if (i3 == 9995 || i3 == 9987) {
z2 = true;
}
}
if (!z2) {
String string = i3 == 9996 ? extras.getString("eventAct") : intent.getAction();
if (string == null) {
string = "?";
}
r7.f("M", "ignoring event when disabled: " + string);
return;
}
}
zq.e(context, "M");
synchronized (B1) {
try {
com.joaomgcd.taskerm.util.p.v(context, intent, ExtensionsContextKt.z0(context), true, true);
} catch (Exception e3) {
r7.l("M", "On start service", e3);
}
}
}
private boolean T6() {
return (this.T & 1024) > 0;
}
private void T7(int i3, k2 k2Var) {
int j3 = k2Var.j();
boolean Z0 = j2.b(j3) ? k2Var.Z0() : false;
int i4 = this.z0.getIntArray(RFactory.layout.multiple_select_dialog_item)[k2Var.l1()];
IntentFilter intentFilter = new IntentFilter();
for (String str : j2.H(k2Var)) {
if (str != null) {
intentFilter.addAction(str);
if (dq.g() >= 19 && str.equals("net.dinglisch.android.tasker.SMSUM") && dq.z(this, "android.permission.RECEIVE_SMS", "MregisterIntent")) {
intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
}
}
}
intentFilter.setPriority(i4);
String v2 = j2.v(j3);
if (v2 != null) {
intentFilter.addDataScheme(v2);
}
U7(intentFilter, Z0, i3);
}
private void T8() {
wo woVar;
l2();
synchronized (this.F0) {
try {
Calendar x2 = bh.x();
x2.add(1, 2);
Calendar x3 = bh.x();
to toVar = this.B0;
boolean z2 = false;
for (Integer num : this.O0) {
int intValue = num.intValue();
if (toVar != null) {
woVar = toVar.c(intValue);
if (woVar != null && !woVar.h1()) {
}
} else {
woVar = null;
}
Calendar h1 = kp.h1(this, x3, this.P0.get(num), 0, 0, com.joaomgcd.taskerm.util.x2.t(toVar, this, woVar, null, "setTimeAlarm"));
if (h1.getTimeInMillis() < x2.getTimeInMillis()) {
x2 = h1;
}
z2 = true;
}
if (z2) {
if (x2.getTimeInMillis() - System.currentTimeMillis() < 0) {
r7.f("M", "bug: trying to set alarm in the past " + x2.getTimeInMillis() + "/" + System.currentTimeMillis() + ", defaulting to 20 seconds in future");
x2 = bh.x();
x2.roll(13, 20);
}
Intent intent = new Intent(this, (Class<?>) ReceiverStaticInternal.class);
intent.setAction("net.dinglisch.android.tasker.ALARUM");
this.D0 = PendingIntent.getBroadcast(this, 0, intent, com.joaomgcd.taskerm.util.k8.g(268435456, intent));
this.E0 = x2.getTimeInMillis();
r7.f("M", "set next time: " + bh.r(x2, true) + " " + bh.i(this, x2));
Q7("setTimeAlarm");
} else {
r7.G("M", "no next time found");
}
} catch (Throwable th2) {
throw th2;
}
}
}
private boolean T9(int i3) {
boolean z2;
int b3;
synchronized (b2) {
try {
z2 = false;
for (i1 i1Var : b2.values()) {
if (i1Var.n() && (b3 = i1Var.b()) > i3) {
r7.f("M", i1Var.k() + ": timeout, age " + b3 + ">" + i3);
i1Var.D();
z2 = true;
}
}
} catch (Throwable th2) {
throw th2;
}
}
return z2;
}
private void U1() {
IntentFilter intentFilter = new IntentFilter();
if (kq.e1(60)) {
r7.f("M", "need monitor playing track");
if (th.J(getPackageManager(), "mobi.beyondpod")) {
r7.f("M", "add beyondpod listener");
intentFilter.addAction("mobi.beyondpod.action.PLAYBACK_STATUS");
}
if (th.J(getPackageManager(), "com.maxmpz.audioplayer")) {
r7.f("M", "add poweramp listener");
intentFilter.addAction("com.maxmpz.audioplayer.TRACK_CHANGED");
intentFilter.addAction("com.maxmpz.audioplayer.STATUS_CHANGED");
}
if (th.H(getPackageManager(), g6.j.a)) {
r7.f("M", "add phantom listener");
intentFilter.addAction(g6.j.b);
}
intentFilter.addAction("com.android.music.metachanged");
intentFilter.addAction("com.android.music.playstatechanged");
intentFilter.addAction("com.android.music.playbackcomplete");
}
if (kq.e1(39)) {
intentFilter.addAction("android.location.PROVIDERS_CHANGED");
}
if (kq.e1(90)) {
intentFilter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE);
intentFilter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE);
intentFilter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE);
intentFilter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE);
intentFilter.addAction("androidx.car.app.connection.action.CAR_CONNECTION_UPDATED");
}
if (kq.e1(63) && !this.c1.contains("net.dinglisch.android.tasker.NNORUM")) {
intentFilter.addAction("net.dinglisch.android.tasker.NNORUM");
}
if (((g1.r1(this) && R6(7)) || (MyAccessibilityService.a() && kq.e1(103))) && !this.c1.contains("net.dinglisch.android.tasker.NWINNY")) {
intentFilter.addAction("net.dinglisch.android.tasker.NWINNY");
}
if (kq.g1() && !this.c1.contains("net.dinglisch.android.tasker.SMSUM")) {
intentFilter.addAction("net.dinglisch.android.tasker.SMSUM");
if (dq.g() >= 19 && dq.z(this, "android.permission.RECEIVE_SMS", "MregisterIntent2")) {
intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
}
}
intentFilter.setPriority(999);
U7(intentFilter, false, -1);
}
private void U2() {
LinkedList<Integer> linkedList = l2;
synchronized (linkedList) {
linkedList.clear();
}
}
@TargetApi(24)
private int U3() {
TelephonyManager telephonyManager;
if (!this.p1.f0(com.joaomgcd.taskerm.util.e5.p0(this)) || (telephonyManager = (TelephonyManager) oi.d(this, "phone", "M", "gmnt")) == null) {
return 0;
}
int networkType = com.joaomgcd.taskerm.util.k.g() ? telephonyManager.getNetworkType() : telephonyManager.getDataNetworkType();
r7.f("M", "getMobileNetworkType type: " + networkType);
if (networkType == 0 || networkType == 1 || networkType == 2 || networkType == 4) {
return 1;
}
if (networkType != 13) {
switch (networkType) {
case 8:
case 9:
case 10:
break;
default:
r7.f("M", "unrecognized network type " + networkType + ". Defaulting to 3G.");
break;
}
return 0;
}
if (!com.joaomgcd.taskerm.util.k.k()) {
TelephonyDisplayInfo f3 = HelperMonitorService.F.f(this, this.p1.U0());
r7.f("M", "getMobileNetworkType telephonyDisplayInfo: " + f3);
if (com.joaomgcd.taskerm.util.x2.j3(f3)) {
return 5;
}
}
return 4;
}
private void U4(Intent intent) {
String str = this.v;
this.v = intent.getStringExtra("title");
if (Z3() != 0) {
Z9(false, true);
return;
}
r7.k("M", intent.getAction() + ": " + this.v + ": no ID");
this.v = str;
}
private boolean U6() {
for (int i3 = 0; i3 < 10; i3++) {
if (this.s[C1[i3]] && aa(D1[i3], E1[i3], false) == 2) {
return true;
}
}
return false;
}
private synchronized void U7(IntentFilter intentFilter, boolean z2, int i3) {
if (this.p1.L0(intentFilter, i3)) {
r7.f("M", "registerDynamic: not registering duplicate filter");
return;
}
ReceiverDynamic receiverDynamic = new ReceiverDynamic(z2, i3 == -1 ? null : this.B0.c(i3), intentFilter, i3);
try {
if (this.p1.s1(receiverDynamic, intentFilter) != null) {
receiverDynamic.c();
}
Iterator<String> actionsIterator = intentFilter.actionsIterator();
while (actionsIterator.hasNext()) {
String next = actionsIterator.next();
if (!this.c1.contains(next)) {
this.c1.add(next);
r7.f("M", "register receiver action: " + next);
}
}
c4().add(receiverDynamic);
} catch (SecurityException e3) {
r7.H("M", "registerDynamic", e3);
}
}
private void U8() {
Y9("setWifiEnableFlag");
boolean[] zArr = this.m0;
boolean[] copyOf = Arrays.copyOf(zArr, zArr.length);
W2("setWifiEnableFlag");
this.m0 = Arrays.copyOf(copyOf, copyOf.length);
}
public boolean U9(int i3) {
Handler handler = this.l0;
return handler != null && handler.hasMessages(i3);
}
private void V1(Notification.Builder builder) {
if (!Kid.a() && Settings.H2(this) && yd.f0.h()) {
String str = th.B() + ".ReceiverStaticInternal";
for (int i3 = 0; i3 < 3; i3++) {
String F12 = Settings.F1(this, i3);
if (!TextUtils.isEmpty(F12)) {
Intent intent = new Intent("net.dinglisch.android.tasker.MNUM");
intent.setClassName(getPackageName(), str);
intent.putExtra("type", 2);
intent.setData(Uri.parse("task://" + Uri.encode(F12)));
yd.f0.a(builder, 2131231046, F12, PendingIntent.getBroadcast(this, -1, intent, com.joaomgcd.taskerm.util.k8.g(134217728, intent)));
} else if (i3 == 0 && !sp.l0(this)) {
Intent intent2 = new Intent("net.dinglisch.android.tasker.MNUM");
intent2.setClassName(getPackageName(), str);
intent2.putExtra("type", 1);
yd.f0.a(builder, 2131231041, vh.g(this, 2131888819, new Object[0]), PendingIntent.getBroadcast(this, -1, intent2, com.joaomgcd.taskerm.util.k8.g(134217728, intent2)));
}
}
}
}
private void V2() {
synchronized (t1) {
M8("", "clearAppMonitorVars");
N8("", "clearAppMonitorVars");
}
}
private PendingIntent V3() {
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.setComponent(new ComponentName(getPackageName(), Tasker.class.getName()));
intent.addFlags(268435456);
return PendingIntent.getActivity(this, 0, intent, com.joaomgcd.taskerm.util.k8.g(0, intent));
}
private void V4(tn tnVar, Set<Integer> set) {
if (tnVar == null) {
r7.G("M", "handleSettingsDelist: null task");
return;
}
for (int i3 = 0; i3 < tnVar.c1(); i3++) {
int j3 = tnVar.A0(i3).j();
if (this.f1.containsKey(Integer.valueOf(j3))) {
this.f1.put(Integer.valueOf(j3), Integer.valueOf(this.f1.get(Integer.valueOf(j3)).intValue() - 1));
if (set != null) {
set.add(Integer.valueOf(j3));
}
}
}
}
public void V5() {
this.l0 = new f0(this);
}
private boolean V6(boolean z2) {
boolean[] zArr = this.s;
if (zArr[3] || zArr[1] || zArr[2] || zArr[20] || S6()) {
return true;
}
if (z2) {
return false;
}
boolean[] zArr2 = this.s;
if (!zArr2[4] && !zArr2[6]) {
return false;
}
r7.f("M", "need user-absent alarm to refresh time alarm");
return true;
}
private void V8() {
this.p1.H1();
this.p1.r(new Runnable() {
@Override
public final void run() {
MonitorService.this.A6();
}
});
}
private void V9() {
if (v5(307)) {
for (Integer num : this.V0.get(307)) {
wo c3 = this.B0.c(num.intValue());
if (c3.h1()) {
k2 k2Var = (k2) c3.T0(7);
k2Var.M0(true);
if (w2(c3, new k2(307), null)) {
g2.put(num, Long.valueOf(System.currentTimeMillis()));
}
k2Var.s0();
}
}
}
}
private void W1(String str) {
synchronized (O1) {
try {
long currentTimeMillis = System.currentTimeMillis();
ArrayList arrayList = new ArrayList();
for (Map.Entry<Long, String> entry : O1.entrySet()) {
Long key = entry.getKey();
long longValue = key.longValue();
if (entry.getValue().equals(str) || currentTimeMillis - longValue > 86400000) {
arrayList.add(key);
}
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
O1.remove((Long) it.next());
}
O1.put(Long.valueOf(System.currentTimeMillis()), str);
} catch (Throwable th2) {
throw th2;
}
}
}
private void W2(String str) {
r7.f("M", "clear flags (" + str + "): " + Thread.currentThread().getName());
Arrays.fill(this.s, false);
vg.j.b().z();
ze.h.b().z();
Iterator<Map.Entry<Integer, a0>> it = this.T0.entrySet().iterator();
while (it.hasNext()) {
it.next().getValue().e(false);
}
Iterator<Map.Entry<Integer, e0>> it2 = this.U0.entrySet().iterator();
while (it2.hasNext()) {
it2.next().getValue().e(false);
}
this.Z0.clear();
Arrays.fill(this.m0, false);
this.T = 0;
this.U = 0;
this.V = false;
}
public int W3(float f3, float f4, float f5, float f6) {
float f7 = (f6 / 1.7f) + 2.0f;
float abs = Math.abs(f3);
float abs2 = Math.abs(f4);
float abs3 = Math.abs(f5);
float f8 = abs / f7;
float f9 = abs2 / f7;
float f10 = abs3 / f7;
if (f3 + f4 < f5 && f5 > 0.0f && abs < f10 && abs2 < f10) {
return 0;
}
float f11 = 0.0f - f3;
if (f11 - f4 > f5 && f5 < 0.0f && abs < f10 && abs2 < f10) {
return 1;
}
if (f3 + f5 < f4 && f4 > 0.0f && abs < f9 && abs3 < f9) {
return 2;
}
if (f11 - f5 > f4 && f4 < 0.0f && abs < f9 && abs3 < f9) {
return 3;
}
if (f4 + f5 >= f3 || f3 <= 0.0f || abs2 >= f8 || abs3 >= f8) {
return (0.0f - f4) - f5 > f3 ? 5 : -1;
}
return 4;
}
public void W5() {
wl.W(this, null);
}
public static void W6(Context context, String str) {
if ("clock_alarm".equals(str)) {
return;
}
Intent intent = new Intent("net.dinglisch.android.tasker.PREFUM");
intent.putExtra("title", str);
intent.setComponent(new ComponentName(context, MonitorService.class.getName()));
J6(context, intent);
}
private void W7() {
final Runnable runnable = new Runnable() {
@Override
public final void run() {
MonitorService.this.s6();
}
};
this.p1.P(HelperMonitorService.p1(this), new xj.a() {
@Override
public final Object invoke() {
lj.e0 t6;
t6 = MonitorService.t6(runnable);
return t6;
}
}, new oi.d() {
@Override
public final void accept(Object obj) {
MonitorService.u6(runnable, (Throwable) obj);
}
});
}
private void W8() {
if (this.e0 == null) {
this.e0 = new g();
IntentFilter intentFilter = new IntentFilter("android.bluetooth.device.action.ACL_CONNECTED");
intentFilter.addAction("android.bluetooth.device.action.FOUND");
intentFilter.addAction("android.bluetooth.adapter.action.DISCOVERY_FINISHED");
intentFilter.addAction("android.bluetooth.adapter.action.DISCOVERY_STARTED");
intentFilter.setPriority(-999);
ExtensionsContextKt.W2(this, this.e0, intentFilter, null, this.p1.y().c());
}
}
private void W9(x1 x1Var) {
if (x1Var == null) {
return;
}
x1Var.a();
this.w0.unregisterContentObserver(x1Var);
}
private void X1() {
long j3;
long[] jArr = x1;
long j4 = jArr[13];
long T3 = T3();
long R3 = R3();
r7.f("M", "adjustBTTimeout: cur: " + j4 + "ms min: " + T3 + "ms max: " + R3 + "ms");
if (this.h0 == -1) {
r7.f("M", "didn't get scan result, add 2000ms");
j3 = 2;
} else {
long currentTimeMillis = System.currentTimeMillis() - this.h0;
if (currentTimeMillis > 300) {
long j5 = 0 - (currentTimeMillis / 4);
r7.f("M", "had result " + currentTimeMillis + "ms ago, adjust by " + j5 + "ms");
j3 = j5;
} else {
r7.f("M", "had result " + currentTimeMillis + "ms ago, close enough, no change");
j3 = 0L;
}
}
long j6 = jArr[13] + j3;
jArr[13] = j6;
if (j6 <= T3) {
jArr[13] = T3;
r7.f("M", "adjusted timeout to " + jArr[13] + "ms (min)");
return;
}
if (j6 <= R3) {
r7.f("M", "adjusted timeout to " + jArr[13] + "ms");
return;
}
jArr[13] = R3;
r7.f("M", "adjusted timeout to " + jArr[13] + "ms (max)");
}
private void X2(int i3) {
List<pn> list;
if (this.Z0.containsKey(Integer.valueOf(i3)) && (list = this.Z0.get(Integer.valueOf(i3))) != null) {
for (pn pnVar : new CopyOnWriteArrayList(list)) {
r7.f("M", "clear check time for code " + i3);
pnVar.r0();
}
}
}
public static hg.l1 X3(Context context, List<wo> list) {
if (list != null && list.size() > 0) {
if (p2 == null) {
p2 = new hg.l1("M", vh.g(context.getApplicationContext(), 2131890546, new Object[0]), "Main Tasker notification that shows status of active profiles and other info");
}
return p2;
}
if (q2 == null) {
q2 = new hg.l1("Mno", vh.g(context, 2131890546, new Object[0]) + " (" + vh.g(context, 2131889244, new Object[0]) + ")", "Main Tasker notification that shows status of active profiles and other info");
}
return q2;
}
public void X5() {
r7.f("M", "ICS workaround, repost service notification");
if (c2(this)) {
Z9(false, true);
}
}
private ji.b X6() {
HelperMonitorService helperMonitorService = this.p1;
return helperMonitorService.j(helperMonitorService.Y0(), new Runnable() {
@Override
public final void run() {
MonitorService.this.Z5();
}
});
}
private void X7() {
if (!zq.j("Sensor") || U6()) {
return;
}
zq.k(this, "Sensor");
}
private void X8() {
boolean z2;
Iterator<Map.Entry<Integer, List<Integer>>> it = this.W0.entrySet().iterator();
while (true) {
int i3 = 2;
int i4 = 6;
if (!it.hasNext()) {
break;
}
Map.Entry<Integer, List<Integer>> next = it.next();
List<Integer> value = next.getValue();
int intValue = next.getKey().intValue();
if (!on.O(intValue)) {
int i5 = 0;
while (i5 < value.size()) {
int intValue2 = value.get(i5).intValue();
String str = null;
int i6 = 0;
while (i6 < i3) {
String p3 = i6 == 0 ? on.p(this, intValue) : on.q(this, intValue);
if (p3 != null && (str == null || !p3.equals(str))) {
IntentFilter intentFilter = new IntentFilter();
"android.net.conn.CONNECTIVITY_CHANGE".equals(p3);
intentFilter.addAction(p3);
if (intValue == 105) {
wo c3 = this.B0.c(intValue2);
int i7 = 4;
while (i7 <= i4) {
if (c3.Z0(i7)) {
pn pnVar = (pn) c3.T0(i7);
if (pnVar.j() == 105 && pnVar.i(3).R()) {
z2 = true;
break;
}
}
i7++;
i4 = 6;
}
}
z2 = false;
U7(intentFilter, z2, intValue2);
if (intValue == 110) {
this.p1.t1();
}
str = p3;
}
i6++;
i3 = 2;
i4 = 6;
}
i5++;
i3 = 2;
i4 = 6;
}
}
}
HashSet hashSet = new HashSet();
HashSet hashSet2 = new HashSet();
Set<Integer> Q = j2.Q();
for (Map.Entry<Integer, List<Integer>> entry : this.V0.entrySet()) {
Integer key = entry.getKey();
int intValue3 = key.intValue();
if (intValue3 == 599) {
Iterator<Integer> it2 = entry.getValue().iterator();
while (it2.hasNext()) {
V7(it2.next().intValue(), new String[0]);
}
} else if (j2.c(intValue3) || intValue3 == 7) {
hashSet2.add(key);
List<Integer> value2 = entry.getValue();
for (int i8 = 0; i8 < value2.size(); i8++) {
int intValue4 = value2.get(i8).intValue();
T7(intValue4, (k2) this.B0.c(intValue4).T0(7));
}
} else {
hashSet.add(key);
}
}
IntentFilter intentFilter2 = new IntentFilter();
if (g1.r1(this) && this.B0.T2(0) && !hashSet2.contains(463)) {
intentFilter2.addAction("net.dinglisch.android.tasker.NWINNY");
}
if (!hashSet2.contains(1000)) {
intentFilter2.addAction("android.intent.action.USER_PRESENT");
}
if (!hashSet2.contains(413)) {
intentFilter2.addAction("android.intent.action.ACTION_SHUTDOWN");
}
if (!hashSet2.contains(210)) {
intentFilter2.addAction("android.intent.action.SCREEN_OFF");
}
if (!hashSet2.contains(208)) {
intentFilter2.addAction("android.intent.action.SCREEN_ON");
}
if (x5(40)) {
intentFilter2.addAction("android.intent.action.NEW_OUTGOING_CALL");
}
if (y5()) {
intentFilter2.addAction("android.bluetooth.headset.action.STATE_CHANGED");
intentFilter2.addAction("android.media.SCO_AUDIO_STATE_CHANGED");
intentFilter2.addAction("android.bluetooth.device.action.ACL_CONNECTED");
intentFilter2.addAction("android.bluetooth.device.action.ACL_DISCONNECTED");
intentFilter2.addAction("android.bluetooth.a2dp.action.SINK_STATE_CHANGED");
intentFilter2.addAction("android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED");
}
if (!intentFilter2.hasAction("android.bluetooth.device.action.ACL_CONNECTED") && (this.B0.q3(341) || TaskerAppWidgetConfigure.o(this, 341))) {
intentFilter2.addAction("android.bluetooth.device.action.ACL_CONNECTED");
intentFilter2.addAction("android.bluetooth.device.action.ACL_DISCONNECTED");
}
if ((this.C0.contains(3) || y5()) && !x5(2)) {
intentFilter2.addAction("android.bluetooth.adapter.action.STATE_CHANGED");
}
if (this.C0.contains(101)) {
intentFilter2.addAction("android.net.wifi.WIFI_STATE_CHANGED");
}
if (this.C0.contains(0)) {
intentFilter2.addAction("android.intent.action.AIRPLANE_MODE");
}
if (this.C0.contains(72)) {
intentFilter2.addAction("android.media.RINGER_MODE_CHANGED");
}
intentFilter2.addAction("android.net.conn.TETHER_STATE_CHANGED");
if ((this.C0.contains(46) || this.C0.contains(72)) && ji.n()) {
intentFilter2.addAction("net.dinglisch.android.tasker.NSI.ACTION_FILTER_CHANGED");
}
if (this.C0.contains(93) || this.C0.contains(94) || this.C0.contains(95) || this.C0.contains(96) || this.C0.contains(97) || this.C0.contains(98) || this.C0.contains(99)) {
intentFilter2.addAction("org.openintents.audio.action_volume_update");
intentFilter2.addAction("android.media.VOLUME_CHANGED_ACTION");
}
if (!this.C0.contains("android.intent.action.ACTION_POWER_CONNECTED")) {
intentFilter2.addAction("android.intent.action.ACTION_POWER_CONNECTED");
}
if (!this.C0.contains("android.intent.action.ACTION_POWER_DISCONNECTED")) {
intentFilter2.addAction("android.intent.action.ACTION_POWER_DISCONNECTED");
}
intentFilter2.setPriority(999);
if (intentFilter2.actionsIterator().hasNext()) {
U7(intentFilter2, false, -1);
}
if (!hashSet2.contains(453) && !hashSet2.contains(450)) {
IntentFilter intentFilter3 = new IntentFilter("android.intent.action.PACKAGE_ADDED");
intentFilter3.addDataScheme("package");
U7(intentFilter3, false, -1);
}
if (!hashSet2.contains(134)) {
T7(-1, new k2(134));
}
if (hashSet2.contains(216)) {
th.R(this, LongPressSearch.class.getName(), hashSet2.contains(216));
}
Q.add(6);
Iterator<Integer> it3 = kq.m0().iterator();
while (it3.hasNext()) {
if (kq.T0(it3.next().intValue()) && !hashSet2.contains(6)) {
hashSet.add(6);
}
}
for (Integer num : Q) {
y3(num.intValue(), hashSet.contains(num));
}
U1();
}
private final void Y1() {
double d3;
double d4;
if (a2.size() > 0) {
long l4 = l4();
long F3 = F3();
if (n2) {
d3 = l4;
d4 = F3;
} else {
double d5 = l4;
d3 = F3;
d4 = d5;
}
long currentTimeMillis = System.currentTimeMillis();
for (i1 i1Var : a2.values()) {
String a3 = i1Var.a();
long e3 = currentTimeMillis - i1Var.e();
double d6 = (float) (e3 / d3);
long j3 = currentTimeMillis - ((long) (d6 * d4));
r7.f("M", a3 + ": mult: " + d6 + " old: " + e3 + "ms new: " + (currentTimeMillis - j3) + "ms");
i1Var.u(j3);
}
}
}
private void Y2() {
LinkedList<Integer> linkedList = l2;
synchronized (linkedList) {
try {
linkedList.clear();
com.joaomgcd.taskerm.util.e eVar = this.Y0;
if (eVar == null) {
return;
}
ArrayList arrayList = new ArrayList(eVar);
int size = arrayList.size();
for (int i3 = 0; i3 < size; i3++) {
l2.add(Integer.valueOf(((wo) arrayList.get(i3)).C0()));
}
} catch (Throwable th2) {
throw th2;
}
}
}
private static hg.l1 Y3(MonitorService monitorService) {
return X3(monitorService, monitorService.Y0);
}
private void Y4(final String str) {
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.N5(str);
}
}, "handleTimeAlarm");
}
public void Y5() {
if (c2(this)) {
B9(this, new Intent("android.intent.action.BOOT_COMPLETED"), -1);
}
com.joaomgcd.taskerm.action.input.o.g(this);
}
private void Y7() {
WifiManager.WifiLock wifiLock = this.Y;
if (wifiLock != null) {
try {
wifiLock.release();
} catch (SecurityException e3) {
r7.H("M", "releaseWifiLock: " + e3.toString(), e3);
} catch (Throwable th2) {
r7.I("M", "releaseWifiLock Throwable: " + th2.toString(), th2);
}
this.Y = null;
}
}
private void Y8() {
if (this.W == null) {
e eVar = new e();
this.W = eVar;
ExtensionsContextKt.W2(this, eVar, new IntentFilter("android.net.wifi.SCAN_RESULTS"), null, this.p1.y().c());
}
}
private void Y9(java.lang.String r42) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.Y9(java.lang.String):void");
}
private final void Z1() {
double d3;
double d4;
if (W1.size() > 0) {
long l4 = l4();
long o4 = o4();
if (n2) {
d3 = l4;
d4 = o4;
} else {
double d5 = l4;
d3 = o4;
d4 = d5;
}
long currentTimeMillis = System.currentTimeMillis();
Iterator<Map.Entry<String, Long>> it = W1.entrySet().iterator();
while (it.hasNext()) {
W1.put(it.next().getKey(), Long.valueOf(currentTimeMillis - ((long) (((float) ((currentTimeMillis - r7.getValue().longValue()) / d3)) * d4))));
}
}
}
private void Z2(to toVar) {
for (Integer num : this.W0.keySet()) {
if (on.O(num.intValue())) {
Iterator<Integer> it = this.W0.get(num).iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (toVar.V(intValue)) {
wo c3 = toVar.c(intValue);
wo c4 = this.B0.c(intValue);
if (c4.d() == c3.d()) {
for (int i3 = 4; i3 <= 6; i3++) {
if (c4.Z0(i3) && c3.Z0(i3)) {
pn pnVar = (pn) c3.T0(i3);
pn pnVar2 = (pn) c4.T0(i3);
int j3 = pnVar.j();
int j4 = pnVar2.j();
if (on.O(j4) && j3 == j4) {
pnVar2.k1(pnVar);
if (c4.h1() && c3.h1()) {
pnVar2.M0(pnVar.G0());
pnVar2.j1(pnVar);
r7.f("M", "profile " + c4.H0() + "/stype " + i3 + ": take over " + pnVar.G0() + " activation from old data");
}
}
}
}
}
}
}
}
}
}
public void Z5() {
bi.b(this, "M");
HelperMonitorService.y1(this);
pg.d.j(new pf.o1());
com.joaomgcd.taskerm.util.u5.v(this, false);
Settings.p1(this.A0, dq.S0(this));
w6.e(getBaseContext());
this.z0 = getResources();
for (int i3 = 13; i3 <= 18; i3++) {
D7(i3, 0, false);
}
F5(true, true);
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.V5();
}
});
H1 = bh.I();
U2();
E5();
r7.f("M", "init");
if (D5() && G5(true)) {
Arrays.fill(this.t, false);
T9(5);
n8();
r7.f("M", "initial match checks");
u3();
r7.f("M", "initial match checks: done");
U8();
A3(false);
V9();
r7.f("M", "onCreate: handleProfileChanges");
O4(this.B0.n2(), null, null, "onAfterInit", true);
r7.f("M", "reshow overlay scenes");
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.W5();
}
});
r7.f("M", "created");
if (dq.O1()) {
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
MonitorService.this.X5();
}
}, 12000L);
}
}
r7.f("M", "------------------ MONITOR STARTUP COMPLETE -----------------");
if (com.joaomgcd.taskerm.util.u5.c(this)) {
r7.f("M", "------------------ BOOT COMPLETED IN MONITOR STARTUP -----------------");
this.p1.p(new Runnable() {
@Override
public final void run() {
MonitorService.this.Y5();
}
});
}
}
@SuppressLint({"MissingPermission"})
private int Z6() {
Set<BluetoothDevice> bondedDevices;
Object a3;
if (!this.p1.f0(com.joaomgcd.taskerm.util.e5.t(this)) || !this.Z0.containsKey(4) || (bondedDevices = j1.h(this).getBondedDevices()) == null) {
return 0;
}
int i3 = 0;
for (BluetoothDevice bluetoothDevice : bondedDevices) {
r7.f("M", "test device: " + bluetoothDevice.getName() + " / " + bluetoothDevice.getAddress());
List<pn> list = this.Z0.get(4);
if (list == null) {
return i3;
}
Iterator it = new CopyOnWriteArrayList(list).iterator();
while (true) {
if (!it.hasNext()) {
break;
}
if (((pn) it.next()).X0(this, bluetoothDevice)) {
r7.f("M", "device matches");
if (j1.p(getPackageManager()) && i1.C(bluetoothDevice.getType()) && yd.g.c() && R6(3)) {
Map<String, Object> map = this.c0;
if (map == null || !map.containsKey(bluetoothDevice.getAddress())) {
Object i4 = j1.i(new m());
if (i4 == null) {
r7.k("M", "no gatt callback");
a3 = null;
} else {
a3 = yd.g.a(bluetoothDevice, this, false, i4);
StringBuilder sb = new StringBuilder();
sb.append("got new gatt: ");
sb.append(a3 != null);
r7.f("M", sb.toString());
if (a3 != null) {
if (this.c0 == null) {
this.c0 = new HashMap();
}
this.c0.put(bluetoothDevice.getAddress(), a3);
}
}
} else {
r7.f("M", "use existing gatt");
a3 = this.c0.get(bluetoothDevice.getAddress());
if (!yd.h.b(a3)) {
r7.f("M", "connect failed");
}
}
if (a3 != null) {
r7.f("M", "started gatt connect for " + bluetoothDevice.getAddress());
i3++;
} else {
r7.G("M", "btScan: failed to get gatt for " + bluetoothDevice.getName());
}
} else if (R6(2)) {
if (bluetoothDevice.fetchUuidsWithSdp()) {
r7.f("M", "started fetch for " + bluetoothDevice.getName());
i3++;
} else {
r7.G("M", "btScan: failed to start fetch for " + bluetoothDevice.getName());
}
}
}
}
}
return i3;
}
private void Z7() {
if (this.c0 != null) {
r7.f("M", "remove gatts");
for (Map.Entry<String, Object> entry : this.c0.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
r7.f("M", "close gatt for " + key);
yd.h.a(value);
}
this.c0 = null;
}
}
private void Z8(boolean z2) {
r9(2, z2, 1, new q(), true);
}
private void a2() {
long j3;
long[] jArr = x1;
long j4 = jArr[7];
long j5 = this.A0.getLong("wip", 10L) * 1000;
long S3 = S3();
r7.f("M", "adjustWifiTimeout: cur: " + j4 + "ms min: " + j5 + "ms max: " + S3 + "ms");
if (this.b0 == -1) {
r7.f("M", "didn't get scan result, add 2000ms");
j3 = 2;
} else {
long currentTimeMillis = System.currentTimeMillis() - this.b0;
if (currentTimeMillis > 300) {
long j6 = 0 - (currentTimeMillis / 4);
r7.f("M", "had result " + currentTimeMillis + "ms ago, adjust by " + j6 + "ms");
j3 = j6;
} else {
r7.f("M", "had result " + currentTimeMillis + "ms ago, close enough, no change");
j3 = 0L;
}
}
long j7 = jArr[7] + j3;
jArr[7] = j7;
if (j7 <= j5) {
jArr[7] = j5;
r7.f("M", "adjusted timeout to " + jArr[7] + "ms (min)");
return;
}
if (j7 <= S3) {
r7.f("M", "adjusted timeout to " + jArr[7] + "ms");
return;
}
jArr[7] = S3;
r7.f("M", "adjusted timeout to " + jArr[7] + "ms (max)");
}
private void a3(to toVar) {
Iterator<Integer> it = toVar.n2().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (this.B0.V(intValue)) {
this.B0.c(intValue).G1(toVar.c(intValue));
}
}
}
private String a4(boolean z2) {
ArrayList arrayList = new ArrayList(this.Y0);
int size = arrayList.size();
String str = "";
if (size <= 0) {
return "";
}
int i3 = 0;
for (int i4 = 0; i4 < size; i4++) {
wo woVar = (wo) arrayList.get(i4);
if (woVar.d1()) {
i3++;
} else {
if (i4 > 0) {
str = str + "|";
}
str = str + woVar.l1(this);
}
}
if (!Kid.b(this) && i3 > 0 && str.length() > 0) {
str = str + "|+" + String.valueOf(i3);
}
if ((str.length() != 0 || i3 <= 0) && (z2 || str.length() <= 35)) {
return str;
}
return dq.s0(getString(size == 1 ? 2131886159 : 2131886160), Integer.valueOf(size));
}
public void a5() {
try {
t2();
if (this.s[5]) {
o8(5, "handleTimerApp");
} else {
r7.f("M", "handleTimerApp not needed");
}
} catch (NullPointerException e3) {
r7.l("M", "handleMessage:app:", e3);
}
}
public void a6(Configuration configuration) {
wl.W(this, configuration);
}
private void a7(NotificationManager notificationManager, Notification notification, boolean z2) {
if (z2) {
notificationManager.notify(Integer.MAX_VALUE, notification);
} else {
stopForeground(true);
com.joaomgcd.taskerm.util.p.p(this, Integer.MAX_VALUE, notification);
}
}
private void a8() {
this.f0 = null;
this.p1.x1();
}
private int aa(String str, int i3, boolean z2) {
if (str == null) {
return 1;
}
int i4 = this.A0.getInt(str, i3);
if (i4 == 1) {
return z2 ? 1 : 0;
}
if (i4 != 2) {
return i4 != 3 ? 0 : 2;
}
return 1;
}
public boolean b2(int i3, long j3) {
List<pn> list = this.Z0.get(Integer.valueOf(i3));
if (list == null) {
return false;
}
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(list);
Iterator it = copyOnWriteArrayList.iterator();
int i4 = 0;
while (it.hasNext()) {
if (((ho) it.next()).w0() > j3) {
i4++;
}
}
if (i4 < copyOnWriteArrayList.size()) {
return false;
}
r7.f("M", "allStatesChecked: for code " + i3 + ": results matched " + i4 + " contexts");
return true;
}
private void b3() {
if (x5(5) || v5(2102)) {
for (int i3 = 0; i3 < bh.D(); i3++) {
if (bh.M(getPackageManager(), i3)) {
this.n0[i3] = new bh(this.w0, i3);
r7.f("M", "have calendar source: " + bh.k(i3));
} else {
this.n0[i3] = null;
}
}
}
}
private String b4(boolean z2, boolean z3) {
String a4 = z2 ? "" : a4(z3);
return TextUtils.isEmpty(a4) ? (this.B0 == null || !com.joaomgcd.taskerm.settings.q0.t(this)) ? getString(2131889244) : getString(2131889245, Integer.valueOf(this.B0.M1().size()), Integer.valueOf(this.B0.b2())) : a4;
}
private void b5() {
L6("btchecktimeout");
if (this.i0 != 0) {
r7.G("M", "previous scan not finished (state " + this.i0 + "), stopping now");
G9(false);
}
if (this.s[20]) {
o8(20, "handleTimerBT");
}
}
public void b6(final Configuration configuration) {
if (x5(122)) {
D7(26, configuration.orientation, true);
}
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.a6(configuration);
}
});
}
private void b7(boolean z2) {
q9(5, z2, 3, new b());
}
private void b8() {
BroadcastReceiver broadcastReceiver = this.e0;
if (broadcastReceiver != null) {
X9(broadcastReceiver, "bt scan");
this.e0 = null;
}
}
private void b9(wo woVar, boolean z2, String str) {
synchronized (this.u) {
try {
r7.f("M", "sig prof change: " + str + " pid: " + woVar.C0() + " enabled: " + woVar.h1() + " active: " + woVar.e1());
for (Object obj : this.u.toArray()) {
((z) obj).b(woVar.C0(), woVar.h1(), woVar.e1(), z2);
}
} catch (Throwable th2) {
throw th2;
}
}
}
private boolean ba(boolean z2) {
return o2 ? m2 : z2;
}
public static boolean c2(Context context) {
return dq.S0(context).getBoolean(ClockContract.AlarmsColumns.ENABLED, true);
}
private void c3(boolean z2) {
this.P0 = new ConcurrentHashMap();
this.R0 = new ConcurrentHashMap();
this.S0 = new ConcurrentHashMap();
this.Q0 = new ConcurrentHashMap();
this.Z0 = new HashMap<>();
this.C0 = new HashSet();
this.X0 = new ArrayList();
this.T0 = new HashMap();
this.U0 = new HashMap();
this.Y0 = new com.joaomgcd.taskerm.util.e();
to toVar = this.B0;
if (toVar != null) {
wc.c.b(this, this.p1.v(), toVar, this.Y0);
}
this.O0 = com.joaomgcd.taskerm.util.k8.h();
this.V0 = new HashMap();
this.W0 = new ConcurrentHashMap();
this.a1 = Collections.synchronizedList(new LinkedList());
this.b1 = new CopyOnWriteArrayList();
this.c1 = new HashSet();
if (z2) {
this.d1 = new HashMap();
this.f1 = new HashMap();
this.y = new ArrayList();
this.z = new ArrayList();
this.A = new ArrayList();
r7.f("M", "initing inbox");
this.g1 = new ConcurrentLinkedDeque<>();
}
}
private void c5() {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - X1 > 15000) {
d9();
return;
}
long j3 = Y1;
if (j3 == 0) {
if (j1.h(this).getState() == 12) {
Y1 = currentTimeMillis;
}
u9(12);
} else if (currentTimeMillis - j3 >= 3000) {
d9();
} else {
u9(12);
}
}
public static final int c7(int i3) {
return (i3 / 1001) * 1001;
}
private void c8() {
if (this.Q == null) {
return;
}
r7.f("M", "unregister cell workaround listener");
LocationManager P3 = P3();
if (P3 == null) {
r7.k("M", "rcnw: null lm");
} else {
P3.removeProximityAlert(this.Q);
}
this.Q = null;
}
private boolean c9() {
if (!com.joaomgcd.taskerm.util.e5.s(this).B()) {
return false;
}
boolean R6 = R6(1);
BluetoothAdapter h3 = j1.h(this);
if (h3 == null) {
r7.k("M", vh.g(this, 2131887709, new Object[0]));
} else if (this.i0 != 0) {
r7.f("M", "start BT scan: already scanning");
} else {
X2(4);
int state = h3.getState();
if (R6 && state != 10 && state != 11) {
r7.f("M", "skip BT enable, not currently OFF or TURNING ON");
R6 = false;
}
if (R6) {
boolean z2 = state == 11;
if (z2 || h3.enable()) {
this.i0 = 1;
if (!z2) {
P8(true);
}
X1 = System.currentTimeMillis();
Y1 = 0L;
u9(12);
} else {
r7.G("M", "failed to start BT enable process");
}
}
if (this.i0 != 1) {
d9();
}
}
return this.i0 != 0;
}
private int d2(Bundle bundle) {
if (bundle == null) {
return -1;
}
int i3 = bundle.getInt("plugged", -1);
if (bundle.containsKey("charge_type") && dq.g() < 19) {
r7.f("M", "bbtp: have charge_type key, pre KK SDK");
if (i3 > 0) {
r7.f("M", "bbtp: charge_type: " + bundle.getInt("charge_type", -1));
}
}
return i3;
}
private void d3(Set<Integer> set) {
if (!this.V) {
r7.f("M", "deactiveUnmonitoredContexts: skip, flags not initialized");
return;
}
Iterator<Integer> it = set.iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
wo c3 = this.B0.c(intValue);
if (c3 == null) {
r7.k("M", "dauc: pid " + intValue + " non-existant");
} else if (c3.e1()) {
for (int i3 = 0; i3 < c3.I0(); i3++) {
ho S0 = c3.S0(i3);
switch (S0.B0()) {
case 0:
if (!this.s[5] && !R6(6) && !R6(7)) {
r7.f("M", "p: " + c3.H0() + " set app inactive");
S0.M0(false);
break;
}
break;
case 1:
if (this.s[4]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set time inactive");
S0.M0(false);
break;
}
case 2:
if (this.s[4]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set day inactive");
S0.M0(false);
break;
}
case 3:
q7 q7Var = (q7) S0;
boolean z2 = q7Var.k1() && this.s[1];
boolean z3 = q7Var.l1() && this.s[2];
if (!z3 && !z2) {
r7.f("M", "p: " + c3.H0() + " set loc inactive gps " + z2 + " net: " + z3);
S0.M0(false);
break;
}
break;
case 4:
case 5:
case ClockContract.InstancesColumns.MISSED_STATE:
int j3 = ((pn) S0).j();
if (j3 != 4) {
if (j3 != 5) {
if (j3 != 7) {
if (j3 != 120) {
if (j3 != 125) {
if (j3 != 145) {
if (j3 != 147) {
if (j3 != 170) {
if (j3 != 180) {
if (j3 != 182) {
if (j3 != 185) {
if (j3 != 103) {
if (j3 != 104) {
if (j3 != 106) {
if (j3 == 107 && !this.s[9]) {
r7.f("M", "p: " + c3.H0() + " set missed call inactive");
S0.M0(false);
break;
}
} else if (this.s[17]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set magnet inactive");
S0.M0(false);
break;
}
} else if (this.s[16]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set pressure inactive");
S0.M0(false);
break;
}
} else if (this.s[13]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set light inactive");
S0.M0(false);
break;
}
} else if (this.s[21]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set humidity inactive");
S0.M0(false);
break;
}
} else if (this.s[24]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set heart rate inactive");
S0.M0(false);
break;
}
} else if (this.s[19]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set temp inactive");
S0.M0(false);
break;
}
} else if (this.s[3]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set wifi near inactive");
S0.M0(false);
break;
}
} else if (this.s[14]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set unread messageinactive");
S0.M0(false);
break;
}
}
} else if (this.s[12]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set prox inactive");
S0.M0(false);
break;
}
} else if (this.s[0]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set orientation inactive");
S0.M0(false);
break;
}
}
if (this.s[10]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set cell near/ss inactive");
S0.M0(false);
break;
}
} else if (this.s[6]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set cal inactive");
S0.M0(false);
break;
}
} else if (this.s[20]) {
break;
} else {
r7.f("M", "p: " + c3.H0() + " set bt near inactive");
S0.M0(false);
break;
}
}
}
}
}
}
public static List<String> d4() {
ArrayList arrayList = new ArrayList();
synchronized (O1) {
try {
Object[] array = O1.keySet().toArray();
Arrays.sort(array, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int J5;
J5 = MonitorService.J5(obj, obj2);
return J5;
}
});
for (Object obj : array) {
arrayList.add(bh.m(((Long) obj).longValue()) + " " + O1.get((Long) obj));
}
} catch (Throwable th2) {
throw th2;
}
}
return arrayList;
}
public void d5() {
s4();
}
public void d6(boolean z2, boolean z3) {
com.joaomgcd.taskerm.util.k8.P(1000L);
J2(null, true, z2, z3);
}
private ji.b d7(final int i3) {
return ji.b.t(new oi.a() {
@Override
public final void run() {
MonitorService.this.l6(i3);
}
});
}
private void d9() {
BluetoothAdapter h3 = j1.h(this);
if (h3.getState() != 12) {
r7.f("M", "start BT scan II: BT not enabled");
} else if (R6(4)) {
r7.f("M", "start standard BT scan");
if (h3.startDiscovery()) {
this.i0 = 2;
} else {
r7.G("M", "btScan: adapter reports failed to start scan");
}
} else if (g9()) {
this.i0 = 2;
}
if (this.i0 != 2) {
G9(true);
return;
}
this.g0 = System.currentTimeMillis();
this.h0 = -1L;
u9(13);
r7.f("M", "started scan at " + this.g0);
}
public static boolean e2(String str) {
synchronized (b2) {
try {
for (i1 i1Var : b2.values()) {
if (!i1Var.n() || (!i1Var.a().equals(str) && !i1Var.i().equals(str))) {
}
return true;
}
return false;
} finally {
}
}
}
private List<tn> e3(to toVar, List<wo> list) {
return g3(toVar, list, null, false, null, false);
}
private boolean e4(Bundle bundle) {
if (!bundle.containsKey("android.intent.extra.REPLACING")) {
return false;
}
Object obj = bundle.get("android.intent.extra.REPLACING");
return (obj.getClass() == Boolean.TYPE || obj.getClass() == Boolean.class) ? bundle.getBoolean("android.intent.extra.REPLACING") : bundle.getInt("android.intent.extra.REPLACING", 0) != 0;
}
private void e5() {
if (T6()) {
r7.f("M", "cell timeout, check cell infos");
if (r2(this, false)) {
r7.f("M", "cell id changed, check match states");
D2(7, true);
} else {
r7.f("M", "no cell id change");
}
}
M9();
}
public void e6(List list, String str, List list2, Long l3) throws Exception {
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
String str2 = (String) it.next();
r7.f("M", "pkg " + str + " updated, query state plugin names " + str2);
l7(str2, null);
}
}
if (list2 != null) {
Iterator it2 = list2.iterator();
while (it2.hasNext()) {
String str3 = (String) it2.next();
r7.f("M", "pkg " + str + " updated, query event plugin names " + str3);
l7(str3, null);
}
}
}
private void e8(int i3) {
c2[i3] = null;
}
@SuppressLint({"MissingPermission"})
private void e9(String str) {
if (com.joaomgcd.taskerm.util.e5.g0(this).A()) {
synchronized (Q1) {
try {
if (new com.joaomgcd.taskerm.util.e5(this, 12, com.joaomgcd.taskerm.util.e5.V()).A()) {
long currentTimeMillis = System.currentTimeMillis() - this.G;
if (str.equals("gps") && 1000 + currentTimeMillis < x1[1]) {
r7.f("M", "startLocUpdate: gps: not starting, last update ago = " + currentTimeMillis);
} else if (Q1.containsKey(str)) {
r7.G("M", "startLocUpdates: already registered for provider " + str);
} else {
LocationListener Q3 = Q3(str);
Q1.put(str, Q3);
LocationManager locationManager = this.x0;
if (locationManager == null) {
r7.k("M", "startLocUpdates: couldn't start location updates with null location manager");
} else {
try {
locationManager.requestLocationUpdates(str, 0L, 0.0f, Q3, this.p1.y().d());
} catch (Throwable th2) {
r7.l("M", "startLocUpdates: rlu failed with iae: xposed problem ?", th2);
}
}
if (str.equals("gps")) {
this.F = null;
this.H = 0;
this.G = System.currentTimeMillis();
if (n2) {
u9(6);
}
}
}
}
} catch (Throwable th3) {
throw th3;
}
}
}
}
private boolean f2(wo woVar) {
if (woVar != null) {
return woVar.e1() && woVar.h1() && !f7(woVar) && !g7(woVar, this.Y0);
}
r7.G("M", "cmal: null profile");
return false;
}
private List<tn> f3(to toVar, List<wo> list, Set<Integer> set, boolean z2, List<Integer> list2) {
return g3(toVar, list, set, z2, list2, true);
}
private tn f4(boolean z2) {
ArrayList<Integer> arrayList = new ArrayList();
synchronized (this.e1) {
try {
for (Integer num : this.d1.keySet()) {
num.intValue();
if (this.f1.get(num).intValue() == 0 || z2) {
arrayList.add(num);
}
}
} finally {
}
}
if (arrayList.size() <= 0) {
return null;
}
tn X12 = to.X1();
X12.D2(X12.m1() + 2002);
for (Integer num2 : arrayList) {
num2.intValue();
synchronized (this.e1) {
X12.a0(this.d1.remove(num2));
this.f1.remove(num2);
}
}
for (int i3 = 0; i3 < X12.c1(); i3++) {
net.dinglisch.android.taskerm.c A0 = X12.A0(i3);
if (A0 != null && A0.j() == 808) {
if (A0.i(0).v() == 0) {
X12.U1(i3, 0);
} else {
X12.U1(i3, X12.c1() - 1);
}
}
}
return X12;
}
private void f5() {
I9("gps");
o8(1, "handleTimerGPS");
}
public void f6() {
i8(true);
this.B0.q4(false);
D4(null, null, "EventCodesX.NEW_WIDGET");
}
private boolean f7(wo woVar) {
int C0 = woVar.C0();
return g2.containsKey(Integer.valueOf(C0)) && woVar.g1(g2.get(Integer.valueOf(C0)).longValue());
}
private void f8() {
to toVar = this.B0;
if (toVar == null) {
return;
}
HashSet hashSet = new HashSet();
for (Map.Entry<Integer, Long> entry : g2.entrySet()) {
Integer key = entry.getKey();
int intValue = key.intValue();
if (!toVar.V(intValue)) {
hashSet.add(key);
} else if (entry.getValue().longValue() > System.currentTimeMillis()) {
if (toVar.c(intValue).e1()) {
r7.f("M", "too old last active, still active, set act time to now");
g2.put(key, Long.valueOf(System.currentTimeMillis()));
} else {
r7.f("M", "too old last act, not active, remove last active entry");
hashSet.add(key);
}
}
}
Iterator it = hashSet.iterator();
while (it.hasNext()) {
g2.remove((Integer) it.next());
}
}
private void f9(int i3) {
if (Q6(i3)) {
r7.f("M", y1[i3] + ": monitor start: already started");
return;
}
if (this.s[i3]) {
O8(i3, true);
if (i3 == 5) {
V2();
}
o8(i3, "startMon");
return;
}
r7.G("M", y1[i3] + ": monitor start: ignore, not needed");
}
private boolean g2(WifiManager wifiManager) {
return yd.d1.b() && yd.d1.e(wifiManager);
}
private List<tn> g3(to toVar, List<wo> list, Set<Integer> set, boolean z2, List<Integer> list2, boolean z3) {
ArrayList arrayList;
synchronized (this.s1) {
try {
arrayList = new ArrayList();
for (int size = list.size() - 1; size >= 0; size--) {
wo woVar = list.get(size);
if (woVar == null) {
r7.k("M", "dip: null profile on active list");
} else if (!woVar.e1() || !woVar.h1()) {
if (woVar.q1()) {
int Q0 = woVar.Q0(0);
if (z3 && Q0 != -1) {
V4(toVar.R(Q0), set);
}
}
list.remove(size);
if (z3 && list2 != null) {
list2.add(Integer.valueOf(woVar.C0()));
}
r7.f("M", "profile -> inactive: " + woVar.H0());
RunLog.K0(this, this.A0, wo.a.Inactive, woVar);
b9(woVar, false, "delist");
if (woVar.c1(1)) {
int Q02 = woVar.Q0(1);
tn R = toVar.R(Q02);
if (R == null) {
r7.G("M", "dip: unknown exit task ID: " + Q02);
} else {
tn r0 = R.r0();
r0.D2(woVar.L0() + 1001);
if (woVar.s0()) {
r0.z2(woVar.C0());
}
r0.B2(woVar.k1("exit"));
r0.I(woVar.F0());
arrayList.add(r0);
}
if (woVar.f0() && !z2) {
this.B0.q4(true);
C7();
i8(true);
v3(woVar);
}
}
}
}
} catch (Throwable th2) {
throw th2;
}
}
return arrayList;
}
private String g4(long j3) {
long j4 = this.w;
return j4 < 0 ? String.valueOf(j4) : bh.m(j4);
}
private void g5() {
I9("network");
o8(2, "handleTimerNet");
}
public void g6(Intent intent) {
Q4(intent.getStringExtra("pfname"), intent.getIntExtra("pfttp", 2));
}
private boolean g7(wo woVar, List<wo> list) {
int C0 = woVar.C0();
Iterator<wo> it = list.iterator();
while (it.hasNext()) {
if (it.next().C0() == C0) {
return true;
}
}
return false;
}
private void g8() {
HashSet hashSet = new HashSet();
Iterator<Map.Entry<Integer, Location>> it = P1.entrySet().iterator();
while (it.hasNext()) {
Integer key = it.next().getKey();
wo c3 = this.B0.c(key.intValue());
if (!this.S0.containsKey(key) || (c3 != null && !c3.h1())) {
hashSet.add(key);
}
}
Iterator it2 = hashSet.iterator();
while (it2.hasNext()) {
P1.remove(it2.next());
}
}
public boolean g9() {
boolean z2;
r7.f("M", "try pings on paired devices");
if (Z6() > 0) {
z2 = true;
} else {
r7.G("M", "btScan: no matching paired devices ");
z2 = false;
}
if (R6(5)) {
if (j1.s(this, this.f0)) {
r7.f("M", "started LE scan");
return true;
}
r7.f("M", "failed to start BT LE scan");
}
return z2;
}
private void h2(int i3) {
synchronized (this.J0) {
try {
if (this.I0[i3] != null) {
r7.f("M", "AC cancel cal alarm: " + bh.k(i3));
this.v0.cancel(this.I0[i3]);
this.I0[i3] = null;
this.K0[i3] = 0;
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void h3() {
int i3 = 0;
while (true) {
bh[] bhVarArr = this.n0;
if (i3 >= bhVarArr.length) {
return;
}
bhVarArr[i3] = null;
i3++;
}
}
private boolean h4() {
if (this.t0 == null) {
r7.f("M", "setup sensor manager");
this.t0 = pp.c(this, "M");
}
if (this.t0 == null) {
dq.n0(this, 2131887720, new Object[0]);
}
return this.t0 != null;
}
private void h5() {
this.J = 0L;
s3(new Runnable() {
@Override
public final void run() {
MonitorService.this.O5();
}
}, "handleTimerProcessQueue");
}
private void h7(boolean z2) {
r9(3, z2, 3, new s(), true);
}
private void h8() {
BroadcastReceiver broadcastReceiver = this.W;
if (broadcastReceiver != null) {
X9(broadcastReceiver, "wifi scan");
this.W = null;
}
}
private boolean h9() {
r7.f("M", "start SM listener");
if (!h4()) {
return false;
}
pp.f(this.t0, pp.b(this), new o());
return true;
}
private void i2() {
PendingIntent pendingIntent = this.G0;
if (pendingIntent != null) {
r7.f("M", "cancel cooldown alarm");
this.v0.cancel(pendingIntent);
this.G0 = null;
}
}
private void i3() {
synchronized (Z1) {
try {
if (Z1.booleanValue()) {
BluetoothAdapter h3 = j1.h(this);
if (h3 != null) {
int state = h3.getState();
if (state != 13 && state != 10) {
if (h3.disable()) {
r7.f("M", "re-disabled BT");
} else {
r7.G("M", "failed to re-disable BT");
}
}
r7.f("M", "redisable BT: BT disabl(ing|ed) already, pull out!");
}
Z1 = Boolean.FALSE;
}
} catch (Throwable th2) {
throw th2;
}
}
}
public static int i4() {
return N1;
}
private void i5() {
L9();
u9(8);
}
private void i7() {
Iterator<Integer> it = this.V0.keySet().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (j2.X(intValue)) {
r7.f("M", "queryAllEventPlugins: " + intValue + " / " + ri.D(ri.c.Event, intValue));
m7(intValue, null);
}
}
}
private void i8(boolean z2) {
boolean z3 = false;
try {
kq.y();
this.B0.F4(this, TaskerAppWidgetConfigure.t(this, true), true, false);
} catch (Exception e3) {
r7.k("M", "init: exception from scanForVars: " + e3.toString());
}
r7.f("M", "rescan done");
StringBuilder sb = new StringBuilder();
Iterator<Integer> it = kq.m0().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (kq.T0(intValue)) {
z3 = true;
}
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(kq.I0(intValue));
}
r7.f("M", "needed monitor vars: " + sb.toString());
if (z2) {
r7.f("M", "handle variable dependent receivers");
if (z3) {
y3(6, true);
}
U1();
}
}
private void i9(final boolean z2) {
s3(new Runnable() {
@Override
public final void run() {
MonitorService.this.D6(z2);
}
}, "startStopCal");
}
private void j2() {
NotificationManager notificationManager = (NotificationManager) oi.d(this, "notification", "M", "umn");
if (notificationManager != null) {
try {
notificationManager.cancel(Integer.MAX_VALUE);
} catch (Exception e3) {
r7.f("M", "cancelNotification: " + e3.getMessage());
}
}
}
private void j3() {
if (x5(80)) {
Iterator<Integer> it = this.W0.get(80).iterator();
boolean z2 = false;
boolean z3 = false;
while (it.hasNext()) {
wo c3 = this.B0.c(it.next().intValue());
for (int i3 = 4; i3 <= 6; i3++) {
if (c3.Z0(i3)) {
pn pnVar = (pn) c3.T0(i3);
if (pnVar.j() == 80) {
int v2 = pnVar.x(0).v();
if (v2 == 0) {
z2 = true;
} else if (v2 != 1) {
if (v2 != 2) {
r7.k("M", "disableEnablessDockingDummies: bad val");
} else {
z2 = true;
}
}
z3 = true;
}
}
}
}
th.R(this, DockActivityDesk.class.getName(), z2);
th.R(this, DockActivityCar.class.getName(), z3);
}
}
private String[] j4(int i3) {
return c2[i3];
}
private void j5() {
zq.k(this, "Tasker.UserAbsentWakelock");
}
public void j6(Intent intent) {
l8(intent.getBooleanExtra("sreamo", false));
}
private void j7() {
Iterator<Integer> it = this.W0.keySet().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (on.O(intValue)) {
r7.f("M", "queryAllStatePlugins: " + intValue + " / " + ri.D(ri.c.Condition, intValue));
n7(intValue);
}
}
}
public static void j8(Context context, boolean z2) {
k8(context, z2, false);
}
private void j9(boolean z2) {
if (dq.z(this, "android.permission.READ_CALL_LOG", "MssCallLogging")) {
if (!z2) {
x1 x1Var = this.M;
if (x1Var != null) {
W9(x1Var);
this.M = null;
return;
}
return;
}
if (this.M != null) {
r7.G("M", "CallLogObserver already started");
return;
}
x1 x1Var2 = new x1(getApplicationContext(), "CallLogObserver", 100L, new y(this));
this.M = x1Var2;
this.w0.registerContentObserver(CallLog.CONTENT_URI, true, x1Var2);
}
}
private void k2() {
synchronized (this.M0) {
try {
if (pp.d(this) && h4()) {
r7.f("M", "cancel SM listener");
pp.a(this.t0, pp.b(this));
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void k3(boolean z2) {
if (Kid.b(this)) {
ReceiverStaticInternal.b(true);
} else if (dq.O1()) {
ReceiverStaticInternal.b(z2);
} else {
th.R(this, ReceiverStaticInternal.class.getName(), z2);
}
}
public String k4(int i3, int i4) {
return c2[i3][i4];
}
private void k5() {
I9("gps");
}
public void k6(int i3, final Intent intent, int i4) {
switch (i3) {
case 9982:
l7(intent.getStringExtra("com.twofortyfouram.locale.intent.extra.ACTIVITY"), vo.b.c(intent));
break;
case 9983:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.f6();
}
}, "EventCodesX.NEW_WIDGET");
break;
case 9984:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.w4();
}
}, "handleCooldownAlarm");
break;
case 9985:
case 9993:
case 9994:
default:
r7.k("M", "unknown event type: " + i3 + ", action" + intent.getAction());
break;
case 9986:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.g6(intent);
}
}, "handleProfileToggle");
break;
case 9987:
W7();
break;
case 9988:
int intExtra = intent.getIntExtra("csrc", -1);
if (intExtra != -1) {
r7.f("M", "cal alarm ding: " + bh.k(intExtra));
u4(intExtra);
break;
} else {
r7.k("M", "received calendar alarm intent without source spec");
break;
}
case 9989:
if (!w5((Intent) intent.getExtras().getParcelable("TaskerIntentIntentExtra"))) {
z4(intent.getBundleExtra("eventExt"));
break;
}
break;
case 9990:
String I = bh.I();
if (I.length() == 0 || !H1.equals(I)) {
v4();
}
H1 = I;
break;
case 9991:
f8();
v4();
break;
case 9992:
f8();
v4();
break;
case 9995:
if (i4 > 1) {
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.j6(intent);
}
}, "EventCodesX.START_MONITOR");
break;
}
break;
case 9996:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.i6(intent);
}
}, "handleSystemEvent");
break;
case 9997:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.h6(intent);
}
}, "handleAppLaunch");
break;
case 9998:
Y4("alarm");
break;
case 9999:
boolean booleanExtra = intent.getBooleanExtra("repeating", true);
r7.f("M", "alarm ding: user-absent update (period " + l4() + "ms) repeating: " + booleanExtra);
o5(booleanExtra);
break;
}
}
private void k7(final int i3, final k2 k2Var, final String str, Bundle bundle, Bundle bundle2) {
Intent intent;
ri.c cVar = ri.c.Event;
boolean z2 = true;
Intent R = ri.R(this, cVar, k2Var.j(), null, true);
if (R == null) {
intent = ri.R(this, cVar, k2Var.j(), null, false);
z2 = false;
} else {
intent = R;
}
if (intent != null) {
if (bundle2 != null) {
vo.b.a(intent, bundle2);
}
if (bundle != null) {
intent.putExtras(bundle);
}
N6(intent, bundle, str);
try {
if (!z2) {
sendOrderedBroadcast(intent, null, new j(i3, k2Var, str), this.p1.X0().c(), 0, null, null);
r7.f("M", "send event broadcast pid " + i3 + " for " + str);
return;
}
com.joaomgcd.taskerm.util.m6 m6Var = intent.getBooleanExtra("net.dinglisch.android.tasker.EXTRA_CAN_BIND_FIRE_SETTING", false) ? new com.joaomgcd.taskerm.util.m6(new com.joaomgcd.taskerm.util.c() {
@Override
public final void a(Object obj) {
((Intent) obj).removeExtra("net.dinglisch.android.tasker.EXTRA_CAN_BIND_FIRE_SETTING");
}
}) : null;
final com.joaomgcd.taskerm.util.m6 m6Var2 = m6Var;
intent.putExtra("net.dinglisch.android.tasker.EXTRA_RESULT_RECEIVER", new PluginResultReceiver(this.p1.X0().c(), new xj.p() {
@Override
public final Object l(Object obj, Object obj2) {
lj.e0 n6;
n6 = MonitorService.this.n6(i3, k2Var, str, m6Var2, (Integer) obj, (Bundle) obj2);
return n6;
}
}));
com.joaomgcd.taskerm.util.p.w(this, intent, intent.getIntExtra("net.dinglisch.android.tasker.EXTRA_TARGET_API", Build.VERSION.SDK_INT), false, false, m6Var);
r7.f("M", "event service start pid " + i3 + " for " + str);
} catch (Exception e3) {
r7.H("M", str + ": queryPluginEvent", e3);
}
}
}
public static void k8(Context context, boolean z2, boolean z3) {
boolean c22 = c2(context);
boolean L2 = dq.L2(context, MonitorService.class.getName());
r7.f("M", "restart: enabled: " + c22 + " running: " + L2 + " evenIfRunning: " + z2);
if (!c22) {
HelperMonitorService.p1(context).y(new oi.a() {
@Override
public final void run() {
MonitorService.w6();
}
}, new oi.d() {
@Override
public final void accept(Object obj) {
r7.g("M", "Couldn't create tasker stopped notification on restart", (Throwable) obj);
}
});
return;
}
HelperMonitorService.y1(context);
if (!L2 || z2) {
B8(context, z3);
}
}
private void k9(boolean z2) {
r7.f("M", "ClipboardManager not null. startFlag: " + z2);
if (!z2) {
if (this.K != null) {
r7.f("M", "remove clip listener");
oe.c.s(this, this.K);
this.K = null;
return;
}
return;
}
if (this.K == null) {
r7.f("M", "add clip listener");
ClipboardManager.OnPrimaryClipChangedListener onPrimaryClipChangedListener = new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public final void onPrimaryClipChanged() {
MonitorService.this.E6();
}
};
this.K = onPrimaryClipChangedListener;
oe.c.k(this, onPrimaryClipChangedListener, this.B0, true);
}
}
private void l2() {
synchronized (this.F0) {
try {
if (this.D0 != null) {
r7.f("M", "AC cancel time alarm");
this.v0.cancel(this.D0);
this.D0 = null;
this.E0 = 0L;
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void l3() {
Iterator<Integer> it = j2.Q().iterator();
while (it.hasNext()) {
y3(it.next().intValue(), false);
}
}
public long l4() {
return this.A0.getLong("lfdd", 600L) * 1000;
}
private void l5() {
L6("wifichecktimeout");
if (this.Z != 0) {
r7.G("M", "previous scan not finished (state " + this.Z + "), stopping now");
O9(false);
}
if (this.s[3]) {
o8(3, "handleTimerWifi");
}
}
public void l6(final int i3) throws Exception {
try {
ConcurrentLinkedDeque<Intent> concurrentLinkedDeque = this.g1;
boolean U9 = U9(10);
int size = concurrentLinkedDeque.size();
while (!U9 && size > 0) {
long currentTimeMillis = System.currentTimeMillis() - this.J;
if (currentTimeMillis > 200) {
this.I = 0L;
} else {
this.I += currentTimeMillis;
}
if (this.I > 8000) {
u9(10);
} else {
long currentTimeMillis2 = System.currentTimeMillis();
final Intent poll = concurrentLinkedDeque.poll();
if (poll == null) {
r7.h("M", "process inbox, null intent, size " + size + " startID: " + i3, true);
if (com.joaomgcd.taskerm.util.x2.u0(concurrentLinkedDeque)) {
concurrentLinkedDeque.clear();
}
U9 = U9(10);
size = concurrentLinkedDeque.size();
} else {
final int intExtra = poll.getIntExtra("eventType", -1);
if (r7.K()) {
r7.h("M", "process inbox, size " + size + " startID: " + i3 + " ecode " + intExtra, true);
if (intExtra != 9997) {
try {
r7.z("pi", poll);
} catch (Throwable th2) {
r7.g("M", "Couldn't log all extras", th2);
}
}
}
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.k6(intExtra, poll, i3);
}
});
long currentTimeMillis3 = System.currentTimeMillis();
this.J = currentTimeMillis3;
this.I += currentTimeMillis3 - currentTimeMillis2;
}
}
U9 = U9(10);
size = concurrentLinkedDeque.size();
}
} catch (RuntimeException e3) {
Throwable cause = e3.getCause();
if (cause == null) {
com.joaomgcd.taskerm.util.o2.h(e3, this, "processInboxBackground runtime");
}
if (cause instanceof InterruptedException) {
r7.f("M", "Interrupted while processing inbox: " + cause);
}
} catch (Exception e4) {
com.joaomgcd.taskerm.util.o2.h(e4, this, "processInboxBackground");
}
}
private void l7(final String str, final Bundle bundle) {
s3(new Runnable() {
@Override
public final void run() {
MonitorService.this.o6(str, bundle);
}
}, "queryPluginsWithEditClass");
}
private void l8(boolean z2) {
r7.f("M", "RESTART");
r7.A("M", "restart");
RunLog.N0(this, this.A0, RunLog.i.Restart);
S9(z2);
F5(true, true);
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.v6();
}
});
com.joaomgcd.taskerm.util.e eVar = this.Y0;
to toVar = this.B0;
this.x0 = null;
if (G5(false)) {
Z2(toVar);
a3(toVar);
u3();
H2(toVar, this.B0);
s2(eVar, toVar);
U8();
A3(false);
P4(this.B0.n2(), eVar, "restart");
}
Y2();
r7.A("M", "restart end");
r7.f("M", "RESTART DONE");
pg.d.j(new pf.m1());
}
private void l9(boolean z2) {
List<ih> list = this.X0;
if (list == null) {
return;
}
for (ih ihVar : new ArrayList(list)) {
if (z2) {
ihVar.c();
} else {
ihVar.d();
}
}
}
private void m2() {
synchronized (this.M0) {
try {
if (this.L0 != null) {
r7.f("M", "AC cancel user-absent updates");
this.v0.cancel(this.L0);
this.L0 = null;
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void m3() {
synchronized (T1) {
try {
if (T1.booleanValue()) {
WifiManager wifiManager = this.y0;
if (wifiManager != null) {
int wifiState = wifiManager.getWifiState();
if (wifiState == 4) {
r7.f("M", "redisable wifi: wifi in unknown state, continuing anyway");
} else if (!this.y0.pingSupplicant()) {
r7.f("M", "wifi near: re-disable wifi, supplicant not responding, continuing anyway");
}
if (wifiState != 0 && wifiState != 1) {
if (this.y0.setWifiEnabled(false)) {
U1 = System.currentTimeMillis();
r7.f("M", "re-disabled wifi");
} else {
r7.G("M", "failed to re-disable wifi");
}
}
r7.f("M", "redisable wifi: wifi disabl(ing|ed) already, pull out!");
}
Q8(false, "M/disableWifiIfNec");
}
} catch (Throwable th2) {
throw th2;
}
}
}
private IntentFilter m4(wo woVar, k2 k2Var) {
String N = kq.N(this, k2Var.N(0).w(), com.joaomgcd.taskerm.util.x2.t(this.B0, this, woVar, null, "registerUserReceiver"));
int v2 = k2Var.x(1).v();
int v3 = k2Var.x(2).v();
String M = kq.M(this, k2Var.N(3).w());
String M2 = kq.M(this, k2Var.N(4).w());
IntentFilter intentFilter = new IntentFilter();
if (!TextUtils.isEmpty(N)) {
intentFilter.addAction(N);
}
String q1 = a1.q1(v2);
if (!TextUtils.isEmpty(q1)) {
intentFilter.addCategory(q1);
}
String q12 = a1.q1(v3);
if (!TextUtils.isEmpty(q12)) {
intentFilter.addCategory(q12);
}
if (!TextUtils.isEmpty(M)) {
intentFilter.addDataScheme(M);
}
if (!TextUtils.isEmpty(M2)) {
intentFilter.addDataScheme(M2);
}
intentFilter.setPriority(k2Var.l1());
r7.f("M", "userIntentFilter: " + N + " c1: " + q1 + " c2: " + q12 + " s: " + M + " t: " + M2);
return intentFilter;
}
private void m5() {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - R1 > 15000) {
A9();
return;
}
long j3 = S1;
if (j3 == 0) {
if (this.y0.getWifiState() == 3) {
S1 = currentTimeMillis;
}
u9(5);
} else if (currentTimeMillis - j3 >= 3000) {
A9();
} else {
u9(5);
}
}
private void m7(int i3, Bundle bundle) {
if (i3 == -1) {
r7.G("M", "queryPluginsWithEventCode: ignoring null code");
return;
}
if (!j2.X(i3)) {
r7.G("M", "queryPluginsWithEventCode: ignoring none-plugin code: " + i3);
return;
}
if (!v5(i3)) {
r7.f("M", "qpwec: no events with code " + i3 + ", hope plugin shuts down soon...");
return;
}
r7.f("M", "queryPluginsWithEventCode: " + i3 + " / " + ri.D(ri.c.Event, i3));
List<Integer> list = this.V0.get(Integer.valueOf(i3));
if (list == null) {
r7.G("M", "queryPluginsWithEventCode: ignoring no profile ids in code: " + i3);
return;
}
Iterator<Integer> it = list.iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
wo c3 = this.B0.c(intValue);
if (c3 == null) {
r7.k("M", "qpwec: null profile, ID " + intValue);
} else {
k2 k2Var = (k2) c3.T0(7);
if (k2Var == null) {
r7.k("M", "qpwec: null event context");
} else if (k2Var.j() == i3) {
if (!c3.h1()) {
r7.f("M", "qpwec: " + c3.H0() + ": profile not enabled");
} else if (f7(c3)) {
r7.f("M", "qpwec: " + c3.H0() + ": cooling down");
} else if (c3.t0() < c3.I0() - 1) {
r7.f("M", "qpwec: " + c3.H0() + ": other contexts not all active");
} else {
r7.f("M", "qpwec: pid " + intValue);
String z2 = j2.z(k2Var.j());
k7(intValue, k2Var, z2, n4(c3, k2Var.a(0), z2), bundle);
}
}
}
}
}
public boolean m8(int i3) {
K9(i3);
return u9(i3);
}
private void m9(boolean z2) {
if (!z2) {
x1 x1Var = this.L;
if (x1Var != null) {
W9(x1Var);
this.L = null;
return;
}
return;
}
if (this.L != null) {
r7.G("M", "smsObserver already started");
return;
}
this.L = new x1(getApplicationContext(), "SmsObserver", 10L, new b0(this));
ContentResolver contentResolver = this.w0;
if (contentResolver == null) {
r7.k("M", "register SMS observer failed! No content resolver.");
return;
}
r7.f("M", "register SMS observer: uri: content://sms");
try {
contentResolver.registerContentObserver(Uri.parse("content://mms-sms"), false, this.L);
} catch (Throwable th2) {
r7.l("M", "register SMS observer failed with exception!", th2);
}
}
private void n2() {
synchronized (this.M0) {
m2();
k2();
}
}
private static boolean n3() {
boolean booleanValue;
synchronized (Z1) {
booleanValue = Z1.booleanValue();
}
return booleanValue;
}
private Bundle n4(wo woVar, net.dinglisch.android.taskerm.f fVar, String str) {
if (!fVar.k()) {
return null;
}
fVar.x();
return fVar.w(this, str, com.joaomgcd.taskerm.util.x2.t(this.B0, this, woVar, null, "getVariableExtrasFromBundle"));
}
public void n5() {
O9(false);
D2(170, true);
m3();
a2();
}
public lj.e0 n6(int i3, k2 k2Var, String str, com.joaomgcd.taskerm.util.m6 m6Var, Integer num, Bundle bundle) {
R4(num == null ? 18 : num.intValue(), i3, k2Var, str, bundle, false);
if (m6Var != null) {
m6Var.a();
}
return lj.e0.a;
}
private void n7(int i3) {
r7.f("M", "queryPluginsWithStateCode " + i3);
if (i3 == -1) {
r7.G("M", "queryPluginsWithStateCode: ignoring null code");
return;
}
if (!on.O(i3)) {
r7.G("M", "queryPluginsWithStateCode: ignoring none-plugin code: " + i3);
return;
}
if (this.W0.containsKey(Integer.valueOf(i3))) {
r7.f("M", "queryPluginsWithStateCode: " + i3 + " / " + ri.D(ri.c.Condition, i3));
List<Integer> list = this.W0.get(Integer.valueOf(i3));
if (list == null) {
return;
}
Iterator<Integer> it = list.iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
wo c3 = this.B0.c(intValue);
if (c3 == null) {
r7.G("M", "qpwcs: state code " + i3 + " profile: " + intValue + " doesn't exist");
} else if (c3.h1()) {
for (int i4 = 4; i4 <= 6; i4++) {
if (c3.Z0(i4)) {
pn pnVar = (pn) c3.T0(i4);
if (pnVar.j() == i3) {
r7.f("M", "queryPluginsWith: pid " + intValue);
q7(c3, intValue, pnVar);
}
}
}
}
}
}
}
private void n8() {
Location D12;
SharedPreferences sharedPreferences = getSharedPreferences(g6.q, 0);
SharedPreferences.Editor edit = sharedPreferences.edit();
for (Map.Entry<String, ?> entry : sharedPreferences.getAll().entrySet()) {
String key = entry.getKey();
Integer num = new Integer(key);
if (!this.S0.containsKey(num)) {
edit.remove(key);
} else if (!P1.containsKey(num) && (D12 = q7.D1((String) entry.getValue())) != null) {
P1.put(num, D12);
}
}
edit.commit();
}
private void n9(int i3) {
if (!this.s[i3]) {
if (Q6(i3)) {
J9(i3, "asNeeded");
}
} else {
if (Q6(i3)) {
return;
}
if (n2) {
f9(i3);
return;
}
int J12 = dq.J1(i3, C1);
if (J12 != -1) {
if (aa(D1[J12], E1[J12], o2()) > 0) {
f9(i3);
}
} else if (dq.J1(i3, this.k0) == -1) {
f9(i3);
}
}
}
private boolean o2() {
int d22;
Bundle G3 = G3();
return G3 != null && ((d22 = d2(G3)) == 1 || d22 == 2 || d22 == 4);
}
private static boolean o3() {
boolean booleanValue;
synchronized (T1) {
booleanValue = T1.booleanValue();
}
return booleanValue;
}
private long o4() {
return this.A0.getLong("wfpiod", 120L) * 1000;
}
public void o5(boolean z2) {
synchronized (this.M0) {
try {
r7.f("M", "handleUserAbsentAlarm: ignore repeating flag");
r7.f("M", "handleUserAbsentAlarm: cancel non-repeating alarm to clear alarm data");
m2();
R7("userAbsentUpdate");
if (V6(true) && kq.v(this)) {
if (this.s[5]) {
t2();
}
r7(true, new int[]{170, 5, 3, 120, 107, 7, 4});
M9();
if (S6()) {
y9();
}
I9("gps");
if (this.s[1] && q7.o1(this.x0, "gps")) {
e9("gps");
}
I9("network");
if (this.s[2]) {
if (!q7.o1(this.x0, "network")) {
r7.f("M", "skipping NET updates, provider disabled");
} else if (dq.x1(this, -1)) {
e9("network");
} else {
r7.f("M", "skipping NET updates, no network");
}
}
if (this.Z != 0) {
O9(true);
}
if (this.i0 != 0) {
G9(true);
}
if (this.s[3] && !z9(R6(0))) {
D2(170, true);
}
if (this.s[20] && !c9()) {
D2(4, true);
}
if (V6(true)) {
if (F9() && !t9(true)) {
r7.k("M", "couldn't acquire wakelock, stop user-absent checks for this time");
L9();
}
} else if (!V6(false)) {
n2();
}
x9();
}
} catch (Throwable th2) {
throw th2;
}
}
}
public void o6(String str, Bundle bundle) {
r7.f("M", "queryPluginsWithEditClass: " + str);
r7.v("pass through", bundle);
int g3 = ri.g(ri.c.Event, null, str);
if (g3 != -1) {
m7(g3, bundle);
return;
}
int g4 = ri.g(ri.c.Condition, null, str);
if (g4 != -1) {
n7(g4);
return;
}
r7.G("M", "queryPluginsWithCode: class: " + str + ": unknown class");
}
private void o8(final int i3, final String str) {
this.p1.r(new Runnable() {
@Override
public final void run() {
MonitorService.this.z6(i3, str);
}
});
}
private void o9() {
for (int i3 = 0; i3 < z1; i3++) {
n9(i3);
}
vg.j.b().A(this);
ze.h.b().A(this);
}
private void p2(String str, Bundle bundle, List<k2> list) {
String[] strArr = e6.b;
int length = strArr.length;
int i3 = 0;
while (true) {
if (i3 >= length) {
break;
}
if (str.equals(strArr[i3])) {
list.add(p4(bundle));
break;
}
i3++;
}
for (String str2 : e6.c) {
if (str.equals(str2)) {
list.add(new k2(306));
return;
}
}
}
private void p3(Runnable runnable, com.joaomgcd.taskerm.util.h3<?> h3Var, String str) {
this.p1.Z(t3().u(h3Var.f()), runnable);
}
private k2 p4(Bundle bundle) {
if (bundle != null) {
byte[] byteArray = bundle.containsKey("intent.extra.alarm_raw") ? bundle.getByteArray("intent.extra.alarm_raw") : bundle.containsKey("com.samsung.sec.android.clockpackage.alarm.ALARM_DATA") ? bundle.getByteArray("com.samsung.sec.android.clockpackage.alarm.ALARM_DATA") : null;
r0 = byteArray != null ? O3(byteArray) : null;
if (r0 == null && bundle.containsKey("alarm_label")) {
r0 = bundle.getString("alarm_label");
}
if (r0 == null && bundle.containsKey("alarm_description")) {
r0 = bundle.getString("alarm_description");
}
}
if (r0 == null) {
r7.f("M", "handleAlarmEvent: no alarm data and no label or descr extra");
r0 = "";
}
k2 k2Var = new k2(305);
k2Var.k0(0, r0);
return k2Var;
}
private void p5(Intent intent) {
int intExtra = intent.getIntExtra("UserIntentPIDExtra", -1);
intent.removeExtra("UserIntentPIDExtra");
to toVar = this.B0;
if (toVar == null) {
return;
}
wo c3 = toVar.c(intExtra);
if (c3 == null) {
r7.G("M", "handleUserIntent: no profile for ID " + intExtra);
return;
}
if (c3.h1()) {
k2 k2Var = new k2(599);
String action = intent.getAction();
if (action == null) {
action = "";
}
k2Var.k0(0, action);
if (!dq.F(intent.getCategories())) {
Iterator<String> it = intent.getCategories().iterator();
int i3 = 0;
while (it.hasNext()) {
int j3 = a1.j(it.next());
if (j3 == -1) {
j3 = 0;
}
if (i3 < 2) {
k2Var.x1(i3 + 1, j3);
}
i3++;
}
}
String scheme = intent.getScheme();
if (scheme == null) {
scheme = "";
}
k2Var.k0(3, scheme);
String type = intent.getType();
if (type == null) {
type = "";
}
k2Var.k0(4, type);
k2 k2Var2 = (k2) c3.T0(7);
if (k2Var2 == null || !k2Var2.W0(k2Var, this, this.w0, null)) {
return;
}
Bundle bundle = new Bundle();
String dataString = intent.getDataString();
if (dataString != null) {
bundle.putString("%intent_data", dataString);
}
Bundle extras = intent.getExtras();
if (extras != null) {
for (String str : extras.keySet()) {
Object obj = extras.get(str);
String str2 = "%" + kq.b1(str.toLowerCase());
while (bundle.containsKey(str2)) {
str2 = str2 + "_dup";
}
if (obj == null) {
bundle.putString(str2, "");
} else if (obj.getClass() == String[].class) {
String[] strArr = (String[]) obj;
int i4 = 0;
while (i4 < strArr.length) {
StringBuilder sb = new StringBuilder();
sb.append(str2);
int i5 = i4 + 1;
sb.append(String.valueOf(i5));
bundle.putString(sb.toString(), strArr[i4]);
i4 = i5;
}
} else if (obj.getClass() == int[].class) {
int[] iArr = (int[]) obj;
int i6 = 0;
while (i6 < iArr.length) {
StringBuilder sb2 = new StringBuilder();
sb2.append(str2);
int i7 = i6 + 1;
sb2.append(String.valueOf(i7));
bundle.putString(sb2.toString(), String.valueOf(iArr[i6]));
i6 = i7;
}
} else if (obj.getClass() == ArrayList.class) {
ArrayList arrayList = (ArrayList) obj;
int i8 = 0;
while (i8 < arrayList.size()) {
StringBuilder sb3 = new StringBuilder();
sb3.append(str2);
int i9 = i8 + 1;
sb3.append(String.valueOf(i9));
bundle.putString(sb3.toString(), String.valueOf(arrayList.get(i8)));
i8 = i9;
}
} else {
try {
if (obj.getClass() == Bundle.class) {
((Bundle) obj).size();
obj = com.joaomgcd.taskerm.util.x2.i1(com.joaomgcd.taskerm.util.x2.w0((Bundle) obj));
}
} catch (BadParcelableException e3) {
r7.H("M", "handleUserIntent", e3);
} catch (Throwable th2) {
r7.I("M", "handleUserIntent throwable", th2);
}
r7.f("M", "add var: " + str2);
bundle.putString(str2, obj.toString());
}
}
}
if (w2(c3, k2Var, bundle)) {
g2.put(Integer.valueOf(intExtra), Long.valueOf(System.currentTimeMillis()));
}
k2Var2.s0();
}
}
public void p6() {
synchronized (this.u) {
try {
List<wo> q22 = this.B0.q2(-2);
for (int i3 = 0; i3 < q22.size(); i3++) {
boolean z2 = true;
if (i3 >= q22.size() - 1) {
z2 = false;
}
wo woVar = q22.get(i3);
for (int i4 = 0; i4 < woVar.I0(); i4++) {
a9(woVar.C0(), woVar.S0(i4), "queryState");
}
b9(woVar, z2, "queryState");
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void p7(int i3, pn pnVar, String str, Bundle bundle) {
Intent Q = ri.Q(this, ri.c.Condition, pnVar.j(), null);
if (Q != null) {
if (bundle != null) {
Q.putExtras(bundle);
}
N6(Q, bundle, str);
try {
sendOrderedBroadcast(Q, null, new i(i3, str, pnVar), this.p1.X0().c(), 0, null, null);
r7.f("M", "send broadcast");
} catch (Exception e3) {
r7.H("M", str + ": queryPluginState", e3);
}
}
}
private net.dinglisch.android.taskerm.c p8(net.dinglisch.android.taskerm.c cVar) {
int e3 = ji.e(this);
if (e3 == -1) {
return null;
}
net.dinglisch.android.taskerm.c cVar2 = new net.dinglisch.android.taskerm.c(312);
cVar2.s1(0, a1.Q0(e3));
return cVar2;
}
private void p9(boolean z2) {
if (com.joaomgcd.taskerm.util.e5.o0(this).A()) {
TelephonyManager telephonyManager = (TelephonyManager) oi.d(this, "phone", "M", "sspsm");
try {
if (telephonyManager == null) {
r7.G("M", vh.g(this, 2131887721, new Object[0]));
} else if (!z2) {
PhoneStateListenerCommon phoneStateListenerCommon = this.O;
if (phoneStateListenerCommon != null) {
telephonyManager.listen(phoneStateListenerCommon, 0);
this.O.stop();
this.O = null;
}
} else if (this.O == null) {
PhoneStateListenerCommon phoneStateListenerCommon2 = PhoneStateListenerCommon.getInstance(this);
this.O = phoneStateListenerCommon2;
phoneStateListenerCommon2.setHandler(new c0(this));
telephonyManager.listen(this.O, this.T);
} else {
r7.G("M", "PhoneMonitor already started");
}
} catch (Exception e3) {
this.O = null;
r7.k("M", "Couldn't start/stop phone state monitor. Start: " + z2 + "; " + e3.toString());
}
}
}
private void q2() {
if (this.p1.f0(com.joaomgcd.taskerm.util.e5.t(this))) {
j1.h(this);
BluetoothAdapter h3 = j1.h(this);
int[] iArr = {1, 2, 3};
for (int i3 = 0; i3 < 3; i3++) {
int i4 = iArr[i3];
if (h3.getProfileConnectionState(i4) == 2) {
try {
if (this.j0 == null) {
this.j0 = new d();
}
h3.getProfileProxy(this, this.j0, i4);
} catch (Exception e3) {
r7.g("M", "checkBTConnectionsViaProxy", e3);
}
}
}
}
}
private void q3(to toVar, List<wo> list, boolean z2, boolean z3) {
List<tn> f3 = f3(toVar, list, null, true, null);
if (z3) {
U2();
} else {
tn f4 = f4(z2);
if (f4 != null) {
f3.add(f4);
}
}
P6(f3, z2, z3);
}
public void h6(Intent intent) {
if (A2(intent.getStringExtra("pkg"))) {
P4(this.R0.keySet(), null, "handleAppLaunch");
}
}
private void q5(boolean z2) {
if (z2 != n2) {
n2 = z2;
synchronized (this.M0) {
if (n2) {
r7.f("M", "+++ user present +++");
n2();
t9(false);
synchronized (Q1) {
try {
if (Q1.containsKey("gps")) {
this.G = 0L;
}
} finally {
}
}
k2();
L9();
Z1();
Y1();
r7(true, new int[]{170, 5, 3, 107, 120, 4});
o9();
} else {
r7.f("M", "+++ user not present +++");
ExecuteService.Q0();
for (int i3 : this.k0) {
J9(i3, "userPresChange");
}
Z1();
Y1();
x9();
}
}
}
}
public void q6(Set set, boolean z2, long j3) {
new l(set, z2).sendEmptyMessageDelayed(0, j3);
}
private void q7(wo woVar, int i3, pn pnVar) {
String F = on.F(pnVar.j());
p7(i3, pnVar, F, n4(woVar, pnVar.a(0), F));
}
public void q8(int i3, Location location) {
getSharedPreferences(g6.q, 0).edit().putString(Integer.toString(i3), q7.u1(location)).commit();
}
private void q9(int i3, boolean z2, int i4, SensorEventListener sensorEventListener) {
r9(i3, z2, i4, sensorEventListener, false);
}
public static boolean r2(MonitorService monitorService, boolean z2) {
r7.f("M", "checkCellInfos: use last: " + z2);
List<Object> lastCellInfos = z2 ? monitorService.O.getLastCellInfos() : null;
if (dq.F(lastCellInfos)) {
r7.f("M", "empty update infos, query all infos from telephony manager");
lastCellInfos = xo.b(monitorService, xo.p(monitorService));
}
if (dq.F(lastCellInfos)) {
r7.f("M", "still empty update infos");
return false;
}
r7.f("M", "checkCellInfos: have : " + lastCellInfos.size() + " infos");
return monitorService.t7(xo.j(lastCellInfos));
}
public static void r3(Context context, boolean z2) {
H8(context, false);
dq.p3(context);
C8(context);
if (z2) {
dq.e0(context, 2131886823, 2131891153, 1);
}
}
public void r4(Context context, BluetoothDevice bluetoothDevice, boolean z2, String str, boolean z3) {
BluetoothAdapter h3;
r7.f("M", "received " + str + " connect " + z2);
if (z3) {
this.p1.R1(bluetoothDevice, z2);
}
if (!j1.d(context, bluetoothDevice)) {
r7.f("M", "BT connect/disconnect: ignoring (unbonded and non-headset event)");
return;
}
i1 i1Var = new i1(bluetoothDevice, z2);
if (!i1Var.o()) {
r7.G("M", "ignoring BTDevice with incomplete data");
return;
}
StringBuilder sb = new StringBuilder();
sb.append("BTDeviceEvent : ");
sb.append(i1Var.c());
sb.append(z2 ? " connected" : " disconnected");
r7.f("M", sb.toString());
if (z2 && (h3 = j1.h(this)) != null && h3.getState() != 12) {
r7.f("M", "ignoring spurious connect, BT is off");
return;
}
if (b2.containsKey(i1Var.a())) {
b2.get(i1Var.a()).n();
}
synchronized (b2) {
b2.put(i1Var.a(), i1Var);
}
D2(3, true);
}
public static Boolean r6(String str, String str2) {
return Boolean.valueOf(str2.equals(str));
}
private void r7(boolean z2, int[] iArr) {
Intent i1;
Intent i12;
TelephonyManager telephonyManager;
if (this.W0.isEmpty()) {
return;
}
N7(false, 0L);
if (y5() && dq.J1(3, iArr) == -1) {
q2();
}
if (x5(154)) {
F7(42, oi.e(this), false);
}
if (x5(7) && dq.J1(7, iArr) == -1) {
t7(xo.k(this));
}
if (x5(100)) {
J7(5, dq.O0(this.w0, "airplane_mode_on") != 0, false);
}
if (x5(123)) {
J7(27, y8(this), false);
}
if (x5(2)) {
J7(32, j1.h(this).getState() == 12, false);
}
if (x5(14)) {
A7(false);
}
if (x5(16)) {
v7(false);
}
if (x5(135)) {
s7(false);
}
if (x5(195)) {
y7(false);
}
if (x5(122)) {
D7(26, dq.Y0(this), false);
}
if (x5(40) && this.p1.f0(com.joaomgcd.taskerm.util.e5.o0(this)) && (telephonyManager = (TelephonyManager) oi.d(this, "phone", "M", "rms")) != null) {
int callState = telephonyManager.getCallState();
if (callState == 0) {
G7(20, "", false);
G7(30, "", false);
} else if (callState == 1 && (!z5(20) || TextUtils.isEmpty(k4(20, 0)))) {
G7(20, "x", false);
}
}
if (x5(107)) {
x7(false);
}
if (x5(120) && dq.J1(120, iArr) == -1) {
D7(19, -1, false);
}
if (x5(80) && (i12 = this.p1.i1(new IntentFilter("android.intent.action.DOCK_EVENT"))) != null) {
x4(i12.getExtras(), false);
}
if (u5(110) || u5(160) || u5(161) || u5(136)) {
E4(false);
}
if (x5(148)) {
Intent i13 = this.p1.i1(new IntentFilter("com.samsung.pen.INSERT"));
if (i13 != null) {
J4(i13.getExtras(), false);
}
}
if (x5(30) && (i1 = this.p1.i1(new IntentFilter("android.intent.action.HEADSET_PLUG"))) != null) {
A4(i1.getExtras(), false);
}
if (x5(50)) {
B4(false);
}
if (x5(140) || x5(141) || x5(10)) {
I2(null, false);
}
E2(-1, iArr, z2);
}
private void r8(net.dinglisch.android.taskerm.c r11) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.r8(net.dinglisch.android.taskerm.c):void");
}
private void r9(int i3, boolean z2, int i4, SensorEventListener sensorEventListener, boolean z3) {
try {
SensorManager sensorManager = this.t0;
if (sensorManager == null) {
r7.G("M", "no sensor manager");
return;
}
if (this.p0[i3] == null) {
r7.f("M", "no default step sensor");
return;
}
SensorEventListener sensorEventListener2 = this.o0[i3];
if (sensorEventListener2 != null) {
if (z3) {
this.p1.d0(sensorManager, sensorEventListener2);
} else {
sensorManager.unregisterListener(sensorEventListener2);
}
this.o0[i3] = null;
if (i3 == 1) {
e8(19);
}
}
Handler handler = this.s0;
if (i3 == 3 && handler != null) {
handler.removeMessages(0);
this.s0 = null;
}
int i5 = C1[i3];
O8(i5, false);
if (!z2) {
X7();
return;
}
this.o0[i3] = sensorEventListener;
if (i3 == 3) {
this.s0 = new d0(this);
}
if (z3 ? this.p1.K(sensorManager, this.o0[i3], this.p0[i3], i4) : sensorManager.registerListener(this.o0[i3], this.p0[i3], i4)) {
O8(i5, true);
if (aa(D1[i3], E1[i3], false) == 2) {
O1();
}
if (i3 == 1) {
this.r0 = this.q0;
return;
}
return;
}
r7.k("M", "no " + F1[i3] + " sensor, or couldn't enable");
this.o0[i3] = null;
} catch (SecurityException e3) {
r7.G("M", "startStopSendor: " + i3 + ConstantsCommonTaskerServer.ID_SEPARATOR + e3.getMessage());
}
}
private void s2(List<wo> list, to toVar) {
LinkedList linkedList = new LinkedList();
Iterator<Integer> it = this.B0.n2().iterator();
while (it.hasNext()) {
wo c3 = this.B0.c(it.next().intValue());
if (f2(c3)) {
linkedList.add(c3);
}
}
LinkedList linkedList2 = new LinkedList();
for (int i3 = 0; i3 < list.size(); i3++) {
wo woVar = list.get(i3);
if (!g7(woVar, linkedList)) {
woVar.b0();
linkedList2.add(woVar);
}
}
q3(toVar, linkedList2, false, false);
}
private void s4() {
r7.f("M", "handle BT scan end");
G9(false);
D2(4, true);
i3();
X1();
}
public void s6() {
synchronized (B1) {
stopSelf();
zq.k(this, "M");
}
}
public void s7(boolean z2) {
J7(44, ContentResolver.getMasterSyncAutomatically(), z2);
}
private void s8(tn tnVar) {
if (tnVar == null) {
r7.G("M", "saveSettings: no task");
return;
}
for (int i3 = 0; i3 < tnVar.c1(); i3++) {
net.dinglisch.android.taskerm.c A0 = tnVar.A0(i3);
int j3 = A0.j();
if (a1.h(j3)) {
u8(A0);
} else if (a1.f(j3)) {
r8(A0);
}
}
}
private void s9(boolean z2) {
if (z2) {
if (this.N == null) {
this.N = ContentResolver.addStatusChangeListener(1, new n());
return;
} else {
r7.G("M", "sync status listener already started");
return;
}
}
Object obj = this.N;
if (obj != null) {
ContentResolver.removeStatusChangeListener(obj);
this.N = null;
}
}
private boolean t2() {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.t2():boolean");
}
private synchronized ji.b t3() {
try {
if (this.q1 == null) {
c3(true);
this.q1 = ExtensionsContextKt.Y1(this).i().A(this.p1.t()).g(X6()).j();
}
} catch (Throwable th2) {
throw th2;
}
return this.q1;
}
public static lj.e0 t6(Runnable runnable) {
runnable.run();
return lj.e0.a;
}
public boolean t7(Object obj) {
boolean z2;
if (obj == null) {
r7.f("M", "got null cell location to record");
} else {
String f3 = xo.f(obj);
if (f3 != null) {
r7.f("M", "recordCellLocation: got id: " + f3);
if (kq.e1(17)) {
if (L1 == null || !L1.equals(f3)) {
L8(L1);
L1 = f3;
kq.F1(this, 17);
} else {
L8(L1);
}
}
M1 = f3;
W1(f3);
z2 = true;
R2();
return z2;
}
r7.f("M", "recordCellLocation: ignoring cell with unknown ID");
}
z2 = false;
R2();
return z2;
}
private net.dinglisch.android.taskerm.c t8(net.dinglisch.android.taskerm.c cVar) {
AudioManager audioManager = (AudioManager) oi.d(this, "audio", "M", "saveSilent");
if (audioManager == null) {
r7.k("M", vh.g(this, 2131887705, new Object[0]));
return null;
}
net.dinglisch.android.taskerm.c cVar2 = new net.dinglisch.android.taskerm.c(310);
int ringerMode = audioManager.getRingerMode();
cVar2.s1(0, ringerMode != 1 ? ringerMode == 0 ? 2 : 0 : 1);
return cVar2;
}
private boolean u2() {
Set<ComponentName> set = this.D;
if (set == null) {
set = new HashSet();
}
this.D = new HashSet();
boolean z2 = false;
if (com.joaomgcd.taskerm.util.k.h()) {
for (ActivityManager.RunningServiceInfo runningServiceInfo : this.u0.getRunningServices(99)) {
String packageName = runningServiceInfo.service.getPackageName();
String className = runningServiceInfo.service.getClassName();
if (runningServiceInfo.started) {
ComponentName componentName = new ComponentName(packageName, className);
this.D.add(componentName);
if (!set.contains(componentName)) {
r7.f("M", "new service: " + packageName + " / " + className);
z2 = true;
}
}
}
} else {
List<ComponentName> list = (List) new ye.a(this).c().f();
for (ComponentName componentName2 : list) {
if (!set.contains(componentName2)) {
r7.f("M", "new service: " + componentName2.getPackageName() + " / " + componentName2.getClassName());
z2 = true;
}
}
this.D.addAll(list);
}
if (!z2) {
for (ComponentName componentName3 : set) {
if (!this.D.contains(componentName3)) {
r7.f("M", "lost service: " + componentName3);
return true;
}
}
}
return z2;
}
private void u3() {
i7();
r7.f("M", "query event plugins done");
j7();
r7.f("M", "query state plugins done");
try {
r7(false, null);
} catch (Exception e3) {
r7.l("M", "dimc/rms", e3);
}
r7.f("M", "recmatch done");
B2(-1);
r7.f("M", "checkMatchLocs: done");
try {
if (g1.s1(this)) {
N8(wp.a(this, 600000L), "doInitialMatchChecks");
A2(this.C);
} else {
A2(this.B);
}
} catch (Exception e4) {
r7.l("M", "dimc/cma", e4);
}
r7.f("M", "checkMatchApp: done");
G2();
r7.f("M", "checkMatchTimeDay: done");
}
public void u4(int i3) {
r7.f("M", "handle cal alarm: " + bh.k(i3));
D2(5, true);
E8(i3);
}
public static void u6(Runnable runnable, Throwable th2) throws Exception {
r7.g("M", "Couldn't create tasker stopped notification", th2);
runnable.run();
}
public void u7(String str, float f3) {
dq.S0(this).edit().putFloat(str, f3).commit();
}
private void u8(net.dinglisch.android.taskerm.c cVar) {
int j3 = cVar.j();
if (this.d1.containsKey(Integer.valueOf(j3))) {
this.f1.put(Integer.valueOf(j3), Integer.valueOf(this.f1.get(Integer.valueOf(j3)).intValue() + 1));
return;
}
net.dinglisch.android.taskerm.c cVar2 = new net.dinglisch.android.taskerm.c(j3);
if (j3 != 812) {
int p0 = cVar2.p0(0);
if (p0 == 0) {
int N0 = dq.N0(this.w0, j3);
if (N0 != -1) {
cVar2.s1(0, N0);
synchronized (this.e1) {
this.d1.put(Integer.valueOf(j3), cVar2);
this.f1.put(Integer.valueOf(j3), 1);
}
}
} else if (p0 != 3) {
r7.k("M", "saveSystemSettings: unhandled arg type: " + p0);
} else {
try {
cVar2.m1(0, H3(j3));
synchronized (this.e1) {
this.d1.put(Integer.valueOf(j3), cVar2);
this.f1.put(Integer.valueOf(j3), 1);
}
} catch (Settings.SettingNotFoundException e3) {
r7.k("M", "saveSystemSettings: " + e3.toString());
}
}
if (j3 == 810) {
for (int i3 = 1; i3 < cVar.Y(); i3++) {
cVar2.k1(i3, cVar.G(i3));
}
return;
}
return;
}
int N02 = dq.N0(this.w0, j3);
if (N02 != -1) {
StringBuilder sb = new StringBuilder();
sb.append("CURVAL: ");
sb.append(N02);
sb.append("ms = ");
int i4 = N02 / 1000;
sb.append(i4);
sb.append("s");
r7.f("M", sb.toString());
int i5 = i4 / 3600;
int i6 = i4 - (i5 * 3600);
int i7 = i6 / 60;
int i8 = i6 - (i7 * 60);
r7.f("M", "hours: " + i5 + " mins: " + i7 + " secs: " + i8);
cVar2.s1(0, i8);
cVar2.s1(1, i7);
cVar2.s1(2, i5);
synchronized (this.e1) {
this.d1.put(Integer.valueOf(j3), cVar2);
this.f1.put(Integer.valueOf(j3), 1);
}
}
}
private boolean u9(int i3) {
return v9(i3, x1[i3]);
}
private void v2(String str, Bundle bundle, List<k2> list) {
int i3 = 0;
int i4 = 0;
while (true) {
try {
String[] strArr = g6.d.a;
if (i4 >= strArr.length) {
return;
}
if (str.equals(strArr[i4])) {
if (bundle == null) {
r7.k("M", str + ": no extras");
return;
}
k2 k2Var = new k2(446);
k2Var.x1(0, i4);
k2Var.k0(1, bundle.containsKey(ProfileManager.EXTRA_PROFILE_NAME) ? bundle.getString(ProfileManager.EXTRA_PROFILE_NAME) : "");
k2Var.k0(2, bundle.containsKey("message") ? bundle.getString("message") : "");
k2Var.k0(3, bundle.containsKey("profile") ? bundle.getString("profile") : "");
if (bundle.containsKey("type")) {
int v3 = dq.v3(bundle.getString("type"), g6.d.b);
if (v3 == -1) {
r7.G("M", str + ": unknown alarm type: " + v3);
} else {
i3 = v3;
}
} else {
r7.G("M", "action: no type specified");
}
k2Var.x1(4, i3);
list.add(k2Var);
return;
}
i4++;
} catch (Exception e3) {
r7.l("M", "GentleAlarm", e3);
return;
}
}
}
private void v3(wo woVar) {
woVar.J1(3, 0);
}
private void v4() {
r7.f("M", "chron change");
if (Q6(6)) {
int i3 = 0;
while (true) {
bh[] bhVarArr = this.n0;
if (i3 >= bhVarArr.length) {
break;
}
if (bhVarArr[i3] != null) {
u4(i3);
}
i3++;
}
}
if (Q6(4)) {
Y4("chronChange");
}
}
private boolean v5(int i3) {
Map<Integer, List<Integer>> map = this.V0;
return map != null && map.containsKey(Integer.valueOf(i3));
}
public void v6() {
this.l0 = new f0(this);
}
private void v7(boolean z2) {
boolean z3;
if (yd.i0.a()) {
z3 = yd.i0.f(yd.i0.c(getApplicationContext()));
} else {
r7.k("M", "recordDeviceIdleState: no API");
z3 = false;
}
J7(47, z3, z2);
}
private net.dinglisch.android.taskerm.c v8(int i3, net.dinglisch.android.taskerm.c cVar) {
AudioManager audioManager = (AudioManager) oi.d(this, "audio", "M", "saveVol");
if (audioManager == null) {
r7.k("M", vh.g(this, 2131887705, new Object[0]));
return null;
}
net.dinglisch.android.taskerm.c cVar2 = new net.dinglisch.android.taskerm.c(cVar.j());
cVar2.s1(0, audioManager.getStreamVolume(i3));
cVar2.m1(1, cVar.i(1).R());
cVar2.m1(2, cVar.i(2).R());
return cVar2;
}
private boolean v9(int i3, long j3) {
Handler handler = this.l0;
if (handler == null) {
return false;
}
if (!U9(i3)) {
if (i3 != 0) {
r7.f("M", "start timer: " + w1[i3] + " " + j3 + "ms");
}
if (!handler.sendEmptyMessageDelayed(i3, j3)) {
r7.G("M", "timer start failed, gulp");
return false;
}
} else if (i3 != 0 && i3 != 5) {
r7.f("M", "timer already started: " + w1[i3]);
}
return true;
}
public boolean w2(wo woVar, k2 k2Var, Bundle bundle) {
ze.b e1;
if (!woVar.e1()) {
r7.f("M", "check instant activation id: " + woVar.C0() + ": not active");
return false;
}
if (f7(woVar)) {
r7.f("M", "check instant activation id: " + woVar.C0() + ": cooling down");
return false;
}
r7.f("M", "check instant activation id: " + woVar.C0() + ": active, not cooling down");
if (k2Var != null && (e1 = k2Var.e1()) != null) {
e1.W(this, k2Var, bundle);
}
Bundle o1 = k2Var == null ? null : k2Var.o1(getResources());
if (bundle == null) {
bundle = o1 != null ? o1 : null;
} else if (o1 != null) {
bundle.putAll(o1);
}
C3(woVar, 0, bundle);
C3(woVar, 1, bundle);
RunLog.K0(this, this.A0, wo.a.Instant, woVar);
if (woVar.f0()) {
this.B0.q4(false);
C7();
i8(true);
Y9("checkInstantActivation");
X7();
v3(woVar);
}
return true;
}
public void w4() {
HashSet hashSet = new HashSet();
for (Integer num : this.B0.n2()) {
wo c3 = this.B0.c(num.intValue());
if (c3 != null && c3.h1() && c3.a1()) {
hashSet.add(num);
}
}
P4(hashSet, null, "cooldownAlarm");
}
public static void w6() throws Exception {
}
private void w8() {
List<Integer> copyOnWriteArrayList;
List<Integer> list;
for (Integer num : this.B0.n2()) {
int intValue = num.intValue();
wo c3 = this.B0.c(intValue);
for (int i3 = 0; i3 < c3.I0(); i3++) {
switch (c3.V0(i3)) {
case 0:
this.R0.put(num, (g1) c3.S0(i3));
break;
case 1:
this.O0.add(Integer.valueOf(c3.C0()));
this.P0.put(num, (kp) c3.S0(i3));
break;
case 2:
this.Q0.put(num, (w1) c3.S0(i3));
this.O0.add(num);
break;
case 3:
this.S0.put(num, (q7) c3.S0(i3));
break;
case 4:
case 5:
case ClockContract.InstancesColumns.MISSED_STATE:
pn pnVar = (pn) c3.S0(i3);
int j3 = pnVar.j();
if (x5(j3)) {
copyOnWriteArrayList = this.W0.get(Integer.valueOf(j3));
} else {
copyOnWriteArrayList = new CopyOnWriteArrayList<>();
this.W0.put(Integer.valueOf(j3), copyOnWriteArrayList);
}
pnVar.d1();
Iterator<Integer> it = copyOnWriteArrayList.iterator();
while (true) {
if (!it.hasNext()) {
copyOnWriteArrayList.add(num);
} else if (it.next().intValue() == intValue) {
}
}
if (s5(j3)) {
for (String str : pnVar.Q().Z()) {
if (kq.U0(str)) {
this.C0.add(Integer.valueOf(kq.H0(str)));
}
}
break;
} else {
break;
}
case 7:
k2 k2Var = (k2) c3.S0(i3);
int j4 = k2Var.j();
if (v5(j4)) {
list = this.V0.get(Integer.valueOf(j4));
} else {
list = new CopyOnWriteArrayList<>();
this.V0.put(Integer.valueOf(j4), list);
}
list.add(num);
if (j4 == 3000) {
a0 a0Var = new a0(intValue, this.A0.getFloat("accMR", 3.5f), 1000000 * this.A0.getLong("acrmd", 1200L), k2Var.N(0).w(), k2Var.N(1).w());
if (a0Var.e) {
break;
} else {
this.T0.put(num, a0Var);
break;
}
} else if (j4 == 3001) {
this.U0.put(num, new e0(intValue, k2Var, this.A0.getFloat("accMax", 14.0f)));
break;
} else if (j4 == 3050) {
String w2 = k2Var.N(0).w();
if (kq.U0(w2)) {
this.C0.add(Integer.valueOf(kq.H0(w2)));
break;
} else {
break;
}
} else {
break;
}
default:
r7.k("M", "bad subcontext");
break;
}
}
}
}
public void w9(long j3, boolean z2) {
r7.f("M", "startUserAbsentAlarm: L or greater, no repeating");
Intent intent = new Intent(this, (Class<?>) ReceiverStaticInternal.class);
intent.setAction("net.dinglisch.android.tasker.ANOFFCHECKORUM");
intent.putExtra("repeating", false);
this.L0 = PendingIntent.getBroadcast(this, 0, intent, com.joaomgcd.taskerm.util.k8.g(268435456, intent));
r7.f("M", "start user-absent updates: " + (j3 / 1000) + " secs, repeating: false");
this.N0 = System.currentTimeMillis() + j3;
S7("start");
}
private void x2(String str, Bundle bundle, List<k2> list) {
int i3 = 0;
while (true) {
String[] strArr = g6.e.a;
if (i3 >= strArr.length) {
return;
}
if (str.equals(strArr[i3])) {
k2 k2Var = new k2(428);
k2Var.x1(0, i3);
k2Var.k0(1, bundle.containsKey("org.kaloersoftware.kaloerclock.intents.EXTRA_ALARM_NAME") ? bundle.getString("org.kaloersoftware.kaloerclock.intents.EXTRA_ALARM_NAME") : "");
list.add(k2Var);
return;
}
i3++;
}
}
private void x3(boolean z2) {
th.R(this, AssistHandler.class.getName(), true);
}
private void x4(Bundle bundle, boolean z2) {
if (!bundle.containsKey("android.intent.extra.DOCK_STATE")) {
r7.k("M", "DOCK_EVENT with no DOCK_STATE");
return;
}
int i3 = bundle.getInt("android.intent.extra.DOCK_STATE");
if (i3 == 0) {
J7(6, false, z2);
J7(7, false, z2);
J7(36, false, z2);
} else {
if (i3 == 1) {
J7(7, true, z2);
return;
}
if (i3 == 2) {
J7(6, true, z2);
return;
}
if (i3 == 9 || i3 == 10) {
J7(36, true, z2);
return;
}
r7.k("M", "DOCK_EVENT with unrecognized DOCK_STATE: " + i3);
}
}
public boolean x5(int i3) {
Map<Integer, List<Integer>> map = this.W0;
return map != null && map.containsKey(Integer.valueOf(i3));
}
@SuppressLint({"MissingPermission"})
public void x7(boolean z2) {
if (dq.z(this, "android.permission.READ_CALL_LOG", "MrecordMissedCalls")) {
try {
Cursor query = this.w0.query(CallLog.Calls.CONTENT_URI, new String[]{"number", "date"}, dq.Z1(new String[]{"type=3", "new=1"}), null, "date DESC");
ArrayList arrayList = new ArrayList();
if (query == null) {
r7.G("M", "missedCallCheck: null cursor from CallLog");
} else {
while (query.moveToNext()) {
String string = query.getString(0);
arrayList.add(string);
if (z2) {
long j3 = query.getLong(1);
if (j3 > I1) {
sendBroadcast(new Intent("net.dinglisch.android.tasker.MCALLMYUM").putExtra("num", string));
I1 = j3;
}
}
}
query.close();
}
I7(21, arrayList, z2);
} catch (Exception e3) {
r7.l("M", "recordMissedCalls", e3);
}
}
}
private void x8() {
File file;
Iterator<Integer> it = this.B0.n2().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
wo c3 = this.B0.c(intValue);
Bundle t2 = com.joaomgcd.taskerm.util.x2.t(this.B0, this, c3, null, "checkMatchTimesDays");
for (int i3 = 0; i3 < c3.I0(); i3++) {
if (c3.V0(i3) == 7) {
k2 k2Var = (k2) c3.S0(i3);
int j3 = k2Var.j();
if (j2.q(j3) == 30) {
String j1 = this.p1.j1(k2Var, 0, t2);
if (j1.startsWith(File.separator)) {
file = new File(j1);
} else {
File c1 = dq.c1();
file = c1 != null ? new File(c1, j1) : null;
}
if (file != null && file.exists()) {
Integer W0 = this.p1.W0(k2Var);
if (W0 == null) {
W0 = Integer.valueOf(ih.g(j3, file.isDirectory()));
}
this.X0.add(new ih(this, file.toString(), j3, W0.intValue(), intValue));
}
}
}
}
}
}
private void x9() {
synchronized (this.M0) {
try {
if (this.L0 == null) {
boolean z2 = false;
boolean V6 = V6(false);
r7.f("M", "startUAAA: need alarm: " + V6);
if (V6) {
this.E = System.currentTimeMillis();
boolean V3 = Settings.V3(this);
if (V3) {
boolean d3 = pp.d(this);
r7.f("M", "wantMotionDetect: " + V3 + " have: " + d3);
if (d3) {
z2 = h9();
}
}
if (!z2) {
long l4 = l4();
r7.f("M", "not listening SM, set alarm for " + l4);
w9(l4, true);
}
}
} else {
r7.f("M", "don't start user-absent updates alarm / SM listener, alarm already set");
}
} catch (Throwable th2) {
throw th2;
}
}
}
private void y2(boolean z2) {
Cursor cursor;
Cursor cursor2;
String str;
if (!oi.a(this)) {
r7.f("M", "skipping MMS check for non-admin user (crash workaround)");
return;
}
if (dq.z(this, "android.permission.READ_SMS", "McheckMMS")) {
try {
cursor = this.w0.query(Uri.parse("content://mms/inbox"), new String[]{"_id", "date", "sub"}, "read=0", null, "_id");
} catch (Exception e3) {
r7.H("M", "query MMS inbox", e3);
cursor = null;
}
if (cursor == null) {
r7.G("M", "checkMMS: null cursor");
return;
}
String str2 = "content://mms/";
while (cursor.moveToNext()) {
int i3 = cursor.getInt(0);
try {
cursor2 = this.w0.query(Uri.parse(str2 + i3 + "/addr"), new String[]{"address"}, null, null, null);
} catch (Exception e4) {
r7.H("M", "query MMS detail", e4);
cursor2 = null;
}
if (cursor2 == null) {
r7.G("M", "no cursor getting address for MMS ID " + i3);
str = str2;
} else {
if (cursor2.moveToNext()) {
long j3 = cursor.getLong(1) * 1000;
String string = cursor.getString(2);
if (string == null) {
string = "";
}
String str3 = string;
String string2 = cursor2.getString(0);
str = str2;
M7(1, string2, str3, j3);
if (j3 > this.x) {
this.x = j3;
if (z2) {
A8(this, 1, string2, str3, ExtensionsContextKt.w1(this, Integer.valueOf(i3)));
}
}
} else {
str = str2;
r7.f("M", "no cursor entry getting address for MMS ID " + i3);
}
cursor2.close();
}
str2 = str;
}
cursor.close();
}
}
private void y3(int i3, boolean z2) {
String j3;
if (i3 == 411 || i3 == 307 || (j3 = j2.j(i3)) == null) {
return;
}
if (!dq.O1()) {
th.R(this, j3, z2);
} else if (j3.equals(ReceiverStaticPhoneState.class.getName())) {
ReceiverStaticPhoneState.b(z2);
} else if (j3.equals(ReceiverStaticNotification.class.getName())) {
ReceiverStaticNotification.b(z2);
}
}
private void y4(String str, Bundle bundle, List<k2> list) {
String C = j2.C(str);
r7.f("M", "handleEmailReceived: " + str + " -> " + C);
k2 k2Var = new k2(425);
StringBuilder sb = new StringBuilder();
sb.append(C);
sb.append(".intent.extra.FROM");
String sb2 = sb.toString();
String string = bundle.containsKey(sb2) ? bundle.getString(sb2) : "";
String str2 = C + ".intent.extra.SUBJECT";
String string2 = bundle.containsKey(str2) ? bundle.getString(str2) : "";
String str3 = C + ".intent.extra.CC";
String string3 = bundle.containsKey(str3) ? bundle.getString(str3) : "";
String str4 = C + ".intent.extra.ACCOUNT";
String string4 = bundle.containsKey(str4) ? bundle.getString(str4) : "";
k2Var.k0(0, string);
k2Var.k0(1, string2);
k2Var.k0(2, string4);
list.add(k2Var);
Calendar x2 = bh.x();
kq.S1(this, 33, string);
kq.S1(this, 34, string3);
kq.S1(this, 35, string2);
kq.S1(this, 36, bh.i(this, x2));
kq.S1(this, 37, bh.o(x2));
}
private boolean y5() {
return x5(3) || v5(2080);
}
public void y6() {
z2(false, "monitorResume");
}
private void y7(boolean z2) {
NfcAdapter defaultAdapter;
NfcManager y12 = ExtensionsContextKt.y1(this);
J7(41, (y12 == null || (defaultAdapter = y12.getDefaultAdapter()) == null) ? false : defaultAdapter.isEnabled(), z2);
}
public static boolean y8(Context context) {
return new com.joaomgcd.taskerm.util.l6(context).f();
}
@SuppressLint({"MissingPermission"})
private void y9() {
if (com.joaomgcd.taskerm.util.e5.g0(this).A()) {
r7.f("M", "start user-absent cell check");
this.P = true;
LocationManager P3 = P3();
if (P3 != null) {
if (this.Q != null) {
r7.f("M", "hmm, still have cell workaround intent... removing it");
P3.removeProximityAlert(this.Q);
}
if (this.A0.getBoolean("workForLoc", false)) {
r7.f("M", "startUserAbsentCellCheck: register a proximity alarm for cell workaround");
Intent intent = new Intent("xaskdn29021sn1naa");
intent.setComponent(new ComponentName(this, (Class<?>) ReceiverStaticAlwaysOn.class));
PendingIntent service = PendingIntent.getService(this, -1, intent, com.joaomgcd.taskerm.util.k8.g(1342177280, intent));
this.Q = service;
P3.addProximityAlert(0.0d, 0.0d, 1.7014117E38f, x1[9] + 500, service);
}
}
oi.m();
u9(9);
}
}
public void z2(boolean z2, String str) {
r7.f("M", "----------- " + str + ": CHECK MS (UPD: " + z2 + ") ------------- ");
this.y.clear();
this.z.clear();
this.A.clear();
L2(z2);
y2(z2);
if (z2) {
D2(147, z2);
}
r7.f("M", "check MS done");
}
private void z3(boolean z2) {
if (x5(150)) {
boolean z3 = !z2 && u5(150);
th.R(this, USBHandler.class.getName(), z3);
USBHandler.o(this, z3);
}
}
private void z4(Bundle bundle) {
if (bundle == null) {
r7.k("BroadcastDecode", "error no intent extras");
return;
}
String str = (String) dq.w0("BroadcastDecode", bundle, "task_name", String.class, true);
if (str != null) {
r7.f("M", "external call, task name " + str);
Bundle bundle2 = null;
if (!Settings.g1(this)) {
if (!Kid.b(this)) {
dq.e0(this, 2131887512, 2131887278, 1);
}
ExecuteService.F0(this, str, null, false);
r7.k("BroadcastDecode", "external access not enabled");
return;
}
to toVar = this.B0;
if (toVar == null) {
r7.G("M", "handleExternalCall no aptData");
return;
}
tn N = toVar.N(str);
if (N == null) {
r7.f("M", "task " + str + " doesn't exist, read actions from intent");
N = to.X1();
if (P1(N, bundle)) {
N.G(str);
Integer num = (Integer) dq.w0("BroadcastDecode", bundle, "task_priority", Integer.class, false);
if (num != null) {
if (TaskerIntent.e(num.intValue())) {
N.D2(num.intValue());
} else {
r7.G("BroadcastDecode", "task priority out of range, ignoring");
}
}
} else {
N = null;
}
}
if (N == null) {
dq.e0(this, 2131887458, 2131887141, 0);
ExecuteService.F0(this, str, null, false);
return;
}
ArrayList arrayList = (ArrayList) dq.w0("BroadcastDecode", bundle, "params", ArrayList.class, false);
if (arrayList != null) {
if (arrayList.size() == 0) {
r7.G("BroadcastDecode", "ignoring empty param list");
} else {
bundle2 = new Bundle();
for (int i3 = 0; i3 < arrayList.size(); i3++) {
String str2 = (String) arrayList.get(i3);
if (str2 == null) {
r7.G("BroadcastDecode", "ignoring null param value index " + i3);
} else {
String h1 = tn.h1(i3 + 1);
if (!kq.c1(h1)) {
r7.G("BroadcastDecode", "param: " + h1 + ": invalid variable name");
} else if (kq.W0(h1)) {
bundle2.putString(h1, str2);
} else {
r7.G("BroadcastDecode", "param: " + h1 + ": not a local variable name");
}
}
}
}
}
ArrayList arrayList2 = (ArrayList) dq.w0("BroadcastDecode", bundle, "varNames", ArrayList.class, false);
if (arrayList2 != null) {
if (arrayList2.size() == 0) {
r7.G("BroadcastDecode", "ignoring empty names list");
} else {
ArrayList arrayList3 = (ArrayList) dq.w0("BroadcastDecode", bundle, "varValues", ArrayList.class, true);
if (arrayList3 != null) {
if (arrayList3.size() != arrayList2.size()) {
r7.G("BroadcastDecode", "ignoring inconsistent var names and values lists");
} else {
if (bundle2 == null) {
bundle2 = new Bundle();
}
for (int i4 = 0; i4 < arrayList2.size(); i4++) {
String str3 = (String) arrayList2.get(i4);
String str4 = (String) arrayList3.get(i4);
if (str3 == null) {
r7.G("BroadcastDecode", "ignoring null var name index " + i4);
} else if (str4 == null) {
r7.G("BroadcastDecode", "ignoring null var value index " + i4);
} else if (!kq.c1(str3)) {
r7.G("BroadcastDecode", "var: " + str3 + ": invalid name");
} else if (kq.W0(str3)) {
bundle2.putString(str3, str4);
} else {
r7.G("BroadcastDecode", "var: " + str3 + ": not a local variable name");
}
}
}
}
}
}
ExecuteService.d6(this, N, 2, -1, -1, -1, null, null, "external", bundle2);
}
}
public boolean z5(int i3) {
return c2[i3] != null;
}
public void z6(int i3, String str) {
if (!Q6(i3)) {
r7.f("M", y1[i3] + ": " + str + ": monitor restart: not running");
return;
}
if (!this.s[i3]) {
J9(i3, "resume");
r7.f("M", y1[i3] + ": " + str + ": monitor restart: not needed, stop");
return;
}
if (i3 != 5) {
r7.f("M", y1[i3] + ": " + str + ": monitor resumption");
}
switch (i3) {
case 0:
N1(true);
break;
case 1:
e9("gps");
u9(1);
break;
case 2:
e9("network");
u9(2);
break;
case 3:
u9(3);
if (!z9(R6(0))) {
D2(170, true);
break;
}
break;
case 4:
T8();
break;
case 5:
u9(0);
break;
case ClockContract.InstancesColumns.MISSED_STATE:
i9(true);
break;
case 7:
l9(false);
this.X0.clear();
x8();
l9(true);
break;
case 8:
dq.r1(this, true, false);
break;
case 9:
j9(true);
break;
case 10:
p9(true);
break;
case 11:
MyAccessibilityService.s(this.U);
break;
case 12:
h7(true);
break;
case 13:
I6(true);
break;
case 14:
if (this.w == -2) {
this.w = -1L;
s3(new Runnable() {
@Override
public final void run() {
MonitorService.this.y6();
}
}, "resumeMonitorIfNecessary");
}
m9(true);
break;
case 15:
Z8(true);
break;
case 16:
b7(true);
break;
case 17:
O6(true);
break;
case 18:
k9(true);
break;
case 19:
Q9(true);
break;
case 20:
u9(11);
if (!c9()) {
D2(4, true);
break;
}
break;
case 21:
B5(true);
break;
case 22:
E9(true);
break;
case 23:
s9(true);
break;
case 24:
A5(true);
break;
case 25:
this.p1.G0(this.B0, this.n1);
break;
case 26:
this.p1.C0(this.o1);
break;
default:
r7.k("M", "bad monitor: " + i3);
break;
}
}
@SuppressLint({"MissingPermission"})
public void z7(boolean z2) {
if (com.joaomgcd.taskerm.util.e5.v(this).A() && dq.z(this, "android.permission.READ_CALL_LOG", "MrecordOutgoingCall")) {
try {
Cursor query = this.w0.query(CallLog.Calls.CONTENT_URI, new String[]{"number", "date", "duration"}, dq.Z1(new String[]{"type=2", "new=1"}), null, "date DESC");
if (query == null) {
r7.G("M", "recordOutgoingCall: null cursor from CallLog");
return;
}
if (query.moveToFirst()) {
String string = query.getString(0);
long j3 = query.getLong(1);
kq.S1(this, 15, string);
kq.S1(this, 13, String.valueOf(query.getLong(2)));
kq.S1(this, 12, bh.h(this, j3));
kq.S1(this, 16, bh.m(j3));
String r2 = eh.r(this, string, "display_name");
if (!TextUtils.isEmpty(r2)) {
string = r2;
}
kq.S1(this, 14, string);
}
query.close();
} catch (Exception e3) {
r7.l("M", "recordOutgoingCall", e3);
}
}
}
public static void z8(Context context, boolean z2) {
if (!z2 || dq.L2(context, MonitorService.class.getName())) {
Intent intent = new Intent(context, (Class<?>) MonitorService.class);
intent.putExtra("eventType", 9987);
J6(context, intent);
}
}
private boolean z9(boolean z2) {
if (this.y0 == null) {
r7.k("M", vh.g(this, 2131887723, new Object[0]));
} else if (this.Z != 0) {
r7.f("M", "start wifi scan: already scanning");
} else {
X2(170);
int wifiState = this.y0.getWifiState();
if (wifiState == 4) {
r7.f("M", "startWifiScan: wifi state unknown, continuing anyway");
} else {
WifiManager.WifiLock wifiLock = this.Y;
if (wifiLock == null) {
wifiLock = this.y0.createWifiLock(2, "Tasker.MonitorService");
this.Y = wifiLock;
} else {
r7.G("M", "already had wifiLock...");
}
if (wifiLock == null) {
r7.G("M", "failed to acquire wifi lock");
} else if (wifiLock.isHeld()) {
r7.G("M", "already held wifi lock");
} else {
wifiLock.setReferenceCounted(false);
wifiLock.acquire();
}
if (z2 && wifiState != 1 && wifiState != 2) {
r7.f("M", "skip wifi enable, not currently DISABLED or ENABLING");
z2 = false;
}
if (z2) {
int a3 = yd.x.b(this) ? yd.d1.a(this.y0) : 1;
r7.f("M", "wifi enable: tether state: " + a3);
if (a3 == 2 || a3 == 3) {
r7.f("M", "skip wifi enable, wifi tether enabl(ed|ing)");
z2 = false;
}
}
if (z2) {
boolean z3 = wifiState == 2;
if (z3 || this.y0.setWifiEnabled(true)) {
this.Z = 1;
if (!z3) {
Q8(true, "startWifiScan");
}
R1 = System.currentTimeMillis();
S1 = 0L;
u9(5);
} else {
r7.G("M", "failed to start wifi enable process");
}
}
if (this.Z != 1) {
A9();
}
}
}
return this.Z != 0;
}
public void C2(Integer num) {
HashSet hashSet = new HashSet();
hashSet.add(num);
F2(hashSet, true);
}
public void C4(SensorEvent sensorEvent) {
try {
float f3 = sensorEvent.values[0];
if (x5(103)) {
if (f3 < h2) {
r7.f("M", "new min level " + h2 + "->" + f3);
h2 = f3;
u7("lmi", f3);
}
if (f3 > i2) {
r7.f("M", "new max level " + i2 + "->" + f3);
i2 = f3;
u7("lma", f3);
}
float f4 = i2;
float f5 = h2;
if (f4 <= f5) {
r7.f("M", "ignoring light sensor readig " + f3 + ", max <= min " + i2 + " < " + h2);
} else {
double d3 = 0.0d;
double log = f5 <= 1.0f ? 0.0d : Math.log(f5);
double log2 = Math.log(i2);
if (f3 > 1.0f) {
d3 = Math.log(f3);
}
r7.f("M", "lmn " + log + " lmx " + log2 + " llvl " + d3);
int i3 = (int) (((d3 - log) / (log2 - log)) * 100.0d);
r7.f("M", "light: acc: " + sensorEvent.accuracy + " level " + f3 + " min " + h2 + " max " + i2 + " %" + i3);
D7(24, i3, true);
}
}
kq.S1(this, 50, String.valueOf(f3));
} catch (Exception e3) {
r7.H("M", "onSensorChanged (light)", e3);
}
}
public void D2(int i3, boolean z2) {
E2(i3, null, z2);
}
public void E4(boolean z2) {
rh[] rhVarArr;
ConnectivityManager connectivityManager = (ConnectivityManager) oi.d(this, "connectivity", "M", "hnce");
int[] iArr = {12, 1, 39, 50};
String[][] strArr = new String[4][];
if (connectivityManager != null) {
if (rh.b()) {
rhVarArr = rh.a(connectivityManager);
} else {
rh rhVar = new rh();
rh[] rhVarArr2 = {rhVar};
rhVar.b = connectivityManager.getActiveNetworkInfo();
rhVarArr2[0].a = true;
rhVarArr = rhVarArr2;
}
for (rh rhVar2 : rhVarArr) {
NetworkInfo networkInfo = rhVar2.b;
if (networkInfo != null && networkInfo.isConnected()) {
int type = networkInfo.getType();
if (type != 0) {
if (type == 1) {
r7.f("M", "wifi connection, major type: " + type);
WifiManager wifiManager = this.y0;
if (wifiManager != null) {
WifiInfo connectionInfo = wifiManager.getConnectionInfo();
if (connectionInfo == null) {
r7.G("M", "no wifi connection info");
} else {
strArr[0] = new String[]{String.valueOf(rhVar2.a), connectionInfo.getSSID(), connectionInfo.getBSSID(), dq.K1(connectionInfo.getIpAddress())};
}
}
} else if (type == 6) {
r7.f("M", "wimax net connection, major type: " + type);
strArr[1] = new String[]{String.valueOf(rhVar2.a), String.valueOf(4)};
} else if (type == 9) {
r7.f("M", "ethernet connection, major type: " + type);
strArr[2] = new String[]{String.valueOf(rhVar2.a)};
} else if (type == 17) {
r7.f("M", "VPN connection, major type: " + type);
strArr[3] = new String[]{String.valueOf(rhVar2.a)};
}
} else if (x5(110)) {
r7.f("M", "mobile net connection, major type: " + type);
strArr[1] = new String[]{String.valueOf(rhVar2.a), String.valueOf(U3())};
}
}
}
for (int i3 = 0; i3 < 4; i3++) {
int i4 = iArr[i3];
if (x5(v1[i4])) {
L7(i4, strArr[i3], z2);
}
}
}
}
public void G4(int i3, k2 k2Var) {
L5(i3, k2Var, null);
}
public void G7(int i3, String str, boolean z2) {
H7(i3, str, z2, false);
}
public void L5(int i3, k2 k2Var, Bundle bundle) {
List<Integer> arrayList;
int j3 = k2Var.j();
if (i3 != -1) {
arrayList = new ArrayList<>();
arrayList.add(Integer.valueOf(i3));
} else if (v5(j3)) {
arrayList = this.V0.get(Integer.valueOf(j3));
} else {
if (j3 == 201) {
dq.e0(this, 2131891164, 2131887968, 1);
} else if (j3 != 453 && j3 != 451 && j3 != 450 && j3 != 411 && j3 != 6 && j3 != 4 && j3 != 2 && j3 != 210 && j3 != 1000 && j3 != 208 && j3 != 134 && j3 != 3050 && j3 != 3060 && j3 != 2005 && j3 != 2010 && j3 != 413 && j3 != 463 && j3 != 7 && j3 != 461 && j3 != 464 && !ze.h.f(j3)) {
r7.k("M", "got system event (" + j3 + ") with no relevant conIDs");
}
arrayList = null;
}
if (arrayList == null) {
r7.f("M", "handleSystemEvent: no profiles");
return;
}
for (int i4 = 0; i4 < arrayList.size(); i4++) {
Integer num = arrayList.get(i4);
int intValue = num.intValue();
if (this.B0.V(intValue)) {
wo c3 = this.B0.c(intValue);
if (c3.h1()) {
k2 k2Var2 = (k2) c3.T0(7);
Bundle K0 = com.joaomgcd.taskerm.util.x2.K0(com.joaomgcd.taskerm.util.x2.t(this.B0, this, c3, bundle, "handleOccuredEvent"));
if (k2Var2 != null && k2Var2.W0(k2Var, this, this.w0, K0) && w2(c3, k2Var, K0)) {
g2.put(num, Long.valueOf(System.currentTimeMillis()));
}
if (k2Var2 != null) {
k2Var2.s0();
}
}
} else {
r7.G("M", "handleSystemEvent: unknown profile ID " + intValue + " from event pid " + i3 + ", code" + j3);
}
}
}
public void I4(final int i3, final k2 k2Var, final Bundle bundle) {
pg.w0.i0(this.p1.Y0().e(), new Runnable() {
@Override
public final void run() {
MonitorService.this.L5(i3, k2Var, bundle);
}
});
}
public net.dinglisch.android.taskerm.k2 L4(java.lang.String r5) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.L4(java.lang.String):net.dinglisch.android.taskerm.k2");
}
public boolean P1(tn tnVar, Bundle bundle) {
String str;
String str2;
Class cls;
Bundle bundle2 = bundle;
String str3 = "action1";
boolean z2 = false;
if (!bundle2.containsKey("action1")) {
r7.k("BroadcastDecode", "no valid actions found");
return false;
}
int i3 = 1;
while (bundle2.containsKey(str3)) {
Bundle bundle3 = (Bundle) dq.w0("BroadcastDecode", bundle2, str3, Bundle.class, z2);
String str4 = "action";
if (bundle3 == null) {
str = "action";
} else {
if (!bundle3.containsKey("action")) {
r7.k("BroadcastDecode", "no action name specified for action no " + i3);
return false;
}
int i4 = bundle3.getInt("action");
if (i4 >= 1000) {
r7.k("BroadcastDecode", "plugins barred from external calls: " + i4);
return z2;
}
if (!a1.c(i4)) {
r7.k("BroadcastDecode", "unknown action code: " + i4);
return z2;
}
if (a1.q(i4)) {
r7.k("BroadcastDecode", "deprecated action code: " + i4);
return z2;
}
if (!a1.m(i4)) {
r7.k("BroadcastDecode", "action barred from external calls: " + i4);
return z2;
}
String v2 = a1.v(i4);
net.dinglisch.android.taskerm.c cVar = new net.dinglisch.android.taskerm.c(i4);
int Y = cVar.Y();
String str5 = "arg:";
if (i4 == 547) {
try {
String str6 = "arg:" + Integer.toString(5);
String str7 = "arg:" + Integer.toString(6);
String str8 = "arg:" + Integer.toString(7);
if (!bundle3.containsKey(str6)) {
String str9 = "arg:" + Integer.toString(4);
String str10 = "arg:" + Integer.toString(3);
bundle3.putBoolean(str6, bundle3.getBoolean(str9));
bundle3.putBoolean(str9, bundle3.getBoolean(str10));
bundle3.putBoolean(str10, new Boolean(false).booleanValue());
}
if (!bundle3.containsKey(str7)) {
bundle3.putInt(str7, 3);
}
if (!bundle3.containsKey(str8)) {
bundle3.putBoolean(str8, false);
}
} catch (Exception e3) {
r7.H("M", "addActionsFromExternalCall: failed to adapt variable set action to new format", e3);
}
}
int i5 = 1;
while (i5 <= Y) {
String str11 = str5 + Integer.toString(i5);
if (!bundle3.containsKey(str11)) {
r7.k("BroadcastDecode", "missing arg no " + str11 + " for action " + v2);
return false;
}
Object obj = bundle3.get(str11);
if (obj == null) {
r7.k("BroadcastDecode", "null arg no " + str11 + " for action " + v2);
return false;
}
int i6 = i5 - 1;
int C = a1.C(i4, i6);
Bundle bundle4 = bundle3;
String str12 = str5;
if (C != 0) {
str2 = str4;
if (C != 1 && C != 2) {
if (C == 3) {
cls = Boolean.class;
} else if (C != 4) {
cls = null;
}
}
cls = String.class;
} else {
str2 = str4;
cls = Integer.class;
}
Class<?> cls2 = obj.getClass();
if (!cls.equals(cls2)) {
r7.k("BroadcastDecode", "bad arg class for arg " + i5 + " (" + cls2.getName() + ", expected " + cls.getName() + ")");
return false;
}
if (cls2 == String.class) {
String str13 = (String) obj;
if (str13.startsWith("app:")) {
if (str13.length() <= 4) {
r7.G("M", "app arg: empty");
return false;
}
String[] split = str13.substring(4).split(",");
cVar.i1(i6, split[0], split[1], "-");
} else {
if (str13.startsWith("icn:")) {
r7.k("BroadcastDecode", "unhandled arg type: icon");
return false;
}
cVar.k0(i6, str13);
}
} else if (cls2 == Integer.class) {
cVar.s1(i6, ((Integer) obj).intValue());
} else {
if (cls2 != Boolean.class) {
r7.k("BroadcastDecode", "action: " + i4 + " arg: " + str11 + ": bad type: " + cls2.getName());
return false;
}
cVar.m1(i6, ((Boolean) obj).booleanValue());
}
i5++;
bundle3 = bundle4;
str5 = str12;
str4 = str2;
}
str = str4;
if (i5 != Y + 1) {
return false;
}
tnVar.a0(cVar);
}
i3++;
str3 = str + Integer.toString(i3);
bundle2 = bundle;
z2 = false;
}
return true;
}
public LocationListener Q3(String str) {
return new p(str);
}
public boolean R6(int i3) {
return this.m0[i3];
}
public void S1(z zVar) {
synchronized (this.u) {
this.u.add(zVar);
}
}
public void V7(int i3, String... strArr) {
final String str;
wo c3 = this.B0.c(i3);
k2 k2Var = (k2) c3.T0(7);
IntentFilter m4 = m4(c3, k2Var);
try {
str = m4.getAction(0);
} catch (Throwable unused) {
str = null;
}
if (str == null || !com.joaomgcd.taskerm.util.x2.H(strArr, new xj.l() {
@Override
public final Object invoke(Object obj) {
Boolean r6;
r6 = MonitorService.r6(str, (String) obj);
return r6;
}
})) {
ReceiverDynamicUser receiverDynamicUser = new ReceiverDynamicUser(k2Var.Z0(), this.B0.c(i3), str);
ExtensionsContextKt.V2(this, receiverDynamicUser, m4);
this.a1.add(receiverDynamicUser);
}
}
public int W4(final Intent intent, int i3) {
if (intent == null) {
r7.f("M", "ignoring null intent");
} else if (this.A0 == null) {
r7.f("M", "skipping start ID " + i3 + ", no prefs -> creation failed");
} else {
String action = intent.getAction();
if (action != null) {
if (action.equals("net.dinglisch.android.tasker.SS")) {
wl.A0(this, intent.getDataString(), intent.getExtras());
} else if (action.equals("net.dinglisch.android.tasker.CE")) {
wl.m(this, intent.getDataString(), intent);
} else if (action.equals("net.dinglisch.android.tasker.DE")) {
wl.u(this, intent.getDataString(), intent);
} else if (action.equals("net.dinglisch.android.tasker.ICOMUM")) {
U4(intent);
} else if (action.equals("net.dinglisch.android.tasker.PREFUM")) {
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.M5(intent);
}
}, "handlePrefsIntent");
} else if (intent.hasExtra("UserIntentPIDExtra")) {
p5(intent);
}
}
if (this.g1 != null) {
Q1(intent, i3, true);
}
}
r7.h("M", "handleStart: finished handling ID " + i3, true);
if (!U9(10)) {
zq.k(this, "M");
}
return 1;
}
public void i6(Intent intent) {
try {
Bundle extras = intent.getExtras();
Bundle d3 = com.joaomgcd.taskerm.util.f1.d(extras.getBundle("eventExt"));
String string = extras.getString("eventAct");
String string2 = extras.getString("eventDt");
String string3 = extras.getString("eventOrigIntent");
int i3 = extras.getInt("eventConID", -1);
List<k2> Y6 = Y6(string, string2, d3, i3, string3);
r7.f("M", "occurred event count: " + Y6.size() + " with action: " + string);
Iterator<k2> it = Y6.iterator();
while (it.hasNext()) {
G4(i3, it.next());
}
} catch (Exception e3) {
r7.l("M", "handleSystemEvent", e3);
}
}
public void X9(BroadcastReceiver broadcastReceiver, String str) {
if (broadcastReceiver == null) {
return;
}
try {
unregisterReceiver(broadcastReceiver);
} catch (Exception e3) {
r7.H("M", "Couldn't unregister receiver " + str, e3);
}
}
java.util.List<net.dinglisch.android.taskerm.k2> Y6(java.lang.String r20, java.lang.String r21, android.os.Bundle r22, int r23, java.lang.String r24) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.Y6(java.lang.String, java.lang.String, android.os.Bundle, int, java.lang.String):java.util.List");
}
public int Z3() {
String str = this.v;
if (str == null) {
if (this.A0.contains("ipn")) {
String a3 = li.a(this.A0.getInt("ipn", -1));
r2 = a3 != null ? a3 : null;
this.A0.edit().remove("ipn").commit();
}
str = r2;
if (str == null) {
str = this.A0.getString("cust_notification", M3(this));
r7.f("M", "null, get default name: " + str);
}
}
if (!Kid.a()) {
str = tp.u(this, str);
}
return getResources().getIdentifier(str, "drawable", Kid.b(this) ? th.B() : getPackageName());
}
public void Z4(int i3) {
if (i3 != 0) {
r7.f("M", "!!! timer ding: " + w1[i3]);
}
switch (i3) {
case 0:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.a5();
}
}, "handleTimerAppCheck");
break;
case 1:
f5();
break;
case 2:
g5();
break;
case 3:
l5();
break;
case 4:
i5();
break;
case 5:
m5();
break;
case ClockContract.InstancesColumns.MISSED_STATE:
k5();
break;
case 7:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.n5();
}
}, "handleTimerWifiTimeout");
break;
case 8:
j5();
break;
case 9:
e5();
break;
case 10:
h5();
break;
case 11:
b5();
break;
case 12:
c5();
break;
case 13:
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.d5();
}
}, "handleTimerBTTimeout");
break;
}
}
@android.annotation.TargetApi(26)
public android.app.Notification Z9(boolean r17, boolean r18) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.Z9(boolean, boolean):android.app.Notification");
}
public void a9(int i3, ho hoVar, String str) {
synchronized (this.u) {
try {
r7.f("M", "sig context change: " + str + ": pid: " + i3 + " cType: " + hoVar.B0());
wo c3 = this.B0.c(i3);
if (c3 != null) {
r7.f("M", "sig context change pid: " + c3.C0() + " cType: " + hoVar.B0() + " enabled: " + c3.h1() + " active: " + hoVar.G0());
for (Object obj : this.u.toArray()) {
((z) obj).a(i3, hoVar.B0(), c3.h1(), hoVar.G0());
}
}
} catch (Throwable th2) {
throw th2;
}
}
}
public synchronized List<ReceiverDynamic> c4() {
return this.b1;
}
public void d8(z zVar) {
synchronized (this.u) {
int i3 = 0;
while (true) {
try {
if (i3 >= this.u.size()) {
break;
}
if (this.u.get(i3) == zVar) {
this.u.remove(i3);
break;
}
i3++;
} catch (Throwable th2) {
throw th2;
}
}
}
}
public boolean e7(int i3) {
try {
d7(i3).B(30L, TimeUnit.SECONDS).h();
return true;
} catch (RuntimeException e3) {
Throwable cause = e3.getCause();
if (cause == null) {
com.joaomgcd.taskerm.util.o2.h(e3, this, "processInboxSync runtime");
}
if (cause instanceof InterruptedException) {
r7.f("M", "Interrupted while processing inbox: " + cause);
}
if (!(cause instanceof TimeoutException)) {
return false;
}
r7.f("M", "Timeout while processing inbox: " + cause);
return false;
} catch (Exception e4) {
com.joaomgcd.taskerm.util.o2.h(e4, this, "processInboxSync");
return false;
}
}
public void o7() {
s3(new Runnable() {
@Override
public final void run() {
MonitorService.this.p6();
}
}, "queryState");
}
@Override
public void onConfigurationChanged(final Configuration configuration) {
w3(new Runnable() {
@Override
public final void run() {
MonitorService.this.b6(configuration);
}
}, "onConfigurationChanged");
}
@Override
public void onCreate() {
com.joaomgcd.taskerm.util.p.s(this, Integer.MAX_VALUE);
RunLog.N0(this, dq.R0(this), RunLog.i.Start);
super.onCreate();
this.p1.I();
if (!Kid.b(this) && !dq.O(this, "autobackup.xml")) {
F4();
RunLog.N0(this, dq.R0(this), RunLog.i.StartFail);
} else {
this.A0 = getSharedPreferences(g6.g, 0);
I8(false);
s3(new Runnable() {
@Override
public final void run() {
r7.f("M", "------------------ MONITOR ASYNC STARTUP COMPLETE -----------------");
}
}, "onCreate");
}
}
@Override
public void onDestroy() {
r7.f("M", "onDestroy");
RunLog.N0(this, dq.R0(this), RunLog.i.Stop);
if (this.g1 != null) {
R9();
Iterator<wo> it = this.Y0.iterator();
while (it.hasNext()) {
it.next().b0();
}
q3(this.B0, this.Y0, true, false);
}
c8();
U2();
this.u.clear();
H9();
j2();
this.q1 = null;
this.p1.J();
super.onDestroy();
if (zq.j("Sensor")) {
zq.k(this, "Sensor");
}
if (zq.j("M")) {
zq.k(this, "M");
}
r7.f("M", "onDestroy done");
}
@Override
public void onLowMemory() {
super.onLowMemory();
r7.G("M", "low memory reported");
}
@Override
public void onStart(Intent intent, int i3) {
W4(intent, i3);
}
@Override
public int onStartCommand(Intent intent, int i3, int i4) {
return W4(intent, i4);
}
@Override
public void onTaskRemoved(Intent intent) {
int g3 = dq.g();
if (g3 < 16 || g3 >= 21) {
return;
}
r7.f("M", "task removed, send dummy activity intent");
try {
startActivity(DummyActivity.a(this));
} catch (Exception e3) {
r7.l("M", "onTaskRemoved: JB workaround", e3);
}
}
public void r5(String str, Bundle bundle, ArrayList<k2> arrayList, String str2) {
boolean equals = str.equals("net.dinglisch.android.tasker.VSETUM");
final String string = bundle.getString("vname");
final String str3 = null;
String Y12 = kq.V0(string) ? kq.Y1(string) : null;
if (string == null) {
r7.f("M", "handleVarSetOrCleared null var name '" + str2 + "'");
return;
}
k2 k2Var = new k2(equals ? 3050 : 3060);
k2Var.k0(0, string);
final String string2 = bundle.getString("sc");
if (string2 != null) {
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.Q5(string2, string);
}
});
return;
}
if (equals) {
str3 = bundle.containsKey("vvalue") ? bundle.getString("vvalue") : kq.B0(this, string);
k2Var.k0(1, str3);
}
arrayList.add(k2Var);
HashSet hashSet = new HashSet();
if (this.B0 != null) {
for (int i3 : on.c) {
Integer valueOf = Integer.valueOf(i3);
if (this.W0.containsKey(valueOf)) {
Iterator<Integer> it = this.W0.get(valueOf).iterator();
while (it.hasNext()) {
wo c3 = this.B0.c(it.next().intValue());
if (c3 != null) {
for (int i4 = 4; i4 <= 6; i4++) {
if (c3.Z0(i4)) {
pn pnVar = (pn) c3.T0(i4);
if (pnVar.C1(string) || (Y12 != null && pnVar.C1(Y12))) {
hashSet.add(valueOf);
break;
}
}
}
}
}
}
}
}
if (x5(143) && string.equals(kq.I0(77))) {
I7(29, ExecuteService.K4(), false);
hashSet.add(143);
}
F2(hashSet, true);
this.p1.m(new Runnable() {
@Override
public final void run() {
MonitorService.this.P5(string, str3);
}
});
this.n1.m(string);
yi.k();
if (T2(string) || Y12 == null) {
return;
}
T2(Y12);
}
public void s3(Runnable runnable, String str) {
r7.f("M", "Doing in background after init: " + str);
this.p1.Z(t3().u(this.p1.t()), runnable);
}
public boolean s5(int i3) {
if (i3 == 165) {
return true;
}
vg.e<?, ?, ?, ?, ?> c3 = vg.j.c(i3);
if (c3 == null) {
return false;
}
return c3.e();
}
public ji.b t4(final BluetoothDevice bluetoothDevice, final int i3, final String str) {
HelperMonitorService helperMonitorService = this.p1;
return helperMonitorService.j(helperMonitorService.y(), new Runnable() {
@Override
public final void run() {
MonitorService.this.K5(bluetoothDevice, str, i3);
}
});
}
public boolean t5(int i3) {
to toVar;
Map<Integer, List<Integer>> map = this.V0;
if (map == null || (toVar = this.B0) == null || !v5(i3)) {
return false;
}
Iterator<Integer> it = map.get(Integer.valueOf(i3)).iterator();
while (it.hasNext()) {
wo c3 = toVar.c(it.next().intValue());
if (c3 != null && c3.h1()) {
return true;
}
}
return false;
}
public boolean t9(boolean z2) {
if (!z2) {
if (zq.j("Tasker.UserAbsentWakelock")) {
if (zq.i("Tasker.UserAbsentWakelock")) {
this.S = true;
}
zq.k(this, "Tasker.UserAbsentWakelock");
}
K9(4);
return true;
}
if (!u9(4)) {
r7.G("M", "couldn't start " + w1[4] + ", not acquiring lock");
return false;
}
if (!this.A0.getBoolean("wakeForLoc", false) || (!this.s[2] && !S6())) {
zq.e(this, "Tasker.UserAbsentWakelock");
return true;
}
this.R = true;
zq.b(this, "Tasker.UserAbsentWakelock");
return true;
}
public boolean u5(int i3) {
Map<Integer, List<Integer>> map;
to toVar = this.B0;
if (toVar == null || !x5(i3) || (map = this.W0) == null) {
return false;
}
Iterator<Integer> it = map.get(Integer.valueOf(i3)).iterator();
while (it.hasNext()) {
wo c3 = toVar.c(it.next().intValue());
if (c3 != null && c3.h1()) {
return true;
}
}
return false;
}
public void w3(Runnable runnable, String str) {
p3(runnable, (com.joaomgcd.taskerm.util.h3) this.p1.Y0().getValue(), str);
}
public boolean w5(Intent intent) {
int match;
if (intent != null && this.V0.containsKey(599)) {
Iterator<Integer> it = this.V0.get(599).iterator();
while (it.hasNext()) {
wo c3 = this.B0.c(it.next().intValue());
k2 k2Var = (k2) c3.T0(7);
if (k2Var.Z0() && (match = m4(c3, k2Var).match(getContentResolver(), intent, false, "M")) != -4 && match != -3 && match != -2 && match != -1) {
return true;
}
}
}
return false;
}
public void w7(android.view.KeyEvent r6) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.MonitorService.w7(android.view.KeyEvent):void");
}
}