Ostrich VPN v1.19.0222版本的 MD5 值为:1b442e5f3dd93fd660d88d6f4b94ace3
以下内容为反编译后的 CommonUtil.java 源代码,内容仅作参考
package com.best.free.vpn.proxy.util;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.LocaleList;
import android.os.StatFs;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import androidx.core.content.ContextCompat;
import com.best.free.vpn.proxy.R;
import com.best.free.vpn.proxy.base.Constant;
import com.google.android.gms.common.internal.ImagesContract;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Charsets;
import kotlin.text.StringsKt;
@Metadata(d1 = {"\u0000N\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010$\n\u0002\b\u0019\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0014\u0010\u0005\u001a\u0004\u0018\u00010\u00062\b\u0010\u0007\u001a\u0004\u0018\u00010\bH\u0002J\u000e\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\fJ7\u0010\r\u001a\u00020\n2\u0006\u0010\u000e\u001a\u00020\u00042!\u0010\u000f\u001a\u001d\u0012\u0013\u0012\u00110\u0006¢\u0006\f\b\u0011\u0012\b\b\u0012\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\n0\u0010H\u0086\bø\u0001\u0000J\u000e\u0010\u0014\u001a\u00020\u00062\u0006\u0010\u0015\u001a\u00020\fJ!\u0010\u0016\u001a\u0004\u0018\u00010\u00172\u0006\u0010\u000b\u001a\u00020\f2\b\u0010\u0018\u001a\u0004\u0018\u00010\u0019H\u0002¢\u0006\u0002\u0010\u001aJ\u0006\u0010\u001b\u001a\u00020\u0006J\u0006\u0010\u001c\u001a\u00020\u0006J\u0006\u0010\u001d\u001a\u00020\u0006J\u0012\u0010\u001e\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\u00060\u001fJ\u001a\u0010 \u001a\u0004\u0018\u00010\u00172\b\u0010\u000b\u001a\u0004\u0018\u00010\f2\u0006\u0010!\u001a\u00020\u0006J\u0010\u0010\"\u001a\u0004\u0018\u00010\u00062\u0006\u0010#\u001a\u00020\u0006J\u0006\u0010$\u001a\u00020\u0004J\u0006\u0010%\u001a\u00020\u0006J\u000e\u0010&\u001a\u00020\u00042\u0006\u0010\u000b\u001a\u00020\fJ#\u0010'\u001a\u0004\u0018\u00010\u00192\b\u0010\u000b\u001a\u0004\u0018\u00010\f2\b\u0010(\u001a\u0004\u0018\u00010\u0006H\u0002¢\u0006\u0002\u0010)J\u000e\u0010*\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\fJ\u0016\u0010+\u001a\u00020\u00192\u0006\u0010,\u001a\u00020\u00042\u0006\u0010-\u001a\u00020\u0004J\u0016\u0010.\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010/\u001a\u00020\u0006J\u0016\u00100\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\u0006\u00101\u001a\u00020\u0006J&\u00102\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\u0006\u00103\u001a\u00020\u00062\u0006\u00104\u001a\u00020\u00062\u0006\u00105\u001a\u00020\u0006J\u001e\u00106\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\u0006\u00105\u001a\u00020\u00062\u0006\u00107\u001a\u00020\u0006R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u00068"}, d2 = {"Lcom/best/free/vpn/proxy/util/CommonUtil;", "", "()V", "ONE_DAY_MS", "", "bytesToHexString", "", "src", "", "feedback", "", "context", "Landroid/content/Context;", "formatConnectTime", "time", "block", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "name", "result", "getAndroidId", "c", "getAppDrawable", "Landroid/graphics/drawable/Drawable;", "resId", "", "(Landroid/content/Context;Ljava/lang/Integer;)Landroid/graphics/drawable/Drawable;", "getCpuArch", "getCpuCore", "getCpuHardWare", "getCpuInfoMap", "", "getDrawable", "regionCode", "getHash", "str", "getInternalMemorySize", "getLang", "getRAMTotalSize", "getResIdByName", "resName", "(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/Integer;", "getSimCountryInfo", "intervalDays", "startTime", "endTime", "openBrowser", ImagesContract.URL, "openGooglePlay", "packageName", "sendEmail", "address", "subject", FirebaseAnalytics.Param.CONTENT, FirebaseAnalytics.Event.SHARE, "title", "vpnkt-v1.19.0(222)_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class CommonUtil {
public static final CommonUtil INSTANCE = new CommonUtil();
private static final long ONE_DAY_MS = 86400000;
private CommonUtil() {
}
public final void share(Context context, String content, String title) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(content, "content");
Intrinsics.checkNotNullParameter(title, "title");
try {
Intent intent = new Intent();
intent.setAction("android.intent.action.SEND");
intent.putExtra("android.intent.extra.TEXT", content);
intent.setType("text/plain");
context.startActivity(Intent.createChooser(intent, title));
} catch (Exception e) {
e.printStackTrace();
}
}
public final void openBrowser(Context context, String url) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(url, "url");
try {
context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
} catch (Exception e) {
e.printStackTrace();
}
}
public final void sendEmail(Context context, String address, String subject, String content) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(address, "address");
Intrinsics.checkNotNullParameter(subject, "subject");
Intrinsics.checkNotNullParameter(content, "content");
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("plain/text");
intent.putExtra("android.intent.extra.EMAIL", new String[]{address});
intent.putExtra("android.intent.extra.TEXT", content);
intent.putExtra("android.intent.extra.SUBJECT", subject);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
public final void feedback(Context context) {
long longVersionCode;
Intrinsics.checkNotNullParameter(context, "context");
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
if (Build.VERSION.SDK_INT <= 28) {
Integer.valueOf(packageInfo.versionCode);
} else {
longVersionCode = packageInfo.getLongVersionCode();
Long.valueOf(longVersionCode);
}
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String string = context.getString(R.string.feed_back_content);
Intrinsics.checkNotNullExpressionValue(string, "getString(...)");
String format = String.format(string, Arrays.copyOf(new Object[]{context.getString(R.string.product_name), packageInfo.versionName, Build.BRAND, Build.MODEL, Build.VERSION.RELEASE}, 5));
Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
String string2 = context.getString(R.string.feedback_title);
Intrinsics.checkNotNullExpressionValue(string2, "getString(...)");
sendEmail(context, Constant.FEED_BACK_EMAIL, string2, format);
}
public final void openGooglePlay(Context context, String packageName) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(packageName, "packageName");
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
intent.setPackage("com.android.vending");
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
return;
}
openBrowser(context, "https://play.google.com/store/apps/details?id=" + packageName);
}
public final Drawable getDrawable(Context context, String regionCode) {
String str;
Intrinsics.checkNotNullParameter(regionCode, "regionCode");
if (context == null) {
return null;
}
try {
if (regionCode.length() > 2) {
str = "default_flag";
} else {
str = "fl_" + regionCode;
}
String lowerCase = str.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase()");
return getAppDrawable(context, getResIdByName(context, lowerCase));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private final Integer getResIdByName(Context context, String resName) {
Resources resources;
if (context == null || (resources = context.getResources()) == null) {
return null;
}
return Integer.valueOf(resources.getIdentifier(resName, "drawable", context.getPackageName()));
}
private final Drawable getAppDrawable(Context context, Integer resId) {
return ContextCompat.getDrawable(context, resId != null ? resId.intValue() : 0);
}
public final void formatConnectTime(long time, Function1<? super String, Unit> block) {
Intrinsics.checkNotNullParameter(block, "block");
int i = (int) (time / 1000);
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("%02d:%02d:%02d", Arrays.copyOf(new Object[]{Integer.valueOf(i / 3600), Integer.valueOf((i % 3600) / 60), Integer.valueOf(i % 60)}, 3));
Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
block.invoke(format);
}
public final String getHash(String str) {
Intrinsics.checkNotNullParameter(str, "str");
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
byte[] bytes = str.getBytes(Charsets.UTF_8);
Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)");
messageDigest.update(bytes);
return bytesToHexString(messageDigest.digest());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private final String bytesToHexString(byte[] src) {
StringBuilder sb = new StringBuilder();
if (src == null || src.length == 0) {
return null;
}
for (byte b : src) {
String hexString = Integer.toHexString(b);
if (hexString.length() < 2) {
sb.append(0);
}
sb.append(hexString);
}
return sb.toString();
}
public final String getAndroidId(Context c) {
Intrinsics.checkNotNullParameter(c, "c");
String string = Settings.Secure.getString(c.getContentResolver(), "android_id");
Intrinsics.checkNotNullExpressionValue(string, "getString(...)");
return string;
}
public final String getLang() {
Locale locale;
LocaleList localeList;
if (Build.VERSION.SDK_INT >= 24) {
localeList = LocaleList.getDefault();
locale = localeList.get(0);
Intrinsics.checkNotNull(locale);
} else {
locale = Locale.getDefault();
Intrinsics.checkNotNullExpressionValue(locale, "getDefault(...)");
}
String language = locale.getLanguage();
Intrinsics.checkNotNullExpressionValue(language, "getLanguage(...)");
return language;
}
public final String getSimCountryInfo(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
Object systemService = context.getSystemService("phone");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.telephony.TelephonyManager");
String simCountryIso = ((TelephonyManager) systemService).getSimCountryIso();
Intrinsics.checkNotNullExpressionValue(simCountryIso, "getSimCountryIso(...)");
return simCountryIso;
}
public final long getRAMTotalSize(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
Object systemService = context.getSystemService("activity");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.ActivityManager");
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
((android.app.ActivityManager) systemService).getMemoryInfo(memoryInfo);
return memoryInfo.totalMem;
}
public final long getInternalMemorySize() {
StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
return statFs.getBlockCountLong() * statFs.getBlockSizeLong();
}
public final Map<String, String> getCpuInfoMap() {
HashMap hashMap = new HashMap();
String str = File.separator;
String str2 = File.separator;
?? sb = new StringBuilder();
sb.append(str);
sb.append("proc");
sb.append(str2);
sb.append("cpuinfo");
BufferedReader bufferedReader = null;
try {
try {
sb = new FileReader(sb.toString());
try {
BufferedReader bufferedReader2 = new BufferedReader((Reader) sb);
while (true) {
try {
String readLine = bufferedReader2.readLine();
if (readLine == null) {
break;
}
Intrinsics.checkNotNull(readLine);
if (StringsKt.contains$default((CharSequence) readLine, (CharSequence) ":", false, 2, (Object) null)) {
String[] strArr = (String[]) StringsKt.split$default((CharSequence) readLine, new String[]{":"}, false, 0, 6, (Object) null).toArray(new String[0]);
if (strArr.length > 1) {
HashMap hashMap2 = hashMap;
String str3 = strArr[0];
int length = str3.length() - 1;
int i = 0;
boolean z = false;
while (i <= length) {
boolean z2 = Intrinsics.compare((int) str3.charAt(!z ? i : length), 32) <= 0;
if (z) {
if (!z2) {
break;
}
length--;
} else if (z2) {
i++;
} else {
z = true;
}
}
String obj = str3.subSequence(i, length + 1).toString();
String str4 = strArr[1];
int length2 = str4.length() - 1;
int i2 = 0;
boolean z3 = false;
while (i2 <= length2) {
boolean z4 = Intrinsics.compare((int) str4.charAt(!z3 ? i2 : length2), 32) <= 0;
if (z3) {
if (!z4) {
break;
}
length2--;
} else if (z4) {
i2++;
} else {
z3 = true;
}
}
hashMap2.put(obj, str4.subSequence(i2, length2 + 1).toString());
}
}
} catch (IOException e) {
e = e;
bufferedReader = bufferedReader2;
e.printStackTrace();
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (Throwable th) {
th = th;
bufferedReader = bufferedReader2;
if (bufferedReader != null) {
bufferedReader.close();
}
if (sb != 0) {
sb.close();
}
throw th;
}
}
bufferedReader2.close();
} catch (IOException e2) {
e = e2;
}
} catch (Throwable th2) {
th = th2;
}
} catch (IOException e3) {
e = e3;
sb = 0;
} catch (Throwable th3) {
th = th3;
sb = 0;
}
sb.close();
return hashMap;
}
public final String getCpuCore() {
String str = getCpuInfoMap().get("CPU architecture");
return str == null ? "" : str;
}
public final String getCpuArch() {
String str = getCpuInfoMap().get("Processor");
return str == null ? "" : str;
}
public final String getCpuHardWare() {
String str = getCpuInfoMap().get("Hardware");
return str == null ? "" : str;
}
public final int intervalDays(long startTime, long endTime) {
Date date = new Date(startTime);
Date date2 = new Date(endTime);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(11, 0);
calendar.set(12, 0);
calendar.set(13, 0);
calendar.set(14, 0);
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(date2);
calendar2.set(11, 0);
calendar2.set(12, 0);
calendar2.set(13, 0);
calendar2.set(14, 0);
return (int) ((calendar2.getTimeInMillis() - calendar.getTimeInMillis()) / ONE_DAY_MS);
}
}