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

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


package com.joaomgcd.taskerm.util;

import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.location.Location;
import android.os.Build;
import android.os.Debug;
import android.os.Environment;
import android.os.Process;
import android.os.SystemClock;
import android.os.UserHandle;
import androidx.core.app.NotificationCompat;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.joaomgcd.taskerm.dialog.ac;
import com.joaomgcd.taskerm.google.drive.a;
import com.joaomgcd.taskerm.google.drive.io.DriveMetadataV3Upload;
import com.joaomgcd.taskerm.google.drive.io.ErrorPayloadGoogleDrive;
import com.joaomgcd.taskerm.util.bw;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import net.danlew.android.joda.R;
import net.dinglisch.android.taskerm.Main;
import net.dinglisch.android.taskerm.Settings;
import net.dinglisch.android.taskerm.av;
import net.dinglisch.android.taskerm.fk;
import net.dinglisch.android.taskerm.fn;
import net.dinglisch.android.taskerm.fo;
public final class ds {
    private static final boolean f9719a = ao.a("6.1.32", "beta", "rc");

    public static final void b(Activity activity) {
        a(activity, (c.f.a.a) null, 1, (Object) null);
    }

    public static final boolean b() {
        return false;
    }

    public static final long r() {
        return s();
    }

    private static final long s() {
        return -1L;
    }

    public static final boolean a() {
        return f9719a;
    }

    public static final boolean c() {
        return g.f9751b.o() || Environment.isExternalStorageManager();
    }

    public static final boolean d() {
        return Main.a() || com.joaomgcd.b.a.f4889a.a();
    }

    private static final <T> T a(String str, String str2, c.f.a.m<? super Resources, ? super Integer, ? extends T> mVar) {
        Resources system = Resources.getSystem();
        int identifier = system.getIdentifier(str, "integer", "android");
        c.f.b.k.a((Object) system, "res");
        return mVar.invoke(system, Integer.valueOf(identifier));
    }

    public static final class d extends c.f.b.l implements c.f.a.m<Resources, Integer, Integer> {
        public static final d f9726a = new d();

        d() {
            super(2);
        }

        @Override
        public Integer invoke(Resources resources, Integer num) {
            return Integer.valueOf(a(resources, num.intValue()));
        }

        public final int a(Resources resources, int i) {
            c.f.b.k.b(resources, "receiver$0");
            return resources.getInteger(i);
        }
    }

    private static final int a(String str) {
        return ((Number) a(str, "integer", d.f9726a)).intValue();
    }

    public static final int e() {
        return a("config_screenBrightnessSettingMaximum");
    }

    static final class c<T, R> implements b.a.d.g<T, R> {
        public static final c f9725a = new c();

        c() {
        }

        @Override
        public final String apply(String str) {
            String name;
            c.f.b.k.b(str, "it");
            if (str.length() == 0) {
                BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
                return (defaultAdapter == null || (name = defaultAdapter.getName()) == null) ? Build.MODEL : name;
            }
            return str;
        }
    }

    @TargetApi(NotificationCompat.MessagingStyle.MAXIMUM_RETAINED_MESSAGES)
    public static final b.a.l<String> a(Context context) {
        c.f.b.k.b(context, "context");
        b.a.l c2 = com.joaomgcd.taskerm.securesettings.ab.b(context, new com.joaomgcd.taskerm.securesettings.g(com.joaomgcd.taskerm.securesettings.q.Global, "device_name", false, 0, 0, 24, null)).c(c.f9725a);
        c.f.b.k.a((Object) c2, "get(context, SecureSetti…else {\n        it\n    }\n}");
        return c2;
    }

    public static final long f() {
        return System.currentTimeMillis();
    }

    public static final long g() {
        return SystemClock.elapsedRealtimeNanos();
    }

    public static final void a(long j) {
        Thread.sleep(j);
    }

    public static final void a(long j, int i, c.f.a.b<? super Integer, Boolean> bVar) {
        c.f.b.k.b(bVar, "until");
        for (int i2 = 0; !bVar.invoke(Integer.valueOf(i2)).booleanValue() && i2 < i; i2++) {
            a(j);
        }
    }

    public static final void b(long j) {
        try {
            Thread.sleep(j * 1000);
        } catch (Throwable unused) {
        }
    }

