导航菜单

页面标题

页面副标题

Tasker v6.6.3 - ServiceVoiceInteractionTasker.java 源代码

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

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


package com.joaomgcd.taskerm.assistant;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.service.voice.VoiceInteractionService;
import androidx.annotation.Keep;
import com.joaomgcd.taskerm.assistant.ServiceVoiceInteractionTasker;
import com.joaomgcd.taskerm.assistant.VoiceAssistantRequest;
import com.joaomgcd.taskerm.rx.EventBusRxSubscription;
import com.joaomgcd.taskerm.util.ExtensionsContextKt;
import com.joaomgcd.taskerm.util.b7;
import com.joaomgcd.taskerm.util.l7;
import com.joaomgcd.taskerm.util.pe;
import com.joaomgcd.taskerm.util.te;
import com.joaomgcd.taskerm.util.ue;
import com.joaomgcd.taskerm.util.we;
import df.p1;
import ik.l;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import je.c0;
import je.h3;
import je.p0;
import je.q0;
import jk.h;
import jk.p;
import net.dinglisch.android.taskerm.ActionEdit;
import net.dinglisch.android.taskerm.j2;
import net.dinglisch.android.taskerm.o7;
import net.dinglisch.android.taskerm.od;
import pg.f1;
import pg.j;
import pg.m;
import pg.n2;
import ti.n;
import ti.r;
import uk.n0;
import vj.e0;
import xf.d7;
import xg.e2;
import xg.h;
import xg.i;
import yi.g;
import ze.e;

@TargetApi(23)
public final class ServiceVoiceInteractionTasker extends VoiceInteractionService implements d7, e {
    public static final a q = new a(null);
    public static final int r = 8;
    private final pe.a i = new pe.a(this);

    public static final class a {

        public static final class C0067a<T> implements g {
            public static final C0067a<T> a = new C0067a<>();

            public final boolean test(Object obj) {
                p.i(obj, "it");
                return obj instanceof c;
            }
        }

        public static final class b implements l<c, e0> {
            public static final b i = new b();

            public final void a(c cVar) {
            }

            public Object invoke(Object obj) {
                a(obj);
                return e0.a;
            }
        }

        public static final class c<T> implements g {
            public static final c<T> a = new c<>();

            public final boolean test(Object obj) {
                p.i(obj, "it");
                return obj instanceof b;
            }
        }

        public static final class d implements l<b, e0> {
            public static final d i = new d();

            public final void a(b bVar) {
            }

            public Object invoke(Object obj) {
                a(obj);
                return e0.a;
            }
        }

        public a(h hVar) {
            this();
        }

        public static final e0 k(Context context, n2 n2Var) {
            p.i(n2Var, "$this$warnWithNotification");
            n2Var.k().addAll(new f1(new pg.e[]{new m(context), new j(context, "https://tasker.joaoapps.com/userguide/en/help/ah_secure_setting_grant.html", false, b7.j6(2131887524, context, new Object[0]), 4, (h) null)}));
            return e0.a;
        }

        public static final pe m(final VoiceAssistantRequest voiceAssistantRequest) {
            pe a;
            c cVar = (c) b7.n6((l) null, new ik.a() {
                public final Object e() {
                    ServiceVoiceInteractionTasker.c n;
                    n = ServiceVoiceInteractionTasker.a.n(VoiceAssistantRequest.this);
                    return n;
                }
            }, 1, (Object) null);
            return (cVar == null || (a = cVar.a()) == null) ? te.c("Couldn't do action with assistant") : a;
        }

        public static final c n(VoiceAssistantRequest voiceAssistantRequest) {
            n E = xg.h.a.j().E(C0067a.a);
            p.g(E, "null cannot be cast to non-null type io.reactivex.Observable<T of com.joaomgcd.taskerm.rx.EventBusRx.forType>");
            r g = E.G().g();
            p.g(g, "null cannot be cast to non-null type io.reactivex.Single<T of com.joaomgcd.taskerm.rx.EventBusRx.waitFor>");
            r L = g.L(5000L, TimeUnit.MILLISECONDS);
            p.h(L, "timeout(...)");
            p.h(L.I(new h.b(b.i), new h.b(i.i)), "subscribe(...)");
            xg.h.m(voiceAssistantRequest);
            return (c) L.f();
        }

