酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

以下内容为反编译后的 g.java 源代码,内容仅作参考


package com.kugou.common.privacy;

import android.text.TextUtils;
import android.util.Log;
import c.c.u;
import c.t;
import com.google.gson.Gson;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.network.v;
import com.kugou.common.network.w;
import com.kugou.common.utils.as;
import com.tencent.stat.DeviceInfo;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Map;
import org.apache.commons.codec.net.StringEncodings;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class g {

    public interface a {
        void a(d dVar);
    }

    public interface b {
        @c.c.f
        rx.e<i> a(@u Map<String, String> map);
    }

    public static g a() {
        return new g();
    }

    public void b() {
        if (d()) {
            if (as.f54365e) {
                as.f("PrivacyUpdateManager", "cache already exist. not need to request");
                return;
            }
            return;
        }
        ((b) new t.a().b("Privacy").a(c.b.a.a.a()).a(c.a.a.i.a()).a(w.a(com.kugou.android.app.a.a.IU, "https://youth.kugou.com/api/policy/v1/info")).a().b().a(b.class)).a(v.a().a("appid").c("clientver").o("plat").a(DeviceInfo.TAG_VERSION, String.valueOf(f.a().b())).f(new String[0]).e(new String[0]).m(new String[0]).c().b()).b(Schedulers.io()).a(new rx.b.b<i>() {
            @Override
            public void call(i iVar) {
                if (iVar == null || iVar.f51252a != 1 || iVar.f51253b == null || iVar.f51253b.f51254a == null) {
                    if (iVar == null) {
                        if (as.f54365e) {
                            as.b("PrivacyUpdateManager", "response body is null");
                            return;
                        }
                        return;
                    } else if (iVar.f51253b == null) {
                        if (as.f54365e) {
                            as.b("PrivacyUpdateManager", "response data is null");
                            return;
                        }
                        return;
                    } else if (iVar.f51252a != 1) {
                        if (as.f54365e) {
                            as.b("PrivacyUpdateManager", "status is not 1");
                            return;
                        }
                        return;
                    } else {
                        if (as.f54365e) {
                            as.b("PrivacyUpdateManager", "privacy info is null");
                            return;
                        }
                        return;
                    }
                }
                try {
                    if (iVar.f51253b.f51254a.a() > f.a().b()) {
                        d dVar = iVar.f51253b.f51254a;
                        if (dVar != null) {
                            String d2 = dVar.d();
                            String e2 = dVar.e();
                            if (!TextUtils.isEmpty(d2) && d2.contains("酷狗概念版")) {
                                dVar.a(d2.replace("酷狗概念版", "酷狗概念版"));
                            }
                            if (!TextUtils.isEmpty(e2) && e2.contains("酷狗概念版")) {
                                dVar.b(e2.replace("酷狗概念版", "酷狗概念版"));
                            }
                        }
                        g.this.a(iVar.f51253b.f51254a);
                        return;
                    }
                    if (as.f54365e) {
                        as.f("PrivacyUpdateManager", "server version less or equal than agreed version");
                    }
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
            }
        }, new rx.b.b<Throwable>() {
            @Override
            public void call(Throwable th) {
                if (as.f54365e) {
                    as.f("PrivacyUpdateManager", Log.getStackTraceString(th));
                }
            }
        });
    }

    public void a(final a aVar) {
        rx.e.a("privacy_info_cache.json").d(new rx.b.e<String, d>() {
            @Override
            public d call(String str) {
                d dVar;
                try {
                    if (!g.this.d()) {
                        return null;
                    }
                    synchronized (g.class) {
                        dVar = (d) new Gson().fromJson((Reader) new InputStreamReader(KGCommonApplication.getContext().openFileInput(str), Charset.forName(StringEncodings.UTF8)), d.class);
                    }
                    return dVar;
                } catch (FileNotFoundException e2) {
                    e2.printStackTrace();
                    return null;
                } catch (Exception e3) {
                    e3.printStackTrace();
                    g.this.c();
                    return null;
                }
            }
        }).b(Schedulers.io()).a(AndroidSchedulers.mainThread()).a((rx.b.b) new rx.b.b<d>() {
            @Override
            public void call(d dVar) {
                if (as.f54365e) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("read from privacy info cache file: ");
                    sb.append(dVar == null ? "null" : dVar.toString());
                    as.f("PrivacyUpdateManager", sb.toString());
                }
                aVar.a(dVar);
            }
        }, new rx.b.b<Throwable>() {
            @Override
            public void call(Throwable th) {
                if (as.f54365e) {
                    as.f("PrivacyUpdateManager", Log.getStackTraceString(th));
                }
            }
        });
    }

    public synchronized void a(d dVar) throws IOException {
        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = KGCommonApplication.getContext().openFileOutput("privacy_info_cache.json", 0);
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream, Charset.forName(StringEncodings.UTF8)));
            String json = new Gson().toJson(dVar);
            if (as.f54365e) {
                as.f("PrivacyUpdateManager", "save privacy info to cache: " + json);
            }
            bufferedWriter.write(json);
            bufferedWriter.flush();
        } finally {
            if (fileOutputStream != null) {
                fileOutputStream.close();
            }
        }
    }

    public boolean d() {
        File fileStreamPath = KGCommonApplication.getContext().getFileStreamPath("privacy_info_cache.json");
        return fileStreamPath != null && fileStreamPath.exists();
    }

    public synchronized void c() {
        if (as.f54365e) {
            as.f("PrivacyUpdateManager", "delete privacy info cache.");
        }
        File fileStreamPath = KGCommonApplication.getContext().getFileStreamPath("privacy_info_cache.json");
        if (fileStreamPath.exists()) {
            fileStreamPath.delete();
        }
    }
}