NetGuard v2.328版本的 MD5 值为:4adaa6f0accf8a6a5ab62c36e5a5d3f8
以下内容为反编译后的 AdapterLog.java 源代码,内容仅作参考
package eu.faircode.netguard;
import B.b;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.view.C0137e0;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.List;
public class AdapterLog extends CursorAdapter {
private static String TAG = "NetGuard.Log";
private int colAllowed;
private int colConnection;
private int colDAddr;
private int colDName;
private int colDPort;
private int colData;
private int colFlags;
private int colInteractive;
private int colProtocol;
private int colSAddr;
private int colSPort;
private int colTime;
private int colUid;
private int colVersion;
private int colorOff;
private int colorOn;
private InetAddress dns1;
private InetAddress dns2;
private int iconSize;
private boolean organization;
private boolean resolve;
private InetAddress vpn4;
private InetAddress vpn6;
public AdapterLog(Context context, Cursor cursor, boolean z2, boolean z3) {
super(context, cursor, 0);
this.dns1 = null;
this.dns2 = null;
this.vpn4 = null;
this.vpn6 = null;
this.resolve = z2;
this.organization = z3;
this.colTime = cursor.getColumnIndex("time");
this.colVersion = cursor.getColumnIndex("version");
this.colProtocol = cursor.getColumnIndex("protocol");
this.colFlags = cursor.getColumnIndex("flags");
this.colSAddr = cursor.getColumnIndex("saddr");
this.colSPort = cursor.getColumnIndex("sport");
this.colDAddr = cursor.getColumnIndex("daddr");
this.colDPort = cursor.getColumnIndex("dport");
this.colDName = cursor.getColumnIndex("dname");
this.colUid = cursor.getColumnIndex("uid");
this.colData = cursor.getColumnIndex("data");
this.colAllowed = cursor.getColumnIndex("allowed");
this.colConnection = cursor.getColumnIndex("connection");
this.colInteractive = cursor.getColumnIndex("interactive");
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorOn, typedValue, true);
this.colorOn = typedValue.data;
context.getTheme().resolveAttribute(R.attr.colorOff, typedValue, true);
this.colorOff = typedValue.data;
this.iconSize = Util.dips2pixels(24, context);
try {
List dns = ServiceSinkhole.getDns(context);
this.dns1 = dns.size() > 0 ? (InetAddress) dns.get(0) : null;
this.dns2 = dns.size() > 1 ? (InetAddress) dns.get(1) : null;
SharedPreferences f = b.f(context);
this.vpn4 = InetAddress.getByName(f.getString("vpn4", "10.1.10.1"));
this.vpn6 = InetAddress.getByName(f.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1"));
} catch (UnknownHostException e2) {
String str = TAG;
Log.e(str, e2.toString() + "\n" + Log.getStackTraceString(e2));
}
}
private String getKnownAddress(String str) {
try {
InetAddress byName = InetAddress.getByName(str);
if (byName.equals(this.dns1)) {
return "dns1";
}
if (byName.equals(this.dns2)) {
return "dns2";
}
if (!byName.equals(this.vpn4)) {
if (!byName.equals(this.vpn6)) {
return str;
}
}
return "vpn";
} catch (UnknownHostException unused) {
return str;
}
}
private String getKnownPort(int i2) {
return i2 != 7 ? i2 != 25 ? i2 != 53 ? i2 != 80 ? i2 != 110 ? i2 != 143 ? i2 != 443 ? i2 != 465 ? i2 != 993 ? i2 != 995 ? Integer.toString(i2) : "pop3s" : "imaps" : "smtps" : "https" : "imap" : "pop3" : "http" : "dns" : "smtp" : "echo";
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
int i2;
String str;
int i3;
String str2;
AdapterLog adapterLog;
ApplicationInfo applicationInfo;
boolean z2;
int i4;
String str3;
long j2 = cursor.getLong(this.colTime);
int i5 = cursor.isNull(this.colVersion) ? -1 : cursor.getInt(this.colVersion);
int i6 = cursor.isNull(this.colProtocol) ? -1 : cursor.getInt(this.colProtocol);
String string = cursor.getString(this.colFlags);
String string2 = cursor.getString(this.colSAddr);
int i7 = cursor.isNull(this.colSPort) ? -1 : cursor.getInt(this.colSPort);
String string3 = cursor.getString(this.colDAddr);
int i8 = cursor.isNull(this.colDPort) ? -1 : cursor.getInt(this.colDPort);
String string4 = cursor.isNull(this.colDName) ? null : cursor.getString(this.colDName);
int i9 = cursor.isNull(this.colUid) ? -1 : cursor.getInt(this.colUid);
String string5 = cursor.getString(this.colData);
if (cursor.isNull(this.colAllowed)) {
str = string5;
i2 = -1;
} else {
i2 = cursor.getInt(this.colAllowed);
str = string5;
}
if (cursor.isNull(this.colConnection)) {
str2 = string4;
i3 = -1;
} else {
i3 = cursor.getInt(this.colConnection);
str2 = string4;
}
int i10 = cursor.isNull(this.colInteractive) ? -1 : cursor.getInt(this.colInteractive);
TextView textView = (TextView) view.findViewById(R.id.tvProtocol);
TextView textView2 = (TextView) view.findViewById(R.id.tvFlags);
int i11 = i9;
TextView textView3 = (TextView) view.findViewById(R.id.tvSAddr);
TextView textView4 = (TextView) view.findViewById(R.id.tvSPort);
final TextView textView5 = (TextView) view.findViewById(R.id.tvDAddr);
TextView textView6 = (TextView) view.findViewById(R.id.tvDPort);
final TextView textView7 = (TextView) view.findViewById(R.id.tvOrganization);
ImageView imageView = (ImageView) view.findViewById(R.id.ivIcon);
TextView textView8 = (TextView) view.findViewById(R.id.tvUid);
TextView textView9 = (TextView) view.findViewById(R.id.tvData);
ImageView imageView2 = (ImageView) view.findViewById(R.id.ivConnection);
int i12 = i8;
ImageView imageView3 = (ImageView) view.findViewById(R.id.ivInteractive);
((TextView) view.findViewById(R.id.tvTime)).setText(new SimpleDateFormat("HH:mm:ss").format(Long.valueOf(j2)));
if (i3 <= 0) {
imageView2.setImageResource(i2 > 0 ? R.drawable.host_allowed : R.drawable.host_blocked);
} else if (i2 > 0) {
imageView2.setImageResource(i3 == 1 ? R.drawable.wifi_on : R.drawable.other_on);
} else {
imageView2.setImageResource(i3 == 1 ? R.drawable.wifi_off : R.drawable.other_off);
}
if (i10 <= 0) {
imageView3.setImageDrawable(null);
} else {
imageView3.setImageResource(R.drawable.screen_on);
}
textView.setText(Util.getProtocolName(i6, i5, false));
textView2.setText(string);
textView2.setVisibility(TextUtils.isEmpty(string) ? 8 : 0);
if (i6 == 6 || i6 == 17) {
adapterLog = this;
textView4.setText(i7 < 0 ? "" : adapterLog.getKnownPort(i7));
textView6.setText(i12 < 0 ? "" : adapterLog.getKnownPort(i12));
} else {
textView4.setText(i7 < 0 ? "" : Integer.toString(i7));
textView6.setText(i12 < 0 ? "" : Integer.toString(i12));
adapterLog = this;
}
PackageManager packageManager = context.getPackageManager();
String[] packagesForUid = packageManager.getPackagesForUid(i11);
if (packagesForUid != null && packagesForUid.length > 0) {
try {
applicationInfo = packageManager.getApplicationInfo(packagesForUid[0], 0);
} catch (PackageManager.NameNotFoundException unused) {
}
if (applicationInfo != null) {
imageView.setImageDrawable(null);
} else if (applicationInfo.icon <= 0) {
imageView.setImageResource(17301651);
} else {
GlideRequest load = GlideApp.with(context).load(Uri.parse("android.resource://" + applicationInfo.packageName + "/" + applicationInfo.icon));
int i13 = adapterLog.iconSize;
load.override(i13, i13).into(imageView);
}
z2 = Process.myUid() == i11;
i4 = i11 % 100000;
if (i4 != -1) {
textView8.setText("");
} else if (i4 == 0) {
textView8.setText(context.getString(R.string.title_root));
} else if (i4 == 9999) {
textView8.setText("-");
} else {
textView8.setText(Integer.toString(i4));
}
textView3.setText(adapterLog.getKnownAddress(string2));
if (z2 && adapterLog.resolve) {
str3 = string3;
if (!adapterLog.isKnownAddress(str3)) {
if (str2 == null) {
textView5.setText(str3);
new AsyncTask() {
@Override
public String doInBackground(String... strArr) {
try {
return InetAddress.getByName(strArr[0]).getHostName();
} catch (UnknownHostException unused2) {
return strArr[0];
}
}
@Override
public void onPostExecute(String str4) {
TextView textView10 = textView5;
textView10.setText(">" + str4);
C0137e0.S(textView5, false);
}
@Override
protected void onPreExecute() {
C0137e0.S(textView5, true);
}
}.execute(str3);
} else {
textView5.setText(str2);
}
textView7.setVisibility(8);
if (!z2 && adapterLog.organization && !adapterLog.isKnownAddress(str3)) {
new AsyncTask() {
@Override
public String doInBackground(String... strArr) {
try {
return Util.getOrganization(strArr[0]);
} catch (Throwable th) {
String str4 = AdapterLog.TAG;
Log.w(str4, th.toString() + "\n" + Log.getStackTraceString(th));
return null;
}
}
@Override
public void onPostExecute(String str4) {
if (str4 != null) {
textView7.setText(str4);
textView7.setVisibility(0);
}
C0137e0.S(textView7, false);
}
@Override
protected void onPreExecute() {
C0137e0.S(textView7, true);
}
}.execute(str3);
}
if (TextUtils.isEmpty(str)) {
textView9.setText("");
textView9.setVisibility(8);
return;
}
textView9.setText(str);
textView9.setVisibility(0);
return;
}
} else {
str3 = string3;
}
textView5.setText(adapterLog.getKnownAddress(str3));
textView7.setVisibility(8);
if (!z2) {
new AsyncTask() {
@Override
public String doInBackground(String... strArr) {
try {
return Util.getOrganization(strArr[0]);
} catch (Throwable th) {
String str4 = AdapterLog.TAG;
Log.w(str4, th.toString() + "\n" + Log.getStackTraceString(th));
return null;
}
}
@Override
public void onPostExecute(String str4) {
if (str4 != null) {
textView7.setText(str4);
textView7.setVisibility(0);
}
C0137e0.S(textView7, false);
}
@Override
protected void onPreExecute() {
C0137e0.S(textView7, true);
}
}.execute(str3);
}
if (TextUtils.isEmpty(str)) {
}
}
applicationInfo = null;
if (applicationInfo != null) {
}
if (Process.myUid() == i11) {
}
i4 = i11 % 100000;
if (i4 != -1) {
}
textView3.setText(adapterLog.getKnownAddress(string2));
if (z2) {
}
str3 = string3;
textView5.setText(adapterLog.getKnownAddress(str3));
textView7.setVisibility(8);
if (!z2) {
}
if (TextUtils.isEmpty(str)) {
}
}
public boolean isKnownAddress(String str) {
try {
InetAddress byName = InetAddress.getByName(str);
if (!byName.equals(this.dns1) && !byName.equals(this.dns2) && !byName.equals(this.vpn4)) {
}
return true;
} catch (UnknownHostException unused) {
}
return false;
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
return LayoutInflater.from(context).inflate(R.layout.log, viewGroup, false);
}
public void setOrganization(boolean z2) {
this.organization = z2;
}
public void setResolve(boolean z2) {
this.resolve = z2;
}
}