ModV2.0.4 v1.86526672844804版本的 MD5 值为:ab8437a2d03fc69805a8b4199bd7fecb

以下内容为反编译后的 al.java 源代码,内容仅作参考


package com.joaomgcd.taskerm.util;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Dialog;
import android.app.SearchManager;
import android.app.Service;
import android.app.UiModeManager;
import android.app.admin.DevicePolicyManager;
import android.app.role.RoleManager;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager;
import android.companion.CompanionDeviceManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.content.pm.SigningInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.projection.MediaProjectionManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.nfc.NfcManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.LocaleList;
import android.os.PowerManager;
import android.os.Vibrator;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import androidx.core.app.NotificationCompat;
import com.google.android.gms.maps.g;
import com.joaomgcd.taskerm.b.a;
import com.joaomgcd.taskerm.genericaction.ActivityGenericAction;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityGetActivity;
import com.joaomgcd.taskerm.helper.HelperMonitorService;
import com.joaomgcd.taskerm.keyboard.InputMethodServiceTasker;
import com.joaomgcd.taskerm.notification.aw;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import cyanogenmod.alarmclock.ClockContract;
import java.io.File;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import net.danlew.android.joda.R;
import net.dinglisch.android.tasker.InputToggleWifi;
import net.dinglisch.android.taskerm.HasArgsEdit;
import net.dinglisch.android.taskerm.IntentHandler;
import net.dinglisch.android.taskerm.Kid;
import net.dinglisch.android.taskerm.Main;
import net.dinglisch.android.taskerm.Tasker;
import net.dinglisch.android.taskerm.av;
import net.dinglisch.android.taskerm.bh;
import net.dinglisch.android.taskerm.bw;
import net.dinglisch.android.taskerm.cc;
import net.dinglisch.android.taskerm.go;
import net.dinglisch.android.taskerm.gs;
import net.dinglisch.android.taskerm.gu;
import net.dinglisch.android.taskerm.gx;
public final class al {
    private static String f9266a;
    private static String f9267b = null;

    @TargetApi(26)
    public static final boolean K(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return false;
    }

    public static final void a(Context context, String str, boolean z) {
        a(context, str, z, false, false, 12, (Object) null);
    }

    public static final Object b(Context context, String str, String str2) {
        return a(context, str, str2, (File[]) null, 4, (Object) null);
    }

    public static final void i(Context context, String str) {
        a(context, str, false, false, false, 14, (Object) null);
    }

    public static final String a(Context context) {
        c.f.b.k.b(context, "receiver$0");
        if (!Kid.a() && com.joaomgcd.oldtaskercompat.b.a(context)) {
            return an.a((int) R.string.tasky, context, new Object[0]);
        }
        String a2 = a(context, context.getPackageName(), (String) null);
        return a2 != null ? a2 : an.a((int) R.string.app_name, context, new Object[0]);
    }

    public static ApplicationInfo a(Context context, String str, int i2, int i3, Object obj) {
        if ((i3 & 2) != 0) {
            i2 = 0;
        }
        return a(context, str, i2);
    }

    public static final ApplicationInfo a(Context context, String str, int i2) {
        c.f.b.k.b(context, "receiver$0");
        if (str == null) {
            return null;
        }
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager != null) {
                return packageManager.getApplicationInfo(str, i2);
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    public static String a(Context context, String str, String str2, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str2 = str;
        }
        return a(context, str, str2);
    }

    public static final class f extends c.f.b.l implements c.f.a.a<String> {
        final Context f9276a;
        final ApplicationInfo f9277b;

        f(Context context, ApplicationInfo applicationInfo) {
            super(0);
            this.f9276a = context;
            this.f9277b = applicationInfo;
        }

        @Override
        public final String invoke() {
            CharSequence applicationLabel;
            PackageManager packageManager = this.f9276a.getPackageManager();
            if (packageManager == null || (applicationLabel = packageManager.getApplicationLabel(this.f9277b)) == null) {
                return null;
            }
            return applicationLabel.toString();
        }
    }

    public static final String a(Context context, String str, String str2) {
        String str3;
        c.f.b.k.b(context, "receiver$0");
        ApplicationInfo a2 = a(context, str, 0, 2, (Object) null);
        return (a2 == null || (str3 = (String) an.a((c.f.a.b) null, new f(context, a2), 1, (Object) null)) == null) ? str2 : str3;
    }

    public static PackageInfo b(Context context, String str, int i2, int i3, Object obj) {
        if ((i3 & 2) != 0) {
            i2 = 0;
        }
        return b(context, str, i2);
    }

