整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3
以下内容为反编译后的 i.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.an;
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.zc;
import com.ss.android.download.api.config.IDownloadButtonClickListener;
import com.ss.android.download.api.config.e;
import com.ss.android.download.api.config.gj;
import com.ss.android.download.api.config.lf;
import com.ss.android.download.api.config.nr;
import com.ss.android.download.api.config.o;
import com.ss.android.download.api.config.ro;
import com.ss.android.download.api.config.t;
import com.ss.android.download.api.config.zy;
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.g;
import com.ss.android.download.api.model.zc;
import com.ss.android.downloadlib.addownload.g.g;
import com.ss.android.downloadlib.addownload.zc.fy;
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 i {
private static final com.ss.android.download.api.download.g.g e;
private static Map<Integer, ITTDownloadAdapter.OnEventLogHandler> fy;
public static volatile String g;
public static ITTDownloadVisitor i;
private static Context r;
private static final AtomicBoolean ql = new AtomicBoolean(false);
public static boolean zc = true;
public static class r implements IDownloadHttpService {
@Override
public IDownloadHttpConnection downloadWithConnection(int i, String str, List<HttpHeader> list) throws IOException {
final zc.g g = com.bytedance.sdk.openadsdk.downloadnew.zc.g(str, list);
if (g != null) {
return new IDownloadHttpConnection() {
@Override
public void cancel() {
}
@Override
public void end() {
try {
g.ql.disconnect();
} catch (Exception unused) {
}
}
@Override
public InputStream getInputStream() {
return g.g;
}
@Override
public int getResponseCode() {
return g.i;
}
@Override
public String getResponseHeaderField(String str2) {
Map<String, String> map = g.zc;
if (map != null) {
return map.get(str2);
}
return null;
}
};
}
return null;
}
}
static {
try {
g = getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath();
} catch (Throwable unused) {
}
e = new com.ss.android.download.api.download.g.g() {
@Override
public void g(DownloadModel downloadModel, DownloadController downloadController, DownloadEventConfig downloadEventConfig) {
com.bytedance.sdk.openadsdk.api.i.zc("TTDownloadVisitor", "completeListener: onDownloadStart");
}
@Override
public void zc(DownloadInfo downloadInfo, String str) {
com.bytedance.sdk.openadsdk.api.i.zc("TTDownloadVisitor", "completeListener: onInstalled");
i.i(str);
}
@Override
public void g(DownloadInfo downloadInfo, String str) {
com.bytedance.sdk.openadsdk.api.i.zc("TTDownloadVisitor", "completeListener: onDownloadFinished");
}
@Override
public void g(DownloadInfo downloadInfo, BaseException baseException, String str) {
com.bytedance.sdk.openadsdk.api.i.zc("TTDownloadVisitor", "completeListener: onDownloadFailed");
}
@Override
public void g(DownloadInfo downloadInfo) {
com.bytedance.sdk.openadsdk.api.i.zc("TTDownloadVisitor", "completeListener: onCanceled");
}
};
}
private static boolean fy() {
return false;
}
private static Context getContext() {
Context context = r;
return context == null ? TTAppContextHolder.getContext() : context;
}
public static void i(String str) {
com.ss.android.downloadad.api.g.zc g2;
JSONObject e2;
if (TextUtils.isEmpty(str) || (g2 = fy.g().g(str)) == null || (e2 = g2.e()) == null || r() == null) {
return;
}
r().checkAutoControl(e2, str);
}
static ITTDownloadVisitor ql() {
return r();
}
private static ITTDownloadVisitor r() {
ITTDownloadVisitor iTTDownloadVisitor = i;
if (iTTDownloadVisitor == null) {
TTAdManager adManager = TTAdSdk.getAdManager();
if (adManager == null) {
return null;
}
return (ITTDownloadVisitor) adManager.getExtra(ITTDownloadVisitor.class, com.bytedance.sdk.openadsdk.downloadnew.g.g(1));
}
return iTTDownloadVisitor;
}
public static class g implements e {
private void i(com.ss.android.download.api.model.i iVar) {
if (iVar == null) {
return;
}
Object nr = iVar.nr();
TTDownloadEventModel label = TTDownloadEventModel.builder().setTag(iVar.zc()).setExtJson(iVar.t()).setMaterialMeta(nr instanceof JSONObject ? (JSONObject) nr : null).setLabel(iVar.i());
boolean z = "download_notification".equals(iVar.zc()) || "landing_h5_download_ad_button".equals(iVar.zc());
if (i.ql() != null) {
i.ql().executeLogUpload(label, z);
}
}
@Override
public void g(com.ss.android.download.api.model.i iVar) {
com.bytedance.sdk.openadsdk.api.i.zc("LibEventLogger", "onV3Event");
g(iVar, true);
}
@Override
public void zc(com.ss.android.download.api.model.i iVar) {
com.bytedance.sdk.openadsdk.api.i.zc("LibEventLogger", "onEvent called");
g(iVar, false);
i(iVar);
}
private void g(com.ss.android.download.api.model.i iVar, boolean z) {
TTDownloadEventLogger tTDownloadEventLogger;
if (i.ql() == null || (tTDownloadEventLogger = i.ql().getTTDownloadEventLogger()) == null || iVar == null) {
return;
}
if (tTDownloadEventLogger.shouldFilterOpenSdkLog() && i.ql().isOpenSdkEvent(iVar.toString())) {
return;
}
if (z) {
tTDownloadEventLogger.onV3Event(i.zc(iVar));
} else {
tTDownloadEventLogger.onEvent(i.zc(iVar));
}
}
}
public static class C0077i implements gj {
@Override
public void g(Activity activity, int i, String[] strArr, int[] iArr) {
}
@Override
public void g(Activity activity, String[] strArr, final o oVar) {
if (i.ql() != null) {
i.ql().requestPermission(activity, strArr, new ITTPermissionCallback() {
@Override
public void onDenied(String str) {
o oVar2 = oVar;
if (oVar2 != null) {
oVar2.g(str);
}
}
@Override
public void onGranted() {
o oVar2 = oVar;
if (oVar2 != null) {
oVar2.g();
}
}
});
}
}
@Override
public boolean g(Context context, String str) {
if (i.ql() != null) {
return i.ql().hasPermission(context, str);
}
return false;
}
}
public static void g(Context context) {
if (context == null) {
context = TTAppContextHolder.getContext();
}
if (context == null) {
return;
}
AtomicBoolean atomicBoolean = ql;
if (atomicBoolean.get()) {
return;
}
synchronized (i.class) {
if (!atomicBoolean.get()) {
r = context.getApplicationContext();
if (r() != null) {
String initPath = r().initPath(zc);
if (!TextUtils.isEmpty(initPath)) {
g = initPath;
}
}
atomicBoolean.set(zc(r));
}
}
}
public static void zc() {
g().e();
if (r() != null) {
r().clearAllData(g);
}
}
public static class ql implements nr {
private final WeakReference<Context> g;
public ql(Context context) {
this.g = new WeakReference<>(context);
}
private DialogBuilder i(final com.ss.android.download.api.model.zc zcVar) {
return DialogBuilder.builder().setTitle(zcVar.zc).setMessage(zcVar.i).setNegativeBtnText(zcVar.r).setPositiveBtnText(zcVar.ql).setIcon(zcVar.e).setDialogStatusChangedListener(new IDialogStatusChangedListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
zc.InterfaceC0462zc interfaceC0462zc = zcVar.t;
if (interfaceC0462zc != null) {
interfaceC0462zc.i(dialogInterface);
}
}
@Override
public void onNegativeBtnClick(DialogInterface dialogInterface) {
zc.InterfaceC0462zc interfaceC0462zc = zcVar.t;
if (interfaceC0462zc != null) {
try {
interfaceC0462zc.zc(dialogInterface);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void onPositiveBtnClick(DialogInterface dialogInterface) {
zc.InterfaceC0462zc interfaceC0462zc = zcVar.t;
if (interfaceC0462zc != null) {
interfaceC0462zc.g(dialogInterface);
}
}
});
}
@Override
public void g(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 zc(com.ss.android.download.api.model.zc zcVar) {
if (zcVar != null && i.ql() != null) {
Context context = zcVar.g;
if (context != null && (context instanceof Activity)) {
return i.ql().showDialogBySelf((Activity) zcVar.g, zcVar.zy == 1, i(zcVar));
}
i.ql().showDialogByDelegate(this.g, zcVar.zy == 1, i(zcVar));
}
return null;
}
}
public static class zc implements t {
private zc() {
}
@Override
public void g(String str, String str2, Map<String, Object> map, final lf lfVar) {
str.hashCode();
int i = 0;
if (!str.equals("GET") && str.equals(an.b)) {
i = 1;
}
if (i.ql() != null) {
i.ql().execute(i, str2, map, new ITTHttpCallback() {
@Override
public void onError(Throwable th) {
lf lfVar2 = lfVar;
if (lfVar2 != null) {
lfVar2.g(th);
}
}
@Override
public void onResponse(String str3) {
lf lfVar2 = lfVar;
if (lfVar2 != null) {
lfVar2.g(str3);
}
}
});
}
}
@Override
public void g(String str, byte[] bArr, String str2, int i, final lf lfVar) {
if (i.ql() != null) {
i.ql().postBody(str, bArr, str2, new ITTHttpCallback() {
@Override
public void onError(Throwable th) {
lf lfVar2 = lfVar;
if (lfVar2 != null) {
lfVar2.g(th);
}
}
@Override
public void onResponse(String str3) {
lf lfVar2 = lfVar;
if (lfVar2 != null) {
lfVar2.g(str3);
}
}
});
}
}
}
private static boolean zc(Context context) {
com.ss.android.download.api.g g2;
if (context == null) {
return false;
}
Context applicationContext = context.getApplicationContext();
String packageName = applicationContext.getPackageName();
if (TextUtils.isEmpty(packageName)) {
packageName = "";
}
if (fy()) {
try {
g2 = com.ss.android.downloadlib.gj.g(applicationContext).g("pangolin");
} catch (Throwable unused) {
}
if (g2 != null) {
return false;
}
com.ss.android.download.api.g g3 = g2.g(new C0077i()).g(new g()).g(new ql(applicationContext)).g(new zc()).g(new zy() {
@Override
public JSONObject g() {
if (i.ql() != null) {
return i.ql().getDownloadSettings();
}
return new JSONObject();
}
}).g(new com.ss.android.download.api.config.zc() {
@Override
public boolean g() {
if (i.ql() != null) {
return i.ql().getAppIsBackground();
}
return false;
}
}).g(new g.C0461g().zc("143").g("open_news").i("5.8.0.7").ql("5807").g()).g(new ro() {
@Override
public byte[] g(byte[] bArr, int i2) {
return new byte[0];
}
});
g3.g(packageName + ".TTFileProvider").g(g(applicationContext, r() != null ? r().getDownloadSettings() : new JSONObject())).g();
com.ss.android.downloadlib.e.g.g();
com.ss.android.downloadlib.gj.g(applicationContext).ql().g(1);
com.ss.android.downloadlib.gj.g(applicationContext).g(e);
com.ss.android.socialbase.appdownloader.ql.zy().g(new IInstallAppHandler() {
@Override
public boolean installApp(Intent intent) {
return false;
}
});
TTDownloadEventLogger tTDownloadEventLogger = r() != null ? r().getTTDownloadEventLogger() : null;
if (tTDownloadEventLogger != null) {
tTDownloadEventLogger.onDownloadConfigReady();
}
return true;
}
g2 = com.ss.android.downloadlib.gj.g(applicationContext).g();
if (g2 != null) {
}
}
public static Map<Integer, ITTDownloadAdapter.OnEventLogHandler> i() {
return fy;
}
public static void g(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
g = str;
}
public static com.ss.android.downloadlib.gj g() {
g(getContext());
return com.ss.android.downloadlib.gj.g(getContext());
}
public static boolean g(Context context, Uri uri, DownloadModel downloadModel, DownloadEventConfig downloadEventConfig, DownloadController downloadController, IDownloadButtonClickListener iDownloadButtonClickListener) {
return g().r().g(context, uri, downloadModel, downloadEventConfig, downloadController, iDownloadButtonClickListener);
}
public static boolean g(Context context, Uri uri, DownloadModel downloadModel, DownloadEventConfig downloadEventConfig, DownloadController downloadController) {
return g().r().g(context, uri, downloadModel, downloadEventConfig, downloadController);
}
public static boolean g(Uri uri) {
return com.ss.android.downloadlib.zc.zy.g(uri);
}
public static void g(int i2) {
Map<Integer, ITTDownloadAdapter.OnEventLogHandler> map = fy;
if (map != null) {
map.remove(Integer.valueOf(i2));
}
}
public static void g(int i2, ITTDownloadAdapter.OnEventLogHandler onEventLogHandler) {
if (onEventLogHandler != null) {
if (fy == null) {
fy = Collections.synchronizedMap(new WeakHashMap());
}
fy.put(Integer.valueOf(i2), onEventLogHandler);
}
}
public static boolean g(String str, String str2, JSONObject jSONObject, Object obj) {
Map<Integer, ITTDownloadAdapter.OnEventLogHandler> i2;
boolean z = false;
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2) && jSONObject != null && (i2 = i()) != null) {
for (Map.Entry<Integer, ITTDownloadAdapter.OnEventLogHandler> entry : i2.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 (!z && !onEventLog) {
z = true;
}
}
}
}
return z;
}
private static DownloaderBuilder g(Context context, JSONObject jSONObject) {
return new DownloaderBuilder(context).downloadSetting(new IDownloadSettings() {
@Override
public JSONObject get() {
if (i.ql() != null) {
return i.ql().getDownloadSettings();
}
return new JSONObject();
}
}).downloadExpSwitch(jSONObject.optInt("download_exp_switch_temp", 1040187391)).httpService(new r());
}
public static JSONObject zc(com.ss.android.download.api.model.i iVar) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("category", iVar.g());
jSONObject.put(TTDownloadField.TT_TAG, iVar.zc());
jSONObject.put(TTDownloadField.TT_LABEL, iVar.i());
jSONObject.put(TTDownloadField.TT_IS_AD, iVar.ql());
jSONObject.put("adId", iVar.r());
jSONObject.put(TTDownloadField.TT_LOG_EXTRA, iVar.fy());
jSONObject.put("extValue", iVar.e());
jSONObject.put("extJson", iVar.t());
jSONObject.put(TTDownloadField.TT_PARAMS_JSON, iVar.gj());
jSONObject.put("eventSource", iVar.il());
jSONObject.put(TTDownloadField.TT_EXTRA_OBJECT, iVar.nr());
jSONObject.put(TTDownloadField.TT_CLICK_TRACK_URL, iVar.zy());
jSONObject.put("isV3", iVar.kc());
jSONObject.put("V3EventName", iVar.b());
jSONObject.put("V3EventParams", iVar.h());
} catch (JSONException e2) {
e2.printStackTrace();
}
return jSONObject;
}
public static boolean g(Context context, String str) {
if (context != null && !TextUtils.isEmpty(str)) {
List<DownloadInfo> zc2 = com.ss.android.socialbase.appdownloader.ql.zy().zc(context);
if (!zc2.isEmpty()) {
for (DownloadInfo downloadInfo : zc2) {
if (downloadInfo != null && str.equals(downloadInfo.getUrl())) {
return true;
}
}
}
}
return false;
}
public static boolean g(Activity activity, final ExitInstallListener exitInstallListener) {
return com.ss.android.downloadlib.addownload.g.g.g().g(activity, false, new g.InterfaceC0464g() {
@Override
public void g() {
ExitInstallListener exitInstallListener2 = ExitInstallListener.this;
if (exitInstallListener2 != null) {
exitInstallListener2.onExitInstall();
}
}
});
}
}