    public static final long c(Context context) {
        long s = s();
        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, "cdl", s, a2);
    }

    public static final void b(Context context, long j) {
        Long valueOf = Long.valueOf(j);
        SharedPreferences a2 = com.joaomgcd.taskerm.q.b.a(context);
        c.f.b.k.a((Object) a2, "preferencesState");
        com.joaomgcd.taskerm.q.b.a(context, "cdl", valueOf, a2);
    }

    static final class a extends c.f.b.l implements c.f.a.a<cr> {
        final Activity f9720a;

        public static final class AnonymousClass1 extends c.f.b.l implements c.f.a.b<File, c.s> {
            public static final AnonymousClass1 f9721a = new AnonymousClass1();

            AnonymousClass1() {
                super(1);
            }

            public final void a(File file) {
                c.f.b.k.b(file, "it");
            }

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

        a(Activity activity) {
            super(0);
            this.f9720a = activity;
        }

        @Override
        public final cr invoke() {
            com.joaomgcd.taskerm.dialog.x xVar;
            String str;
            Object[] array;
            Object obj;
            boolean z;
            ErrorPayloadGoogleDrive errorPayloadGoogleDrive;
            GoogleSignInAccount b2;
            b.a.l<File> c2;
            int i = 2;
            ?? r7 = 0;
            cr b3 = bw.f9512c.a(this.f9720a, bw.a.a(bw.f9512c, (Context) this.f9720a, 0, 2, (Object) null)).b();
            if (b3.b()) {
                if (ds.c(this.f9720a) == ds.r()) {
                    if (!((com.joaomgcd.taskerm.dialog.x) com.joaomgcd.taskerm.dialog.y.a(this.f9720a, (int) R.string.ml_create_debug_log, (int) R.string.dc_starting_debug_log, 0, false, (String) null, 56, (Object) null).b()).d()) {
                        return ct.a("User cancelled");
                    }
                    ds.b(this.f9720a, System.currentTimeMillis());
                    com.joaomgcd.taskerm.dialog.x b4 = com.joaomgcd.taskerm.dialog.y.a(this.f9720a, (int) R.string.ml_create_debug_log, (int) R.string.dc_starting_debug_log_ask_video_catpure, (int) R.string.button_label_yes_with_audio).b();
                    boolean g = b4.g();
                    if (b4.d() || g) {
                        com.joaomgcd.taskerm.t.c d2 = al.d(this.f9720a).d();
                        if (d2 != null && (c2 = d2.c()) != null) {
                            c2.b();
                        }
                        boolean z2 = (!g || bw.a.s(bw.f9512c, this.f9720a, 0, 2, null).b().b().b()) ? g : false;
                        Thread.sleep(500L);
                        com.joaomgcd.taskerm.t.c d3 = al.d(this.f9720a).d();
                        File cacheDir = this.f9720a.getCacheDir();
                        c.f.b.k.a((Object) cacheDir, "this.cacheDir");
                        String absolutePath = cacheDir.getAbsolutePath();
                        c.f.b.k.a((Object) absolutePath, "this.cacheDir.absolutePath");
                        com.joaomgcd.taskerm.rx.h.a(d3.a(new com.joaomgcd.taskerm.t.b(absolutePath, "userreport", z2, null, null, null, null, null, null, 504, null)), this.f9720a, AnonymousClass1.f9721a);
                    }
                    net.dinglisch.android.taskerm.bo.g();
                    com.joaomgcd.taskerm.settings.ai.b(this.f9720a, true);
                    ao.c("Started debugging. Use the same option to finish debugging.", this.f9720a);
                    obj = null;
                } else {
                    b.a.l<File> c3 = al.d(this.f9720a).d().c();
                    File b5 = c3 != null ? c3.b() : null;
                    ds.b(this.f9720a, ds.r());
                    com.joaomgcd.taskerm.settings.ai.b(this.f9720a, false);
                    File f2 = net.dinglisch.android.taskerm.bo.f();
                    if (f2 == null) {
                        ao.b("Couldn't find log file!", this.f9720a);
                        return ct.a("Couldn't find log file!");
                    }
                    ao.b("Finished debugging", this.f9720a);
                    if (!((com.joaomgcd.taskerm.dialog.x) com.joaomgcd.taskerm.dialog.y.a(this.f9720a, (int) R.string.dt_what_are_reporting, (String) null, 0, true, (String) null, 40, (Object) null).b()).d()) {
                        return ct.a("User cancelled");
                    }
                    String str2 = al.A(this.f9720a) + "\n\nUser report: " + xVar.j();
                    ArrayList h = c.a.d.h(new File[]{f2, b5});
                    try {
                        a.C0166a c0166a = com.joaomgcd.taskerm.google.drive.a.f7190a;
                        Activity activity = this.f9720a;
                        GoogleSignInAccount a2 = com.joaomgcd.taskerm.signin.c.f8926a.a(this.f9720a);
                        b2 = c0166a.a(activity, false, true, a2 != null ? a2.c() : null).b();
                    } catch (Exception unused) {
                    }
                    if (b2 != null) {
                        str = b2.c();
                        if (str == null) {
                            com.joaomgcd.taskerm.google.drive.j jVar = new com.joaomgcd.taskerm.google.drive.j(this.f9720a, str);
                            com.joaomgcd.taskerm.google.drive.l lVar = com.joaomgcd.taskerm.google.drive.l.Normal;
                            List<File> list = h;
                            ArrayList arrayList = new ArrayList(c.a.j.a((Iterable) list, 10));
                            for (File file : list) {
                                String name = file.getName();
                                c.f.b.k.a((Object) name, "it.name");
                                ArrayList arrayList2 = arrayList;
                                arrayList2.add(new com.joaomgcd.taskerm.google.drive.g(new com.joaomgcd.taskerm.net.x(file, r7, i, r7), name, new com.joaomgcd.taskerm.google.drive.w(new com.joaomgcd.taskerm.google.drive.c("Tasker/data/bugreports", lVar, true, false, 8, null), lVar), false, null, false, null, 120, null));
                                arrayList = arrayList2;
                                i = 2;
                                r7 = 0;
                            }
                            com.joaomgcd.taskerm.dialog.ac a3 = ac.a.a(com.joaomgcd.taskerm.dialog.ac.f6387a, this.f9720a, R.string.dc_uploading_report_files, false, 4, null);
                            Object[] array2 = arrayList.toArray(new com.joaomgcd.taskerm.google.drive.g[0]);
                            if (array2 != null) {
                                List<cw<DriveMetadataV3Upload, ErrorPayloadGoogleDrive>> b6 = jVar.a((com.joaomgcd.taskerm.google.drive.g[]) array2, "support@joaoapps.com").b();
                                c.f.b.k.a((Object) b6, "uploadAndShareResult");
                                List<cw<DriveMetadataV3Upload, ErrorPayloadGoogleDrive>> list2 = b6;
                                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                                    Iterator<T> it = list2.iterator();
                                    while (it.hasNext()) {
                                        if (!((cw) it.next()).b()) {
                                            z = false;
                                            break;
                                        }
                                    }
                                }
                                z = true;
                                if (z) {
                                    h = new ArrayList();
                                    str2 = str2 + "\n\nFiles:\n" + c.a.j.a(list2, "\n", null, null, 0, null, AnonymousClass2.f9722a, 30, null);
                                } else {
                                    StringBuilder sb = new StringBuilder();
                                    sb.append("Couldn't upload files to Google Drive: ");
                                    cw cwVar = (cw) c.a.j.f((List<? extends Object>) b6);
                                    sb.append((cwVar == null || (errorPayloadGoogleDrive = (ErrorPayloadGoogleDrive) cwVar.e()) == null) ? null : errorPayloadGoogleDrive.getErrorMessage());
                                    ao.c(sb.toString(), this.f9720a);
                                }
                                com.joaomgcd.taskerm.dialog.ac.a(a3, null, 1, null);
                            } else {
                                throw new c.q("null cannot be cast to non-null type kotlin.Array<T>");
                            }
                        } else {
                            ao.c("Attaching files directly to email...", this.f9720a);
                        }
                        Activity activity2 = this.f9720a;
                        array = h.toArray(new File[0]);
                        if (array == null) {
                            al.a(activity2, "Debug Log", str2, (File[]) array);
                            obj = null;
                        } else {
                            throw new c.q("null cannot be cast to non-null type kotlin.Array<T>");
                        }
                    }
                    str = null;
                    if (str == null) {
                    }
                    Activity activity22 = this.f9720a;
                    array = h.toArray(new File[0]);
                    if (array == null) {
                    }
                }
                return ct.a(obj);
            }
            return b3;
        }

        public static final class AnonymousClass2 extends c.f.b.l implements c.f.a.b<cw<DriveMetadataV3Upload, ErrorPayloadGoogleDrive>, CharSequence> {
            public static final AnonymousClass2 f9722a = new AnonymousClass2();

            AnonymousClass2() {
                super(1);
            }

            @Override
            public final CharSequence invoke(cw<DriveMetadataV3Upload, ErrorPayloadGoogleDrive> cwVar) {
                c.f.b.k.b(cwVar, "it");
                DriveMetadataV3Upload d2 = cwVar.d();
                return (d2 == null || (r2 = d2.getWebUrl()) == null) ? "Error File" : "Error File";
            }
        }
    }

    public static final b.a.l<cr> a(Activity activity) {
        c.f.b.k.b(activity, "receiver$0");
        return com.joaomgcd.taskerm.rx.h.b(new a(activity));
    }

    public static final UserHandle h() {
        return Process.myUserHandle();
    }

    public static final <T> Set<T> i() {
        return Collections.newSetFromMap(new ConcurrentHashMap());
    }

    @TargetApi(31)
    public static final int a(int i) {
        return g.f9751b.n() ? i : i | 33554432;
    }

    public static void a(Activity activity, c.f.a.a aVar, int i, Object obj) {
        if ((i & 1) != 0) {
            aVar = null;
        }
        a(activity, aVar);
    }

    public static final class b extends c.f.b.l implements c.f.a.a<c.s> {
        final Activity f9723a;
        final c.f.a.a f9724b;

        b(Activity activity, c.f.a.a aVar) {
            super(0);
            this.f9723a = activity;
            this.f9724b = aVar;
        }

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

        public final void a() {
            com.joaomgcd.taskerm.dialog.ac a2 = ac.a.a(com.joaomgcd.taskerm.dialog.ac.f6387a, this.f9723a, R.string.dc_signing_in, false, 4, null);
            try {
                try {
                    GoogleSignInAccount googleSignInAccount = (GoogleSignInAccount) a.C0166a.a(com.joaomgcd.taskerm.google.drive.a.f7190a, this.f9723a, false, 2, (Object) null).b();
                    c.f.b.k.a((Object) googleSignInAccount, "signInAccount");
                    Settings.a(this.f9723a, googleSignInAccount.c());
                    bz.c(this.f9723a, true);
                    com.joaomgcd.taskerm.dialog.y.d(this.f9723a, R.string.word_enabled, R.string.dc_will_keep_daily_backups_on_google_drive).b();
                } catch (Exception e2) {
                    com.joaomgcd.taskerm.rx.h.a(this.f9723a, e2);
                    c.f.a.a aVar = this.f9724b;
                    if (aVar != null) {
                        c.s sVar = (c.s) aVar.invoke();
                    }
                }
            } finally {
                com.joaomgcd.taskerm.dialog.ac.a(a2, null, 1, null);
            }
        }
    }

    public static final void a(Activity activity, c.f.a.a<c.s> aVar) {
        c.f.b.k.b(activity, "receiver$0");
        com.joaomgcd.taskerm.rx.h.c(new b(activity, aVar));
    }

    private static final double b(String str) {
        return Double.parseDouble(str);
    }

    public static final Location a(String str, String str2) {
        c.f.b.k.b(str, "latitude");
        c.f.b.k.b(str2, "longitude");
        return a(b(str), b(str2));
    }

    public static final Location a(double d2, double d3) {
        Location location = new Location("Tasker");
        location.setLatitude(d2);
        location.setLongitude(d3);
        return location;
    }

    static final class f extends c.f.b.l implements c.f.a.a<c.s> {
        final long f9728a;
        final c.f.a.a f9729b;
        final long f9730c;

        f(long j, c.f.a.a aVar, long j2) {
            super(0);
            this.f9728a = j;
            this.f9729b = aVar;
            this.f9730c = j2;
        }

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

        public final void a() {
            if (this.f9728a > 0) {
                ds.a(this.f9728a);
            }
            while (!((Boolean) this.f9729b.invoke()).booleanValue()) {
                ds.a(this.f9730c);
            }
        }
    }

    public static final b.a.b a(c.f.a.a<Boolean> aVar, long j, long j2, long j3) {
        c.f.b.k.b(aVar, "stateGetter");
        b.a.b c2 = com.joaomgcd.taskerm.rx.h.d(new f(j3, aVar, j)).c(j2, TimeUnit.MILLISECONDS);
        c.f.b.k.a((Object) c2, "completeInBackground {\n …s, TimeUnit.MILLISECONDS)");
        return c2;
    }

    public static final String j() {
        String uuid = UUID.randomUUID().toString();
        c.f.b.k.a((Object) uuid, "UUID.randomUUID().toString()");
        return uuid;
    }

    public static final boolean k() {
        return c.f.b.k.a((Object) Build.MANUFACTURER, (Object) "Xiaomi");
    }

    public static final long l() {
        return Debug.getNativeHeapSize() - Debug.getNativeHeapFreeSize();
    }

    public static final float m() {
        return (((float) l()) / 1024.0f) / 1024.0f;
    }

    public static final long n() {
        Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
        Debug.getMemoryInfo(memoryInfo);
        return (memoryInfo.getTotalPrivateDirty() + memoryInfo.getTotalPrivateClean()) * 1024;
    }

    public static final float o() {
        return (((float) n()) / 1024.0f) / 1024.0f;
    }

    public static final String p() {
        return ("Native: " + m() + "; ") + ' ' + ("JVM: " + o() + ';');
    }

    public static final void q() {
        if (b()) {
            HashMap hashMap = new HashMap();
            e eVar = new e(hashMap);
            bq c2 = bq.f9459b.c();
            av.a aVar = av.a.Action;
            net.dinglisch.android.taskerm.m[] a2 = net.dinglisch.android.taskerm.n.a();
            c.f.b.k.a((Object) a2, "ActionSpecs.getSpecs()");
            eVar.a2(c2, aVar, (fk[]) a2);
            bq a3 = bq.f9459b.a();
            av.a aVar2 = av.a.Event;
            net.dinglisch.android.taskerm.am[] a4 = net.dinglisch.android.taskerm.an.a();
            c.f.b.k.a((Object) a4, "EventSpecs.getSpecs()");
            eVar.a2(a3, aVar2, (fk[]) a4);
            bq b2 = bq.f9459b.b();
            av.a aVar3 = av.a.State;
            fn[] a5 = fo.a();
            c.f.b.k.a((Object) a5, "StateSpecs.getSpecs()");
            eVar.a2(b2, aVar3, (fk[]) a5);
            net.dinglisch.android.taskerm.bo.b("ENTITY_NEW_VERSIONS", an.a((Object) hashMap));
        }
    }

    static final class e extends c.f.b.l implements c.f.a.q<bq, av.a, fk[], c.s> {
        final HashMap f9727a;

        e(HashMap hashMap) {
            super(3);
            this.f9727a = hashMap;
        }

        @Override
        public c.s a(bq bqVar, av.a aVar, fk[] fkVarArr) {
            a2(bqVar, aVar, fkVarArr);
            return c.s.f2131a;
        }

        public final void a2(bq bqVar, av.a aVar, fk[] fkVarArr) {
            bl blVar;
            bp e2;
            String i;
            boolean z;
            c.f.b.k.b(aVar, "type");
            c.f.b.k.b(fkVarArr, "specs");
            ArrayList<c.k> arrayList = new ArrayList();
            for (fk fkVar : fkVarArr) {
                c.k kVar = null;
                if (bqVar != null) {
                    Iterator<bl> it = bqVar.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            blVar = null;
                            break;
                        }
                        blVar = it.next();
                        if (blVar.d() == fkVar.g()) {
                            z = true;
                            continue;
                        } else {
                            z = false;
                            continue;
                        }
                        if (z) {
                            break;
                        }
                    }
                    bl blVar2 = blVar;
                    if (blVar2 != null && (e2 = blVar2.e()) != null) {
                        Object b2 = e2.b();
                        if (b2 == null) {
                            b2 = e2.a();
                        }
                        if (b2 != null && (i = fkVar.i()) != null) {
                            kVar = new c.k(aVar.a() + '_' + i, b2);
                        }
                    }
                }
                if (kVar != null) {
                    arrayList.add(kVar);
                }
            }
            for (c.k kVar2 : arrayList) {
                this.f9727a.put(kVar2.a(), kVar2.b());
            }
        }
    }

    public static final <T, K> List<T> a(Iterable<? extends T> iterable, c.f.a.b<? super T, ? extends K> bVar) {
        c.f.b.k.b(iterable, "receiver$0");
        c.f.b.k.b(bVar, "selector");
        HashSet hashSet = new HashSet();
        ArrayList arrayList = new ArrayList();
        Iterator<? extends T> it = iterable.iterator();
        while (it.hasNext()) {
            Object obj = (T) it.next();
            if (hashSet.add(bVar.invoke(obj))) {
                arrayList.add(obj);
            }
        }
        return arrayList;
    }
}