ModV2.0.4 v1.86526672844804版本的 MD5 值为:ab8437a2d03fc69805a8b4199bd7fecb
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.joaomgcd.taskerm.b;
import android.content.Context;
import c.f.b.w;
import com.joaomgcd.taskerm.settings.ai;
import com.joaomgcd.taskerm.util.al;
import com.joaomgcd.taskerm.util.an;
import com.joaomgcd.taskerm.util.ao;
import com.joaomgcd.taskerm.util.dq;
import com.joaomgcd.taskerm.util.ds;
import java.io.File;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.List;
import java.util.concurrent.TimeUnit;
import net.dinglisch.android.taskerm.bo;
public final class a {
static final c.j.g[] f5977a = {c.f.b.x.a(new c.f.b.v(c.f.b.x.a(a.class), "publicKey", "getPublicKey()Ljava/io/File;")), c.f.b.x.a(new c.f.b.v(c.f.b.x.a(a.class), "privateKey", "getPrivateKey()Ljava/io/File;")), c.f.b.x.a(new c.f.b.v(c.f.b.x.a(a.class), "base64", "getBase64()Lcom/joaomgcd/taskerm/adblib/AdbBase64;")), c.f.b.x.a(new c.f.b.v(c.f.b.x.a(a.class), "crypto", "getCrypto()Lcom/joaomgcd/taskerm/adblib/AdbCrypto;"))};
public static final c f5978b = new c(null);
private static Boolean h;
private final c.e f5979c;
private final c.e f5980d;
private final c.e f5981e;
private final c.e f5982f;
private final Context g;
public interface e {
void a();
}
public final File d() {
c.e eVar = this.f5979c;
c.j.g gVar = f5977a[0];
return (File) eVar.b();
}
public final File e() {
c.e eVar = this.f5980d;
c.j.g gVar = f5977a[1];
return (File) eVar.b();
}
public final x f() {
c.e eVar = this.f5981e;
c.j.g gVar = f5977a[2];
return (x) eVar.b();
}
public final z g() {
c.e eVar = this.f5982f;
c.j.g gVar = f5977a[3];
return (z) eVar.b();
}
public static final class j extends c.f.b.l implements c.f.a.b<String, c.s> {
final boolean f5997b;
final com.joaomgcd.taskerm.securesettings.g f5998c;
j(boolean z, com.joaomgcd.taskerm.securesettings.g gVar) {
super(1);
this.f5997b = z;
this.f5998c = gVar;
}
@Override
public c.s invoke(String str) {
a(str);
return c.s.f2131a;
}
public final void a(String str) {
c.f.b.k.b(str, "receiver$0");
if (this.f5997b) {
com.joaomgcd.taskerm.securesettings.ab.a(a.this.c(), new com.joaomgcd.taskerm.securesettings.s(this.f5998c, str)).b();
ds.a(250L);
if (c.f.b.k.a((Object) str, (Object) "1")) {
com.joaomgcd.taskerm.rx.h.a(com.joaomgcd.taskerm.rx.h.a(new AnonymousClass1()), 3, 1L, TimeUnit.SECONDS, null, 8, null).b();
}
}
}
public static final class AnonymousClass1 extends c.f.b.l implements c.f.a.a<b.a.l<Boolean>> {
AnonymousClass1() {
super(0);
}
@Override
public final b.a.l<Boolean> invoke() {
return a.this.a().b(2L, TimeUnit.SECONDS).c(new b.a.d.g<T, R>() {
@Override
public final Boolean apply(Boolean bool) {
c.f.b.k.b(bool, "it");
if (bool.booleanValue()) {
return bool;
}
throw new RuntimeException("Can't enable debugging");
}
});
}
}
}
public static final class k extends c.f.b.l implements c.f.a.a<c.s> {
final j f6001a;
final w.d f6002b;
final w.d f6003c;
final b f6004d;
k(j jVar, w.d dVar, w.d dVar2, b bVar) {
super(0);
this.f6001a = jVar;
this.f6002b = dVar;
this.f6003c = dVar2;
this.f6004d = bVar;
}
@Override
public c.s invoke() {
a();
return c.s.f2131a;
}
public final void a() {
try {
this.f6001a.a("0");
ab abVar = (ab) this.f6002b.f2028a;
if (abVar != null) {
abVar.close();
}
y yVar = (y) this.f6003c.f2028a;
if (yVar != null) {
yVar.close();
}
OutputStream h = this.f6004d.h();
if (h != null) {
h.close();
}
} catch (Throwable unused) {
}
}
}
public static final class p<T, R> implements b.a.d.g<T, R> {
public static final p f6022a = new p();
p() {
}
public final boolean a(String str) {
c.f.b.k.b(str, "it");
return true;
}
@Override
public Object apply(Object obj) {
return Boolean.valueOf(a((String) obj));
}
}
public static final class c {
private c() {
}
public c(c.f.b.g gVar) {
this();
}
public final b.a.l<Boolean> a(Context context) {
c.f.b.k.b(context, "context");
return new a(context).a();
}
public final boolean b(Context context) {
c.f.b.k.b(context, "context");
return new a(context).b();
}
public final String a(String str, String str2) {
c.f.b.k.b(str, "packageName");
c.f.b.k.b(str2, "className");
return "cmd package set-home-activity \"" + str + '/' + str2 + '\"';
}
}
public a(Context context) {
c.f.b.k.b(context, "context");
this.g = context;
this.f5979c = c.f.a(new i());
this.f5980d = c.f.a(new h());
this.f5981e = c.f.a(f.f5991a);
this.f5982f = c.f.a(new g());
}
public final Context c() {
return this.g;
}
static final class i extends c.f.b.l implements c.f.a.a<File> {
i() {
super(0);
}
@Override
public final File invoke() {
return dq.a(a.this.c(), "pub.key", (String) null, 2, (Object) null);
}
}
static final class h extends c.f.b.l implements c.f.a.a<File> {
h() {
super(0);
}
@Override
public final File invoke() {
return dq.a(a.this.c(), "priv.key", (String) null, 2, (Object) null);
}
}
static final class f extends c.f.b.l implements c.f.a.a<x> {
public static final f f5991a = new f();
f() {
super(0);
}
@Override
public final x invoke() {
return new x() {
@Override
public final String a(byte[] bArr) {
c.f.b.k.a((Object) bArr, "it");
return an.d(bArr);
}
};
}
}
static final class g extends c.f.b.l implements c.f.a.a<z> {
g() {
super(0);
}
@Override
public final z invoke() {
z zVar;
if (a.this.d().exists() && a.this.e().exists()) {
try {
zVar = z.a(a.this.f(), a.this.e(), a.this.d());
} catch (Throwable th) {
a.this.a("Couldn't read adb crypto from file", th);
}
if (zVar != null) {
z a2 = z.a(a.this.f());
c.f.b.k.a((Object) a2, "AdbCrypto.generateAdbKeyPair(base64)");
a2.a(a.this.e(), a.this.d());
a.a(a.this, "Generated new adb crypto key pair", (Throwable) null, 1, (Object) null);
return a2;
}
a.a(a.this, "Loaded existing adb crypto key pair", (Throwable) null, 1, (Object) null);
return zVar;
}
zVar = null;
if (zVar != null) {
}
}
}
public static void a(a aVar, String str, Throwable th, int i2, Object obj) {
if ((i2 & 1) != 0) {
th = null;
}
aVar.a(str, th);
}
public final void a(String str, Throwable th) {
bo.a("ADB", str, th);
}
public static class C0116a {
private final String f5983a;
private final int f5984b;
public C0116a(String str, int i) {
c.f.b.k.b(str, "ip");
this.f5983a = str;
this.f5984b = i;
}
public final String a() {
return this.f5983a;
}
public final int b() {
return this.f5984b;
}
}
public static final class b extends C0116a {
private final String f5985a;
private final Integer f5986b;
private final boolean f5987c;
private final boolean f5988d;
private final String f5989e;
private final OutputStream f5990f;
private final c.f.a.b<e, c.s> g;
public b(String str, int i, String str2, Integer num, boolean z, boolean z2, String str3, OutputStream outputStream, c.f.a.b<? super e, c.s> bVar) {
super(str, i);
c.f.b.k.b(str, "ip");
c.f.b.k.b(str2, "command");
this.f5985a = str2;
this.f5986b = num;
this.f5987c = z;
this.f5988d = z2;
this.f5989e = str3;
this.f5990f = outputStream;
this.g = bVar;
}
public b(String str, int i, String str2, Integer num, boolean z, boolean z2, String str3, OutputStream outputStream, c.f.a.b bVar, int i2, c.f.b.g gVar) {
this(str, i, str2, (i2 & 8) != 0 ? 1000 : num, (i2 & 16) != 0 ? false : z, (i2 & 32) != 0 ? false : z2, (i2 & 64) != 0 ? null : str3, (i2 & 128) != 0 ? null : outputStream, (i2 & 256) != 0 ? null : bVar);
}
public final String c() {
return this.f5985a;
}
public final Integer d() {
return this.f5986b;
}
public final boolean e() {
return this.f5987c;
}
public final boolean f() {
return this.f5988d;
}
public final String g() {
return this.f5989e;
}
public final OutputStream h() {
return this.f5990f;
}
public final c.f.a.b<e, c.s> i() {
return this.g;
}
}
public final b.a.l<Boolean> a() {
return a(this, "test", 0, 2, (Object) null);
}
public final boolean b() {
Boolean bool = h;
if (bool != null) {
boolean booleanValue = bool.booleanValue();
bo.b("ADB", "isAdbWifiAvailableWithCacheIfNeeded with cache: " + booleanValue);
return booleanValue;
} else if (com.joaomgcd.taskerm.rx.h.c()) {
bo.b("ADB", "isAdbWifiAvailableWithCacheIfNeeded ui thread: true");
return true;
} else {
Boolean bool2 = (Boolean) a(this, "test", 0, 2, (Object) null).b();
bo.b("ADB", "isAdbWifiAvailableWithCacheIfNeeded no cache: " + bool2);
c.f.b.k.a((Object) bool2, "result");
return bool2.booleanValue();
}
}
public static final class q<T, R> implements b.a.d.g<Throwable, b.a.p<? extends Boolean>> {
public static final q f6023a = new q();
q() {
}
@Override
public final b.a.l<Boolean> apply(Throwable th) {
c.f.b.k.b(th, "it");
return b.a.l.a(false);
}
}
public static b.a.l a(a aVar, String str, int i2, int i3, Object obj) {
if ((i3 & 2) != 0) {
i2 = 1000;
}
return aVar.a(str, i2);
}
public final b.a.l<Boolean> a(String str, int i2) {
c.f.b.k.b(str, "command");
try {
b.a.l<Boolean> d2 = b(this, str, i2, false, 0, null, false, 60, null).c(p.f6022a).d(q.f6023a);
c.f.b.k.a((Object) d2, "sendLocalCommand(command…xt { Single.just(false) }");
return d2;
} catch (Throwable unused) {
b.a.l<Boolean> a2 = b.a.l.a(false);
c.f.b.k.a((Object) a2, "Single.just(false)");
return a2;
}
}
public static final class o<T, R> implements b.a.d.g<T, R> {
public static final o f6021a = new o();
o() {
}
@Override
public final List<String> apply(String str) {
c.f.b.k.b(str, "it");
return c.l.n.b((CharSequence) str, new String[]{"\n"}, false, 0, 6, (Object) null);
}
}
public static b.a.l a(a aVar, String str, int i2, boolean z, int i3, String str2, boolean z2, int i4, Object obj) {
int i5 = (i4 & 2) != 0 ? 1000 : i2;
boolean z3 = (i4 & 4) != 0 ? false : z;
if ((i4 & 8) != 0) {
i3 = ai.a(aVar.g);
}
int i6 = i3;
if ((i4 & 16) != 0) {
str2 = "localhost";
}
return aVar.a(str, i5, z3, i6, str2, (i4 & 32) != 0 ? false : z2);
}
public final b.a.l<List<String>> a(String str, int i2, boolean z, int i3, String str2, boolean z2) {
c.f.b.k.b(str, "command");
c.f.b.k.b(str2, "host");
return b(str, i2, z, i3, str2, z2).c(o.f6021a);
}
public static b.a.l b(a aVar, String str, int i2, boolean z, int i3, String str2, boolean z2, int i4, Object obj) {
int i5 = (i4 & 2) != 0 ? 1000 : i2;
boolean z3 = (i4 & 4) != 0 ? false : z;
if ((i4 & 8) != 0) {
i3 = ai.a(aVar.g);
}
int i6 = i3;
if ((i4 & 16) != 0) {
str2 = "localhost";
}
return aVar.b(str, i5, z3, i6, str2, (i4 & 32) != 0 ? false : z2);
}
public final b.a.l<String> b(String str, int i2, boolean z, int i3, String str2, boolean z2) {
c.f.b.k.b(str, "command");
c.f.b.k.b(str2, "host");
return a(new b(str2, i3, str, Integer.valueOf(i2), z, z2, null, null, null, 448, null));
}
public final b.a.l<String> a(b bVar) {
c.f.b.k.b(bVar, "args");
w.d dVar = new w.d();
dVar.f2028a = (y) 0;
w.d dVar2 = new w.d();
dVar2.f2028a = (ab) 0;
com.joaomgcd.taskerm.securesettings.g gVar = new com.joaomgcd.taskerm.securesettings.g(com.joaomgcd.taskerm.securesettings.q.Global, "adb_enabled", false, 0, 0, 28, null);
boolean z = true;
j jVar = new j((bVar.f() && (c.f.b.k.a((Object) com.joaomgcd.taskerm.securesettings.ab.b(this.g, gVar).b(), (Object) "1") ^ true)) ? false : false, gVar);
k kVar = new k(jVar, dVar2, dVar, bVar);
c.f.a.b<e, c.s> i2 = bVar.i();
if (i2 != null) {
i2.invoke(new l(kVar));
}
b.a.l<String> a2 = com.joaomgcd.taskerm.rx.h.a(new m(bVar, jVar, dVar, dVar2, kVar)).a((b.a.d.a) new n(kVar));
c.f.b.k.a((Object) a2, "getInBackground {\n … finish()\n }");
return a2;
}
public static final class l implements e {
final k f6005a;
l(k kVar) {
this.f6005a = kVar;
}
@Override
public void a() {
this.f6005a.a();
}
}
public static final class m extends c.f.b.l implements c.f.a.a<b.a.l<String>> {
final b f6007b;
final j f6008c;
final w.d f6009d;
final w.d f6010e;
final k f6011f;
m(b bVar, j jVar, w.d dVar, w.d dVar2, k kVar) {
super(0);
this.f6007b = bVar;
this.f6008c = jVar;
this.f6009d = dVar;
this.f6010e = dVar2;
this.f6011f = kVar;
}
@Override
public final b.a.l<String> invoke() {
String a2 = this.f6007b.a();
int b2 = this.f6007b.b();
String c2 = this.f6007b.c();
al.b(a.this.c(), 375).c();
this.f6008c.a("1");
try {
?? a3 = y.a(new Socket(a2, b2), a.this.g());
this.f6009d.f2028a = a3;
a3.a();
if (a3 == 0) {
throw new c.q("null cannot be cast to non-null type com.joaomgcd.taskerm.adblib.AdbConnection");
}
?? a4 = a3.a("shell:");
this.f6010e.f2028a = a4;
a4.a(c2 + '\n');
StringBuilder sb = new StringBuilder();
final AnonymousClass1 anonymousClass1 = new AnonymousClass1(sb);
b.a.l b3 = com.joaomgcd.taskerm.rx.h.b(new C0118a(a4, sb, anonymousClass1));
if (this.f6007b.d() != null) {
b3 = b3.b(this.f6007b.d().intValue(), TimeUnit.MILLISECONDS);
}
return b3.d(new b.a.d.g<Throwable, b.a.p<? extends String>>() {
@Override
public final b.a.l<String> apply(Throwable th) {
c.f.b.k.b(th, "it");
return b.a.l.a(AnonymousClass1.this.invoke());
}
}).a(new b.a.d.a() {
@Override
public final void run() {
m.this.f6011f.a();
}
});
} catch (ConnectException unused) {
a.h = null;
throw new d();
}
}
public static final class AnonymousClass1 extends c.f.b.l implements c.f.a.a<String> {
final StringBuilder f6013b;
AnonymousClass1(StringBuilder sb) {
super(0);
this.f6013b = sb;
}
@Override
public final String invoke() {
String sb = this.f6013b.toString();
c.f.b.k.a((Object) sb, "result.toString()");
String a2 = ao.a(ao.a(sb, "\r"), "^@");
if (m.this.f6007b.e()) {
a2 = c.a.j.a(c.a.j.b(c.a.j.b((Iterable) c.l.n.b((CharSequence) a2, new String[]{"\n"}, false, 0, 6, (Object) null), 2), 1), "\n", null, null, 0, null, null, 62, null);
}
a.h = true;
return a2;
}
}
public static final class C0118a extends c.f.b.l implements c.f.a.a<String> {
final ab f6017b;
final StringBuilder f6018c;
final AnonymousClass1 f6019d;
C0118a(ab abVar, StringBuilder sb, AnonymousClass1 anonymousClass1) {
super(0);
this.f6017b = abVar;
this.f6018c = sb;
this.f6019d = anonymousClass1;
}
@Override
public final String invoke() {
String str = null;
while (true) {
try {
ab abVar = this.f6017b;
c.f.b.k.a((Object) abVar, "stream");
if (!abVar.e()) {
byte[] d2 = this.f6017b.d();
c.f.b.k.a((Object) d2, "responseBytes");
String g = m.this.f6007b.g();
if (g == null) {
g = "US-ASCII";
}
Charset forName = Charset.forName(g);
c.f.b.k.a((Object) forName, "Charset.forName(charsetName)");
String str2 = new String(d2, forName);
OutputStream h = m.this.f6007b.h();
if (h != null) {
h.write(d2);
}
if (m.this.f6007b.h() == null || str == null) {
this.f6018c.append(str2);
}
if (str != null && c.l.n.b((CharSequence) str2, (CharSequence) str, false, 2, (Object) null)) {
break;
} else if (str == null) {
String sb = this.f6018c.toString();
c.f.b.k.a((Object) sb, "result.toString()");
String str3 = sb;
int i = 0;
int i2 = 0;
while (true) {
boolean z = true;
if (i >= str3.length()) {
break;
}
if (str3.charAt(i) != '\n') {
z = false;
}
if (z) {
i2++;
}
i++;
}
if (i2 >= 2) {
String sb2 = this.f6018c.toString();
c.f.b.k.a((Object) sb2, "result.toString()");
String a2 = ao.a((String) c.l.n.b((CharSequence) sb2, new String[]{"\n"}, false, 0, 6, (Object) null).get(1), "^@");
str = c.l.n.a(a2, ":/", (String) null, 2, (Object) null) + ":/ $";
if (c.l.n.b((CharSequence) str2, (CharSequence) ('|' + str), false, 2, (Object) null)) {
break;
}
} else {
continue;
}
}
} else {
break;
}
} finally {
try {
return this.f6019d.invoke();
} finally {
}
}
}
return this.f6019d.invoke();
}
}
}
public static final class n implements b.a.d.a {
final k f6020a;
n(k kVar) {
this.f6020a = kVar;
}
@Override
public final void run() {
this.f6020a.a();
}
}
public static final class d extends RuntimeException {
public d() {
super("Can't connect to ADB Wifi. Check here: https://tasker.joaoapps.com/userguide/en/help/ah_adb_wifi.html");
}
}
}