我要上王者 v1.1版本的 MD5 值为:b7d3566522def961cabeb92cb17f5db9
以下内容为反编译后的 z.java 源代码,内容仅作参考
package com.bytedance.sdk.openadsdk.downloadnew;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils;
import android.widget.Toast;
import com.baidu.mobads.sdk.internal.am;
import com.bytedance.sdk.openadsdk.TTAdManager;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTAppContextHolder;
import com.bytedance.sdk.openadsdk.TTDownloadEventLogger;
import com.bytedance.sdk.openadsdk.downloadnew.core.DialogBuilder;
import com.bytedance.sdk.openadsdk.downloadnew.core.ExitInstallListener;
import com.bytedance.sdk.openadsdk.downloadnew.core.IDialogStatusChangedListener;
import com.bytedance.sdk.openadsdk.downloadnew.core.ITTDownloadAdapter;
import com.bytedance.sdk.openadsdk.downloadnew.core.ITTDownloadVisitor;
import com.bytedance.sdk.openadsdk.downloadnew.core.ITTHttpCallback;
import com.bytedance.sdk.openadsdk.downloadnew.core.ITTPermissionCallback;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadEventModel;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.bytedance.sdk.openadsdk.downloadnew.x;
import com.ss.android.download.api.config.IDownloadButtonClickListener;
import com.ss.android.download.api.config.hz;
import com.ss.android.download.api.config.jl;
import com.ss.android.download.api.config.k;
import com.ss.android.download.api.config.nn;
import com.ss.android.download.api.config.uu;
import com.ss.android.download.api.config.w;
import com.ss.android.download.api.download.DownloadController;
import com.ss.android.download.api.download.DownloadEventConfig;
import com.ss.android.download.api.download.DownloadModel;
import com.ss.android.download.api.model.Cif;
import com.ss.android.downloadlib.addownload.p055if.Cif;
import com.ss.android.downloadlib.addownload.x.r;
import com.ss.android.downloadlib.b;
import com.ss.android.downloadlib.x.vf;
import com.ss.android.socialbase.downloader.depend.IDownloadSettings;
import com.ss.android.socialbase.downloader.depend.IInstallAppHandler;
import com.ss.android.socialbase.downloader.downloader.DownloaderBuilder;
import com.ss.android.socialbase.downloader.exception.BaseException;
import com.ss.android.socialbase.downloader.logger.Logger;
import com.ss.android.socialbase.downloader.model.DownloadInfo;
import com.ss.android.socialbase.downloader.model.HttpHeader;
import com.ss.android.socialbase.downloader.network.IDownloadHttpConnection;
import com.ss.android.socialbase.downloader.network.IDownloadHttpService;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;
public class z {
public static volatile String f77if;
private static Map<Integer, ITTDownloadAdapter.OnEventLogHandler> r;
private static Context tc;
private static final com.ss.android.download.api.download.p052if.Cif w;
public static ITTDownloadVisitor z;
private static final AtomicBoolean j = new AtomicBoolean(false);
public static boolean x = true;
private static boolean r() {
return false;
}
static ITTDownloadVisitor j() {
return tc();
}
static {
try {
f77if = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();
} catch (Throwable unused) {
}
w = new com.ss.android.download.api.download.p052if.Cif() {
@Override
public void mo174if(DownloadModel downloadModel, DownloadController downloadController, DownloadEventConfig downloadEventConfig) {
com.bytedance.sdk.openadsdk.api.z.x("TTDownloadVisitor", "completeListener: onDownloadStart");
}
@Override
public void mo177if(DownloadInfo downloadInfo, String str) {
com.bytedance.sdk.openadsdk.api.z.x("TTDownloadVisitor", "completeListener: onDownloadFinished");
}
@Override
public void x(DownloadInfo downloadInfo, String str) {
com.bytedance.sdk.openadsdk.api.z.x("TTDownloadVisitor", "completeListener: onInstalled");
z.z(str);
}
@Override
public void mo176if(DownloadInfo downloadInfo, BaseException baseException, String str) {
com.bytedance.sdk.openadsdk.api.z.x("TTDownloadVisitor", "completeListener: onDownloadFailed");
}
@Override
public void mo175if(DownloadInfo downloadInfo) {
com.bytedance.sdk.openadsdk.api.z.x("TTDownloadVisitor", "completeListener: onCanceled");
}
};
}
private static ITTDownloadVisitor tc() {
ITTDownloadVisitor iTTDownloadVisitor = z;
if (iTTDownloadVisitor == null) {
TTAdManager adManager = TTAdSdk.getAdManager();
if (adManager == null) {
return null;
}
return (ITTDownloadVisitor) adManager.getExtra(ITTDownloadVisitor.class, com.bytedance.sdk.openadsdk.downloadnew.Cif.m136if(1));
}
return iTTDownloadVisitor;
}
public static void z(String str) {
com.ss.android.downloadad.api.p054if.x m618if;
JSONObject w2;
if (TextUtils.isEmpty(str) || (m618if = r.m612if().m618if(str)) == null || (w2 = m618if.w()) == null || tc() == null) {
return;
}
tc().checkAutoControl(w2, str);
}
public static void m163if(Context context) {
if (context == null) {
context = TTAppContextHolder.getContext();
}
if (context == null) {
return;
}
AtomicBoolean atomicBoolean = j;
if (atomicBoolean.get()) {
return;
}
synchronized (z.class) {
if (!atomicBoolean.get()) {
tc = context.getApplicationContext();
if (tc() != null) {
String initPath = tc().initPath(x);
if (!TextUtils.isEmpty(initPath)) {
f77if = initPath;
}
}
atomicBoolean.set(x(tc));
}
}
}
public static void m164if(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
f77if = str;
}
public static b m158if() {
m163if(getContext());
return b.m655if(getContext());
}
public static boolean m167if(Context context, Uri uri, DownloadModel downloadModel, DownloadEventConfig downloadEventConfig, DownloadController downloadController, IDownloadButtonClickListener iDownloadButtonClickListener) {
return m158if().tc().mo368if(context, uri, downloadModel, downloadEventConfig, downloadController, iDownloadButtonClickListener);
}
public static boolean m166if(Context context, Uri uri, DownloadModel downloadModel, DownloadEventConfig downloadEventConfig, DownloadController downloadController) {
return m158if().tc().mo367if(context, uri, downloadModel, downloadEventConfig, downloadController);
}
public static boolean m169if(Uri uri) {
return vf.m872if(uri);
}
public static void x() {
m158if().w();
if (tc() != null) {
tc().clearAllData(f77if);
}
}
public static void m161if(int i) {
Map<Integer, ITTDownloadAdapter.OnEventLogHandler> map = r;
if (map != null) {
map.remove(Integer.valueOf(i));
}
}
public static void m162if(int i, ITTDownloadAdapter.OnEventLogHandler onEventLogHandler) {
if (onEventLogHandler != null) {
if (r == null) {
r = Collections.synchronizedMap(new WeakHashMap());
}
r.put(Integer.valueOf(i), onEventLogHandler);
}
}
public static Map<Integer, ITTDownloadAdapter.OnEventLogHandler> z() {
return r;
}
public static boolean m170if(String str, String str2, JSONObject jSONObject, Object obj) {
Map<Integer, ITTDownloadAdapter.OnEventLogHandler> z2;
boolean z3 = false;
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2) && jSONObject != null && (z2 = z()) != null) {
for (Map.Entry<Integer, ITTDownloadAdapter.OnEventLogHandler> entry : z2.entrySet()) {
int intValue = entry.getKey().intValue();
ITTDownloadAdapter.OnEventLogHandler value = entry.getValue();
if (value != null) {
boolean onEventLog = value.onEventLog(intValue, jSONObject.toString(), str, str2, obj);
if (!z3 && !onEventLog) {
z3 = true;
}
}
}
}
return z3;
}
private static boolean x(Context context) {
com.ss.android.download.api.Cif m658if;
if (context == null) {
return false;
}
Context applicationContext = context.getApplicationContext();
String packageName = applicationContext.getPackageName();
if (TextUtils.isEmpty(packageName)) {
packageName = "";
}
if (r()) {
try {
m658if = b.m655if(applicationContext).m658if("pangolin");
} catch (Throwable unused) {
}
if (m658if != null) {
return false;
}
com.ss.android.download.api.Cif mo312if = m658if.mo310if(new C0192z()).mo315if(new Cif()).mo311if(new j(applicationContext)).mo313if(new x()).mo314if(new com.ss.android.download.api.config.vf() {
@Override
public JSONObject mo173if() {
if (z.j() != null) {
return z.j().getDownloadSettings();
}
return new JSONObject();
}
}).mo316if(new com.ss.android.download.api.config.x() {
@Override
public boolean mo172if() {
if (z.j() != null) {
return z.j().getAppIsBackground();
}
return false;
}
}).mo317if(new Cif.C0367if().x("143").m323if("open_news").z("5.6.1.6").j("5616").m324if()).mo312if(new jl() {
@Override
public byte[] mo171if(byte[] bArr, int i) {
return new byte[0];
}
});
mo312if.mo319if(packageName + ".TTFileProvider").mo318if(m159if(applicationContext, tc() != null ? tc().getDownloadSettings() : new JSONObject())).mo320if();
com.ss.android.downloadlib.w.Cif.m797if();
b.m655if(applicationContext).j().mo355if(1);
b.m655if(applicationContext).m661if(w);
com.ss.android.socialbase.appdownloader.j.vf().m960if(new IInstallAppHandler() {
@Override
public boolean installApp(Intent intent) {
return false;
}
});
TTDownloadEventLogger tTDownloadEventLogger = tc() != null ? tc().getTTDownloadEventLogger() : null;
if (tTDownloadEventLogger != null) {
tTDownloadEventLogger.onDownloadConfigReady();
}
return true;
}
m658if = b.m655if(applicationContext).m657if();
if (m658if != null) {
}
}
private static DownloaderBuilder m159if(Context context, JSONObject jSONObject) {
return new DownloaderBuilder(context).downloadSetting(new IDownloadSettings() {
@Override
public JSONObject get() {
if (z.j() != null) {
return z.j().getDownloadSettings();
}
return new JSONObject();
}
}).downloadExpSwitch(jSONObject.optInt("download_exp_switch_temp", 1040187391)).httpService(new tc());
}
public static boolean m168if(Context context, String str) {
if (context != null && !TextUtils.isEmpty(str)) {
List<DownloadInfo> x2 = com.ss.android.socialbase.appdownloader.j.vf().x(context);
if (!x2.isEmpty()) {
for (DownloadInfo downloadInfo : x2) {
if (downloadInfo != null && str.equals(downloadInfo.getUrl())) {
return true;
}
}
}
}
return false;
}
private static Context getContext() {
Context context = tc;
return context == null ? TTAppContextHolder.getContext() : context;
}
public static class C0192z implements com.ss.android.download.api.config.b {
@Override
public void mo185if(Activity activity, int i, String[] strArr, int[] iArr) {
}
@Override
public void mo186if(Activity activity, String[] strArr, final uu uuVar) {
if (z.j() != null) {
z.j().requestPermission(activity, strArr, new ITTPermissionCallback() {
@Override
public void onGranted() {
uu uuVar2 = uuVar;
if (uuVar2 != null) {
uuVar2.mo306if();
}
}
@Override
public void onDenied(String str) {
uu uuVar2 = uuVar;
if (uuVar2 != null) {
uuVar2.mo307if(str);
}
}
});
}
}
@Override
public boolean mo187if(Context context, String str) {
if (z.j() != null) {
return z.j().hasPermission(context, str);
}
return false;
}
}
public static class x implements k {
private x() {
}
@Override
public void mo183if(String str, String str2, Map<String, Object> map, final nn nnVar) {
str.hashCode();
int i = 0;
if (!str.equals(am.c) && str.equals(am.f5321b)) {
i = 1;
}
if (z.j() != null) {
z.j().execute(i, str2, map, new ITTHttpCallback() {
@Override
public void onResponse(String str3) {
nn nnVar2 = nnVar;
if (nnVar2 != null) {
nnVar2.mo301if(str3);
}
}
@Override
public void onError(Throwable th) {
nn nnVar2 = nnVar;
if (nnVar2 != null) {
nnVar2.mo302if(th);
}
}
});
}
}
@Override
public void mo184if(String str, byte[] bArr, String str2, int i, final nn nnVar) {
if (z.j() != null) {
z.j().postBody(str, bArr, str2, new ITTHttpCallback() {
@Override
public void onResponse(String str3) {
nn nnVar2 = nnVar;
if (nnVar2 != null) {
nnVar2.mo301if(str3);
}
}
@Override
public void onError(Throwable th) {
nn nnVar2 = nnVar;
if (nnVar2 != null) {
nnVar2.mo302if(th);
}
}
});
}
}
}
public static class tc implements IDownloadHttpService {
@Override
public IDownloadHttpConnection downloadWithConnection(int i, String str, List<HttpHeader> list) throws IOException {
final x.Cif m155if = com.bytedance.sdk.openadsdk.downloadnew.x.m155if(str, list);
if (m155if != null) {
return new IDownloadHttpConnection() {
@Override
public void cancel() {
}
@Override
public InputStream getInputStream() {
return m155if.f76if;
}
@Override
public String getResponseHeaderField(String str2) {
if (m155if.x != null) {
return m155if.x.get(str2);
}
return null;
}
@Override
public int getResponseCode() {
return m155if.z;
}
@Override
public void end() {
try {
m155if.j.disconnect();
} catch (Exception unused) {
}
}
};
}
return null;
}
}
public static class j implements hz {
private final WeakReference<Context> f79if;
public j(Context context) {
this.f79if = new WeakReference<>(context);
}
@Override
public void mo182if(int i, Context context, DownloadModel downloadModel, String str, Drawable drawable, int i2) {
try {
if (TextUtils.isEmpty(str)) {
return;
}
Toast.makeText(context, str, 0).show();
} catch (Exception e) {
Logger.e("LibUIFactory", "showToastWithDuration e " + e.getMessage());
}
}
@Override
public AlertDialog x(com.ss.android.download.api.model.x xVar) {
if (xVar != null && z.j() != null) {
if (xVar.f273if != null && (xVar.f273if instanceof Activity)) {
return z.j().showDialogBySelf((Activity) xVar.f273if, xVar.vf == 1, z(xVar));
}
z.j().showDialogByDelegate(this.f79if, xVar.vf == 1, z(xVar));
}
return null;
}
private DialogBuilder z(final com.ss.android.download.api.model.x xVar) {
return DialogBuilder.builder().setTitle(xVar.x).setMessage(xVar.z).setNegativeBtnText(xVar.tc).setPositiveBtnText(xVar.j).setIcon(xVar.w).setDialogStatusChangedListener(new IDialogStatusChangedListener() {
@Override
public void onPositiveBtnClick(DialogInterface dialogInterface) {
if (xVar.k != null) {
xVar.k.mo336if(dialogInterface);
}
}
@Override
public void onNegativeBtnClick(DialogInterface dialogInterface) {
if (xVar.k != null) {
try {
xVar.k.x(dialogInterface);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void onCancel(DialogInterface dialogInterface) {
if (xVar.k != null) {
xVar.k.z(dialogInterface);
}
}
});
}
}
public static class Cif implements w {
@Override
public void mo180if(com.ss.android.download.api.model.z zVar) {
com.bytedance.sdk.openadsdk.api.z.x("LibEventLogger", "onV3Event");
m179if(zVar, true);
}
@Override
public void x(com.ss.android.download.api.model.z zVar) {
com.bytedance.sdk.openadsdk.api.z.x("LibEventLogger", "onEvent called");
m179if(zVar, false);
z(zVar);
}
private void z(com.ss.android.download.api.model.z zVar) {
if (zVar == null) {
return;
}
Object hz = zVar.hz();
TTDownloadEventModel label = TTDownloadEventModel.builder().setTag(zVar.x()).setExtJson(zVar.k()).setMaterialMeta(hz instanceof JSONObject ? (JSONObject) hz : null).setLabel(zVar.z());
boolean z = "download_notification".equals(zVar.x()) || "landing_h5_download_ad_button".equals(zVar.x());
if (z.j() != null) {
z.j().executeLogUpload(label, z);
}
}
private void m179if(com.ss.android.download.api.model.z zVar, boolean z) {
TTDownloadEventLogger tTDownloadEventLogger;
if (z.j() == null || (tTDownloadEventLogger = z.j().getTTDownloadEventLogger()) == null || zVar == null) {
return;
}
if (tTDownloadEventLogger.shouldFilterOpenSdkLog() && z.j().isOpenSdkEvent(zVar.toString())) {
return;
}
if (z) {
tTDownloadEventLogger.onV3Event(z.x(zVar));
} else {
tTDownloadEventLogger.onEvent(z.x(zVar));
}
}
}
public static JSONObject x(com.ss.android.download.api.model.z zVar) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("category", zVar.m337if());
jSONObject.put(TTDownloadField.TT_TAG, zVar.x());
jSONObject.put(TTDownloadField.TT_LABEL, zVar.z());
jSONObject.put(TTDownloadField.TT_IS_AD, zVar.j());
jSONObject.put("adId", zVar.tc());
jSONObject.put(TTDownloadField.TT_LOG_EXTRA, zVar.r());
jSONObject.put("extValue", zVar.w());
jSONObject.put("extJson", zVar.k());
jSONObject.put(TTDownloadField.TT_PARAMS_JSON, zVar.b());
jSONObject.put("eventSource", zVar.sl());
jSONObject.put(TTDownloadField.TT_EXTRA_OBJECT, zVar.hz());
jSONObject.put(TTDownloadField.TT_CLICK_TRACK_URL, zVar.vf());
jSONObject.put("isV3", zVar.xq());
jSONObject.put("V3EventName", zVar.un());
jSONObject.put("V3EventParams", zVar.bw());
} catch (JSONException e) {
e.printStackTrace();
}
return jSONObject;
}
public static boolean m165if(Activity activity, final ExitInstallListener exitInstallListener) {
return com.ss.android.downloadlib.addownload.p055if.Cif.m466if().m473if(activity, false, new Cif.InterfaceC0370if() {
@Override
public void mo178if() {
ExitInstallListener exitInstallListener2 = ExitInstallListener.this;
if (exitInstallListener2 != null) {
exitInstallListener2.onExitInstall();
}
}
});
}
}