导航菜单

页面标题

页面副标题

Tasker v6.5.11 - RunLog.java 源代码

正在查看: Tasker v6.5.11 应用的 RunLog.java JAVA 源代码文件

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


package net.dinglisch.android.taskerm;

import android.R;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.ToggleButton;
import cyanogenmod.app.ProfileManager;
import java.io.File;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Pattern;
import net.dinglisch.android.taskerm.HTMLView;
import net.dinglisch.android.taskerm.c;
import net.dinglisch.android.taskerm.mh;
import net.dinglisch.android.taskerm.tn;
import net.dinglisch.android.taskerm.wo;

public class RunLog extends MyActivity {
    private static final int[] C = {2131891222, 2131891258, 2131891115};
    private static final int[] D = {2131297647, 2131297649, 2131297648};
    private static final String[] E = {"runlogProfs", "runlogTasks", "runlogActions", "runlogMonStatus", "runlogExeStatus"};
    private static final boolean[] F = {true, true, true, true, true};
    private static final Object G = new Object();
    public static char[] H = {'P', 'T', 'A', 'M', 'E'};
    public static char I = ' ';
    private static int J = -1;
    private static int K = -1;
    private static c.b L = null;
    private EditText A;
    private ToggleButton[] B = new ToggleButton[h.values().length];
    private FileView v;
    private SharedPreferences w;
    private Switch x;
    private View y;
    private ImageView z;

