Fing.apk(点击下载) / TracerouteActivity.java


package com.overlook.android.fing.ui.mobiletools.traceroute;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.overlook.android.fing.R;
import com.overlook.android.fing.engine.j.g.c;
import com.overlook.android.fing.engine.j.l.b;
import com.overlook.android.fing.engine.l.u;
import com.overlook.android.fing.engine.l.z;
import com.overlook.android.fing.engine.model.net.GeoIpInfo;
import com.overlook.android.fing.engine.model.net.HardwareAddress;
import com.overlook.android.fing.engine.model.net.IpAddress;
import com.overlook.android.fing.engine.model.net.Node;
import com.overlook.android.fing.engine.model.net.t;
import com.overlook.android.fing.ui.base.ServiceActivity;
import com.overlook.android.fing.ui.misc.g;
import com.overlook.android.fing.ui.mobiletools.ping.PingActivity;
import com.overlook.android.fing.ui.mobiletools.servicescan.ServiceScanActivity;
import com.overlook.android.fing.ui.service.FingAppService;
import com.overlook.android.fing.vl.components.CircularProgressIndicator;
import com.overlook.android.fing.vl.components.MeasurementCompact;
import com.overlook.android.fing.vl.components.Pill;
import com.overlook.android.fing.vl.components.SummaryEvent;
import com.overlook.android.fing.vl.components.h1;
import e.f.a.a.b.h.d;
import e.f.a.a.b.h.m;
import e.f.a.a.b.j.j;
import java.util.ArrayList;
import java.util.List;

public class TracerouteActivity extends ServiceActivity implements b.AbstractC0151b, c.a {
    private CircularProgressIndicator A;
    private MeasurementCompact B;
    private MeasurementCompact C;
    private LinearLayoutManager D;
    private RecyclerView E;
    private a F;
    private Node o;
    private c p;
    private b q;
    private b.d t;
    private g u;
    private IpAddress v;
    private String w;
    private Menu x;
    private MenuItem y;
    private MenuItem z;

    /* access modifiers changed from: private */
    public class a extends RecyclerView.e<h1<View>> {
        a(k kVar) {
        }

