package com.tencent.mm.plugin.fav.b.e;

import android.database.Cursor;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.al.f;
import com.tencent.mm.kernel.g;
import com.tencent.mm.network.n.a;
import com.tencent.mm.plugin.fav.a.ae;
import com.tencent.mm.plugin.fav.a.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.at;
import com.tencent.ytcommon.BuildConfig;

class a$1 extends a {
    final /* synthetic */ a mgY;

    a$1(a aVar) {
        this.mgY = aVar;
    }

    public final void gl(int i) {
        AppMethodBeat.i(5325);
        try {
            boolean isWifi = at.isWifi(ah.getContext());
            ab.i("MicroMsg.Fav.FavCdnService", "onNetworkChange st:%d isWifi:%B, lastIsWifi:%B", new Object[]{Integer.valueOf(i), Boolean.valueOf(isWifi), Boolean.valueOf(this.mgY.mgU)});
            if (i == 4 || i == 6) {
                a aVar;
                if (this.mgY.mgU && !isWifi) {
                    c cVar;
                    aVar = this.mgY;
                    ab.i("MicroMsg.Fav.FavCdnService", "pauseAll");
                    Cursor buN = ((ae) g.M(ae.class)).getFavCdnStorage().buN();
                    if (buN != null && buN.moveToFirst()) {
                        while (buN.moveToNext()) {
                            cVar = new c();
                            cVar.d(buN);
                            ab.i("MicroMsg.Fav.FavCdnService", "pauseAll, pauseUpload dataId:%s", new Object[]{cVar.field_dataId});
                            cVar.field_status = 4;
                            ((ae) g.M(ae.class)).getFavCdnStorage().a(cVar, new String[]{"dataId"});
                            f.afx().rN(cVar.field_dataId);
                            a.g(((ae) g.M(ae.class)).getFavCdnStorage().LR(cVar.field_dataId));
                            aVar.LW(cVar.field_dataId);
                        }
                        buN.close();
                    }
                    buN = ((ae) g.M(ae.class)).getFavCdnStorage().buO();
                    if (buN != null && buN.moveToFirst()) {
                        while (buN.moveToNext()) {
                            cVar = new c();
                            cVar.d(buN);
                            ab.i("MicroMsg.Fav.FavCdnService", "pauseAll, pauseDownload dataId:%s", new Object[]{cVar.field_dataId});
                            cVar.field_status = 4;
                            ((ae) g.M(ae.class)).getFavCdnStorage().a(cVar, new String[]{"dataId"});
                            f.afx().rO(cVar.field_dataId);
                            a.g(((ae) g.M(ae.class)).getFavCdnStorage().LR(cVar.field_dataId));
                            aVar.LW(cVar.field_dataId);
                        }
                    }
                    if (buN != null) {
                        buN.close();
                    }
                }
                if (!this.mgY.mgU && isWifi) {
                    aVar = this.mgY;
                    ab.i("MicroMsg.Fav.FavCdnService", "startAll");
                    ((ae) g.M(ae.class)).getFavCdnStorage().buL();
                    aVar.run();
                }
                this.mgY.mgU = isWifi;
                AppMethodBeat.o(5325);
                return;
            }
            this.mgY.mgU = isWifi;
            AppMethodBeat.o(5325);
        } catch (Exception e) {
            ab.printErrStackTrace("MicroMsg.Fav.FavCdnService", e, BuildConfig.FLAVOR, new Object[0]);
            AppMethodBeat.o(5325);
        }
    }
}