    class a extends Handler {
        a() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 1) {
                RunLog.this.S0();
            }
        }
    }

    class b implements AdapterView.OnItemLongClickListener {
        b() {
        }

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
            RunLog runLog = RunLog.this;
            runLog.B0(i, runLog.v.s(i), RunLog.this.v.p(i), view);
            return true;
        }
    }

    class c implements View.OnClickListener {
        final int i;

        c(int i) {
            this.i = i;
        }

        @Override
        public void onClick(View view) {
            h hVar = h.values()[this.i];
            boolean isChecked = RunLog.this.B[this.i].isChecked();
            RunLog.this.v.setWantEntry(hVar, isChecked, true);
            RunLog.this.w.edit().putBoolean(RunLog.E[this.i], isChecked).commit();
        }
    }

    class d implements TextWatcher {
        d() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            RunLog.this.v.setFilter(editable.toString(), true);
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }
    }

    class e implements mh.f {
        final int a;
        final String b;

        e(int i, String str) {
            this.a = i;
            this.b = str;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            int ordinal = g.values()[mhVar.A()].ordinal();
            if (ordinal == 0) {
                RunLog.this.A.setText(this.b);
            } else {
                if (ordinal != 1) {
                    return;
                }
                RunLog.this.A0(this.a, true);
            }
        }
    }

    class f implements PopupMenu.OnMenuItemClickListener {
        f() {
        }

        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            return RunLog.this.onOptionsItemSelected(menuItem);
        }
    }

    private enum g {
        FilterSimilar,
        GoTo
    }

    public enum h {
        Profile,
        Task,
        Action,
        MonitorStatus,
        ExeStatus
    }

    public enum i {
        Start,
        StartFail,
        Restart,
        Stop
    }

    public boolean A0(int i2, boolean z) {
        Integer E3;
        Integer num;
        String t = this.v.t(i2);
        r7.f("RLV", "goToItem: position " + i2 + " id " + t);
        if (t == null) {
            return false;
        }
        h u = this.v.u(i2);
        Integer num2 = null;
        if (t.contains(".")) {
            String[] split = t.split(Pattern.quote("."));
            if (split.length == 2) {
                E3 = dq.E3(split[0]);
                num = dq.E3(split[1]);
            } else {
                num = null;
                E3 = null;
            }
        } else {
            E3 = dq.E3(t);
            num = null;
        }
        to h2 = to.h2(this);
        String s = this.v.s(i2);
        r7.f("RLV", "goToItem: id: " + E3 + " sid " + num + " descr: " + s);
        int ordinal = u.ordinal();
        if (ordinal != 0) {
            if (ordinal != 1) {
                if (ordinal != 2) {
                    return false;
                }
                if (s.indexOf(46) > 0) {
                    s = s.split("\\.")[0];
                }
            }
            r9 = s != null ? h2.n(s) : -1;
            if (!C0(E3) || !h2.T(E3.intValue())) {
                E3 = Integer.valueOf(r9);
            }
            if (!C0(E3) || !h2.T(E3.intValue())) {
                if (!z) {
                    return false;
                }
                dq.a0(this, 2131887913, new Object[0]);
                return false;
            }
            if (z) {
                v0(u.name(), E3, num);
            }
        } else {
            if (s != null) {
                List<Integer> G2 = h2.G(s);
                if (G2.size() == 1) {
                    r9 = G2.get(0).intValue();
                }
            }
            if (C0(E3) && h2.V(E3.intValue())) {
                num2 = num;
            } else {
                E3 = Integer.valueOf(r9);
            }
            if (!C0(E3) || !h2.V(E3.intValue())) {
                if (!z) {
                    return false;
                }
                dq.a0(this, 2131887909, new Object[0]);
                return false;
            }
            if (z) {
                v0(u.name(), E3, num2);
            }
        }
        return true;
    }

    public void B0(int i2, String str, boolean z, View view) {
        mh mhVar = new mh(this, view);
        mhVar.n(g.FilterSimilar.ordinal(), vh.g(this, 2131888862, str), 2130969267);
        if (z && A0(i2, false)) {
            mhVar.k(g.GoTo.ordinal(), 2131888833, 2130969197);
        }
        mhVar.F(new e(i2, str)).show();
    }

    private boolean C0(Integer num) {
        return num != null && num.intValue() >= 0;
    }

    private void D0() {
        synchronized (G) {
            try {
                File z0 = z0();
                if (E0(this) && z0 != null && !z0.exists()) {
                    dq.o2(z0.getParentFile());
                    dq.K(z0);
                    if (z0.exists()) {
                        r7.f("RLV", "exists");
                        dq.C3("\n", z0, false);
                        r7.f("RLV", "wrte file");
                    }
                }
                FileView fileView = this.v;
                if (fileView == null) {
                    u0(false);
                    return;
                }
                fileView.setFile(z0);
                fileView.setHandler(new a());
                fileView.A(true);
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    public static boolean E0(Context context) {
        return dq.R0(context).getBoolean("lpa", false);
    }

    public void F0(com.joaomgcd.taskerm.util.s6 s6Var) throws Exception {
        if (s6Var.b()) {
            lp.e(this, 1, 2131890929, 1);
            D0();
        } else {
            this.x.setChecked(false);
            dq.o0(this, "Can't enable without storage permissions", new Object[0]);
        }
    }

    public void G0(Throwable th2) throws Exception {
        pg.w0.X0(this, th2);
    }

    public void H0(CompoundButton compoundButton, boolean z) {
        this.w.edit().putBoolean("lpa", z).commit();
        if (z) {
            com.joaomgcd.taskerm.util.e5.x(this).r(this).B(li.a.b()).I(new oi.d() {
                @Override
                public final void accept(Object obj) {
                    RunLog.this.F0((com.joaomgcd.taskerm.util.s6) obj);
                }
            }, new oi.d() {
                @Override
                public final void accept(Object obj) {
                    RunLog.this.G0((Throwable) obj);
                }
            });
        }
    }

    private void J0() {
        this.v = (FileView) findViewById(2131296896);
        this.y = findViewById(2131297641);
        ImageView imageView = (ImageView) findViewById(2131297251);
        this.z = imageView;
        up.x(this, imageView, tp.L(this));
        this.v.setOnItemLongClickListener(new b());
        for (h hVar : h.values()) {
            int ordinal = hVar.ordinal();
            boolean z = this.w.getBoolean(E[ordinal], F[ordinal]);
            this.v.setWantEntry(hVar, z, false);
            if (hVar != h.MonitorStatus && hVar != h.ExeStatus) {
                this.B[ordinal] = (ToggleButton) findViewById(D[ordinal]);
                String g2 = vh.g(this, C[ordinal], new Object[0]);
                this.B[ordinal].setTextOn(g2);
                this.B[ordinal].setTextOff(g2);
                this.B[ordinal].setChecked(z);
                this.B[ordinal].setOnClickListener(new c(ordinal));
            }
        }
        EditText editText = (EditText) findViewById(2131297650);
        this.A = editText;
        editText.setHint(vh.g(this, 2131888231, new Object[0]));
        this.A.addTextChangedListener(new d());
        Switch r1 = new Switch(this);
        this.x = r1;
        r1.setChecked(E0(this));
        this.x.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public final void onCheckedChanged(CompoundButton compoundButton, boolean z2) {
                RunLog.this.H0(compoundButton, z2);
            }
        });
        this.x.setPadding(0, 0, 20, 0);
        try {
            ColorStateList n = tp.n(this);
            if (n != null) {
                yq.i(this.x, n);
            }
        } catch (Exception e2) {
            r7.H("RLV", "setTrackTintList", e2);
        }
        dq.M2(this, 2131297638, 2131890358);
        TextView textView = (TextView) findViewById(2131297632);
        if (textView != null) {
            String g3 = vh.g(this, 2131890015, new Object[0]);
            if (g3.length() < 8) {
                int length = 8 - g3.length();
                for (int i2 = 0; i2 < length; i2++) {
                    g3 = g3 + " ";
                }
            }
            textView.setText(g3);
        }
        dq.M2(this, 2131297526, 2131889974);
        dq.M2(this, 2131296987, 2131889665);
        dq.M2(this, 2131297164, 2131889561);
        if (tp.e0()) {
            findViewById(2131296876).setBackgroundColor(0);
            findViewById(2131297641).setBackgroundColor(0);
            findViewById(2131296952).setVisibility(0);
            findViewById(2131296951).setVisibility(0);
            findViewById(2131296952).setElevation(tp.w(this, 2131166027));
            up.D(findViewById(2131296440));
        }
    }

    public static void K0(Context context, SharedPreferences sharedPreferences, wo.a aVar, wo woVar) {
        s0(context, sharedPreferences, h.Profile, aVar.name(), woVar.C0(), Integer.MIN_VALUE, Integer.MIN_VALUE, woVar.u() ? woVar.getName() : woVar.v0(context, true, false, false));
    }

    private void L0() {
        r7.f("RLV", "recordPosStatic " + this.v.getFirstVisiblePosition() + " count " + this.v.getCount());
        O0(this, this.v.getFirstVisiblePosition(), this.v.getCount());
    }

    public static void M0(Context context, SharedPreferences sharedPreferences, i iVar) {
        s0(context, sharedPreferences, h.ExeStatus, iVar.toString(), 0, 0, 0, "TaskService");
    }

    public static void N0(Context context, SharedPreferences sharedPreferences, i iVar) {
        s0(context, sharedPreferences, h.MonitorStatus, iVar.toString(), 0, 0, 0, "Monitor");
    }

    private static void O0(Context context, int i2, int i3) {
        r7.f("RLV", "recordPosStatic " + i2 + " count " + i3);
        SharedPreferences.Editor edit = dq.S0(context).edit();
        edit.putInt("runlogLast", i2);
        edit.putInt("runlogLastCount", i3);
        edit.commit();
        r7.f("RLV", "record entry id " + i2 + " count " + i3);
    }

    private void P0() {
        int i2 = dq.S0(this).getInt("runlogLast", -1);
        r7.f("RLV", "restorePos: " + i2 + " count " + dq.S0(this).getInt("runlogLastCount", 0) + ", have " + this.v.getCount());
        if (i2 != -1) {
            this.v.setSelection(i2);
        }
    }

    public static void Q0(Context context, SharedPreferences sharedPreferences, tn.e eVar, tn tnVar) {
        s0(context, sharedPreferences, h.Task, eVar.name(), tnVar.P0(), tnVar.K0(), Integer.MIN_VALUE, tnVar.u() ? tnVar.getName() : "");
    }

    private void R0(boolean z, boolean z2) {
        this.v.setForward(z, z2);
    }

    public void S0() {
        FileView fileView;
        ImageView imageView = this.z;
        if (imageView == null || (fileView = this.v) == null) {
            return;
        }
        imageView.setImageResource(tp.J(this, fileView.w() ? 2130969231 : 2130969230));
    }

    private void T0(View view) {
        PopupMenu popupMenu = new PopupMenu(this, view);
        I0(popupMenu.getMenu());
        popupMenu.setOnMenuItemClickListener(new f());
        popupMenu.show();
    }

    private static void s0(Context context, SharedPreferences sharedPreferences, h hVar, String str, int i2, int i3, int i4, String str2) {
        synchronized (G) {
            try {
                if (sharedPreferences.getBoolean("lpa", false) && dq.q3()) {
                    if (dq.k1() == null) {
                        r7.G("RLV", "failed to write activation data, no storage card");
                    } else {
                        File l1 = dq.l1("log", true);
                        if (l1 != null) {
                            File file = new File(l1, "runlog.txt");
                            Calendar x = bh.x();
                            String G2 = bh.G(x);
                            String r = bh.r(x, true);
                            StringBuilder sb = new StringBuilder();
                            sb.append(G2);
                            sb.append(I);
                            sb.append(r);
                            sb.append(I);
                            sb.append(H[hVar.ordinal()]);
                            sb.append(I);
                            sb.append(String.format("%-8s", str));
                            sb.append(" ID");
                            String valueOf = String.valueOf(i2);
                            if (i3 != Integer.MIN_VALUE && i3 != 1) {
                                valueOf = valueOf + ':' + String.valueOf(i3);
                            }
                            if (i4 != Integer.MIN_VALUE) {
                                valueOf = valueOf + "." + String.valueOf(i4);
                            }
                            String g2 = TextUtils.isEmpty(str2) ? i2 < 0 ? vh.g(context, 2131887006, new Object[0]) : hVar.equals(h.Task) ? vh.g(context, 2131891124, new Object[0]) : "?" : str2.replace('\n', ' ');
                            sb.append(String.format("%-6s", valueOf));
                            sb.append(I);
                            sb.append(g2);
                            sb.append("\n");
                            String sb2 = sb.toString();
                            r7.C(file, sb2.length() + sharedPreferences.getLong("aSize", 1262144L));
                            dq.C3(sb2, file, true);
                        }
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    public static void t0(Context context) {
        r7.f("RLV", "clearPos");
        O0(context, -1, 0);
    }

    private void u0(boolean z) {
        if (z) {
            L0();
        } else {
            t0(this);
        }
        finish();
    }

    private void v0(String str, Integer num, Integer num2) {
        Intent intent = new Intent();
        intent.putExtra(ProfileManager.EXTRA_PROFILE_NAME, str);
        intent.putExtra("ID", num);
        if (num2 != null) {
            intent.putExtra("subID", num2);
        }
        setResult(-1, intent);
        u0(true);
    }

    public static void w0(Context context, SharedPreferences sharedPreferences, tn tnVar, int i2, net.dinglisch.android.taskerm.c cVar, String str, c.b bVar) {
        int j = cVar.j();
        int K0 = tnVar.K0();
        if ((j != 30 && j != 35) || K != K0 || J != i2 || bVar != L) {
            String replace = cVar.getName().replace("Variable", "Var");
            String N = cVar.Q0() ? kq.N(context, cVar.t0(), tnVar.m()) : null;
            if (N == null && str != null) {
                N = replace + ", " + str;
            }
            if (N == null) {
                for (int i3 = 0; i3 < cVar.Y(); i3++) {
                    if (cVar.p0(i3) == 1 && "uvar".equals(a1.D0(cVar.j(), i3))) {
                        String w = cVar.N(i3).w();
                        if (!TextUtils.isEmpty(w)) {
                            if (N == null) {
                                N = replace;
                            }
                            String N2 = kq.N(context, w, tnVar.m());
                            if (N2 == null) {
                                N2 = "";
                            } else if (N2.length() > 20) {
                                N2 = N2.substring(0, 18) + "..";
                            }
                            N = N + ", " + w + "=" + N2;
                        }
                    }
                }
            }
            if (N != null) {
                replace = N.replace("\n", " ");
            }
            s0(context, sharedPreferences, h.Action, bVar.name(), tnVar.P0(), K0, i2 + 1, (tnVar.u() ? tnVar.getName() : vh.g(context, 2131891124, new Object[0])) + "." + replace);
        }
        K = K0;
        J = i2;
        L = bVar;
    }

    public static int x0(Context context, h hVar) {
        int ordinal = hVar.ordinal();
        return tp.C(context, ordinal != 0 ? ordinal != 1 ? (ordinal == 3 || ordinal == 4) ? R.attr.colorForeground : 2130968872 : 2130968882 : 2130968879, "RLV/gebc");
    }

    public static Intent y0(Context context) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(context, (Class<?>) RunLog.class));
        return intent;
    }

    public static File z0() {
        File k1 = dq.k1();
        if (k1 != null) {
            return new File(new File(k1, "log"), "runlog.txt");
        }
        return null;
    }

    public void I0(Menu menu) {
        menu.add(0, 3, 0, vh.g(this, 2131888861, new Object[0]));
        menu.add(0, 2, 0, vh.g(this, 2131889072, new Object[0]));
        menu.add(0, 1, 0, vh.g(this, 2131888789, new Object[0]));
        dq.l(this, menu, 7, 6);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        if (keyEvent.getKeyCode() != 82) {
            return super.dispatchKeyEvent(keyEvent);
        }
        if (keyEvent.getAction() == 1) {
            T0(this.B[1]);
        }
        return true;
    }

    @Override
    public void onBackPressed() {
        u0(false);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setResult(0);
        this.w = dq.R0(this);
        setContentView(2131494210);
        net.dinglisch.android.taskerm.a.T(this, true);
        setTitle(vh.g(this, 2131889087, new Object[0]));
        J0();
        R0(this.w.getBoolean("runlogDir", false), false);
        D0();
        S0();
        P0();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        FileView fileView = this.v;
        if (fileView != null) {
            fileView.setHandler(null);
        }
        synchronized (G) {
            this.v.A(false);
        }
        FileView fileView2 = this.v;
        if (fileView2 != null) {
            fileView2.y();
            this.v = null;
        }
        this.w = null;
        this.x = null;
        this.y = null;
        this.z = null;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 1) {
            synchronized (G) {
                try {
                    File z0 = z0();
                    if (z0 != null && z0.exists() && z0.length() > 0) {
                        z0.delete();
                        D0();
                    }
                } catch (Throwable th2) {
                    throw th2;
                }
            }
        } else if (itemId != 2) {
            if (itemId == 3) {
                com.joaomgcd.taskerm.util.g8.J0(z0(), this);
            } else if (itemId == 5) {
                T0(this.x);
            } else if (itemId == 6) {
                HTMLView.G0(this, "index.html");
            } else if (itemId == 7) {
                HTMLView.H0(this, "activity_runlog.html", -1, HTMLView.g.Inform);
            } else if (itemId == 16908332) {
                u0(false);
            }
        } else if (this.y.getVisibility() == 0) {
            this.y.setVisibility(8);
        } else {
            this.y.setVisibility(0);
        }
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        net.dinglisch.android.taskerm.a.q(this, 0, this.x, menu);
        I0(menu);
        return true;
    }
}