淘歌音乐 v2.0.49版本的 MD5 值为:49b2dab2d28afd9ea0c9c8648d644406
以下内容为反编译后的 i.java 源代码,内容仅作参考
package com.ss.android.downloadlib.f;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Looper;
import android.os.StatFs;
import android.text.TextUtils;
import com.ss.android.a.a.a.o;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Iterator;
import java.util.List;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.json.JSONException;
import org.json.JSONObject;
public class i {
private static Object[] b = new Object[0];
private static Object[] c = new Object[73];
static final char[] a = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static String d = null;
public static boolean a(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
return new File(str).exists();
}
public static boolean b(String str) {
return !TextUtils.isEmpty(str) && new File(str).exists();
}
public static long a(JSONObject jSONObject, String str) {
if (jSONObject == null) {
return 0L;
}
try {
return Long.valueOf(jSONObject.optString(str)).longValue();
} catch (Exception unused) {
return 0L;
}
}
public static JSONObject a(JSONObject jSONObject, JSONObject jSONObject2) {
if (jSONObject != null && jSONObject2 != null) {
try {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
jSONObject2.put(next, jSONObject.get(next));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return jSONObject2;
}
public static JSONObject a(JSONObject jSONObject) {
return a(jSONObject, new JSONObject());
}
public static JSONObject a(JSONObject... jSONObjectArr) {
JSONObject jSONObject = new JSONObject();
if (jSONObjectArr != null && jSONObjectArr.length != 0) {
for (JSONObject jSONObject2 : jSONObjectArr) {
if (jSONObject2 != null) {
a(jSONObject2, jSONObject);
}
}
}
return jSONObject;
}
public static boolean a(Context context, Intent intent) {
try {
List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 65536);
if (queryIntentActivities != null) {
return !queryIntentActivities.isEmpty();
}
return false;
} catch (Exception unused) {
return false;
}
}
public static PackageInfo a(com.ss.android.downloadad.a.b.a aVar) {
com.ss.android.socialbase.downloader.g.c h;
if (aVar == null || (h = com.ss.android.socialbase.downloader.downloader.f.a(com.ss.android.downloadlib.a.j.a()).h(aVar.t())) == null) {
return null;
}
try {
return com.ss.android.socialbase.appdownloader.c.a(com.ss.android.downloadlib.a.j.a(), h, h.k(), h.h());
} catch (Throwable unused) {
return null;
}
}
public static Drawable a(Context context, String str) {
PackageManager packageManager;
PackageInfo packageArchiveInfo;
if (context != null && !TextUtils.isEmpty(str) && (packageArchiveInfo = (packageManager = context.getPackageManager()).getPackageArchiveInfo(str, 0)) != null) {
ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
applicationInfo.sourceDir = str;
applicationInfo.publicSourceDir = str;
try {
return applicationInfo.loadIcon(packageManager);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
public static int b(Context context, String str) {
if (context == null || TextUtils.isEmpty(str)) {
return -1;
}
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 0);
if (packageInfo != null) {
return packageInfo.versionCode;
}
return -1;
} catch (PackageManager.NameNotFoundException unused) {
return -1;
}
}
public static Drawable c(Context context, String str) {
if (context != null && !TextUtils.isEmpty(str)) {
try {
PackageManager packageManager = context.getPackageManager();
return packageManager.getApplicationInfo(str, 0).loadIcon(packageManager);
} catch (PackageManager.NameNotFoundException unused) {
}
}
return null;
}
public static boolean d(Context context, String str) {
if (context == null) {
context = com.ss.android.downloadlib.a.j.a();
}
if (context == null || TextUtils.isEmpty(str)) {
return false;
}
try {
return context.getPackageManager().getPackageInfo(str, 0) != null;
} catch (Exception unused) {
return false;
}
}
public static com.ss.android.downloadlib.a.b.b a(String str, int i, String str2) {
com.ss.android.downloadlib.a.b.b bVar = new com.ss.android.downloadlib.a.b.b();
if (TextUtils.isEmpty(str)) {
return bVar;
}
try {
PackageInfo packageInfo = com.ss.android.downloadlib.a.j.a().getPackageManager().getPackageInfo(str, 0);
if (packageInfo != null) {
bVar.b(packageInfo.versionCode);
bVar.a(com.ss.android.downloadlib.a.b.b.b);
o h = com.ss.android.downloadlib.a.j.h();
if (h != null && h.a() && !a(packageInfo.versionCode, i, packageInfo.versionName, str2)) {
bVar.a(com.ss.android.downloadlib.a.b.b.c);
}
}
} catch (Exception unused) {
}
return bVar;
}
private static boolean a(int i, int i2, String str, String str2) {
if (i2 == 0 && TextUtils.isEmpty(str2)) {
return true;
}
return (i2 > 0 && i >= i2) || a(str, str2) >= 0;
}
public static boolean b(com.ss.android.downloadad.a.b.a aVar) {
if (aVar == null) {
return false;
}
return a(aVar.m(), aVar.r(), aVar.s()).a();
}
public static boolean a(com.ss.android.a.a.b.c cVar) {
if (cVar == null) {
return false;
}
return a(cVar.v(), cVar.r(), cVar.s()).a();
}
public static boolean b(Context context, Intent intent) {
if (intent == null) {
return false;
}
if (context == null) {
context = com.ss.android.downloadlib.a.j.a();
}
List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 65536);
return queryIntentActivities != null && queryIntentActivities.size() > 0;
}
public static boolean a(Context context, String str, String str2) {
PackageInfo packageArchiveInfo;
PackageInfo packageInfo;
if (context == null || TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
return false;
}
try {
File file = new File(str);
if (!file.exists() || (packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(file.getAbsolutePath(), 0)) == null || !packageArchiveInfo.packageName.equals(str2)) {
return false;
}
int i = packageArchiveInfo.versionCode;
try {
packageInfo = context.getPackageManager().getPackageInfo(str2, 0);
} catch (PackageManager.NameNotFoundException unused) {
packageInfo = null;
}
if (packageInfo == null) {
return false;
}
return i == packageInfo.versionCode;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static boolean e(Context context, String str) {
PackageInfo packageArchiveInfo;
PackageInfo packageInfo;
if (context == null || str == null || TextUtils.isEmpty(str)) {
return false;
}
try {
File file = new File(str);
if (!file.exists() || (packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(file.getAbsolutePath(), 0)) == null) {
return false;
}
String str2 = packageArchiveInfo.packageName;
int i = packageArchiveInfo.versionCode;
try {
packageInfo = context.getPackageManager().getPackageInfo(str2, 0);
} catch (PackageManager.NameNotFoundException unused) {
packageInfo = null;
}
if (packageInfo == null) {
return false;
}
return i <= packageInfo.versionCode;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static Intent f(Context context, String str) {
Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str);
if (launchIntentForPackage == null) {
return null;
}
if (!launchIntentForPackage.hasCategory("android.intent.category.LAUNCHER")) {
launchIntentForPackage.addCategory("android.intent.category.LAUNCHER");
}
launchIntentForPackage.setPackage(null);
launchIntentForPackage.addFlags(2097152);
launchIntentForPackage.addFlags(268435456);
return launchIntentForPackage;
}
public static int a(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.targetSdkVersion;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return 0;
}
}
public static Signature[] g(Context context, String str) {
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 64);
if (packageInfo != null) {
return packageInfo.signatures;
}
return null;
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static Signature[] h(Context context, String str) {
try {
PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(str, 64);
if (packageArchiveInfo != null) {
return packageArchiveInfo.signatures;
}
return null;
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static boolean a(Signature[] signatureArr, Signature[] signatureArr2) {
if (signatureArr == signatureArr2) {
return true;
}
if (signatureArr == null || signatureArr2 == null || signatureArr.length != signatureArr2.length) {
return false;
}
for (int i = 0; i < signatureArr.length; i++) {
if ((signatureArr[i] == null && signatureArr2[i] != null) || (signatureArr[i] != null && !signatureArr[i].equals(signatureArr2[i]))) {
return false;
}
}
return true;
}
public static int a(Context context, float f) {
return (int) ((f * context.getResources().getDisplayMetrics().density) + 0.5f);
}
public static byte[] a(byte[] bArr, byte[] bArr2, String str) throws Exception {
SecretKeySpec secretKeySpec = new SecretKeySpec(bArr2, str);
Mac mac = Mac.getInstance(str);
mac.init(secretKeySpec);
return mac.doFinal(bArr);
}
public static String a(String str, int i) {
return i == 0 ? "" : (TextUtils.isEmpty(str) || str.length() <= i) ? str : str.substring(0, i);
}
public static boolean c(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
if (str.startsWith("http://ad.toutiao.com/advertiser_package/") || str.startsWith("https://ad.toutiao.com/advertiser_package/")) {
return true;
}
return d(str);
}
public static boolean d(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
return str.startsWith("http://lf3-ttcdn-tos.pstatp.com/") || str.startsWith("https://lf3-ttcdn-tos.pstatp.com/");
}
public static int a(String str, String str2) {
try {
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
if (str.equals(str2)) {
return 0;
}
String[] split = str.split("\\.");
String[] split2 = str2.split("\\.");
int min = Math.min(split.length, split2.length);
int i = 0;
int i2 = 0;
while (i < min) {
i2 = Integer.parseInt(split[i]) - Integer.parseInt(split2[i]);
if (i2 != 0) {
break;
}
i++;
}
if (i2 != 0) {
return i2 > 0 ? 1 : -1;
}
for (int i3 = i; i3 < split.length; i3++) {
if (Integer.parseInt(split[i3]) > 0) {
return 1;
}
}
while (i < split2.length) {
if (Integer.parseInt(split2[i]) > 0) {
return -1;
}
i++;
}
return 0;
}
} catch (Exception unused) {
}
return -2;
}
public static String a(String... strArr) {
for (String str : strArr) {
if (!TextUtils.isEmpty(str)) {
return str;
}
}
return "ERROR";
}
public static void a(Activity activity) {
if (activity == null || activity.isFinishing()) {
return;
}
activity.finish();
}
public static <T> T a(T... tArr) {
if (tArr == null) {
throw new IllegalArgumentException("args is null");
}
for (T t : tArr) {
if (t != null) {
return t;
}
}
throw new IllegalArgumentException("args is null");
}
public static long a(File file) {
if (file == null) {
return -1L;
}
try {
return com.ss.android.socialbase.downloader.m.d.c(file.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
return -1L;
}
}
public static long b(File file) {
long j = -1;
if (file == null) {
return -1L;
}
try {
StatFs statFs = new StatFs(file.getAbsolutePath());
if (Build.VERSION.SDK_INT >= 18) {
j = statFs.getTotalBytes();
} else {
j = statFs.getTotalBytes() * statFs.getBlockSize();
}
} catch (Throwable th) {
th.printStackTrace();
}
return j;
}
public static boolean a() {
return Looper.myLooper() == Looper.getMainLooper();
}
public static void b() {
a(new Throwable());
}
public static void a(Throwable th) {
com.ss.android.downloadlib.a.j.g().a(null, new com.ss.android.socialbase.downloader.e.a(1, b(th)), 1);
}
public static String b(Throwable th) {
if (th == null) {
return null;
}
try {
StringWriter stringWriter = new StringWriter();
th.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
} catch (Exception unused) {
return null;
}
}
}