        public static r p(a aVar, Context context, h3 h3Var, boolean z, int i, Object obj) {
            if ((i & 4) != 0) {
                z = true;
            }
            return aVar.o(context, h3Var, z);
        }

        private static final pe q(q0 q0Var) {
            return te.f(q0Var);
        }

        public static final pe r(Context context, q0 q0Var, String str, h3 h3Var) {
            final r rVar;
            String packageName = context.getPackageName();
            if (p.d(q0Var.getPackageName(), str)) {
                o7.f("ServiceVoiceInteractionTasker", "No need to change assistant, alread " + str);
                return q(q0Var);
            }
            o7.f("ServiceVoiceInteractionTasker", "Changing assistant from " + q0Var + " to " + str);
            if (p.d(str, packageName)) {
                n E = xg.h.a.j().E(c.a);
                p.g(E, "null cannot be cast to non-null type io.reactivex.Observable<T of com.joaomgcd.taskerm.rx.EventBusRx.forType>");
                r g = E.G().g();
                p.g(g, "null cannot be cast to non-null type io.reactivex.Single<T of com.joaomgcd.taskerm.rx.EventBusRx.waitFor>");
                rVar = g.L(3000L, TimeUnit.MILLISECONDS);
                p.h(rVar, "timeout(...)");
                p.h(rVar.I(new h.b(d.i), new h.b(i.i)), "subscribe(...)");
            } else {
                rVar = null;
            }
            pe peVar = (pe) h3Var.a(context).f();
            if (!peVar.b()) {
                return peVar;
            }
            if (rVar == null || ((b) b7.n6((l) null, new ik.a() {
                public final Object e() {
                    ServiceVoiceInteractionTasker.b s;
                    s = ServiceVoiceInteractionTasker.a.s(rVar);
                    return s;
                }
            }, 1, (Object) null)) != null) {
                return q(q0Var);
            }
            return te.c("Couldn't set " + str + " as an assistant");
        }

        public static final b s(r rVar) {
            return (b) rVar.f();
        }

        public static final e0 t(String str, pe peVar) {
            if (peVar.b()) {
                o7.f("ServiceVoiceInteractionTasker", "Set assistant to " + str + "!");
            } else {
                o7.f("ServiceVoiceInteractionTasker", "Couldn't set assistant to " + str + ": " + peVar.a());
            }
            return e0.a;
        }

        public static final void u(l lVar, Object obj) {
            lVar.invoke(obj);
        }

        public static final e0 w(Activity activity, p1 p1Var) {
            p.i(p1Var, "dialogMessage");
            if (p1Var.k()) {
                ActionEdit.q5(activity, "secure_setting_grant", (String) null);
            }
            if (p1Var.o()) {
                activity.startActivity(od.c());
            }
            return e0.a;
        }

        public final pe i(Context context, VoiceAssistantRequest voiceAssistantRequest) {
            String str;
            p.i(context, "context");
            p.i(voiceAssistantRequest, "request");
            String packageName = context.getPackageName();
            p.f(packageName);
            Object f = p(this, context, new p0(context, packageName), false, 4, null).f();
            we weVar = f instanceof we ? (we) f : null;
            if (weVar == null) {
                return te.c("Could set Tasker as assistant");
            }
            if (!weVar.b()) {
                o7.f("ServiceVoiceInteractionTasker", "Couldn't set assistant to " + packageName + ": " + weVar.a());
                return weVar;
            }
            o7.f("ServiceVoiceInteractionTasker", "Set assistant to " + packageName + " before assistant command!");
            h3 h3Var = (h3) weVar.d();
            if (h3Var == null) {
                return te.c("Couldn't check which app is assistant");
            }
            boolean z = !p.d(h3Var.getPackageName(), packageName);
            pe peVar = (pe) l(context, voiceAssistantRequest).f();
            if (!peVar.b()) {
                Intent intent = voiceAssistantRequest.getIntent();
                str = intent != null ? intent.getAction() : null;
                o7.f("ServiceVoiceInteractionTasker", "Couldn't send assistant request " + str + " to " + packageName + ": " + weVar.a());
                p.f(peVar);
                return peVar;
            }
            o7.f("ServiceVoiceInteractionTasker", "Sent assistant request with action " + voiceAssistantRequest.getAction() + "!");
            Object f2 = o(context, h3Var, z).f();
            str = f2 instanceof we ? (we) f2 : null;
            if (str == null) {
                return te.c("Could not set " + h3Var + " back as assistant");
            }
            if (str.b()) {
                o7.f("ServiceVoiceInteractionTasker", "Set assistant back to " + h3Var + " after assistant command!");
                return new ue();
            }
            o7.f("ServiceVoiceInteractionTasker", "Couldn't set assistant back to " + h3Var + ": " + weVar.a());
            return str;
        }

