导航菜单

页面标题

页面副标题

Aptoide v9.22.5.3 - UserAgentInterceptor.java 源代码

正在查看: Aptoide v9.22.5.3 应用的 UserAgentInterceptor.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package cm.aptoide.pt.networking;

import android.os.Build;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import cm.aptoide.pt.BuildConfig;
import cm.aptoide.pt.crashreports.CrashReport;
import cm.aptoide.pt.preferences.AptoideMd5Manager;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class UserAgentInterceptor implements Interceptor {
    private final AptoideMd5Manager aptoideMd5Manager;
    private final DisplayMetrics displayMetrics;
    private final IdsRepository idsRepository;

    public UserAgentInterceptor(IdsRepository idsRepository, DisplayMetrics displayMetrics, AptoideMd5Manager aptoideMd5Manager) {
        this.idsRepository = idsRepository;
        this.displayMetrics = displayMetrics;
        this.aptoideMd5Manager = aptoideMd5Manager;
    }

    private String getDefaultUserAgent() {
        return "Aptoide/9.22.5.3 (Linux; Android " + Build.VERSION.RELEASE + "; " + Build.VERSION.SDK_INT + "; " + Build.MODEL + " Build/" + Build.PRODUCT + "; " + System.getProperty("os.arch") + "; cm.aptoide.pt; " + BuildConfig.VERSION_CODE + "; " + this.aptoideMd5Manager.getAptoideMd5() + "; " + (this.displayMetrics.widthPixels + "x" + this.displayMetrics.heightPixels) + ";" + ((String) this.idsRepository.getUniqueIdentifier().y().b()) + ")";
    }

    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        String str;
        Request request = chain.request();
        try {
            str = getDefaultUserAgent();
        } catch (Exception e2) {
            CrashReport.getInstance().log(e2);
            str = null;
        }
        try {
            return !TextUtils.isEmpty(str) ? chain.proceed(request.newBuilder().header("User-Agent", str).build()) : chain.proceed(request);
        } catch (IOException e3) {
            CrashReport.getInstance().log(e3);
            throw e3;
        }
    }
}