ComeetChat v1.866866806590版本的 MD5 值为:4a7461802cd62adce19de75377dd7ca7
以下内容为反编译后的 MyVpnService.java 源代码,内容仅作参考
package net.dinglisch.android.taskerm;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.VpnService;
import android.os.ParcelFileDescriptor;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import net.danlew.android.joda.R;
import net.dinglisch.android.taskerm.bw;
public class MyVpnService extends VpnService {
private static List<String> f11648a;
private static a f11649b;
private static MyVpnService f11650c;
private static Object f11651d = new Object();
private static Object f11652e = new Object();
private static final int[] f11653f = {R.string.ml_allow_all, R.string.word_allow, R.string.ml_deny_all, R.string.word_deny};
private Thread g = null;
private boolean h = true;
public enum a {
AllowAll,
Allow,
DenyAll,
Deny
}
public static a a() {
return f11649b == null ? a.AllowAll : f11649b;
}
public static List<String> b() {
return f11648a;
}
public static boolean a(Context context, a aVar, List<String> list) {
boolean z;
boolean z2;
boolean z3;
synchronized (f11652e) {
bo.b("MyVpnService", "start: curmode: " + f11649b + " curPkg: " + gs.d(f11648a) + " wantmode: " + aVar + " wantpkgs: " + gs.d(list));
if (aVar != a.AllowAll) {
if (aVar == a.DenyAll) {
if (!a.DenyAll.equals(f11649b)) {
z = true;
z2 = true;
if (z && !z2) {
a(context);
if (!a(context, false)) {
bo.d("MyVpnService", "vpn service still running after shutdown");
z3 = false;
if (z3) {
f11649b = aVar;
f11648a = list;
if (z2) {
bo.b("MyVpnService", "start: have instance: " + g());
if (g()) {
f11650c.c();
} else {
context.startService(new Intent(context, (Class<?>) MyVpnService.class));
if (!a(context, true)) {
bo.d("MyVpnService", "vpn service failed to start");
h();
z3 = false;
}
}
}
}
}
}
z3 = true;
if (z3) {
}
}
z = false;
} else {
if (f11649b == aVar) {
if (!gs.a(list, f11648a)) {
}
z = false;
}
z = true;
z2 = true;
if (z) {
a(context);
if (!a(context, false)) {
}
}
z3 = true;
if (z3) {
}
}
}
z = true;
z2 = false;
if (z) {
}
z3 = true;
if (z3) {
}
}
return z3;
}
private static boolean g() {
boolean z;
synchronized (f11651d) {
z = f11650c != null;
}
return z;
}
private static void b(MyVpnService myVpnService) {
synchronized (f11651d) {
f11650c = myVpnService;
}
}
private static boolean a(Context context, boolean z) {
long currentTimeMillis = System.currentTimeMillis();
while (System.currentTimeMillis() - currentTimeMillis < 8000 && z != g()) {
bo.b("MyVpnService", "wait for instance start/stop " + z);
try {
Thread.sleep(50L);
} catch (InterruptedException unused) {
}
}
return z == g();
}
public static void a(Context context) {
synchronized (f11652e) {
synchronized (f11651d) {
if (f11650c != null) {
f11650c.d();
}
}
}
}
private static void h() {
f11648a = null;
f11649b = null;
}
public static String[] a(Resources resources) {
return ct.a(resources, f11653f);
}
public static boolean a(int i) {
return i == a.AllowAll.ordinal() || i == a.DenyAll.ordinal();
}
public void c() {
this.h = true;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
b(this);
i();
j();
return 1;
}
@Override
public void onRevoke() {
d();
}
public void d() {
i();
stopSelf();
h();
}
@Override
public void onDestroy() {
i();
super.onDestroy();
b(null);
}
private void i() {
if (this.g != null) {
this.g.interrupt();
this.g = null;
}
}
private void j() {
this.g = new Thread(new Runnable() {
@Override
public void run() {
ParcelFileDescriptor parcelFileDescriptor;
FileInputStream fileInputStream;
ParcelFileDescriptor parcelFileDescriptor2;
FileInputStream fileInputStream2 = null;
fileInputStream2 = null;
ParcelFileDescriptor parcelFileDescriptor3 = null;
try {
byte[] bArr = new byte[32767];
parcelFileDescriptor = null;
ParcelFileDescriptor parcelFileDescriptor4 = null;
while (true) {
try {
if (fileInputStream2 != null) {
try {
if (fileInputStream2.read(bArr) > 0) {
}
} catch (Exception e2) {
e = e2;
fileInputStream = fileInputStream2;
parcelFileDescriptor3 = parcelFileDescriptor4;
try {
e.printStackTrace();
MyVpnService.this.a(parcelFileDescriptor3);
gs.a((InputStream) fileInputStream);
MyVpnService.this.a(parcelFileDescriptor);
return;
} catch (Throwable th) {
th = th;
parcelFileDescriptor2 = parcelFileDescriptor;
parcelFileDescriptor = parcelFileDescriptor3;
fileInputStream2 = fileInputStream;
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
throw th;
}
} catch (Throwable th2) {
th = th2;
ParcelFileDescriptor parcelFileDescriptor5 = parcelFileDescriptor4;
parcelFileDescriptor2 = parcelFileDescriptor;
parcelFileDescriptor = parcelFileDescriptor5;
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
throw th;
}
}
Thread.sleep(2000L);
} catch (InterruptedException unused) {
bo.b("MyVpnService", "thread interrupt");
ParcelFileDescriptor parcelFileDescriptor6 = parcelFileDescriptor4;
parcelFileDescriptor2 = parcelFileDescriptor;
parcelFileDescriptor = parcelFileDescriptor6;
}
if (MyVpnService.this.h) {
MyVpnService.this.h = false;
gs.a((InputStream) fileInputStream2);
try {
parcelFileDescriptor2 = MyVpnService.this.a(MyVpnService.f11649b, (List<String>) MyVpnService.f11648a).establish();
if (parcelFileDescriptor2 == null) {
break;
}
try {
fileInputStream = new FileInputStream(parcelFileDescriptor2.getFileDescriptor());
try {
MyVpnService.this.a(parcelFileDescriptor);
fileInputStream2 = fileInputStream;
parcelFileDescriptor4 = parcelFileDescriptor;
parcelFileDescriptor = parcelFileDescriptor2;
} catch (Exception e3) {
e = e3;
parcelFileDescriptor3 = parcelFileDescriptor;
parcelFileDescriptor = parcelFileDescriptor2;
e.printStackTrace();
MyVpnService.this.a(parcelFileDescriptor3);
gs.a((InputStream) fileInputStream);
MyVpnService.this.a(parcelFileDescriptor);
return;
} catch (Throwable th3) {
th = th3;
fileInputStream2 = fileInputStream;
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
throw th;
}
} catch (Exception e4) {
e = e4;
fileInputStream = fileInputStream2;
} catch (Throwable th4) {
th = th4;
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
throw th;
}
} catch (Exception e5) {
e = e5;
fileInputStream = fileInputStream2;
parcelFileDescriptor3 = parcelFileDescriptor;
} catch (Throwable th5) {
th = th5;
parcelFileDescriptor2 = parcelFileDescriptor;
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
throw th;
}
}
}
bo.d("MyVpnService", "failed to create interface");
MyVpnService.this.a(parcelFileDescriptor);
gs.a((InputStream) fileInputStream2);
MyVpnService.this.a(parcelFileDescriptor2);
} catch (Exception e6) {
e = e6;
parcelFileDescriptor = null;
fileInputStream = null;
} catch (Throwable th6) {
th = th6;
parcelFileDescriptor = null;
}
}
}, "MyVpnService.runnable");
this.g.start();
}
public void a(ParcelFileDescriptor parcelFileDescriptor) {
if (parcelFileDescriptor != null) {
try {
parcelFileDescriptor.close();
} catch (Exception e2) {
bo.b("MyVpnService", "closeInterface", e2);
}
}
}
public VpnService.Builder a(a aVar, List<String> list) {
VpnService.Builder builder = new VpnService.Builder(this);
builder.setSession("NetAccessService").addAddress("192.168.0.1", 24).addDnsServer("8.8.8.8").addRoute("0.0.0.0", 0).addRoute("::", 0).addAddress("fde4:8dba:82e1:ffff::1", 64);
if (list != null) {
if (bw.ay.b()) {
for (String str : list) {
if (aVar == a.Allow) {
bw.ay.b(builder, str);
} else if (aVar == a.Deny) {
bw.ay.a(builder, str);
}
}
} else {
bo.d("MyVpnService", "app specification not supported");
}
}
return builder;
}
}