        public final pe j(final Context context, int i, VoiceAssistantRequest voiceAssistantRequest) {
            p.i(context, "context");
            p.i(voiceAssistantRequest, "request");
            if (!com.joaomgcd.taskerm.util.r.a.G()) {
                return te.c("Can only request with assistant on Marshmallow or above");
            }
            if (c0.j(context) || ExtensionsContextKt.c1(context)) {
                return i(context, voiceAssistantRequest);
            }
            n2.A.m(context, "airplanemodeassistant", b7.j6(i, context, new Object[0]), b7.j6(2131890246, context, new Object[0]), new l() {
                public final Object invoke(Object obj) {
                    e0 k;
                    k = ServiceVoiceInteractionTasker.a.k(context, (n2) obj);
                    return k;
                }
            }).h();
            return te.c("Couldn't request with assistant. Notification posted.");
        }

        public final r<pe> l(Context context, final VoiceAssistantRequest voiceAssistantRequest) {
            p.i(context, "context");
            p.i(voiceAssistantRequest, "request");
            if (c0.j(context)) {
                return e2.y1(new ik.a() {
                    public final Object e() {
                        pe m;
                        m = ServiceVoiceInteractionTasker.a.m(VoiceAssistantRequest.this);
                        return m;
                    }
                });
            }
            r<pe> w = r.w(te.c("This app must be the current assistant app to do this"));
            p.h(w, "just(...)");
            return w;
        }

        public final r<pe> o(final Context context, final h3 h3Var, boolean z) {
            p.i(context, "context");
            p.i(h3Var, "assistantApp");
            final q0 q0Var = new q0(context);
            final String packageName = h3Var.getPackageName();
            o7.f("ServiceVoiceInteractionTasker", "Request to set assistant to " + packageName + "; currently: " + q0Var);
            if (!z) {
                r<pe> w = r.w(q(q0Var));
                p.h(w, "just(...)");
                return w;
            }
            r y1 = e2.y1(new ik.a() {
                public final Object e() {
                    pe r;
                    r = ServiceVoiceInteractionTasker.a.r(context, q0Var, packageName, h3Var);
                    return r;
                }
            });
            final l lVar = new l() {
                public final Object invoke(Object obj) {
                    e0 t;
                    t = ServiceVoiceInteractionTasker.a.t(packageName, (pe) obj);
                    return t;
                }
            };
            r<pe> m = y1.m(new yi.d() {
                public final void accept(Object obj) {
                    ServiceVoiceInteractionTasker.a.u(lVar, obj);
                }
            });
            p.h(m, "doAfterSuccess(...)");
            return m;
        }

        public final void v(final Activity activity, int i) {
            p.i(activity, "context");
            if (com.joaomgcd.taskerm.util.r.a.n() || c0.i(activity) || ExtensionsContextKt.c1(activity)) {
                return;
            }
            String j6 = b7.j6(i, activity, new Object[0]);
            if (rg.i.A(activity, l7.C(j6), (SharedPreferences) null, 2, (Object) null)) {
                return;
            }
            e2.C2(com.joaomgcd.taskerm.dialog.a.n4(activity, i, 2131890246, 2131887524, 2131888756, j6), activity, new l() {
                public final Object invoke(Object obj) {
                    e0 w;
                    w = ServiceVoiceInteractionTasker.a.w(activity, (p1) obj);
                    return w;
                }
            });
        }

        private a() {
        }
    }

    public static final class b {
    }

    public static final class c {
        private final pe a;

        public c(pe peVar) {
            p.i(peVar, "simpleResult");
            this.a = peVar;
        }

        public final pe a() {
            return this.a;
        }
    }

    public static final class d {
        private final Context a;
        private final Bundle b;
        private final AssistStructure c;
        private final AssistContent d;
        private final Bundle e;

