package com.duoyou.task.pro.b; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Point; import android.net.Uri; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.LinearLayout; import android.widget.Toast; import androidx.core.content.FileProvider; import com.baidu.idl.face.platform.FaceEnvironment; import com.duoyou.task.pro.e.b; import com.duoyou.task.pro.g.d; import com.duoyou.task.pro.g.e; import com.duoyou.task.pro.g.f; import com.duoyou.task.pro.g.i; import com.duoyou.task.sdk.xutils.ex.HttpException; import com.duoyou.task.sdk.xutils.http.RequestParams; import com.duoyou.task.sdk.xutils.x; import com.kwai.video.player.KsMediaMeta; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; import com.ss.android.downloadad.api.constant.AdBaseConstants; import com.uc.crashsdk.export.LogType; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.net.Proxy; import java.security.MessageDigest; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class a { /* renamed from: com.duoyou.task.pro.b.a$a reason: collision with other inner class name */ public static class C0041a extends com.duoyou.task.pro.f.a { @Override // com.duoyou.task.pro.f.a public void onFailure(String str, String str2) { Log.i("json", "upload count time onFailure = " + str2); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // com.duoyou.task.sdk.xutils.common.Callback.CommonCallback, com.duoyou.task.pro.f.a public void onSuccess(String str) { Log.i("json", "upload count time onSuccess = " + str); } @Override // com.duoyou.task.pro.f.a public void onSuccess(String str) { Log.i("json", "upload count time onSuccess = " + str); } } public static int a(int i, int i2) { if (i2 == 0) { return i; } float f = 1.0f - (((float) i2) / 255.0f); return Color.argb(255, (int) (((double) (((float) ((i >> 16) & 255)) * f)) + 0.5d), (int) (((double) (((float) ((i >> 8) & 255)) * f)) + 0.5d), (int) (((double) (((float) (i & 255)) * f)) + 0.5d)); } public static int a(Context context, float f) { return (int) ((f * context.getResources().getDisplayMetrics().density) + 0.5f); } public static int a(Context context, String str, int i) { return context == null ? i : context.getSharedPreferences("dy_ad_config", 0).getInt(str, i); } public static String a(long j) { StringBuilder sb; String str; try { DecimalFormat decimalFormat = new DecimalFormat("#.00"); if (j < 1024) { sb = new StringBuilder(); sb.append(decimalFormat.format((double) j)); str = "B"; } else if (j < 1048576) { sb = new StringBuilder(); sb.append(decimalFormat.format(((double) j) / 1024.0d)); str = "KB"; } else if (j < KsMediaMeta.AV_CH_STEREO_RIGHT) { sb = new StringBuilder(); sb.append(decimalFormat.format(((double) j) / 1048576.0d)); str = "MB"; } else { sb = new StringBuilder(); sb.append(decimalFormat.format(((double) j) / 1.073741824E9d)); str = "GB"; } sb.append(str); return sb.toString(); } catch (Exception e) { e.printStackTrace(); return "未知"; } } public static String a(Context context) { try { return Settings.System.getString(context.getContentResolver(), "android_id"); } catch (Exception e) { e.printStackTrace(); return ""; } } public static String a(Context context, int i) { try { return Build.VERSION.SDK_INT >= 23 ? ((TelephonyManager) context.getSystemService("phone")).getDeviceId(i) : ""; } catch (Exception e) { e.printStackTrace(); return ""; } } public static String a(Context context, String str, String str2) { return context == null ? str2 : context.getSharedPreferences("dy_ad_config", 0).getString(str, str2); } public static String a(Throwable th) { return th == null ? "其他错误" : th instanceof HttpException ? ((HttpException) th).getMessage() : th.getMessage(); } public static JSONObject a(String str) { try { JSONObject jSONObject = new JSONObject(str); return jSONObject.optJSONObject("data") == null ? new JSONObject() : jSONObject.optJSONObject("data"); } catch (JSONException e) { e.printStackTrace(); return new JSONObject(); } } public static void a(Activity activity) { int i = Build.VERSION.SDK_INT; if (i >= 19) { Window window = activity.getWindow(); if (i >= 21) { window.addFlags(Integer.MIN_VALUE); window.getDecorView().setSystemUiVisibility(LogType.UNEXP_ANR); window.setStatusBarColor(0); return; } window.addFlags(67108864); } } public static void a(Context context, String str) { try { ArrayList arrayList = (ArrayList) d(context); Iterator it = arrayList.iterator(); while (it.hasNext()) { if (str.equals(((b) it.next()).a)) { it.remove(); } } JSONArray jSONArray = new JSONArray(); for (int i = 0; i < arrayList.size(); i++) { b bVar = (b) arrayList.get(i); JSONObject jSONObject = new JSONObject(); jSONObject.put("username", bVar.a); jSONObject.put("password", bVar.b); jSONArray.put(jSONObject); } String jSONArray2 = jSONArray.toString(); a(e.a() + "game_sdk_u.mark", jSONArray2, "utf-8"); } catch (Exception e) { e.printStackTrace(); } } public static void a(WebView webView, String str) { try { webView.post(new i(webView, str)); } catch (Exception e) { e.printStackTrace(); } } public static boolean a(Context context, String str, boolean z) { return context == null ? z : context.getSharedPreferences("dy_ad_config", 0).getBoolean(str, z); } public static int b(Context context, String str) { return context.getResources().getIdentifier(str, "id", context.getPackageName()); } /* JADX WARNING: Removed duplicated region for block: B:16:0x0047 */ /* JADX WARNING: Removed duplicated region for block: B:19:0x0050 */ /* JADX WARNING: Removed duplicated region for block: B:22:0x0059 */ /* JADX WARNING: Removed duplicated region for block: B:25:0x0062 */ /* JADX WARNING: Removed duplicated region for block: B:28:0x006b */ /* JADX WARNING: Removed duplicated region for block: B:31:0x0074 */ /* JADX WARNING: Removed duplicated region for block: B:35:0x0086 A[LOOP:0: B:33:0x0080->B:35:0x0086, LOOP_END] */ /* JADX WARNING: Removed duplicated region for block: B:38:0x009f */ /* JADX WARNING: Removed duplicated region for block: B:41:0x00ae */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00bf */ public static String b(Context context) { String str; String str2; Iterator it; String c; String a; String a2; int i = 0; try { String b = b(context, 0); String b2 = b(context, 1); String a3 = a(context, 0); String a4 = a(context, 1); try { str = ((TelephonyManager) context.getSystemService("phone")).getDeviceId(); } catch (Exception e) { e.printStackTrace(); str = ""; } try { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (Build.VERSION.SDK_INT >= 26) { str2 = telephonyManager.getImei(); HashSet hashSet = new HashSet(); if (!TextUtils.isEmpty(b)) { hashSet.add(b); } if (!TextUtils.isEmpty(b2)) { hashSet.add(b2); } if (!TextUtils.isEmpty(a3)) { hashSet.add(a3); } if (!TextUtils.isEmpty(a4)) { hashSet.add(a4); } if (!TextUtils.isEmpty(str)) { hashSet.add(str); } if (!TextUtils.isEmpty(str2)) { hashSet.add(str2); } JSONObject jSONObject = new JSONObject(); it = hashSet.iterator(); while (it.hasNext()) { i++; jSONObject.put(String.valueOf(i), (String) it.next()); } c = c(context); if (!TextUtils.isEmpty(c)) { jSONObject.put("5", c); } a = a(context); if (!TextUtils.isEmpty(a)) { jSONObject.put("6", a); } a2 = a(context, "oaid", ""); if (!TextUtils.isEmpty(a2)) { jSONObject.put("7", a2); } return jSONObject.toString(); } } catch (Exception e2) { e2.printStackTrace(); } str2 = ""; HashSet hashSet2 = new HashSet(); if (!TextUtils.isEmpty(b)) { } if (!TextUtils.isEmpty(b2)) { } if (!TextUtils.isEmpty(a3)) { } if (!TextUtils.isEmpty(a4)) { } if (!TextUtils.isEmpty(str)) { } if (!TextUtils.isEmpty(str2)) { } JSONObject jSONObject2 = new JSONObject(); it = hashSet2.iterator(); while (it.hasNext()) { } c = c(context); if (!TextUtils.isEmpty(c)) { } a = a(context); if (!TextUtils.isEmpty(a)) { } a2 = a(context, "oaid", ""); if (!TextUtils.isEmpty(a2)) { } return jSONObject2.toString(); } catch (Exception e3) { e3.printStackTrace(); return ""; } } public static String b(Context context, int i) { try { return Build.VERSION.SDK_INT >= 26 ? ((TelephonyManager) context.getSystemService("phone")).getImei(i) : ""; } catch (Exception e) { e.printStackTrace(); return ""; } } public static String b(String str) { if (TextUtils.isEmpty(str) || str.startsWith("http://") || str.startsWith("https://")) { return str; } return "https://h5.ads66.com/" + str; } public static void b(Context context, String str, int i) { if (context != null) { context.getSharedPreferences("dy_ad_config", 0).edit().putInt(str, i).commit(); } } public static void b(Context context, String str, boolean z) { if (context != null) { context.getSharedPreferences("dy_ad_config", 0).edit().putBoolean(str, z).commit(); } } public static int c(Context context, String str) { return context.getResources().getIdentifier(str, TtmlNode.TAG_LAYOUT, context.getPackageName()); } public static String c(Context context) { String a = com.duoyou.task.pro.g.b.a(); String str = ""; String a2 = a(context, "utdid", str); if (TextUtils.isEmpty(a2)) { String b = com.duoyou.task.pro.g.a.b(a(a, "UTF-8")); if (TextUtils.isEmpty(b)) { String a3 = a(context, "oaid", str); a2 = a(context); boolean a4 = a(com.duoyou.task.pro.g.b.a(), com.duoyou.task.pro.g.a.c(a2), "UTF-8"); if (Build.VERSION.SDK_INT >= 29 && !TextUtils.isEmpty(a3) && !a4) { b = f.a(a3).toLowerCase(); } c(context, "utdid", a2); } a2 = b; c(context, "utdid", a2); } else if (TextUtils.isEmpty(com.duoyou.task.pro.g.a.b(a(a, "UTF-8")))) { a(com.duoyou.task.pro.g.b.a(), com.duoyou.task.pro.g.a.c(a2), "UTF-8"); } int i = f.a; try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(a2.getBytes()); byte[] digest = instance.digest(); StringBuffer stringBuffer = new StringBuffer(str); for (byte b2 : digest) { int i2 = b2; if (b2 < 0) { i2 = b2 + 256; } if (i2 < 16) { stringBuffer.append("0"); } stringBuffer.append(Integer.toHexString(i2 == 1 ? 1 : 0)); } str = stringBuffer.toString().substring(8, 24); } catch (Exception e) { e.printStackTrace(); } if (TextUtils.isEmpty(str) || str.length() <= 9) { return str; } return str.substring(0, 9) + "1" + str.substring(9); } public static void c(Context context, String str, String str2) { if (context != null) { context.getSharedPreferences("dy_ad_config", 0).edit().putString(str, str2).commit(); } } public static boolean c(String str) { try { JSONObject jSONObject = new JSONObject(str); return "0".equals(jSONObject.optString("status")) || "200".equals(jSONObject.optString("status_code")); } catch (JSONException e) { e.printStackTrace(); return false; } } public static PackageInfo d(Context context, String str) { if (TextUtils.isEmpty(str)) { return null; } try { return context.getPackageManager().getPackageInfo(str, 0); } catch (Exception unused) { return null; } } public static List<b> d(Context context) { ArrayList arrayList = new ArrayList(); try { String a = a(e.a() + "game_sdk_u.mark", "utf-8"); if (!TextUtils.isEmpty(a)) { JSONArray jSONArray = new JSONArray(a); for (int i = 0; i < jSONArray.length(); i++) { JSONObject optJSONObject = jSONArray.optJSONObject(i); b bVar = new b(); bVar.a = optJSONObject.optString("username"); bVar.b = optJSONObject.optString("password"); arrayList.add(bVar); } } } catch (Exception e) { e.printStackTrace(); } return arrayList; } public static boolean d(String str) { try { return str.contains("://h5.ads66.com") && str.contains("tasks"); } catch (Exception e) { e.printStackTrace(); return false; } } public static int e(Context context) { Point point = new Point(); int i = Build.VERSION.SDK_INT; Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); if (i >= 17) { defaultDisplay.getRealSize(point); } else { defaultDisplay.getSize(point); } return point.y; } public static int e(Context context, String str) { return context.getResources().getIdentifier(str, TtmlNode.TAG_STYLE, context.getPackageName()); } public static boolean e(String str) { try { return str.contains("://h5.ads66.com") && str.contains("home"); } catch (Exception e) { e.printStackTrace(); return false; } } public static int f(Context context) { Point point = new Point(); int i = Build.VERSION.SDK_INT; Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); if (i >= 17) { defaultDisplay.getRealSize(point); } else { defaultDisplay.getSize(point); } return point.x; } public static boolean f(Context context, String str) { try { return new File(str).exists() && context.getPackageManager().getPackageArchiveInfo(str, 1) != null; } catch (Exception e) { e.printStackTrace(); } } public static boolean g(Context context, String str) { return d(context, str) != null; } public static void h(Context context, String str) { try { Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS"); intent.setData(Uri.parse("package:" + str)); context.startActivity(intent.addFlags(268435456)); } catch (Exception e) { e.printStackTrace(); } } public static void i(Context context, String str) { HashMap hashMap = new HashMap(); hashMap.put("click_type", str); d c = d.c(); if (TextUtils.isEmpty(c.c)) { c.c = a(c.o, "task_id", ""); } hashMap.put("advert_id", c.c); a(com.duoyou.task.pro.g.b.a(context, "https://h5.ads66.com/index.php/click/log"), hashMap, new b()); } public static void j(Context context, String str) { try { if (!TextUtils.isEmpty(str)) { Toast.makeText(context, str, 1).show(); } } catch (Exception e) { e.printStackTrace(); } } public static void k(Context context, String str) { try { if (!TextUtils.isEmpty(str)) { Toast.makeText(context, str, 0).show(); } } catch (Exception e) { e.printStackTrace(); } } public static boolean b(Context context, String str, String str2) { Uri fromFile; if (d.c().B) { try { Log.i("json", "filePath =" + str); Intent intent = new Intent(); intent.setAction("android.intent.action.INSTALL_PACKAGE"); intent.putExtra("android.intent.extra.NOT_UNKNOWN_SOURCE", false); intent.putExtra("android.intent.extra.INSTALLER_PACKAGE_NAME", str2); intent.putExtra("android.intent.extra.RETURN_RESULT", true); if (Build.VERSION.SDK_INT >= 24) { fromFile = FileProvider.getUriForFile(context, context.getApplicationInfo().packageName + ".dyFileProvider", new File(str)); intent.addFlags(3); } else { fromFile = Uri.fromFile(new File(str)); } intent.setDataAndType(fromFile, AdBaseConstants.MIME_APK); context.startActivity(intent); return true; } catch (Exception e) { e.printStackTrace(); return false; } } else { try { Log.i("json", "filePath =" + str); Intent intent2 = new Intent("android.intent.action.VIEW"); if (Build.VERSION.SDK_INT >= 24) { Uri uriForFile = FileProvider.getUriForFile(context, context.getApplicationInfo().packageName + ".dyFileProvider", new File(str)); intent2.setFlags(268435456); intent2.addFlags(1); intent2.setDataAndType(uriForFile, AdBaseConstants.MIME_APK); } else { intent2.setDataAndType(Uri.fromFile(new File(str)), AdBaseConstants.MIME_APK); intent2.setFlags(268435456); } context.startActivity(intent2); return true; } catch (Exception e2) { e2.printStackTrace(); return false; } } } public static void d(Context context, String str, String str2) { try { b bVar = new b(); bVar.a = str; bVar.b = str2; String str3 = e.a() + "game_sdk_u.mark"; String a = a(str3, "utf-8"); if (TextUtils.isEmpty(a)) { a = a(context, "recent_account_string", ""); } ArrayList arrayList = new ArrayList(); if (!TextUtils.isEmpty(a)) { JSONArray jSONArray = new JSONArray(a); for (int i = 0; i < jSONArray.length(); i++) { JSONObject optJSONObject = jSONArray.optJSONObject(i); String optString = optJSONObject.optString("username"); String optString2 = optJSONObject.optString("password"); b bVar2 = new b(); bVar2.a = optString; bVar2.b = optString2; arrayList.add(bVar2); } b bVar3 = null; int i2 = 0; while (true) { if (i2 >= arrayList.size()) { break; } b bVar4 = (b) arrayList.get(i2); if (bVar4.a.equals(str)) { bVar3 = bVar4; break; } i2++; } if (bVar3 != null) { bVar3.b = bVar.b; } else { arrayList.add(0, bVar); } } else { arrayList.add(bVar); } JSONArray jSONArray2 = new JSONArray(); for (int i3 = 0; i3 < arrayList.size(); i3++) { b bVar5 = (b) arrayList.get(i3); JSONObject jSONObject = new JSONObject(); jSONObject.put("username", bVar5.a); jSONObject.put("password", bVar5.b); jSONArray2.put(jSONObject); } if (jSONArray2.length() > 0) { String jSONArray3 = jSONArray2.toString(); a(str3, jSONArray3, "utf-8"); c(context, "recent_account_string", jSONArray3); } } catch (Exception e) { e.printStackTrace(); } } public static void a(String str, Map<String, String> map, com.duoyou.task.pro.f.a aVar) { RequestParams requestParams = new RequestParams(); requestParams.setProxy(Proxy.NO_PROXY); Log.i("dy_task_sdk", "url = " + str); requestParams.setUri(str); for (String str2 : map.keySet()) { requestParams.addBodyParameter(str2, map.get(str2)); } requestParams.setRedirectHandler(new com.duoyou.task.pro.c.d()); x.http().get(requestParams, aVar); } public static String a(String str, String str2) { byte[] bArr; try { FileInputStream fileInputStream = new FileInputStream(str); bArr = new byte[fileInputStream.available()]; fileInputStream.read(bArr); fileInputStream.close(); } catch (Exception e) { e.printStackTrace(); bArr = null; } try { return new String(bArr, str2); } catch (Exception e2) { e2.printStackTrace(); return null; } } public static void a(Activity activity, int i, int i2, boolean z) { if (Build.VERSION.SDK_INT >= 19) { View findViewWithTag = ((ViewGroup) activity.getWindow().getDecorView()).findViewWithTag("TAG_ALPHA"); if (findViewWithTag != null) { findViewWithTag.setVisibility(8); } a(activity); ViewGroup viewGroup = (ViewGroup) (z ? activity.getWindow().getDecorView() : activity.findViewById(16908290)); View findViewWithTag2 = viewGroup.findViewWithTag("TAG_COLOR"); if (findViewWithTag2 != null) { if (findViewWithTag2.getVisibility() == 8) { findViewWithTag2.setVisibility(0); } findViewWithTag2.setBackgroundColor(a(i, i2)); return; } View view = new View(activity); Resources system = Resources.getSystem(); view.setLayoutParams(new LinearLayout.LayoutParams(-1, system.getDimensionPixelSize(system.getIdentifier("status_bar_height", "dimen", FaceEnvironment.OS)))); view.setBackgroundColor(a(i, i2)); view.setTag("TAG_COLOR"); viewGroup.addView(view); } } public static void a(Activity activity, WebView webView) { WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDefaultTextEncodingName("UTF-8"); settings.setCacheMode(2); settings.setBuiltInZoomControls(false); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(false); settings.setPluginState(WebSettings.PluginState.ON); settings.setDomStorageEnabled(true); settings.setLoadsImagesAutomatically(true); settings.setAppCacheMaxSize(Long.MAX_VALUE); settings.setAppCachePath(activity.getApplicationContext().getCacheDir().getAbsolutePath()); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); settings.setTextZoom(100); int i = Build.VERSION.SDK_INT; if (i >= 21) { settings.setMixedContentMode(0); } if (i >= 19 && d.c().C) { WebView.setWebContentsDebuggingEnabled(true); } webView.removeJavascriptInterface("searchBoxJavaBridge_"); webView.removeJavascriptInterface("accessibility"); webView.removeJavascriptInterface("accessibilityTraversal"); } public static void a(Context context, String str, int i, int i2) { String str2; if (context != null) { HashMap hashMap = new HashMap(); String a = d.c().a(); String f = d.c().f(); String b = b(context); hashMap.put("media_id", a); hashMap.put("user_id", f); hashMap.put("device_ids", b); hashMap.put("id", str); hashMap.put("type", i + ""); try { str2 = UUID.randomUUID().toString(); } catch (Exception e) { e.printStackTrace(); str2 = System.nanoTime() + ""; } hashMap.put("uuid", str2); hashMap.put("count_time", i2 + ""); hashMap.put("current_time", (System.currentTimeMillis() / 1000) + ""); try { hashMap.put("sign", f.a(hashMap, d.c().b())); a("https://api.ads66.com/index.php/cpa/play", hashMap, new C0041a()); } catch (Exception e2) { e2.printStackTrace(); k(context, e2.getMessage()); } } } public static boolean a(String str, String str2, String str3) { try { byte[] bytes = str2.getBytes(str3); try { FileOutputStream fileOutputStream = new FileOutputStream(str); fileOutputStream.write(bytes); fileOutputStream.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } } catch (Exception e2) { e2.printStackTrace(); return false; } } }