    public static final PackageInfo b(Context context, String str, int i2) {
        c.f.b.k.b(context, "receiver$0");
        if (str == null) {
            return null;
        }
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager != null) {
                return packageManager.getPackageInfo(str, i2);
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    public static final List<ApplicationInfo> b(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return context.getPackageManager().getInstalledApplications(128);
    }

    public static final boolean a(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        return net.dinglisch.android.taskerm.cr.g(context.getPackageManager(), str);
    }

    public static final String b(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        PackageInfo b2 = b(context, str, 0, 2, (Object) null);
        if (b2 != null) {
            return b2.versionName;
        }
        return null;
    }

    public static final String c(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return b(context, context.getPackageName());
    }

    public static final TaskerApp d(Context context) {
        c.f.b.k.b(context, "receiver$0");
        Context applicationContext = context.getApplicationContext();
        if (applicationContext != null) {
            return (TaskerApp) applicationContext;
        }
        throw new c.q("null cannot be cast to non-null type com.joaomgcd.taskerm.util.TaskerApp");
    }

    public static final int e(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return d(context).a();
    }

    public static final Integer c(Context context, String str) {
        ApplicationInfo applicationInfo;
        c.f.b.k.b(context, "receiver$0");
        PackageInfo b2 = b(context, str, 0, 2, (Object) null);
        if (b2 == null || (applicationInfo = b2.applicationInfo) == null) {
            return null;
        }
        return Integer.valueOf(applicationInfo.targetSdkVersion);
    }

    public static final Integer a(Context context, ComponentName componentName) {
        c.f.b.k.b(context, "receiver$0");
        return c(context, componentName != null ? componentName.getPackageName() : null);
    }

    public static final boolean f(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return gs.j(context);
    }

    public static final ComponentName g(Context context) {
        c.f.b.k.b(context, "receiver$0");
        Intent b2 = an.b(new Intent("android.intent.action.VIEW", Uri.parse("https://joaoapps.com")), context);
        if (b2 != null) {
            return b2.getComponent();
        }
        return null;
    }

    public static final SharedPreferences h(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return gs.h(context);
    }

    public static final long i(Context context) {
        c.f.b.k.b(context, "receiver$0");
        if (h(context).getLong(bh.o.f12242b, -1L) == -1) {
            return System.currentTimeMillis();
        }
        return h(context).getLong(bh.o.f12242b, -1L);
    }

    public static final long j(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (System.currentTimeMillis() - i(context)) / 86400000;
    }

    public static final boolean k(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return Kid.a(context);
    }

    public static final boolean a(Context context, String... strArr) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(strArr, "features");
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            for (String str : strArr) {
                if (packageManager.hasSystemFeature(str)) {
                    return true;
                }
            }
            return false;
        }
        return false;
    }

    public static final boolean l(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return bw.al.a(context);
    }

    public static final boolean m(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return g(context, "android.permission.WRITE_SECURE_SETTINGS");
    }

    public static final boolean n(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return m(context);
    }

    public static final class o extends c.f.b.l implements c.f.a.a<String> {
        final Context f9293a;

        o(Context context) {
            super(0);
            this.f9293a = context;
        }

        @Override
        public final String invoke() {
            return Settings.Secure.getString(this.f9293a.getContentResolver(), com.joaomgcd.taskerm.securesettings.f.a());
        }
    }

    public static final String o(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (String) an.a((c.f.a.b) null, new o(context), 1, (Object) null);
    }

    public static final void d(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        if (str != null && m(context)) {
            net.dinglisch.android.taskerm.bo.b("ClipboardGetter", "Set keyboard to " + str);
            Settings.Secure.putString(context.getContentResolver(), com.joaomgcd.taskerm.securesettings.f.a(), str);
        }
    }

    public static final String e(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        String f2 = f(context, str);
        d(context, f2);
        return f2;
    }

    public static final String f(Context context, String str) {
        String str2;
        List<InputMethodInfo> enabledInputMethodList;
        Object obj;
        ComponentName component;
        c.f.b.k.b(context, "receiver$0");
        ComponentName componentName = new ComponentName(context, InputMethodServiceTasker.class);
        if (!c.f.b.k.a((Object) str, (Object) componentName.flattenToString())) {
            f9266a = str;
        }
        String str3 = f9266a;
        if (str3 != null) {
            str2 = str3;
        } else {
            InputMethodManager r2 = r(context);
            if (r2 != null && (enabledInputMethodList = r2.getEnabledInputMethodList()) != null) {
                Iterator<T> it = enabledInputMethodList.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        obj = null;
                        break;
                    }
                    obj = it.next();
                    InputMethodInfo inputMethodInfo = (InputMethodInfo) obj;
                    c.f.b.k.a((Object) inputMethodInfo, "inputMethod");
                    boolean z = false;
                    if (!c.f.b.k.a(inputMethodInfo.getComponent(), componentName)) {
                        ComponentName component2 = inputMethodInfo.getComponent();
                        c.f.b.k.a((Object) component2, "inputMethod.component");
                        String className = component2.getClassName();
                        c.f.b.k.a((Object) className, "inputMethod.component.className");
                        if (className != null) {
                            String lowerCase = className.toLowerCase();
                            c.f.b.k.a((Object) lowerCase, "(this as java.lang.String).toLowerCase()");
                            if (c.l.n.b((CharSequence) lowerCase, (CharSequence) "voice", false, 2, (Object) null)) {
                                continue;
                            } else {
                                z = true;
                                continue;
                            }
                        } else {
                            throw new c.q("null cannot be cast to non-null type java.lang.String");
                        }
                    }
                    if (z) {
                        break;
                    }
                }
                InputMethodInfo inputMethodInfo2 = (InputMethodInfo) obj;
                if (inputMethodInfo2 != null && (component = inputMethodInfo2.getComponent()) != null) {
                    str2 = component.flattenToString();
                }
            }
            str2 = null;
        }
        return str2 != null ? str2 : str;
    }

    @TargetApi(g.a.MapAttrs_latLngBoundsNorthEastLongitude)
    public static final boolean p(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return com.joaomgcd.taskerm.util.g.f9751b.t() && a(context, "android.hardware.fingerprint", "android.hardware.biometrics.iris", "android.hardware.biometrics.face");
    }

    public static final WindowManager q(Context context) {
        return (WindowManager) (context != null ? context.getSystemService("window") : null);
    }

    public static final WindowManager a(Context context, Window window) {
        WindowManager q2 = q(context);
        if (q2 != null) {
            return q2;
        }
        if (window != null) {
            return window.getWindowManager();
        }
        return null;
    }

    public static final Display b(Context context, Window window) {
        WindowManager a2 = a(context, window);
        if (a2 != null) {
            return a2.getDefaultDisplay();
        }
        return null;
    }

    public static final InputMethodManager r(Context context) {
        return (InputMethodManager) (context != null ? context.getSystemService("input_method") : null);
    }

    public static final TelecomManager s(Context context) {
        return (TelecomManager) (context != null ? context.getSystemService("telecom") : null);
    }

    public static final WifiManager t(Context context) {
        return (WifiManager) (context != null ? context.getSystemService("wifi") : null);
    }

    public static final boolean u(Context context) {
        WifiManager t = t(context);
        return t != null && t.getWifiState() == 3;
    }

    public static final void a(Context context, boolean z) {
        if (context != null) {
            if (com.joaomgcd.taskerm.util.g.f9751b.h()) {
                net.dinglisch.android.tasker.d.f10849a.a(context, new InputToggleWifi(z));
                return;
            }
            WifiManager t = t(context);
            if (t != null) {
                t.setWifiEnabled(z);
            }
        }
    }

    public static final List<ScanResult> v(Context context) {
        List<ScanResult> scanResults;
        WifiManager t = t(context);
        return (t == null || (scanResults = t.getScanResults()) == null) ? new ArrayList() : scanResults;
    }

    public static final Vibrator w(Context context) {
        return (Vibrator) (context != null ? context.getSystemService("vibrator") : null);
    }

    @TargetApi(g.a.MapAttrs_latLngBoundsNorthEastLongitude)
    public static final boolean g(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "permission");
        return com.joaomgcd.taskerm.util.g.f9751b.d() || com.joaomgcd.taskerm.util.h.a(context) || context.checkSelfPermission(str) == 0;
    }

    public static final int h(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "permission");
        return context.getPackageManager().getPermissionInfo("net.dinglisch.android.tasker.PERMISSION_RUN_TASKS", 0).protectionLevel;
    }

    public static Object a(Context context, String str, String str2, File[] fileArr, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            fileArr = null;
        }
        return a(context, str, str2, fileArr);
    }

    public static final Object a(Context context, String str, String str2, File[] fileArr) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "title");
        c.f.b.k.b(str2, "text");
        try {
            context.startActivity(dr.a(context, "[Tasker] " + str, str2, fileArr));
            return c.s.f2131a;
        } catch (ActivityNotFoundException unused) {
            return Boolean.valueOf(gs.a(context, "No email app found", new Object[0]));
        }
    }

    public static void a(Context context, String str, boolean z, boolean z2, boolean z3, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            z = false;
        }
        if ((i2 & 4) != 0) {
            z2 = true;
        }
        if ((i2 & 8) != 0) {
            z3 = false;
        }
        a(context, str, z, z2, z3);
    }

    public static final void a(Context context, String str, boolean z, boolean z2, boolean z3) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "url");
        try {
            Intent intent = new Intent();
            an.a(intent, context, str, z);
            if (z3) {
                intent.putExtra("com.android.browser.application_id", context.getPackageName());
            }
            an.a(intent, context);
        } catch (Throwable th) {
            if (z2) {
                com.joaomgcd.taskerm.rx.h.a(context, th);
                return;
            }
            throw th;
        }
    }

    public static final void j(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        a(context, "https://play.google.com/apps/testing/" + str, true, false, true, 4, (Object) null);
    }

    public static final void k(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        a(context, "https://play.google.com/store/apps/details?id=" + str, false, false, false, 12, (Object) null);
    }

    public static final void x(Context context) {
        c.f.b.k.b(context, "receiver$0");
        String packageName = context.getPackageName();
        c.f.b.k.a((Object) packageName, "packageName");
        j(context, packageName);
    }

    public static final void y(Context context) {
        c.f.b.k.b(context, "receiver$0");
        String packageName = context.getPackageName();
        c.f.b.k.a((Object) packageName, "packageName");
        k(context, packageName);
    }

    public static final void z(Context context) {
        c.f.b.k.b(context, "receiver$0");
        a(context, "https://www.patreon.com/joaoapps", false, false, false, 14, (Object) null);
    }

    public static final void a(Context context, cp cpVar) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(cpVar, "args");
        context.startActivity(dr.a(context, cpVar));
    }

    public static final String A(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return c.l.n.a(context.getPackageName() + " version " + c(context) + "; flavor: market; Source \"" + X(context) + "\"; BuildTime " + an.a(1683815563712L, (String) null, 1, (Object) null) + "\n\n\nOS Buid " + Build.DISPLAY + "\nOS Code " + Build.VERSION.SDK_INT + "\nOS Target " + e(context) + "\nDevice " + Build.MODEL + "\nManufacturer " + Build.MANUFACTURER + "\nProduct " + Build.PRODUCT + '\n', (String) null, 1, (Object) null);
    }

    public static final void a(Context context, Long l2) {
        c.f.b.k.b(context, "receiver$0");
        String str = bh.o.f12243c;
        c.f.b.k.a((Object) str, "Keys.S.VALIDATED_DATE_GOOGLE_PLAY");
        SharedPreferences b2 = com.joaomgcd.taskerm.q.b.b(context);
        c.f.b.k.a((Object) b2, "preferencesStateName");
        com.joaomgcd.taskerm.q.b.a(context, str, l2, b2);
    }

    public static final boolean B(Context context) {
        c.f.b.k.b(context, "receiver$0");
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        return com.joaomgcd.taskerm.q.b.a(context, "gdf", false, a2);
    }

    public static final void b(Context context, boolean z) {
        c.f.b.k.b(context, "receiver$0");
        Boolean valueOf = Boolean.valueOf(z);
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        com.joaomgcd.taskerm.q.b.a(context, "gdf", valueOf, a2);
    }

    public static final String C(Context context) {
        c.f.b.k.b(context, "receiver$0");
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        return com.joaomgcd.taskerm.q.b.b(context, "lkc", null, a2);
    }

    public static final void l(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        com.joaomgcd.taskerm.q.b.a(context, "lkc", str, a2);
    }

    public static final void m(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        com.joaomgcd.taskerm.q.b.a(context, "lkad", str, a2);
    }

    public static b.a.b b(Context context, String str, String str2, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str2 = str;
        }
        return c(context, str, str2);
    }

    public static final class p<T, R> implements b.a.d.g<T, R> {
        final Context f9294a;
        final String f9295b;

        p(Context context, String str) {
            this.f9294a = context;
            this.f9295b = str;
        }

        @Override
        public Object apply(Object obj) {
            a((Bitmap) obj);
            return c.s.f2131a;
        }

        public final void a(Bitmap bitmap) {
            c.f.b.k.b(bitmap, "it");
            byte[] a2 = com.joaomgcd.taskerm.m.b.a(bitmap);
            c.f.b.k.a((Object) a2, "it.byteArray");
            Uri a3 = dq.a(an.a(a2, this.f9294a, (String) null, "clipboard", 2, (Object) null), this.f9294a, (String[]) null, (Intent) null, false, 14, (Object) null);
            ClipboardManager G = al.G(this.f9294a);
            if (G != null) {
                G.setPrimaryClip(ClipData.newUri(this.f9294a.getContentResolver(), this.f9295b, a3));
            }
            com.joaomgcd.taskerm.e.b.a(a3, c.a.j.a("image/png"));
        }
    }

    public static final b.a.b c(Context context, String str, String str2) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "image");
        c.f.b.k.b(str2, ClockContract.AlarmSettingColumns.LABEL);
        b.a.b d2 = com.joaomgcd.taskerm.m.b.a(str, context, (Integer) null, (Integer) null, 6, (Object) null).c(new p(context, str2)).d();
        c.f.b.k.a((Object) d2, "image.getBitmap(this).ma…\"))\n    }.toCompletable()");
        return d2;
    }

    public static final boolean n(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "text");
        return net.dinglisch.android.taskerm.cc.a(context, str, cc.a.None);
    }

    @TargetApi(24)
    public static final Locale D(Context context) {
        Context applicationContext;
        Resources resources;
        Configuration configuration;
        LocaleList locales;
        Locale locale = null;
        try {
            if (com.joaomgcd.taskerm.util.g.f9751b.w()) {
                if (context != null && (applicationContext = context.getApplicationContext()) != null && (resources = applicationContext.getResources()) != null && (configuration = resources.getConfiguration()) != null && (locales = configuration.getLocales()) != null) {
                    locale = locales.get(0);
                }
                if (locale == null) {
                    net.dinglisch.android.taskerm.bo.b("LOCALE", "Using default nougat");
                    locale = Locale.getDefault(Locale.Category.DISPLAY);
                } else {
                    net.dinglisch.android.taskerm.bo.b("LOCALE", "Using from resources nougat");
                }
            } else {
                net.dinglisch.android.taskerm.bo.b("LOCALE", "Using default pre-nougat");
                locale = Locale.getDefault();
            }
        } catch (Exception e2) {
            net.dinglisch.android.taskerm.bo.b("LOCALE", "Using default pre-nougat with error: " + am.a(e2));
            locale = Locale.getDefault();
        }
        if (locale != null) {
            return locale;
        }
        net.dinglisch.android.taskerm.bo.b("LOCALE", "Using default en-us");
        return new Locale("en", "us");
    }

    @TargetApi(24)
    public static final String E(Context context) {
        SimpleDateFormat simpleDateFormat;
        if (com.joaomgcd.taskerm.util.g.f9751b.w()) {
            simpleDateFormat = new SimpleDateFormat("EEEE", D(context));
        } else {
            DateFormat dateInstance = SimpleDateFormat.getDateInstance();
            if (dateInstance == null) {
                throw new c.q("null cannot be cast to non-null type java.text.SimpleDateFormat");
            }
            simpleDateFormat = (SimpleDateFormat) dateInstance;
            simpleDateFormat.applyPattern("EEEE");
        }
        return simpleDateFormat.format(new Date(System.currentTimeMillis()));
    }

    public static final String a(Context context, Calendar calendar) {
        Locale D;
        TaskerApp d2;
        c.f.b.k.b(calendar, "calendar");
        if (context == null || (d2 = d(context)) == null || (D = d2.b()) == null) {
            D = D(context);
        }
        DateFormat dateInstance = DateFormat.getDateInstance(3, D);
        if (dateInstance == null) {
            net.dinglisch.android.taskerm.bo.b("DATE", "New Date Format: using basic format");
            return net.dinglisch.android.taskerm.cb.b(calendar);
        }
        String format = dateInstance.format(new Date(calendar.getTimeInMillis()));
        if (format == null) {
            net.dinglisch.android.taskerm.bo.b("DATE", "New Date Format: using basic format because of string");
            return net.dinglisch.android.taskerm.cb.b(calendar);
        }
        String str = File.separator;
        c.f.b.k.a((Object) str, "File.separator");
        return c.l.n.a(format, str, "-", false, 4, (Object) null);
    }

    public static final char[] F(Context context) {
        c.f.b.k.b(context, "receiver$0");
        String bestDateTimePattern = android.text.format.DateFormat.getBestDateTimePattern(d(context).b(), "dMy");
        c.f.b.k.a((Object) bestDateTimePattern, "bestDateTimePattern");
        List<String> c2 = new c.l.k("[^dMy]").c(bestDateTimePattern, 0);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) c2, 10));
        for (String str : c2) {
            arrayList.add(c.l.n.a((CharSequence) str, 0));
        }
        ArrayList arrayList2 = arrayList;
        if (an.c((Iterable) arrayList2)) {
            return null;
        }
        return c.a.j.c((Collection<Character>) c.a.j.f((Iterable) arrayList2));
    }

    public static final ClipboardManager G(Context context) {
        if (context != null) {
            return d(context).h();
        }
        return null;
    }

    public static final String H(Context context) {
        String str;
        String obj;
        if (context == null) {
            return null;
        }
        try {
            String str2 = null;
            ClipboardManager a2 = net.dinglisch.android.taskerm.cc.a(context);
            c.f.b.k.a((Object) a2, "manager");
            CharSequence text = a2.getText();
            if (text != null && (obj = text.toString()) != null) {
                if (obj == null) {
                    throw new c.q("null cannot be cast to non-null type kotlin.CharSequence");
                }
                String obj2 = c.l.n.b((CharSequence) obj).toString();
                if (obj2 != null) {
                    str = ao.A(obj2);
                    if (str == null) {
                        return str;
                    }
                    ClipData primaryClip = a2.getPrimaryClip();
                    if ((primaryClip != null ? primaryClip.getItemCount() : 0) > 0 && (str2 = (String) an.a((c.f.a.b) null, new c(context, primaryClip), 1, (Object) null)) == null) {
                        str2 = (String) an.a((c.f.a.b) null, new d(a2), 1, (Object) null);
                    }
                    l(context, str2);
                    return str2;
                }
            }
            str = null;
            if (str == null) {
            }
        } catch (Throwable th) {
            net.dinglisch.android.taskerm.bo.b("Clipboard", "Can't get clipboard", th);
            return null;
        }
    }

    public static final class c extends c.f.b.l implements c.f.a.a<String> {
        final Context f9270a;
        final ClipData f9271b;

        c(Context context, ClipData clipData) {
            super(0);
            this.f9270a = context;
            this.f9271b = clipData;
        }

        @Override
        public final String invoke() {
            ClipData.Item itemAt;
            CharSequence coerceToText;
            ClipData clipData = this.f9271b;
            if (clipData == null || (itemAt = clipData.getItemAt(0)) == null || (coerceToText = itemAt.coerceToText(this.f9270a)) == null) {
                return null;
            }
            return coerceToText.toString();
        }
    }

    public static final class d extends c.f.b.l implements c.f.a.a<String> {
        final ClipboardManager f9272a;

        d(ClipboardManager clipboardManager) {
            super(0);
            this.f9272a = clipboardManager;
        }

        @Override
        public final String invoke() {
            ClipboardManager clipboardManager = this.f9272a;
            c.f.b.k.a((Object) clipboardManager, "manager");
            CharSequence text = clipboardManager.getText();
            if (text != null) {
                return text.toString();
            }
            return null;
        }
    }

    public static final ax a(ClipData clipData) {
        c.f.b.k.b(clipData, "receiver$0");
        return new ax(clipData);
    }

    public static final List<ClipData.Item> b(ClipData clipData) {
        c.f.b.k.b(clipData, "receiver$0");
        return c.k.h.d(c.k.h.a(a(clipData)));
    }

    public static final az I(Context context) {
        return new az(context);
    }

    public static final CompanionDeviceManager J(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (CompanionDeviceManager) context.getSystemService("companiondevice");
    }

    @TargetApi(26)
    public static final String L(Context context) {
        CompanionDeviceManager J;
        List<String> associations;
        c.f.b.k.b(context, "receiver$0");
        if (com.joaomgcd.taskerm.util.g.f9751b.r() || !K(context) || (J = J(context)) == null || (associations = J.getAssociations()) == null) {
            return null;
        }
        return associations.get(0);
    }

    public static final int M(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return d(context).c();
    }

    public static final DevicePolicyManager N(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (DevicePolicyManager) context.getSystemService("device_policy");
    }

    public static final MediaProjectionManager O(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (MediaProjectionManager) context.getSystemService("media_projection");
    }

    public static final RoleManager P(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (RoleManager) context.getSystemService("role");
    }

    public static final boolean o(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "role");
        if (com.joaomgcd.taskerm.util.g.f9751b.q()) {
            return true;
        }
        RoleManager P = P(context);
        if (P != null) {
            return P.isRoleHeld(str);
        }
        return false;
    }

    public static final boolean Q(Context context) {
        c.f.b.k.b(context, "receiver$0");
        if (com.joaomgcd.taskerm.util.g.f9751b.q()) {
            return true;
        }
        return o(context, "android.app.role.CALL_SCREENING");
    }

    public static final NfcManager R(Context context) {
        c.f.b.k.b(context, "receiver$0");
        try {
            return (NfcManager) context.getSystemService("nfc");
        } catch (Exception unused) {
            return null;
        }
    }

    public static final BatteryManager S(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (BatteryManager) context.getSystemService("batterymanager");
    }

    public static final UiModeManager T(Context context) {
        c.f.b.k.b(context, "receiver$0");
        try {
            return (UiModeManager) context.getSystemService("uimode");
        } catch (Exception unused) {
            return null;
        }
    }

    public static final Intent U(Context context) {
        c.f.b.k.b(context, "receiver$0");
        Intent intent = new Intent(context, Tasker.class);
        intent.setAction("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        intent.addFlags(268435456);
        return intent;
    }

    public static final void V(Context context) {
        c.f.b.k.b(context, "receiver$0");
        context.startActivity(U(context));
    }

    public static final void W(Context context) {
        c.f.b.k.b(context, "receiver$0");
        try {
            context.startActivity(net.dinglisch.android.taskerm.cr.a());
        } catch (Throwable th) {
            com.joaomgcd.taskerm.rx.h.a(context, th);
        }
    }

    public static final void a(Context context, String str, String str2, Integer num) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        try {
            Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str);
            if (launchIntentForPackage != null) {
                launchIntentForPackage.setPackage(null);
                launchIntentForPackage.removeCategory("android.intent.category.LAUNCHER");
                launchIntentForPackage.setFlags(num != null ? num.intValue() : 270532608);
                if (str2 != null) {
                    launchIntentForPackage.setComponent(new ComponentName(str, str2));
                }
            } else {
                launchIntentForPackage = null;
            }
            context.startActivity(launchIntentForPackage);
        } catch (Throwable th) {
            com.joaomgcd.taskerm.rx.h.a(context, th);
        }
    }

    public static final <T extends Activity> void a(Context context, Class<T> cls, Integer num) {
        c.f.b.k.b(context, "receiver$0");
        String packageName = context.getPackageName();
        c.f.b.k.a((Object) packageName, "packageName");
        a(context, packageName, cls != null ? cls.getName() : null, num);
    }

    public static void a(Context context, Class cls, Integer num, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            num = null;
        }
        a(context, cls, num);
    }

    public static final String X(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return context.getPackageManager().getInstallerPackageName(context.getPackageName());
    }

    public static final boolean Y(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return c.f.b.k.a((Object) X(context), (Object) "com.android.vending");
    }

    public static final boolean Z(Context context) {
        c.f.b.k.b(context, "receiver$0");
        boolean b2 = bz.b(context);
        if (b2) {
            net.dinglisch.android.taskerm.bo.b(com.joaomgcd.taskerm.dialog.y.a(), "Showing auth dialog, so ignoring app");
        }
        return b2;
    }

    public static final Bitmap a(Context context, com.joaomgcd.taskerm.util.o oVar) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(oVar, "args");
        PackageManager packageManager = context.getPackageManager();
        c.f.b.k.a((Object) packageManager, "packageManager");
        return a(context, new com.joaomgcd.taskerm.util.p(packageManager, oVar));
    }

    private static final int a(Integer num, Context context) {
        if (num == null || num.intValue() <= 0) {
            return dx.a(context, 48);
        }
        return num.intValue();
    }

    private static final Bitmap a(Context context, com.joaomgcd.taskerm.util.p pVar) {
        try {
            Drawable activityIcon = context.getPackageManager().getActivityIcon(new ComponentName(pVar.b(), pVar.c()));
            c.f.b.k.a((Object) activityIcon, "drawable");
            Bitmap createBitmap = Bitmap.createBitmap(a(Integer.valueOf(activityIcon.getIntrinsicWidth()), context), a(Integer.valueOf(activityIcon.getIntrinsicHeight()), context), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(createBitmap);
            activityIcon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            activityIcon.draw(canvas);
            if (pVar.d() == null || pVar.e() == null) {
                return createBitmap;
            }
            c.f.b.k.a((Object) createBitmap, "bitmap");
            return com.joaomgcd.taskerm.m.b.a(createBitmap, pVar.d().intValue(), pVar.e().intValue());
        } catch (PackageManager.NameNotFoundException unused) {
            return null;
        } catch (OutOfMemoryError unused2) {
            String a2 = pVar.a();
            net.dinglisch.android.taskerm.bo.d(a2, "getIcon: " + pVar + ".packageName: out of memory");
            return null;
        }
    }

    public static final boolean p(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        try {
            q(context, str);
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

    public static final String q(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        PackageManager packageManager = context.getPackageManager();
        c.f.b.k.a((Object) packageManager, "packageManager");
        return a(packageManager, str);
    }

    public static final void r(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        if (str == null) {
            throw new IllegalArgumentException("Launching app: package name can't be null");
        }
        Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str);
        if (launchIntentForPackage == null) {
            throw new RuntimeException("App doesn't have a launch component");
        }
        launchIntentForPackage.setPackage(null);
        context.startActivity(launchIntentForPackage);
    }

    public static final String a(PackageManager packageManager, String str) {
        ComponentName component;
        String className;
        c.f.b.k.b(packageManager, "receiver$0");
        c.f.b.k.b(str, "packageName");
        Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(str);
        if (launchIntentForPackage == null || (component = launchIntentForPackage.getComponent()) == null || (className = component.getClassName()) == null) {
            throw new RuntimeException("Can't get " + str + " launch intent: no launch intent");
        }
        return className;
    }

    public static final ComponentName aa(Context context) {
        ActivityInfo activityInfo;
        String str;
        String str2;
        c.f.b.k.b(context, "receiver$0");
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.HOME");
        ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(intent, 65536);
        if (resolveActivity == null || (activityInfo = resolveActivity.activityInfo) == null || (str = activityInfo.packageName) == null || (str2 = activityInfo.name) == null) {
            return null;
        }
        return new ComponentName(str, str2);
    }

    public static final cr b(Context context, ComponentName componentName) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(componentName, "component");
        a.c cVar = com.joaomgcd.taskerm.b.a.f5978b;
        String packageName = componentName.getPackageName();
        c.f.b.k.a((Object) packageName, "component.packageName");
        String className = componentName.getClassName();
        c.f.b.k.a((Object) className, "component.className");
        cr b2 = com.joaomgcd.taskerm.b.h.a(cVar.a(packageName, className), context).b();
        c.f.b.k.a((Object) b2, "setLauncherCommand.runCo…BWifi(this).blockingGet()");
        return b2;
    }

    public static final void a(Context context, cx cxVar) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(cxVar, "options");
        Intent a2 = cxVar.a();
        if (!Activity.class.isAssignableFrom(context.getClass())) {
            cxVar.a(268435456);
        }
        if (!cxVar.b()) {
            cxVar.a(1082130432);
        }
        int c2 = cxVar.c();
        if (c2 != 0) {
            a2.addFlags(c2);
        }
        String d2 = cxVar.d();
        if (ao.z(d2)) {
            a2.setAction(d2);
        }
        context.startActivity(a2);
    }

    public static final <T extends Activity> b.a.b a(Context context, Class<T> cls, boolean z) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(cls, "clss");
        return c(context, (Class<?>) cls, z);
    }

    public static final <T extends Service> b.a.b b(Context context, Class<T> cls, boolean z) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(cls, "clss");
        return c(context, (Class<?>) cls, z);
    }

    public static final class e extends c.f.b.l implements c.f.a.a<c.s> {
        final Context f9273a;
        final boolean f9274b;
        final Class f9275c;

        e(Context context, boolean z, Class cls) {
            super(0);
            this.f9273a = context;
            this.f9274b = z;
            this.f9275c = cls;
        }

        @Override
        public c.s invoke() {
            a();
            return c.s.f2131a;
        }

        public final void a() {
            int i = this.f9274b ? 1 : 2;
            net.dinglisch.android.taskerm.bo.b("MyPM", "Changed component enabled status to " + this.f9274b + ':' + i);
            this.f9273a.getPackageManager().setComponentEnabledSetting(new ComponentName(this.f9273a, this.f9275c), i, 1);
        }
    }

    private static final b.a.b c(Context context, Class<?> cls, boolean z) {
        return com.joaomgcd.taskerm.rx.h.d(new e(context, z, cls));
    }

    public static final AudioManager ab(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (AudioManager) context.getSystemService("audio");
    }

    public static final UsageStatsManager ac(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (UsageStatsManager) context.getSystemService("usagestats");
    }

    public static final AlarmManager ad(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM);
    }

    public static final SensorManager ae(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (SensorManager) context.getSystemService("sensor");
    }

    public static final List<Sensor> af(Context context) {
        c.f.b.k.b(context, "receiver$0");
        SensorManager ae = ae(context);
        if (ae != null) {
            return ae.getSensorList(-1);
        }
        return null;
    }

    public static final LocationManager ag(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (LocationManager) context.getSystemService("location");
    }

    public static final SearchManager ah(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (SearchManager) context.getSystemService("search");
    }

    public static final boolean ai(Context context) {
        c.f.b.k.b(context, "receiver$0");
        if (!com.joaomgcd.taskerm.util.g.f9751b.n()) {
            AlarmManager ad = ad(context);
            if (!(ad != null ? ad.canScheduleExactAlarms() : false)) {
                return false;
            }
        }
        return true;
    }

    public static final cr aj(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return ai(context) ? new cu() : ct.a("Can't schedule exact alarm");
    }

    public static final boolean ak(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return al(context) || am(context);
    }

    public static final boolean al(Context context) {
        c.f.b.k.b(context, "receiver$0");
        LocationManager ag = ag(context);
        if (ag != null) {
            return ag.isProviderEnabled("gps");
        }
        return false;
    }

    public static final boolean am(Context context) {
        c.f.b.k.b(context, "receiver$0");
        LocationManager ag = ag(context);
        if (ag != null) {
            return ag.isProviderEnabled("network");
        }
        return false;
    }

    public static final void a(Context context, Intent intent) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(intent, "intent");
        if (com.joaomgcd.taskerm.util.g.f9751b.r()) {
            context.startService(intent);
        } else {
            context.startForegroundService(intent);
        }
    }

    public static final UsageEvents a(Context context, long j2) {
        UsageEvents usageEvents;
        c.f.b.k.b(context, "receiver$0");
        UsageStatsManager ac = ac(context);
        if (ac != null) {
            long currentTimeMillis = System.currentTimeMillis();
            try {
                usageEvents = ac.queryEvents(currentTimeMillis - (j2 + 1), currentTimeMillis);
                if (usageEvents == null) {
                    return null;
                }
            } catch (Exception unused) {
                usageEvents = null;
            }
            if (usageEvents != null) {
                return usageEvents;
            }
            return null;
        }
        return null;
    }

    public static final UsageEvents a(Context context, long j2, long j3) {
        UsageEvents usageEvents;
        c.f.b.k.b(context, "receiver$0");
        UsageStatsManager ac = ac(context);
        if (ac != null) {
            try {
                usageEvents = ac.queryEvents(j2, j3);
                if (usageEvents == null) {
                    return null;
                }
            } catch (Exception unused) {
                usageEvents = null;
            }
            if (usageEvents != null) {
                return usageEvents;
            }
            return null;
        }
        return null;
    }

    public static final ArrayList<UsageEvents.Event> a(Context context, long j2, Integer num) {
        c.f.b.k.b(context, "receiver$0");
        return an.a(a(context, j2), num);
    }

    public static ArrayList a(Context context, long j2, Integer num, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            num = 1;
        }
        return a(context, j2, num);
    }

    public static final ArrayList<UsageEvents.Event> a(Context context, long j2, long j3, Integer num) {
        c.f.b.k.b(context, "receiver$0");
        return an.a(a(context, j2, j3), num);
    }

    public static ArrayList a(Context context, long j2, long j3, Integer num, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            num = 1;
        }
        return a(context, j2, j3, num);
    }

    public static final String b(Context context, long j2) {
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        ArrayList arrayList = new ArrayList();
        Iterator<T> it = a(context, j2, (Integer) null).iterator();
        while (true) {
            boolean z = false;
            if (!it.hasNext()) {
                break;
            }
            Object next = it.next();
            UsageEvents.Event event = (UsageEvents.Event) next;
            if ((an.a(event) || an.b(event)) ? true : true) {
                arrayList.add(next);
            }
        }
        List<UsageEvents.Event> g2 = c.a.j.g((Iterable) arrayList);
        ArrayList arrayList2 = new ArrayList();
        for (UsageEvents.Event event2 : g2) {
            if (an.b(event2)) {
                arrayList2.add(event2);
            } else {
                Iterator it2 = arrayList2.iterator();
                while (true) {
                    if (!it2.hasNext()) {
                        obj = null;
                        break;
                    }
                    obj = it2.next();
                    if (c.f.b.k.a((Object) ((UsageEvents.Event) obj).getClassName(), (Object) event2.getClassName())) {
                        break;
                    }
                }
                if (!(obj != null)) {
                    return event2.getPackageName();
                }
            }
        }
        return null;
    }

    public static final ComponentName an(Context context) {
        c.f.b.k.b(context, "receiver$0");
        UsageEvents.Event event = (UsageEvents.Event) c.a.j.h((List<? extends Object>) a(context, 1800000L, (Integer) null, 2, (Object) null));
        if (event != null) {
            return an.c(event);
        }
        return null;
    }

    public static final ComponentName ao(Context context) {
        String packageName;
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        List g2 = c.a.j.g((Iterable) a(context, 3600000L, (Integer) null, 2, (Object) null));
        UsageEvents.Event event = (UsageEvents.Event) c.a.j.f((List<? extends Object>) g2);
        if (event == null || (packageName = event.getPackageName()) == null) {
            return null;
        }
        ComponentName aa = aa(context);
        String packageName2 = aa != null ? aa.getPackageName() : null;
        Iterator it = g2.iterator();
        while (true) {
            if (!it.hasNext()) {
                obj = null;
                break;
            }
            obj = it.next();
            UsageEvents.Event event2 = (UsageEvents.Event) obj;
            boolean z = false;
            if (!an.a(event2.getClassName(), IntentHandler.class.getName(), ActivitySecondaryApp.class.getName())) {
                String packageName3 = event2.getPackageName();
                if (!c.f.b.k.a((Object) packageName3, (Object) packageName) && !c.f.b.k.a((Object) packageName3, (Object) packageName2)) {
                    c.f.b.k.a((Object) packageName3, "packageName");
                    if (p(context, packageName3)) {
                        z = true;
                        continue;
                    } else {
                        continue;
                    }
                }
            }
            if (z) {
                break;
            }
        }
        UsageEvents.Event event3 = (UsageEvents.Event) obj;
        if (event3 != null) {
            return an.c(event3);
        }
        return null;
    }

    public static final String ap(Context context) {
        c.f.b.k.b(context, "receiver$0");
        ComponentName ao = ao(context);
        if (ao != null) {
            return ao.getPackageName();
        }
        return null;
    }

    public static final String aq(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return a(context, ap(context), (String) null, 2, (Object) null);
    }

    public static final String ar(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return net.dinglisch.android.taskerm.bj.a(com.joaomgcd.taskerm.q.b.d(context));
    }

    public static final String s(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "document");
        return "https://tasker.joaoapps.com/userguide/" + ar(context) + '/' + str;
    }

    public static final String a(Context context, av.a aVar, int i2) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(aVar, "type");
        String a2 = aVar.a();
        net.dinglisch.android.taskerm.m k2 = net.dinglisch.android.taskerm.n.k(523);
        c.f.b.k.a((Object) k2, "ActionSpecs.getActionSpe…ActionCodes.NOTIFY_PLAIN)");
        String a3 = HasArgsEdit.a(a2, k2.i());
        c.f.b.k.a((Object) a3, "document");
        return s(context, a3);
    }

    public static final class j<T> extends c.f.b.l implements c.f.a.a<T> {
        final Context f9282a;
        final c.f.a.b f9283b;

        j(Context context, c.f.a.b bVar) {
            super(0);
            this.f9282a = context;
            this.f9283b = bVar;
        }

        @Override
        public final T invoke() {
            Object obj;
            ActivityGenericAction activityGenericAction;
            String uuid = UUID.randomUUID().toString();
            c.f.b.k.a((Object) uuid, "UUID.randomUUID().toString()");
            cr b2 = new GenericActionActivityGetActivity(uuid).run(this.f9282a).b();
            if (b2.b() && (b2 instanceof cw)) {
                cw cwVar = (cw) b2;
                if (cwVar.d() != null && (cwVar.d() instanceof ActivityGenericAction)) {
                    obj = cwVar.d();
                    activityGenericAction = (ActivityGenericAction) obj;
                    if (activityGenericAction != null) {
                        throw new RuntimeException("Couldn't get activity");
                    }
                    try {
                        return (T) ((b.a.l) this.f9283b.invoke(activityGenericAction)).b();
                    } finally {
                        activityGenericAction.c().b();
                    }
                }
            }
            obj = null;
            activityGenericAction = (ActivityGenericAction) obj;
            if (activityGenericAction != null) {
            }
        }
    }

    public static final <T> b.a.l<T> a(Context context, c.f.a.b<? super Activity, ? extends b.a.l<T>> bVar) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(bVar, "block");
        return com.joaomgcd.taskerm.rx.h.b(new j(context, bVar));
    }

    public static final void a(Context context, BroadcastReceiver broadcastReceiver) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(broadcastReceiver, "receiver");
        try {
            context.unregisterReceiver(broadcastReceiver);
        } catch (Exception unused) {
        }
    }

    public static final ConnectivityManager as(Context context) {
        Context applicationContext;
        return (ConnectivityManager) ((context == null || (applicationContext = context.getApplicationContext()) == null) ? null : applicationContext.getSystemService("connectivity"));
    }

    public static final Boolean at(Context context) {
        ConnectivityManager as = as(context);
        if (as != null) {
            return Boolean.valueOf(bw.x.a(as));
        }
        return null;
    }

    public static final TelephonyManager au(Context context) {
        Context applicationContext;
        return (TelephonyManager) ((context == null || (applicationContext = context.getApplicationContext()) == null) ? null : applicationContext.getSystemService("phone"));
    }

    public static final PowerManager av(Context context) {
        Context applicationContext;
        return (PowerManager) ((context == null || (applicationContext = context.getApplicationContext()) == null) ? null : applicationContext.getSystemService("power"));
    }

    public static final ActivityManager aw(Context context) {
        Context applicationContext;
        return (ActivityManager) ((context == null || (applicationContext = context.getApplicationContext()) == null) ? null : applicationContext.getSystemService("activity"));
    }

    public static final HashMap<Integer, gu> ax(Context context) {
        c.f.b.k.b(context, "receiver$0");
        Set<String> a2 = gx.a(context, false, true);
        c.f.b.k.a((Object) a2, "Variables.getSet(this, false, true)");
        ArrayList arrayList = new ArrayList();
        for (Object obj : a2) {
            if (!gx.r((String) obj)) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = arrayList;
        ArrayList arrayList3 = new ArrayList(c.a.j.a((Iterable) arrayList2, 10));
        int i2 = 0;
        for (Object obj2 : arrayList2) {
            int i3 = i2 + 1;
            if (i2 < 0) {
                c.a.j.b();
            }
            arrayList3.add(new c.k(Integer.valueOf(i2), new gu(context, (String) obj2)));
            i2 = i3;
        }
        Object[] array = arrayList3.toArray(new c.k[0]);
        if (array != null) {
            c.k[] kVarArr = (c.k[]) array;
            return c.a.z.b((c.k[]) Arrays.copyOf(kVarArr, kVarArr.length));
        }
        throw new c.q("null cannot be cast to non-null type kotlin.Array<T>");
    }

    public static final HashMap<Integer, com.joaomgcd.taskerm.settings.l> ay(Context context) {
        c.f.b.k.b(context, "receiver$0");
        SharedPreferences c2 = com.joaomgcd.taskerm.q.b.c(context);
        c.f.b.k.a((Object) c2, "preferencesSettings");
        Map<String, ?> all = c2.getAll();
        if (all == null) {
            return new HashMap<>();
        }
        List d2 = c.a.z.d(all);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) d2, 10));
        int i2 = 0;
        for (Object obj : d2) {
            int i3 = i2 + 1;
            if (i2 < 0) {
                c.a.j.b();
            }
            c.k kVar = (c.k) obj;
            Object a2 = kVar.a();
            c.f.b.k.a(a2, "entry.first");
            arrayList.add(new c.k(Integer.valueOf(i2), new com.joaomgcd.taskerm.settings.l(context, (String) a2, kVar.b())));
            i2 = i3;
        }
        Object[] array = arrayList.toArray(new c.k[0]);
        if (array != null) {
            c.k[] kVarArr = (c.k[]) array;
            return c.a.z.b((c.k[]) Arrays.copyOf(kVarArr, kVarArr.length));
        }
        throw new c.q("null cannot be cast to non-null type kotlin.Array<T>");
    }

    private static final <T extends ComponentInfo> List<T> a(Context context, String str, c.f.a.b<? super Intent, ? extends List<? extends ResolveInfo>> bVar, c.f.a.b<? super ResolveInfo, ? extends T> bVar2) {
        context.getPackageManager();
        Intent intent = new Intent();
        intent.setAction(str);
        List<? extends ResolveInfo> invoke = bVar.invoke(intent);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) invoke, 10));
        for (Object obj : invoke) {
            arrayList.add(bVar2.invoke(obj));
        }
        return arrayList;
    }

    private static final <T extends ComponentInfo> List<T> a(Context context, Uri uri, c.f.a.b<? super Intent, ? extends List<? extends ResolveInfo>> bVar, c.f.a.b<? super ResolveInfo, ? extends T> bVar2) {
        context.getPackageManager();
        Intent intent = new Intent();
        an.a(intent, context, uri, false, 4, (Object) null);
        List<? extends ResolveInfo> invoke = bVar.invoke(intent);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) invoke, 10));
        for (Object obj : invoke) {
            arrayList.add(bVar2.invoke(obj));
        }
        return arrayList;
    }

    private static final <T extends ComponentInfo> List<T> a(Context context, Intent intent, c.f.a.b<? super Intent, ? extends List<? extends ResolveInfo>> bVar, c.f.a.b<? super ResolveInfo, ? extends T> bVar2) {
        List<? extends ResolveInfo> invoke = bVar.invoke(intent);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) invoke, 10));
        for (Object obj : invoke) {
            arrayList.add(bVar2.invoke(obj));
        }
        return arrayList;
    }

    public static final class h extends c.f.b.l implements c.f.a.b<Intent, List<ResolveInfo>> {
        final Context f9280a;

        h(Context context) {
            super(1);
            this.f9280a = context;
        }

        @Override
        public final List<ResolveInfo> invoke(Intent intent) {
            c.f.b.k.b(intent, "it");
            List<ResolveInfo> queryIntentServices = this.f9280a.getPackageManager().queryIntentServices(intent, 192);
            c.f.b.k.a((Object) queryIntentServices, "packageManager.queryInte…ageManager.GET_META_DATA)");
            return queryIntentServices;
        }
    }

    public static final class i extends c.f.b.l implements c.f.a.b<ResolveInfo, ServiceInfo> {
        public static final i f9281a = new i();

        i() {
            super(1);
        }

        @Override
        public final ServiceInfo invoke(ResolveInfo resolveInfo) {
            c.f.b.k.b(resolveInfo, "it");
            return resolveInfo.serviceInfo;
        }
    }

    public static final class a extends c.f.b.l implements c.f.a.b<Intent, List<ResolveInfo>> {
        final Context f9268a;

        a(Context context) {
            super(1);
            this.f9268a = context;
        }

        @Override
        public final List<ResolveInfo> invoke(Intent intent) {
            c.f.b.k.b(intent, "it");
            List<ResolveInfo> queryIntentActivities = this.f9268a.getPackageManager().queryIntentActivities(intent, 192);
            c.f.b.k.a((Object) queryIntentActivities, "packageManager.queryInte…ageManager.GET_META_DATA)");
            return queryIntentActivities;
        }
    }

    public static final List<ServiceInfo> t(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "action");
        return a(context, str, new h(context), i.f9281a);
    }

    public static final class b extends c.f.b.l implements c.f.a.b<ResolveInfo, ActivityInfo> {
        public static final b f9269a = new b();

        b() {
            super(1);
        }

        @Override
        public final ActivityInfo invoke(ResolveInfo resolveInfo) {
            c.f.b.k.b(resolveInfo, "it");
            ActivityInfo activityInfo = resolveInfo.activityInfo;
            c.f.b.k.a((Object) activityInfo, "it.activityInfo");
            return activityInfo;
        }
    }

    private static final c.f.a.b<Intent, List<ResolveInfo>> aT(Context context) {
        return new a(context);
    }

    private static final c.f.a.b<ResolveInfo, ActivityInfo> aU(Context context) {
        return b.f9269a;
    }

    public static final List<ActivityInfo> u(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "action");
        return a(context, str, aT(context), aU(context));
    }

    public static final List<ActivityInfo> a(Context context, Uri uri) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(uri, "dataUri");
        return a(context, uri, aT(context), aU(context));
    }

    public static final List<ActivityInfo> b(Context context, Intent intent) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(intent, "intent");
        return a(context, intent, aT(context), aU(context));
    }

    public static final ActivityInfo a(Context context, String str, Uri uri) {
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        c.f.b.k.b(uri, "dataUri");
        Iterator<T> it = a(context, uri).iterator();
        while (true) {
            if (!it.hasNext()) {
                obj = null;
                break;
            }
            obj = it.next();
            ActivityInfo activityInfo = (ActivityInfo) obj;
            if (c.f.b.k.a((Object) (activityInfo != null ? activityInfo.packageName : null), (Object) str)) {
                break;
            }
        }
        return (ActivityInfo) obj;
    }

    public static final boolean v(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "action");
        return u(context, str).size() > 0;
    }

    public static final List<ComponentName> az(Context context) {
        c.f.b.k.b(context, "receiver$0");
        Intent a2 = net.dinglisch.android.taskerm.cr.a();
        c.f.b.k.a((Object) a2, "MyPM.getLauncherIntent()");
        ArrayList arrayList = new ArrayList();
        for (ActivityInfo activityInfo : b(context, a2)) {
            ComponentName componentName = activityInfo == null ? null : new ComponentName(activityInfo.packageName, activityInfo.name);
            if (componentName != null) {
                arrayList.add(componentName);
            }
        }
        return arrayList;
    }

    public static final ComponentName w(Context context, String str) {
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "packageName");
        Iterator<T> it = az(context).iterator();
        while (true) {
            if (!it.hasNext()) {
                obj = null;
                break;
            }
            obj = it.next();
            if (c.f.b.k.a((Object) ((ComponentName) obj).getPackageName(), (Object) str)) {
                break;
            }
        }
        return (ComponentName) obj;
    }

    public static final boolean a(Activity activity, Intent intent, int i2) {
        c.f.b.k.b(activity, "receiver$0");
        c.f.b.k.b(intent, "intent");
        try {
            activity.startActivityForResult(intent, i2);
            return true;
        } catch (Exception e2) {
            am.a(e2, activity);
            return false;
        }
    }

    public static final boolean a(Activity activity, int i2, int i3, int i4, String str) {
        c.f.b.k.b(activity, "receiver$0");
        c.f.b.k.b(str, "linkExplaining");
        Activity activity2 = activity;
        boolean a2 = com.joaomgcd.taskerm.q.b.a(activity2, new com.joaomgcd.taskerm.util.l(activity2, i4, new Object[0]), null, 2, null);
        boolean a3 = HelperMonitorService.f7306c.a(activity2, i2);
        if (a2) {
            activity.finish();
            return a3;
        } else if (a3) {
            return true;
        } else {
            com.joaomgcd.taskerm.rx.h.c(new k(activity, i3, i4, str));
            return false;
        }
    }

    public static final class k extends c.f.b.l implements c.f.a.a<c.s> {
        final Activity f9284a;
        final int f9285b;
        final int f9286c;
        final String f9287d;

        k(Activity activity, int i, int i2, String str) {
            super(0);
            this.f9284a = activity;
            this.f9285b = i;
            this.f9286c = i2;
            this.f9287d = str;
        }

        @Override
        public c.s invoke() {
            a();
            return c.s.f2131a;
        }

        public final void a() {
            if (((com.joaomgcd.taskerm.dialog.x) com.joaomgcd.taskerm.dialog.y.a(this.f9284a, this.f9285b, this.f9286c, (com.joaomgcd.taskerm.util.i) null, 8, (Object) null).b()).d()) {
                al.a((Context) this.f9284a, this.f9287d, false, false, false, 14, (Object) null);
            }
            this.f9284a.finish();
        }
    }

    public static final boolean aA(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return com.google.android.gms.common.c.a().a(context) == 0;
    }

    public static final boolean a(Activity activity) {
        Dialog a2;
        c.f.b.k.b(activity, "receiver$0");
        com.google.android.gms.common.c a3 = com.google.android.gms.common.c.a();
        c.f.b.k.a((Object) a3, "GoogleApiAvailability.getInstance()");
        int a4 = a3.a(activity);
        if (a4 != 0) {
            if (!a3.a(a4) || (a2 = a3.a(activity, a4, 2404)) == null) {
                return false;
            }
            a2.show();
            return false;
        }
        return true;
    }

    public static final boolean aB(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return c.f.b.k.a((Object) Build.MANUFACTURER, (Object) "samsung");
    }

    public static final boolean aC(Context context) {
        c.f.b.k.b(context, "receiver$0");
        if (aB(context)) {
            ComponentName aa = aa(context);
            if (c.f.b.k.a((Object) (aa != null ? aa.getClassName() : null), (Object) "com.sec.android.app.launcher.activities.LauncherActivity")) {
                return true;
            }
        }
        return false;
    }

    public static final class n extends c.f.b.l implements c.f.a.a<c.s> {
        final Activity f9291a;
        final boolean f9292b;

        n(Activity activity, boolean z) {
            super(0);
            this.f9291a = activity;
            this.f9292b = z;
        }

        @Override
        public c.s invoke() {
            a();
            return c.s.f2131a;
        }

        public final void a() {
            if (this.f9292b) {
                this.f9291a.getWindow().addFlags(128);
            } else {
                this.f9291a.getWindow().clearFlags(128);
            }
        }
    }

    public static final void a(Activity activity, boolean z) {
        c.f.b.k.b(activity, "receiver$0");
        com.joaomgcd.taskerm.rx.h.e(new n(activity, z));
    }

    @TargetApi(28)
    public static final void b(Activity activity) {
        c.f.b.k.b(activity, "receiver$0");
        if (com.joaomgcd.taskerm.util.g.f9751b.p()) {
            return;
        }
        activity.getWindow().getAttributes().layoutInDisplayCutoutMode = 1;
    }

    public static final boolean aD(Context context) {
        Configuration configuration;
        c.f.b.k.b(context, "receiver$0");
        Resources resources = context.getResources();
        return (resources == null || (configuration = resources.getConfiguration()) == null || (configuration.uiMode & 48) != 32) ? false : true;
    }

    public static final String[] b(Context context, Uri uri) {
        Cursor cursor;
        String[] columnNames;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(uri, "uri");
        Cursor cursor2 = null;
        try {
            cursor = context.getContentResolver().query(uri, null, null, null, null);
            if (cursor != null) {
                try {
                    columnNames = cursor.getColumnNames();
                    if (columnNames != null) {
                        if (cursor != null) {
                            cursor.close();
                        }
                        return columnNames;
                    }
                } catch (Throwable th) {
                    th = th;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            }
            columnNames = new String[0];
            if (cursor != null) {
            }
            return columnNames;
        } catch (Throwable th2) {
            th = th2;
            cursor = cursor2;
        }
    }

    public static final ArrayList<HashMap<String, Serializable>> a(Context context, Uri uri, String str, String[] strArr, String[] strArr2, int i2, String str2) {
        Long l2;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(uri, "uri");
        ArrayList<HashMap<String, Serializable>> arrayList = new ArrayList<>();
        Cursor query = context.getContentResolver().query(uri, strArr2, str, strArr, str2);
        if (query != null) {
            int i3 = 0;
            while (query.moveToNext() && i3 < i2) {
                try {
                    HashMap<String, Serializable> hashMap = new HashMap<>();
                    try {
                        int columnCount = query.getColumnCount();
                        for (int i4 = 0; i4 < columnCount; i4++) {
                            String columnName = query.getColumnName(i4);
                            switch (query.getType(i4)) {
                                case 0:
                                    l2 = null;
                                    break;
                                case 1:
                                    l2 = Long.valueOf(query.getLong(i4));
                                    break;
                                case 2:
                                    l2 = Float.valueOf(query.getFloat(i4));
                                    break;
                                case 3:
                                    l2 = query.getString(i4);
                                    break;
                                case 4:
                                    l2 = (Serializable) query.getBlob(i4);
                                    break;
                                default:
                                    l2 = query.getString(i4);
                                    break;
                            }
                            c.f.b.k.a((Object) columnName, "columnName");
                            hashMap.put(columnName, l2);
                        }
                        i3++;
                    } catch (Exception unused) {
                    }
                    arrayList.add(hashMap);
                } finally {
                    query.close();
                }
            }
            return arrayList;
        }
        return arrayList;
    }

    public static final void x(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "command");
        com.joaomgcd.taskerm.event.app.r rVar = new com.joaomgcd.taskerm.event.app.r(str, null, null, null, null, 30, null);
        Object obj = null;
        com.joaomgcd.taskerm.inputoutput.a.b bVar = null;
        Iterator it = com.joaomgcd.taskerm.event.h.a().c().iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Object next = it.next();
            if (((com.joaomgcd.taskerm.event.b) next) instanceof com.joaomgcd.taskerm.event.app.d) {
                obj = next;
                break;
            }
        }
        if (obj != null) {
            com.joaomgcd.taskerm.event.b.a((com.joaomgcd.taskerm.event.app.d) obj, context, null, rVar, null, null, bVar, 16, null);
            return;
        }
        throw new c.q("null cannot be cast to non-null type com.joaomgcd.taskerm.event.app.EventCommand");
    }

    public static final LayoutInflater aE(Context context) {
        c.f.b.k.b(context, "receiver$0");
        LayoutInflater from = LayoutInflater.from(context);
        c.f.b.k.a((Object) from, "LayoutInflater.from(this)");
        return from;
    }

    public static final StorageManager aF(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (StorageManager) context.getSystemService("storage");
    }

    public static final AccessibilityManager aG(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return (AccessibilityManager) context.getSystemService("accessibility");
    }

    public static final String a(Context context, int i2) {
        c.f.b.k.b(context, "receiver$0");
        return dq.a(context.getResources().openRawResource(i2));
    }

    public static final boolean aH(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return go.a.b(context);
    }

    public static final boolean a(Context context, Intent intent, String str, Object obj) {
        String canonicalName;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "key");
        if (intent == null || (canonicalName = Main.class.getCanonicalName()) == null) {
            return false;
        }
        intent.setComponent(new ComponentName(context, canonicalName));
        if (obj != null ? obj instanceof String : true) {
            intent.putExtra(str, (String) obj);
        } else if (obj instanceof String) {
            intent.putExtra(str, (String) obj);
        } else if (obj instanceof Integer) {
            intent.putExtra(str, ((Number) obj).intValue());
        } else if (obj instanceof Boolean) {
            intent.putExtra(str, ((Boolean) obj).booleanValue());
        } else if (obj instanceof Float) {
            intent.putExtra(str, ((Number) obj).floatValue());
        } else if (obj instanceof Double) {
            intent.putExtra(str, ((Number) obj).doubleValue());
        }
        return c(context, intent);
    }

    private static final boolean c(Context context, Intent intent) {
        return a(context, intent, true);
    }

    public static final boolean a(Context context, Intent intent, boolean z) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(intent, "intent");
        intent.addFlags(268435456);
        intent.addFlags(4);
        intent.addFlags(536870912);
        if (z) {
            intent.addFlags(8388608);
        }
        return gs.a(context, intent);
    }

    public static final b.a.b b(Context context, int i2) {
        c.f.b.k.b(context, "receiver$0");
        com.joaomgcd.taskerm.securesettings.k kVar = new com.joaomgcd.taskerm.securesettings.k();
        b.a.b b2 = com.joaomgcd.taskerm.securesettings.ab.b(context, kVar).b(new r(context, kVar, i2));
        c.f.b.k.a((Object) b2, "com.joaomgcd.taskerm.sec…omplete()\n        }\n    }");
        return b2;
    }

    public static final class r<T, R> implements b.a.d.g<String, b.a.d> {
        final Context f9305a;
        final com.joaomgcd.taskerm.securesettings.k f9306b;
        final int f9307c;

        r(Context context, com.joaomgcd.taskerm.securesettings.k kVar, int i) {
            this.f9305a = context;
            this.f9306b = kVar;
            this.f9307c = i;
        }

        @Override
        public final b.a.d apply(String str) {
            c.f.b.k.b(str, "it");
            if (!c.f.b.k.a((Object) str, (Object) this.f9306b.h())) {
                return com.joaomgcd.taskerm.securesettings.ab.a(this.f9305a, (com.joaomgcd.taskerm.securesettings.s) this.f9306b).b(new b.a.d.g<Boolean, b.a.d>() {
                    {
                        r.this = this;
                    }

                    @Override
                    public final b.a.b apply(Boolean bool) {
                        c.f.b.k.b(bool, "it");
                        aw.a aVar = com.joaomgcd.taskerm.notification.aw.f8309b;
                        Context context = r.this.f9305a;
                        String a2 = an.a((int) R.string.action_may_need_restart, r.this.f9305a, new Object[0]);
                        Context context2 = r.this.f9305a;
                        String u = net.dinglisch.android.taskerm.n.u(r.this.f9307c);
                        c.f.b.k.a((Object) u, "ActionSpecs.getActionNameByCode(actionCode)");
                        return aw.a.a(aVar, context, "neededrestart", a2, an.a((int) R.string.action_may_need_restart_explained, context2, u), null, 16, null);
                    }
                });
            }
            return b.a.b.a();
        }
    }

    private static final boolean a() {
        return f9267b != null;
    }

    public static final b.a.b c(Context context, boolean z) {
        String str;
        c.f.b.k.b(context, "receiver$0");
        if (com.joaomgcd.taskerm.util.g.f9751b.n()) {
            b.a.b a2 = b.a.b.a();
            c.f.b.k.a((Object) a2, "Completable.complete()");
            return a2;
        } else if (z && !a()) {
            b.a.b a3 = b.a.b.a();
            c.f.b.k.a((Object) a3, "Completable.complete()");
            return a3;
        } else {
            if (z) {
                str = f9267b;
                if (str == null) {
                    str = "2";
                }
            } else {
                str = "0";
            }
            com.joaomgcd.taskerm.securesettings.r rVar = new com.joaomgcd.taskerm.securesettings.r();
            rVar.a(str);
            b.a.b b2 = com.joaomgcd.taskerm.securesettings.ab.b(context, rVar).b(new q(context, str, rVar, z));
            c.f.b.k.a((Object) b2, "com.joaomgcd.taskerm.sec…omplete()\n        }\n    }");
            return b2;
        }
    }

    public static final class q<T, R> implements b.a.d.g<String, b.a.d> {
        final Context f9296a;
        final String f9297b;
        final com.joaomgcd.taskerm.securesettings.r f9298c;
        final boolean f9299d;

        q(Context context, String str, com.joaomgcd.taskerm.securesettings.r rVar, boolean z) {
            this.f9296a = context;
            this.f9297b = str;
            this.f9298c = rVar;
            this.f9299d = z;
        }

        @Override
        public final b.a.d apply(final String str) {
            c.f.b.k.b(str, "oldValue");
            if (!c.f.b.k.a((Object) str, (Object) this.f9297b)) {
                return com.joaomgcd.taskerm.securesettings.ab.a(this.f9296a, (com.joaomgcd.taskerm.securesettings.s) this.f9298c).b(new b.a.d.f<Boolean>() {
                    {
                        q.this = this;
                    }

                    @Override
                    public final void accept(Boolean bool) {
                        c.f.b.k.b(bool, "it");
                        if (!q.this.f9299d) {
                            al.f9267b = str;
                        } else {
                            al.f9267b = null;
                        }
                    }
                }).c(new b.a.d.f<Throwable>() {

                    public static final class C02612 extends c.f.b.l implements c.f.a.a<c.s> {
                        public static final C02612 f9304a = new C02612();

                        C02612() {
                            super(0);
                        }

                        public final void a() {
                        }

                        @Override
                        public c.s invoke() {
                            a();
                            return c.s.f2131a;
                        }
                    }

                    {
                        q.this = this;
                    }

                    public static final class AnonymousClass1 extends c.f.b.l implements c.f.a.b<com.joaomgcd.taskerm.notification.aw, c.s> {
                        AnonymousClass1() {
                            super(1);
                            AnonymousClass2.this = r1;
                        }

                        @Override
                        public c.s invoke(com.joaomgcd.taskerm.notification.aw awVar) {
                            a(awVar);
                            return c.s.f2131a;
                        }

                        public final void a(com.joaomgcd.taskerm.notification.aw awVar) {
                            c.f.b.k.b(awVar, "receiver$0");
                            awVar.a(new com.joaomgcd.taskerm.notification.ai(q.this.f9296a));
                            awVar.a(true);
                        }
                    }

                    @Override
                    public final void accept(Throwable th) {
                        c.f.b.k.b(th, "it");
                        com.joaomgcd.taskerm.rx.h.a(com.joaomgcd.taskerm.notification.aw.f8309b.b(q.this.f9296a, "nonblockoverlaysandroid12needsecuresetting", an.a((int) R.string.non_blocking_overlay_android_12, q.this.f9296a, new Object[0]), an.a((int) R.string.non_blocking_overlay_android_12_explained, q.this.f9296a, new Object[0]), new AnonymousClass1()), q.this.f9296a, C02612.f9304a);
                    }
                }).d();
            }
            if (!this.f9299d) {
                al.f9267b = null;
            }
            return b.a.b.a();
        }
    }

    public static final b.a.b aI(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return c(context, false);
    }

    public static final b.a.b aJ(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return c(context, true);
    }

    public static final String a(Context context, Integer num) {
        c.f.b.k.b(context, "receiver$0");
        return y(context, num != null ? String.valueOf(num.intValue()) : null);
    }

    public static final String y(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        if (str == null) {
            return null;
        }
        Cursor query = context.getContentResolver().query(Uri.parse("content://mms/part/"), new String[]{"ct", "text", "_id"}, "mid = ?", new String[]{str}, null);
        Throwable th = null;
        try {
            Cursor cursor = query;
            if (cursor == null) {
                c.e.b.a(query, th);
                return null;
            }
            while (cursor.moveToNext()) {
                if (!(!c.f.b.k.a((Object) "text/plain", (Object) cursor.getString(0)))) {
                    String string = cursor.getString(1);
                    c.e.b.a(query, th);
                    return string;
                }
            }
            c.s sVar = c.s.f2131a;
            c.e.b.a(query, th);
            return null;
        } finally {
        }
    }

    public static final Intent a(Context context, IntentFilter intentFilter, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(intentFilter, "intentFilter");
        c.f.b.k.b(str, "tag");
        BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context2, Intent intent) {
            }
        };
        try {
            try {
                Intent registerReceiver = context.registerReceiver(broadcastReceiver, intentFilter, null, null);
                try {
                    context.unregisterReceiver(broadcastReceiver);
                } catch (Exception e2) {
                    net.dinglisch.android.taskerm.bo.b(str, "Error unregistering null receiver: " + intentFilter, e2);
                }
                return registerReceiver;
            } catch (Exception e3) {
                net.dinglisch.android.taskerm.bo.b(str, "Error registering null receiver: " + intentFilter, e3);
                try {
                    context.unregisterReceiver(broadcastReceiver);
                    return null;
                } catch (Exception e4) {
                    net.dinglisch.android.taskerm.bo.b(str, "Error unregistering null receiver: " + intentFilter, e4);
                    return null;
                }
            }
        } catch (Throwable th) {
            try {
                context.unregisterReceiver(broadcastReceiver);
            } catch (Exception e5) {
                net.dinglisch.android.taskerm.bo.b(str, "Error unregistering null receiver: " + intentFilter, e5);
            }
            throw th;
        }
    }

    public static final BatteryInfo aK(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return new BatteryInfo(context);
    }

    public static final List<com.joaomgcd.taskerm.util.a> aL(Context context) {
        c.f.b.k.b(context, "receiver$0");
        List<AccessibilityServiceInfo> aM = aM(context);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) aM, 10));
        for (AccessibilityServiceInfo accessibilityServiceInfo : aM) {
            c.f.b.k.a((Object) accessibilityServiceInfo, "it");
            ResolveInfo resolveInfo = accessibilityServiceInfo.getResolveInfo();
            c.f.b.k.a((Object) resolveInfo, "it.resolveInfo");
            arrayList.add(new com.joaomgcd.taskerm.util.a(context, an.a(resolveInfo)));
        }
        return arrayList;
    }

    public static final class l extends c.f.b.l implements c.f.a.a<List<AccessibilityServiceInfo>> {
        final Context f9288a;

        l(Context context) {
            super(0);
            this.f9288a = context;
        }

        @Override
        public final List<AccessibilityServiceInfo> invoke() {
            AccessibilityManager aG = al.aG(this.f9288a);
            if (aG != null) {
                return aG.getInstalledAccessibilityServiceList();
            }
            return null;
        }
    }

    public static final List<AccessibilityServiceInfo> aM(Context context) {
        c.f.b.k.b(context, "receiver$0");
        List<AccessibilityServiceInfo> list = (List) an.a((c.f.a.b) null, new l(context), 1, (Object) null);
        return list != null ? list : c.a.j.a();
    }

    public static final List<ComponentName> aN(Context context) {
        c.f.b.k.b(context, "receiver$0");
        List<AccessibilityServiceInfo> aM = aM(context);
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) aM, 10));
        for (AccessibilityServiceInfo accessibilityServiceInfo : aM) {
            c.f.b.k.a((Object) accessibilityServiceInfo, "it");
            ResolveInfo resolveInfo = accessibilityServiceInfo.getResolveInfo();
            c.f.b.k.a((Object) resolveInfo, "it.resolveInfo");
            arrayList.add(an.a(resolveInfo));
        }
        return arrayList;
    }

    public static final List<ComponentName> aO(Context context) {
        List<AccessibilityServiceInfo> enabledAccessibilityServiceList;
        c.f.b.k.b(context, "receiver$0");
        AccessibilityManager aG = aG(context);
        if (aG == null || (enabledAccessibilityServiceList = aG.getEnabledAccessibilityServiceList(63)) == null) {
            return c.a.j.a();
        }
        List<AccessibilityServiceInfo> list = enabledAccessibilityServiceList;
        ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) list, 10));
        for (AccessibilityServiceInfo accessibilityServiceInfo : list) {
            c.f.b.k.a((Object) accessibilityServiceInfo, "it");
            ResolveInfo resolveInfo = accessibilityServiceInfo.getResolveInfo();
            c.f.b.k.a((Object) resolveInfo, "it.resolveInfo");
            arrayList.add(an.a(resolveInfo));
        }
        return arrayList;
    }

    public static final List<ComponentName> aP(Context context) {
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        List<ComponentName> aN = aN(context);
        List<ComponentName> aO = aO(context);
        ArrayList<ComponentName> arrayList = new ArrayList();
        for (Object obj2 : aS(context)) {
            if (!d(context, (ComponentName) obj2)) {
                arrayList.add(obj2);
            }
        }
        ArrayList arrayList2 = new ArrayList();
        for (ComponentName componentName : arrayList) {
            Iterator<T> it = aN.iterator();
            while (true) {
                if (!it.hasNext()) {
                    obj = null;
                    break;
                }
                obj = it.next();
                if (c.f.b.k.a((ComponentName) obj, componentName)) {
                    break;
                }
            }
            ComponentName componentName2 = (ComponentName) obj;
            if (componentName2 != null) {
                arrayList2.add(componentName2);
            }
        }
        return c.a.j.b((Collection) aO, (Iterable) arrayList2);
    }

    public static final List<ComponentName> aQ(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return aP(context);
    }

    public static final String aR(Context context) {
        c.f.b.k.b(context, "receiver$0");
        return Settings.Secure.getString(context.getContentResolver(), "enabled_accessibility_services");
    }

    public static final List<ComponentName> aS(Context context) {
        c.f.b.k.b(context, "receiver$0");
        List<ComponentName> aN = aN(context);
        ArrayList arrayList = new ArrayList();
        for (Object obj : a(aR(context))) {
            if (aN.contains((ComponentName) obj)) {
                arrayList.add(obj);
            }
        }
        return c.a.j.l(arrayList);
    }

    public static final List<ComponentName> a(String str) {
        List b2;
        if (str == null || (b2 = c.l.n.b((CharSequence) str, new String[]{ConstantsCommonTaskerServer.ID_SEPARATOR}, false, 0, 6, (Object) null)) == null) {
            return c.a.j.a();
        }
        ArrayList<String> arrayList = new ArrayList();
        Iterator it = b2.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Object next = it.next();
            if (((String) next).length() > 0) {
                arrayList.add(next);
            }
        }
        ArrayList arrayList2 = new ArrayList();
        for (String str2 : arrayList) {
            List b3 = c.l.n.b((CharSequence) str2, new String[]{"/"}, false, 0, 6, (Object) null);
            ComponentName componentName = null;
            if (b3.size() == 2) {
                String str3 = (String) b3.get(0);
                String str4 = (String) b3.get(1);
                if (c.l.n.a(str4, ".", false, 2, (Object) null)) {
                    str4 = str3 + str4;
                }
                componentName = new ComponentName(str3, str4);
            }
            if (componentName != null) {
                arrayList2.add(componentName);
            }
        }
        return arrayList2;
    }

    public static final boolean c(Context context, ComponentName componentName) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(componentName, "component");
        List<ComponentName> aP = aP(context);
        if ((aP instanceof Collection) && aP.isEmpty()) {
            return false;
        }
        for (ComponentName componentName2 : aP) {
            if (c.f.b.k.a(componentName2, componentName)) {
                return true;
            }
        }
        return false;
    }

    public static final boolean d(Context context, ComponentName componentName) {
        Object obj;
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(componentName, "component");
        Iterator<T> it = aM(context).iterator();
        while (true) {
            if (!it.hasNext()) {
                obj = null;
                break;
            }
            obj = it.next();
            AccessibilityServiceInfo accessibilityServiceInfo = (AccessibilityServiceInfo) obj;
            c.f.b.k.a((Object) accessibilityServiceInfo, "it");
            ResolveInfo resolveInfo = accessibilityServiceInfo.getResolveInfo();
            c.f.b.k.a((Object) resolveInfo, "it.resolveInfo");
            if (c.f.b.k.a(an.a(resolveInfo), componentName)) {
                break;
            }
        }
        AccessibilityServiceInfo accessibilityServiceInfo2 = (AccessibilityServiceInfo) obj;
        return (accessibilityServiceInfo2 == null || accessibilityServiceInfo2.feedbackType == 0) ? false : true;
    }

    public static final class g extends c.f.b.l implements c.f.a.a<String> {
        final Context f9278a;
        final ComponentName f9279b;

        g(Context context, ComponentName componentName) {
            super(0);
            this.f9278a = context;
            this.f9279b = componentName;
        }

        @Override
        public final String invoke() {
            return this.f9278a.getPackageManager().getServiceInfo(this.f9279b, 0).loadLabel(this.f9278a.getPackageManager()).toString();
        }
    }

    public static final String e(Context context, ComponentName componentName) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(componentName, "component");
        String str = (String) an.a((c.f.a.b) null, new g(context, componentName), 1, (Object) null);
        return str != null ? str : componentName.flattenToString();
    }

    @TargetApi(28)
    public static final boolean z(Context context, String str) {
        c.f.b.k.b(context, "receiver$0");
        c.f.b.k.b(str, "otherPackageName");
        if (ds.b()) {
            return true;
        }
        Boolean bool = (Boolean) an.a((c.f.a.b) null, new m(context, str), 1, (Object) null);
        if (bool != null) {
            return bool.booleanValue();
        }
        return false;
    }

    public static final class m extends c.f.b.l implements c.f.a.a<Boolean> {
        final Context f9289a;
        final String f9290b;

        m(Context context, String str) {
            super(0);
            this.f9289a = context;
            this.f9290b = str;
        }

        @Override
        public Boolean invoke() {
            return Boolean.valueOf(a());
        }

        public final boolean a() {
            Signature[] signatureArr;
            PackageInfo packageInfo;
            Signature[] signatureArr2;
            SigningInfo signingInfo;
            PackageInfo packageInfo2;
            SigningInfo signingInfo2;
            if (com.joaomgcd.taskerm.util.g.f9751b.g()) {
                PackageInfo packageInfo3 = this.f9289a.getPackageManager().getPackageInfo(this.f9289a.getPackageName(), 134217728);
                if (packageInfo3 == null || (signingInfo = packageInfo3.signingInfo) == null || (packageInfo2 = this.f9289a.getPackageManager().getPackageInfo(this.f9290b, 134217728)) == null || (signingInfo2 = packageInfo2.signingInfo) == null) {
                    return false;
                }
                Signature[] signingCertificateHistory = signingInfo.getSigningCertificateHistory();
                c.f.b.k.a((Object) signingCertificateHistory, "mySigningInfo.signingCertificateHistory");
                Signature[] signingCertificateHistory2 = signingInfo2.getSigningCertificateHistory();
                c.f.b.k.a((Object) signingCertificateHistory2, "otherSigningInfo.signingCertificateHistory");
                return Arrays.equals(signingCertificateHistory, signingCertificateHistory2);
            }
            PackageInfo packageInfo4 = this.f9289a.getPackageManager().getPackageInfo(this.f9289a.getPackageName(), 64);
            if (packageInfo4 == null || (signatureArr = packageInfo4.signatures) == null || (packageInfo = this.f9289a.getPackageManager().getPackageInfo(this.f9290b, 64)) == null || (signatureArr2 = packageInfo.signatures) == null) {
                return false;
            }
            return Arrays.equals(signatureArr, signatureArr2);
        }
    }
}