        public d(Context context, Bundle bundle, AssistStructure assistStructure, AssistContent assistContent, Bundle bundle2) {
            p.i(context, "context");
            this.a = context;
            this.b = bundle;
            this.c = assistStructure;
            this.d = assistContent;
            this.e = bundle2;
        }

        public final String a() {
            HashMap hashMap;
            HashMap hashMap2;
            HashMap hashMap3;
            Intent intent;
            AssistContent assistContent = this.d;
            if (assistContent == null || (intent = assistContent.getIntent()) == null || (hashMap = b7.o1(intent)) == null) {
                hashMap = new HashMap();
            }
            Bundle bundle = this.b;
            if (bundle == null || (hashMap2 = b7.x1(bundle)) == null) {
                hashMap2 = new HashMap();
            }
            Bundle bundle2 = this.e;
            if (bundle2 == null || (hashMap3 = b7.x1(bundle2)) == null) {
                hashMap3 = new HashMap();
            }
            for (Map.Entry entry : hashMap2.entrySet()) {
                hashMap.put(entry.getKey(), entry.getValue());
            }
            for (Map.Entry entry2 : hashMap3.entrySet()) {
                hashMap.put(entry2.getKey(), entry2.getValue());
            }
            if (hashMap.isEmpty()) {
                return null;
            }
            return b7.n2(hashMap);
        }

        public final java.lang.String b() {
            throw new UnsupportedOperationException("Method not decompiled: com.joaomgcd.taskerm.assistant.ServiceVoiceInteractionTasker.d.b():java.lang.String");
        }

        public final ComponentName c() {
            String string;
            ComponentName activityComponent;
            AssistStructure assistStructure = this.c;
            if (assistStructure != null && (activityComponent = assistStructure.getActivityComponent()) != null) {
                return activityComponent;
            }
            Bundle bundle = this.b;
            return (bundle == null || (string = bundle.getString("android.intent.extra.ASSIST_PACKAGE")) == null) ? ExtensionsContextKt.p1(this.a) : new ComponentName(string, "");
        }

        public final j2 d() {
            j2 j2Var = new j2(201);
            ComponentName c = c();
            if (c != null) {
                j2Var.w1(0, c.getPackageName(), c.getClassName(), "");
            }
            Uri e = e();
            if (e != null) {
                j2Var.o0(1, e.toString());
            }
            String a = a();
            if (a != null) {
                j2Var.o0(3, a);
            }
            String b = b();
            if (b != null) {
                j2Var.o0(2, b);
            }
            return j2Var;
        }

        public final Uri e() {
            AssistContent assistContent = this.d;
            if (assistContent != null) {
                return assistContent.getWebUri();
            }
            return null;
        }

        public d(Context context, Bundle bundle, AssistStructure assistStructure, AssistContent assistContent, Bundle bundle2, int i, jk.h hVar) {
            this(context, (i & 2) != 0 ? null : bundle, (i & 4) != 0 ? null : assistStructure, (i & 8) != 0 ? null : assistContent, (i & 16) != 0 ? null : bundle2);
        }
    }

    public static final e0 c() {
        xg.h.m(new b());
        return e0.a;
    }

    public pe.a getHelper() {
        return this.i;
    }

    @Override
    public n0 getCoroutineScope() {
        return super.getCoroutineScope();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        getHelper().g0();
    }

    @Override
    public void onDestroy() {
        xg.h.q(this);
        getHelper().h0();
        super.onDestroy();
    }

    @Override
    public void onReady() {
        super.onReady();
        getHelper().n0(xg.h.o(this), new ik.a() {
            public final Object e() {
                e0 c2;
                c2 = ServiceVoiceInteractionTasker.c();
                return c2;
            }
        });
    }

    @EventBusRxSubscription
    @Keep
    public final void onRequest(VoiceAssistantRequest voiceAssistantRequest) {
        p.i(voiceAssistantRequest, "request");
        if (voiceAssistantRequest instanceof VoiceAssistantRequestAssistInfo) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putParcelable("request", voiceAssistantRequest);
        showSession(bundle, 0);
    }

    @EventBusRxSubscription
    @Keep
    public final void onRequestAssistInfo(VoiceAssistantRequestAssistInfo voiceAssistantRequestAssistInfo) {
        p.i(voiceAssistantRequestAssistInfo, "request");
        Bundle bundle = new Bundle();
        bundle.putParcelable("request", voiceAssistantRequestAssistInfo);
        showSession(bundle, 1);
    }
}