ModV2.0.4 v1.86526672844804版本的 MD5 值为:ab8437a2d03fc69805a8b4199bd7fecb
以下内容为反编译后的 ServiceVoiceInteractionTasker.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.net.Uri;
import android.os.Bundle;
import android.service.voice.VoiceInteractionService;
import androidx.annotation.Keep;
import b.a.d.i;
import b.a.h;
import c.f.b.k;
import c.f.b.l;
import c.l.n;
import c.q;
import c.s;
import com.google.android.gms.maps.g;
import com.joaomgcd.taskerm.action.system.ba;
import com.joaomgcd.taskerm.action.system.v;
import com.joaomgcd.taskerm.action.system.w;
import com.joaomgcd.taskerm.dialog.x;
import com.joaomgcd.taskerm.dialog.y;
import com.joaomgcd.taskerm.notification.al;
import com.joaomgcd.taskerm.notification.aw;
import com.joaomgcd.taskerm.notification.j;
import com.joaomgcd.taskerm.rx.EventBusRxSubscription;
import com.joaomgcd.taskerm.rx.b;
import com.joaomgcd.taskerm.util.an;
import com.joaomgcd.taskerm.util.ao;
import com.joaomgcd.taskerm.util.cr;
import com.joaomgcd.taskerm.util.ct;
import com.joaomgcd.taskerm.util.cu;
import com.joaomgcd.taskerm.util.cw;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import net.danlew.android.joda.R;
import net.dinglisch.android.taskerm.ActionEdit;
import net.dinglisch.android.taskerm.bo;
import net.dinglisch.android.taskerm.bq;
@TargetApi(g.a.MapAttrs_latLngBoundsNorthEastLongitude)
public final class ServiceVoiceInteractionTasker extends VoiceInteractionService {
public static final a f5948a = new a(null);
private final com.joaomgcd.taskerm.assistant.a f5949b = new com.joaomgcd.taskerm.assistant.a(this);
public static final class b {
}
static final class e extends l implements c.f.a.a<s> {
public static final e f5970a = new e();
e() {
super(0);
}
@Override
public s invoke() {
a();
return s.f2131a;
}
public final void a() {
com.joaomgcd.taskerm.rx.b.c(new b());
}
}
@Override
public void onCreate() {
super.onCreate();
this.f5949b.n();
}
@Override
public void onReady() {
super.onReady();
this.f5949b.a(com.joaomgcd.taskerm.rx.b.a(this), e.f5970a);
}
@Override
public void onDestroy() {
com.joaomgcd.taskerm.rx.b.b(this);
this.f5949b.b();
super.onDestroy();
}
@EventBusRxSubscription
@Keep
public final void onRequest(VoiceAssistantRequest voiceAssistantRequest) {
k.b(voiceAssistantRequest, "request");
if (voiceAssistantRequest instanceof VoiceAssistantRequestAssistInfo) {
return;
}
Bundle bundle = new Bundle();
bundle.putParcelable("request", voiceAssistantRequest);
showSession(bundle, 0);
}
public static final class a {
public static final class b extends l implements c.f.a.a<cr> {
final VoiceAssistantRequest f5951a;
b(VoiceAssistantRequest voiceAssistantRequest) {
super(0);
this.f5951a = voiceAssistantRequest;
}
public static final class C0112a extends l implements c.f.a.a<c> {
C0112a() {
super(0);
}
public static final class C0113a<T> implements i<Object> {
public static final C0113a f5953a = new C0113a();
@Override
public final boolean a(Object obj) {
k.b(obj, "it");
return obj instanceof c;
}
}
@Override
public final c invoke() {
VoiceAssistantRequest voiceAssistantRequest = b.this.f5951a;
h<Object> a2 = com.joaomgcd.taskerm.rx.b.f8673b.a().a((i<? super Object>) C0113a.f5953a);
if (a2 != null) {
b.a.l<Object> a3 = a2.d().a();
if (a3 == null) {
throw new q("null cannot be cast to non-null type io.reactivex.Single<T>");
}
b.a.l<Object> b2 = a3.b(5000L, TimeUnit.MILLISECONDS);
k.a((Object) b2, "result.timeout(it, TimeUnit.MILLISECONDS)");
b2.a(b.c.f8684a, b.d.f8685a);
com.joaomgcd.taskerm.rx.b.c(voiceAssistantRequest);
return (c) b2.b();
}
throw new q("null cannot be cast to non-null type io.reactivex.Observable<T>");
}
}
@Override
public final cr invoke() {
cr a2;
c cVar = (c) an.a((c.f.a.b) null, new C0112a(), 1, (Object) null);
return (cVar == null || (a2 = cVar.a()) == null) ? ct.a("Couldn't do action with assistant") : a2;
}
}
public static final class d extends l implements c.f.a.a<cr> {
final Context f5955a;
final w f5956b;
final String f5957c;
final c f5958d;
final ba f5959e;
d(Context context, w wVar, String str, c cVar, ba baVar) {
super(0);
this.f5955a = context;
this.f5956b = wVar;
this.f5957c = str;
this.f5958d = cVar;
this.f5959e = baVar;
}
public static final class C0114a<T> implements i<Object> {
public static final C0114a f5961a = new C0114a();
@Override
public final boolean a(Object obj) {
k.b(obj, "it");
return obj instanceof b;
}
}
@Override
public final cr invoke() {
b.a.l<Object> lVar;
String packageName = this.f5955a.getPackageName();
if (k.a((Object) this.f5956b.getPackageName(), (Object) this.f5957c)) {
bo.b("ServiceVoiceInteractionTasker", "No need to change assistant, alread " + this.f5957c);
return this.f5958d.invoke();
}
bo.b("ServiceVoiceInteractionTasker", "Changing assistant from " + this.f5956b + " to " + this.f5957c);
if (k.a((Object) this.f5957c, (Object) packageName)) {
h<Object> a2 = com.joaomgcd.taskerm.rx.b.f8673b.a().a((i<? super Object>) C0114a.f5961a);
if (a2 != null) {
b.a.l<Object> a3 = a2.d().a();
if (a3 == null) {
throw new q("null cannot be cast to non-null type io.reactivex.Single<T>");
}
lVar = a3.b(3000L, TimeUnit.MILLISECONDS);
k.a((Object) lVar, "result.timeout(it, TimeUnit.MILLISECONDS)");
lVar.a(b.c.f8684a, b.d.f8685a);
} else {
throw new q("null cannot be cast to non-null type io.reactivex.Observable<T>");
}
} else {
lVar = null;
}
cr b2 = this.f5959e.a(this.f5955a).b();
if (b2.b()) {
if (lVar == null || ((b) an.a((c.f.a.b) null, new AnonymousClass1(lVar), 1, (Object) null)) != null) {
return this.f5958d.invoke();
}
return ct.a("Couldn't set " + this.f5957c + " as an assistant");
}
return b2;
}
public static final class AnonymousClass1 extends l implements c.f.a.a<b> {
final b.a.l f5960a;
AnonymousClass1(b.a.l lVar) {
super(0);
this.f5960a = lVar;
}
@Override
public final b invoke() {
return (b) this.f5960a.b();
}
}
}
static final class C0111a extends l implements c.f.a.b<aw, s> {
final Context f5950a;
C0111a(Context context) {
super(1);
this.f5950a = context;
}
@Override
public s invoke(aw awVar) {
a(awVar);
return s.f2131a;
}
public final void a(aw awVar) {
k.b(awVar, "receiver$0");
awVar.u().addAll(new al(new j(this.f5950a), new com.joaomgcd.taskerm.notification.g(this.f5950a, "https://tasker.joaoapps.com/userguide/en/help/ah_secure_setting_grant.html", false, an.a((int) R.string.dt_permission, this.f5950a, new Object[0]), 4, null)));
}
}
static final class f extends l implements c.f.a.b<x, s> {
final Activity f5963a;
f(Activity activity) {
super(1);
this.f5963a = activity;
}
@Override
public s invoke(x xVar) {
a(xVar);
return s.f2131a;
}
public final void a(x xVar) {
k.b(xVar, "dialogMessage");
if (xVar.e()) {
ActionEdit.a(this.f5963a, "secure_setting_grant", (String) null);
}
if (xVar.d()) {
this.f5963a.startActivity(bq.b());
}
}
}
private a() {
}
public a(c.f.b.g gVar) {
this();
}
public static b.a.l a(a aVar, Context context, ba baVar, boolean z, int i, Object obj) {
if ((i & 4) != 0) {
z = true;
}
return aVar.a(context, baVar, z);
}
public final b.a.l<cr> a(Context context, ba baVar, boolean z) {
k.b(context, "context");
k.b(baVar, "assistantApp");
w wVar = new w(context);
String packageName = baVar.getPackageName();
bo.b("ServiceVoiceInteractionTasker", "Request to set assistant to " + packageName + "; currently: " + wVar);
c cVar = new c(wVar);
if (!z) {
b.a.l<cr> a2 = b.a.l.a(cVar.invoke());
k.a((Object) a2, "Single.just(finishSuccessfully())");
return a2;
}
b.a.l<cr> a3 = com.joaomgcd.taskerm.rx.h.b(new d(context, wVar, packageName, cVar, baVar)).a((b.a.d.f) new e(packageName));
k.a((Object) a3, "getResultInBackground {\n… }\n }");
return a3;
}
public static final class c extends l implements c.f.a.a<cr> {
final w f5954a;
c(w wVar) {
super(0);
this.f5954a = wVar;
}
@Override
public final cr invoke() {
return ct.a(this.f5954a);
}
}
public static final class e<T> implements b.a.d.f<cr> {
final String f5962a;
e(String str) {
this.f5962a = str;
}
@Override
public final void accept(cr crVar) {
k.b(crVar, "it");
if (crVar.b()) {
bo.b("ServiceVoiceInteractionTasker", "Set assistant to " + this.f5962a + '!');
return;
}
bo.b("ServiceVoiceInteractionTasker", "Couldn't set assistant to " + this.f5962a + ": " + crVar.a());
}
}
public final b.a.l<cr> a(Context context, VoiceAssistantRequest voiceAssistantRequest) {
k.b(context, "context");
k.b(voiceAssistantRequest, "request");
if (com.joaomgcd.taskerm.action.system.q.c(context)) {
return com.joaomgcd.taskerm.rx.h.b(new b(voiceAssistantRequest));
}
b.a.l<cr> a2 = b.a.l.a(ct.a("This app must be the current assistant app to do this"));
k.a((Object) a2, "Single.just(SimpleResult…sistant app to do this\"))");
return a2;
}
public final cr b(Context context, VoiceAssistantRequest voiceAssistantRequest) {
k.b(context, "context");
k.b(voiceAssistantRequest, "request");
String packageName = context.getPackageName();
a aVar = this;
k.a((Object) packageName, "myPackageName");
Object b2 = a(aVar, context, new v(context, packageName), false, 4, null).b();
if (!(b2 instanceof cw)) {
b2 = null;
}
cw cwVar = (cw) b2;
if (cwVar == null) {
return ct.a("Could set Tasker as assistant");
}
if (!cwVar.b()) {
bo.b("ServiceVoiceInteractionTasker", "Couldn't set assistant to " + packageName + ": " + cwVar.a());
return cwVar;
}
bo.b("ServiceVoiceInteractionTasker", "Set assistant to " + packageName + " before assistant command!");
ba baVar = (ba) cwVar.d();
if (baVar == null) {
return ct.a("Couldn't check which app is assistant");
}
boolean z = !k.a((Object) baVar.getPackageName(), (Object) packageName);
cr b3 = aVar.a(context, voiceAssistantRequest).b();
if (!b3.b()) {
StringBuilder sb = new StringBuilder();
sb.append("Couldn't send assistant request ");
Intent intent = voiceAssistantRequest.getIntent();
sb.append(intent != null ? intent.getAction() : null);
sb.append(" to ");
sb.append(packageName);
sb.append(": ");
sb.append(cwVar.a());
bo.b("ServiceVoiceInteractionTasker", sb.toString());
k.a((Object) b3, "resultAssistantRequest");
return b3;
}
bo.b("ServiceVoiceInteractionTasker", "Sent assistant request with action " + voiceAssistantRequest.getAction() + '!');
cr b4 = aVar.a(context, baVar, z).b();
if (!(b4 instanceof cw)) {
b4 = null;
}
cw cwVar2 = (cw) b4;
if (cwVar2 == null) {
return ct.a("Could not set " + baVar + " back as assistant");
} else if (!cwVar2.b()) {
bo.b("ServiceVoiceInteractionTasker", "Couldn't set assistant back to " + baVar + ": " + cwVar.a());
return cwVar2;
} else {
bo.b("ServiceVoiceInteractionTasker", "Set assistant back to " + baVar + " after assistant command!");
return new cu();
}
}
public final cr a(Context context, int i, VoiceAssistantRequest voiceAssistantRequest) {
k.b(context, "context");
k.b(voiceAssistantRequest, "request");
if (com.joaomgcd.taskerm.util.g.f9751b.t()) {
if (com.joaomgcd.taskerm.action.system.q.c(context) || com.joaomgcd.taskerm.util.al.m(context)) {
return b(context, voiceAssistantRequest);
}
aw.f8309b.b(context, "airplanemodeassistant", an.a(i, context, new Object[0]), an.a((int) R.string.run_airplane_mode_no_root_or_adb_wifi, context, new Object[0]), new C0111a(context)).b();
return ct.a("Couldn't request with assistant. Notification posted.");
}
return ct.a("Can only request with assistant on Marshmallow or above");
}
public final void a(Activity activity, int i) {
k.b(activity, "context");
if (com.joaomgcd.taskerm.util.g.f9751b.d()) {
return;
}
Activity activity2 = activity;
if (com.joaomgcd.taskerm.action.system.q.b(activity2) || com.joaomgcd.taskerm.util.al.m(activity2)) {
return;
}
String a2 = an.a(i, activity2, new Object[0]);
if (com.joaomgcd.taskerm.q.b.a(activity2, ao.D(a2), null, 2, null)) {
return;
}
com.joaomgcd.taskerm.rx.h.a(y.a(activity, i, (int) R.string.run_airplane_mode_no_root_or_adb_wifi, (int) R.string.dt_permission, (int) R.string.ml_android_settings_assistant_settings, a2), activity2, new f(activity));
}
}
@EventBusRxSubscription
@Keep
public final void onRequestAssistInfo(VoiceAssistantRequestAssistInfo voiceAssistantRequestAssistInfo) {
k.b(voiceAssistantRequestAssistInfo, "request");
Bundle bundle = new Bundle();
bundle.putParcelable("request", voiceAssistantRequestAssistInfo);
showSession(bundle, 1);
}
public static final class c {
private final cr f5964a;
public c(cr crVar) {
k.b(crVar, "simpleResult");
this.f5964a = crVar;
}
public final cr a() {
return this.f5964a;
}
}
public static final class d {
private final Context f5965a;
private final Bundle f5966b;
private final AssistStructure f5967c;
private final AssistContent f5968d;
private final Bundle f5969e;
public d(Context context, Bundle bundle, AssistStructure assistStructure, AssistContent assistContent, Bundle bundle2) {
k.b(context, "context");
this.f5965a = context;
this.f5966b = bundle;
this.f5967c = assistStructure;
this.f5968d = assistContent;
this.f5969e = bundle2;
}
public d(Context context, Bundle bundle, AssistStructure assistStructure, AssistContent assistContent, Bundle bundle2, int i, c.f.b.g gVar) {
this(context, (i & 2) != 0 ? null : bundle, (i & 4) != 0 ? null : assistStructure, (i & 8) != 0 ? null : assistContent, (i & 16) != 0 ? null : bundle2);
}
public final ComponentName a() {
ComponentName componentName;
String string;
AssistStructure assistStructure = this.f5967c;
if (assistStructure == null || (componentName = assistStructure.getActivityComponent()) == null) {
Bundle bundle = this.f5966b;
componentName = (bundle == null || (string = bundle.getString("android.intent.extra.ASSIST_PACKAGE")) == null) ? null : new ComponentName(string, "");
}
return componentName != null ? componentName : com.joaomgcd.taskerm.util.al.an(this.f5965a);
}
public final Uri b() {
AssistContent assistContent = this.f5968d;
if (assistContent != null) {
return assistContent.getWebUri();
}
return null;
}
public final String c() {
HashMap<String, Object> hashMap;
HashMap<String, Object> hashMap2;
HashMap<String, Object> hashMap3;
Intent intent;
AssistContent assistContent = this.f5968d;
if (assistContent == null || (intent = assistContent.getIntent()) == null || (hashMap = an.b(intent)) == null) {
hashMap = new HashMap<>();
}
Bundle bundle = this.f5966b;
if (bundle == null || (hashMap2 = an.b(bundle)) == null) {
hashMap2 = new HashMap<>();
}
Bundle bundle2 = this.f5969e;
if (bundle2 == null || (hashMap3 = an.b(bundle2)) == null) {
hashMap3 = new HashMap<>();
}
for (Map.Entry<String, Object> entry : hashMap2.entrySet()) {
hashMap.put(entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Object> entry2 : hashMap3.entrySet()) {
hashMap.put(entry2.getKey(), entry2.getValue());
}
if (!hashMap.isEmpty()) {
return an.a((Object) hashMap);
}
return null;
}
public final String d() {
ArrayList arrayList;
List<AssistStructure.ViewNode> a2;
String str;
HashMap<String, Object> b2;
boolean z;
boolean z2;
HashMap hashMap;
String obj;
AssistStructure assistStructure = this.f5967c;
boolean z3 = false;
if (assistStructure == null || (a2 = com.joaomgcd.taskerm.assistant.b.a(assistStructure)) == null) {
arrayList = null;
} else {
ArrayList arrayList2 = new ArrayList();
for (AssistStructure.ViewNode viewNode : a2) {
CharSequence text = viewNode.getText();
if (text != null && (obj = text.toString()) != null) {
if (obj == null) {
throw new q("null cannot be cast to non-null type kotlin.CharSequence");
}
String obj2 = n.b((CharSequence) obj).toString();
if (obj2 != null) {
str = ao.A(obj2);
Bundle extras = viewNode.getExtras();
b2 = extras == null ? an.b(extras) : null;
HashMap<String, Object> hashMap2 = b2;
z = (hashMap2 != null || hashMap2.isEmpty()) && b2.get("href") != null;
z2 = str == null && (k.a((Object) str, (Object) ".") ^ true);
if (!z2 || z) {
hashMap = new HashMap();
com.joaomgcd.taskerm.assistant.b.a(hashMap, "text", str, z2);
com.joaomgcd.taskerm.assistant.b.a(hashMap, "extras", b2, z);
} else {
hashMap = null;
}
if (hashMap == null) {
arrayList2.add(hashMap);
}
}
}
str = null;
Bundle extras2 = viewNode.getExtras();
if (extras2 == null) {
}
HashMap<String, Object> hashMap22 = b2;
if (hashMap22 != null || hashMap22.isEmpty()) {
}
if (str == null) {
}
if (z2) {
}
hashMap = new HashMap();
com.joaomgcd.taskerm.assistant.b.a(hashMap, "text", str, z2);
com.joaomgcd.taskerm.assistant.b.a(hashMap, "extras", b2, z);
if (hashMap == null) {
}
}
arrayList = arrayList2;
}
ArrayList arrayList3 = arrayList;
if ((arrayList3 == null || arrayList3.isEmpty()) ? true : true) {
return null;
}
return an.a((Object) arrayList);
}
public final net.dinglisch.android.taskerm.ao e() {
net.dinglisch.android.taskerm.ao aoVar = new net.dinglisch.android.taskerm.ao(201);
ComponentName a2 = a();
if (a2 != null) {
aoVar.a(0, a2.getPackageName(), a2.getClassName(), "");
}
Uri b2 = b();
if (b2 != null) {
aoVar.b(1, b2.toString());
}
String c2 = c();
if (c2 != null) {
aoVar.b(3, c2);
}
String d2 = d();
if (d2 != null) {
aoVar.b(2, d2);
}
return aoVar;
}
}
}