        @Override // androidx.recyclerview.widget.RecyclerView.e
        public int e() {
            if (TracerouteActivity.this.t == null || TracerouteActivity.this.t.f15254e == null) {
                return 0;
            }
            return TracerouteActivity.this.t.f15254e.size();
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$x, int] */
        @Override // androidx.recyclerview.widget.RecyclerView.e
        @SuppressLint({"DefaultLocale"})
        public void q(h1<View> h1Var, int i2) {
            String str;
            Pill pill;
            int i3;
            GeoIpInfo geoIpInfo;
            String str2;
            IpAddress ipAddress;
            h1<View> h1Var2 = h1Var;
            if (TracerouteActivity.this.t.f15254e != null) {
                b.c cVar = TracerouteActivity.this.t.f15254e.get(i2);
                Resources resources = TracerouteActivity.this.getResources();
                int dimensionPixelSize = resources.getDimensionPixelSize(R.dimen.spacing_mini);
                int dimensionPixelSize2 = resources.getDimensionPixelSize(R.dimen.spacing_small);
                SummaryEvent summaryEvent = (SummaryEvent) h1Var2.f1428a.findViewById(R.id.summary);
                Pill pill2 = (Pill) h1Var2.f1428a.findViewById(R.id.hop);
                Pill pill3 = (Pill) h1Var2.f1428a.findViewById(R.id.country);
                summaryEvent.w(0.0f);
                summaryEvent.setPaddingRelative(dimensionPixelSize2, i2 == 0 ? dimensionPixelSize2 : dimensionPixelSize, dimensionPixelSize, dimensionPixelSize2);
                summaryEvent.G(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.text100));
                summaryEvent.J(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.text80));
                boolean z = !cVar.b.isEmpty() && !cVar.b.contains(null);
                boolean z2 = !TextUtils.isEmpty(cVar.f15249c);
                boolean z3 = z && cVar.f15250d == TracerouteActivity.this.t.f15252c.O();
                boolean z4 = z && TracerouteActivity.this.t.f15251a == b.a.READY;
                String str3 = "*";
                String obj = (!z || (ipAddress = cVar.f15250d) == null) ? str3 : ipAddress.toString();
                if (!z) {
                    str = str3;
                } else {
                    str = z2 ? cVar.f15249c : "-";
                }
                if (z) {
                    TracerouteActivity tracerouteActivity = TracerouteActivity.this;
                    Object[] objArr = new Object[1];
                    int i4 = 0;
                    int i5 = 0;
                    for (Integer num : cVar.b) {
                        if (num != null) {
                            i4 = num.intValue() + i4;
                            i5++;
                        }
                    }
                    String valueOf = String.valueOf(i4 / i5);
                    pill = pill3;
                    i3 = 0;
                    objArr[0] = valueOf;
                    str3 = tracerouteActivity.getString(R.string.generic_pingvalue, objArr);
                } else {
                    pill = pill3;
                    i3 = 0;
                }
                int i6 = R.color.green100;
                if (z3) {
                    summaryEvent.x(i3);
                    summaryEvent.y(BitmapFactory.decodeResource(resources, R.drawable.important_16));
                    summaryEvent.B(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.green100));
                    summaryEvent.C(i3);
                    geoIpInfo = null;
                } else {
                    Context context = TracerouteActivity.this.getContext();
                    if (!z) {
                        i6 = R.color.yellow100;
                    }
                    summaryEvent.x(androidx.core.content.a.b(context, i6));
                    geoIpInfo = null;
                    summaryEvent.y(null);
                    summaryEvent.C(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.grey20));
                }
                summaryEvent.F(obj);
                summaryEvent.I(str);
                summaryEvent.E(str3);
                summaryEvent.setOnClickListener(new g(this, z4, i2, z2));
                pill2.D(TracerouteActivity.this.getString(R.string.traceroute_hopnum, new Object[]{String.valueOf(i2 + 1)}));
                GeoIpInfo a2 = (cVar.f15250d == null || TracerouteActivity.this.p == null) ? geoIpInfo : TracerouteActivity.this.p.a(cVar.f15250d);
                if (a2 == null || (a2.y() == null && a2.A() == null)) {
                    pill.setVisibility(8);
                    return;
                }
                if (e.f.a.a.c.b.b.i()) {
                    str2 = z.c(a2.x(), a2.B(), a2.y(), true);
                } else {
                    str2 = u.b(a2.y());
                }
                if (TextUtils.isEmpty(str2)) {
                    str2 = a2.A();
                }
                if (TextUtils.isEmpty(str2)) {
                    str2 = a2.y();
                }
                pill.D(str2);
                String lowerCase = a2.y() != null ? a2.y().toLowerCase() : geoIpInfo;
                if (lowerCase != null) {
                    d u = d.u(TracerouteActivity.this.getContext());
                    u.r(String.format("https://cdn.fing.io/images/flags/1x1/%s.png", lowerCase));
                    u.j(R.drawable.website_24);
                    u.k(new m(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.text80)));
                    u.i(new f(this, pill));
                    u.a();
                } else {
                    pill.w(R.drawable.website_24);
                    pill.y(androidx.core.content.a.b(TracerouteActivity.this.getContext(), R.color.text80));
                }
                pill.setVisibility(0);
            }
        }

        /* Return type fixed from 'androidx.recyclerview.widget.RecyclerView$x' to match base method */
        @Override // androidx.recyclerview.widget.RecyclerView.e
        public h1<View> r(ViewGroup viewGroup, int i2) {
            View inflate = LayoutInflater.from(TracerouteActivity.this.getContext()).inflate(R.layout.layout_traceroute_item, (ViewGroup) null);
            inflate.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
            e.f.a.a.c.b.b.c(TracerouteActivity.this.getContext(), inflate);
            return new h1(inflate);
        }
    }

    private void A1(boolean z2) {
        b bVar;
        if (M0() && (bVar = this.q) != null) {
            ((com.overlook.android.fing.engine.j.l.c) bVar).d();
            if (z2) {
                F0().x();
                this.q = null;
            }
        }
    }

    private void B1() {
        if (M0() && K0()) {
            FingAppService F0 = F0();
            if (this.p == null) {
                this.p = F0.i();
            }
            this.p.e(this);
        }
    }

    private void C1() {
        if (M0()) {
            FingAppService F0 = F0();
            if (this.q == null) {
                this.q = F0.m();
            }
            ((com.overlook.android.fing.engine.j.l.c) this.q).i(150);
            this.t = ((com.overlook.android.fing.engine.j.l.c) this.q).a(this);
        }
    }

    private void J1() {
        if (M0() && this.q != null && this.o != null) {
            j.w("Device_Traceroute_Start");
            ((com.overlook.android.fing.engine.j.l.c) this.q).k(this.o);
        }
    }

    private void K1(boolean z2) {
        if (z2) {
            J1();
            return;
        }
        b bVar = this.q;
        if (bVar != null) {
            this.t = ((com.overlook.android.fing.engine.j.l.c) bVar).f();
            L1(true);
        }
    }

    private void L1(boolean z2) {
        b.d dVar;
        Menu menu;
        b.d dVar2;
        b.a aVar = b.a.READY;
        if (M0() && this.t != null) {
            if (!(!M0() || (menu = this.x) == null || (dVar2 = this.t) == null)) {
                b.a aVar2 = dVar2.f15251a;
                if (aVar2 == aVar) {
                    if (dVar2.f15254e.size() > 0) {
                        this.A.c(1.0f, z2, new a(this));
                    } else {
                        this.A.b(0.0f);
                        onPrepareOptionsMenu(this.x);
                    }
                } else if (aVar2 == b.a.RUNNING) {
                    this.A.c(((float) dVar2.f15253d) / 100.0f, z2, null);
                    onPrepareOptionsMenu(this.x);
                } else {
                    onPrepareOptionsMenu(menu);
                }
            }
            if (M0() && (dVar = this.t) != null) {
                int size = dVar.f15254e.size();
                b.d dVar3 = this.t;
                if (dVar3.f15251a != aVar || dVar3.f15255f || size <= 0) {
                    this.C.s(String.valueOf(size));
                } else {
                    this.C.s(getText(R.string.ping_unreachable));
                }
                this.B.q(e.e.a.a.a.a.z(this.o, this.b));
                this.B.r(androidx.core.content.a.b(this, R.color.text100));
            }
            this.F.i();
        }
    }

    private void z1(boolean z2) {
        c cVar;
        if (M0() && (cVar = this.p) != null) {
            cVar.e(null);
            if (z2) {
                F0().u();
                this.p = null;
            }
        }
    }

    public /* synthetic */ void D1(View view) {
        if (M0()) {
            Node node = new Node(HardwareAddress.b, this.v);
            String str = this.w;
            if (str != null) {
                node.g1(str);
            }
            if (this.v != null) {
                node.i1(t.R0);
            }
            Intent intent = new Intent(this, PingActivity.class);
            intent.putExtra("node", node);
            startActivity(intent);
        }
    }

    public /* synthetic */ void E1(View view) {
        if (M0()) {
            Node node = new Node(HardwareAddress.b, this.v);
            String str = this.w;
            if (str != null) {
                node.g1(str);
            }
            if (this.v != null) {
                node.i1(t.R0);
            }
            Intent intent = new Intent(this, ServiceScanActivity.class);
            intent.putExtra("node_key", node);
            intent.putExtra("LanMode", Boolean.FALSE);
            startActivity(intent);
        }
    }

    public void F1(b.d dVar) {
        b.d dVar2;
        List<b.c> list;
        this.t = dVar;
        if (!(!M0() || !K0() || this.p == null || (dVar2 = this.t) == null || (list = dVar2.f15254e) == null)) {
            for (b.c cVar : list) {
                IpAddress ipAddress = cVar.f15250d;
                if (ipAddress != null) {
                    this.p.d(ipAddress);
                }
            }
        }
        b.d dVar3 = this.t;
        if (dVar3 != null && dVar3.f15251a == b.a.READY && dVar3.f15253d >= 100) {
            e.e.a.a.a.a.I(this);
        }
        int e2 = this.F.e();
        if (e2 > 0) {
            k kVar = new k(this, this);
            kVar.j(e2 - 1);
            this.D.n1(kVar);
        }
        L1(true);
    }

    public /* synthetic */ void G1() {
        if (this.t.f15251a == b.a.READY) {
            this.A.b(0.0f);
            onPrepareOptionsMenu(this.x);
        }
    }

    public /* synthetic */ void H1(View view) {
        onOptionsItemSelected(this.y);
    }

    public /* synthetic */ void I1() {
        this.F.i();
    }

    /* access modifiers changed from: protected */
    @Override // com.overlook.android.fing.ui.base.ServiceActivity
    public void b1(boolean z2) {
        super.b1(z2);
        C1();
        B1();
        K1(z2);
    }

    /* access modifiers changed from: protected */
    @Override // com.overlook.android.fing.ui.base.ServiceActivity
    public void d1() {
        super.d1();
        C1();
        B1();
        K1(false);
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_traceroute);
        this.o = (Node) getIntent().getParcelableExtra("node");
        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
        MeasurementCompact measurementCompact = (MeasurementCompact) findViewById(R.id.target_host);
        this.B = measurementCompact;
        measurementCompact.s(e.e.a.a.a.a.A(this, this.o));
        this.B.q(e.e.a.a.a.a.z(this.o, this.b));
        this.B.r(androidx.core.content.a.b(this, R.color.text100));
        this.C = (MeasurementCompact) findViewById(R.id.hops);
        boolean z2 = true;
        this.D = new LinearLayoutManager(1, false);
        this.F = new a(null);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
        this.E = recyclerView;
        recyclerView.B0(this.F);
        this.E.F0(this.D);
        ArrayList arrayList = new ArrayList();
        arrayList.add(new g.a(R.drawable.ping_24, androidx.core.content.a.b(this, R.color.accent100), getString(R.string.generic_ping), new e(this)));
        arrayList.add(new g.a(R.drawable.tile_unlocked, androidx.core.content.a.b(this, R.color.accent100), getString(R.string.servicescan_title), new j(this)));
        this.u = new g(this, arrayList);
        if (bundle == null) {
            z2 = false;
        }
        t0(false, z2);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        menu.clear();
        getMenuInflater().inflate(R.menu.tool_menu, menu);
        this.y = menu.findItem(R.id.action_stop);
        this.z = menu.findItem(R.id.action_start);
        e.e.a.a.a.a.g0(this, R.string.generic_start, menu.findItem(R.id.action_start));
        CircularProgressIndicator circularProgressIndicator = (CircularProgressIndicator) this.y.getActionView().findViewById(R.id.progress_indicator);
        this.A = circularProgressIndicator;
        circularProgressIndicator.setOnClickListener(new i(this));
        this.A.d(100);
        this.x = menu;
        return super.onCreateOptionsMenu(menu);
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onDestroy() {
        A1(true);
        z1(true);
        super.onDestroy();
    }

    @Override // com.overlook.android.fing.ui.base.BaseActivity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        b bVar;
        if (menuItem.getItemId() == R.id.action_start) {
            if (this.q != null && this.t.f15251a == b.a.READY) {
                j.w("Device_Traceroute_Refresh");
                c cVar = this.p;
                if (cVar != null) {
                    cVar.c();
                }
                J1();
            }
            return true;
        } else if (menuItem.getItemId() != R.id.action_stop) {
            return super.onOptionsItemSelected(menuItem);
        } else {
            if (this.q != null && this.t.f15251a == b.a.RUNNING) {
                j.w("Device_Traceroute_Stop");
                if (M0() && (bVar = this.q) != null) {
                    ((com.overlook.android.fing.engine.j.l.c) bVar).j();
                }
            }
            return true;
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onPause() {
        super.onPause();
        A1(false);
        z1(false);
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
        b.d dVar = this.t;
        boolean z2 = true;
        boolean z3 = dVar != null && dVar.f15251a == b.a.READY;
        if (dVar == null || dVar.f15251a != b.a.RUNNING) {
            z2 = false;
        }
        this.z.setVisible(z3);
        this.y.setVisible(z2);
        return super.onPrepareOptionsMenu(menu);
    }

    @Override // androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onResume() {
        super.onResume();
        j.y(this, "Device_Traceroute");
        L1(false);
    }
}