Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,655 @@
package com.tencent.open.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.ijm.dataencryption.de.DataDecryptTool;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.connect.auth.QQToken;
import com.tencent.open.utils.i;
import com.tencent.tauth.IRequestListener;
import java.io.ByteArrayOutputStream;
import java.io.CharConversionException;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidClassException;
import java.io.InvalidObjectException;
import java.io.NotActiveException;
import java.io.NotSerializableException;
import java.io.OptionalDataException;
import java.io.StreamCorruptedException;
import java.io.SyncFailedException;
import java.io.UTFDataFormatException;
import java.io.UnsupportedEncodingException;
import java.io.WriteAbortedException;
import java.net.BindException;
import java.net.ConnectException;
import java.net.HttpRetryException;
import java.net.MalformedURLException;
import java.net.NoRouteToHostException;
import java.net.PortUnreachableException;
import java.net.ProtocolException;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.net.UnknownServiceException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileLockInterruptionException;
import java.nio.charset.MalformedInputException;
import java.nio.charset.UnmappableCharacterException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.InvalidPropertiesFormatException;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLKeyException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLProtocolException;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.apache.http.ConnectionClosedException;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.MalformedChunkCodingException;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpProtocolParams;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class HttpUtils {
/* compiled from: ProGuard */
public static class HttpStatusException extends Exception {
public static final String ERROR_INFO = "http status code error:";
public HttpStatusException(String str) {
super(str);
}
}
/* compiled from: ProGuard */
public static class NetworkUnavailableException extends Exception {
public static final String ERROR_INFO = "network unavailable";
public NetworkUnavailableException(String str) {
super(str);
}
}
/* compiled from: ProGuard */
public static class a extends SSLSocketFactory {
private final SSLContext a;
public a(KeyStore keyStore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(keyStore);
b bVar;
this.a = SSLContext.getInstance("TLS");
try {
bVar = new b();
} catch (Exception unused) {
bVar = null;
}
this.a.init(null, new TrustManager[]{bVar}, null);
}
@Override // org.apache.http.conn.ssl.SSLSocketFactory, org.apache.http.conn.scheme.LayeredSocketFactory
public Socket createSocket(Socket socket, String str, int i, boolean z) throws IOException, UnknownHostException {
return this.a.getSocketFactory().createSocket(socket, str, i, z);
}
@Override // org.apache.http.conn.ssl.SSLSocketFactory, org.apache.http.conn.scheme.SocketFactory
public Socket createSocket() throws IOException {
return this.a.getSocketFactory().createSocket();
}
}
/* compiled from: ProGuard */
public static class b implements X509TrustManager {
X509TrustManager a;
b() throws Exception {
KeyStore keyStore;
FileInputStream fileInputStream;
Throwable th;
TrustManager[] trustManagers;
try {
keyStore = KeyStore.getInstance("JKS");
} catch (Exception unused) {
keyStore = null;
}
if (keyStore != null) {
try {
fileInputStream = new FileInputStream("trustedCerts");
} catch (Throwable th2) {
fileInputStream = null;
th = th2;
}
try {
keyStore.load(fileInputStream, "passphrase".toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509", "SunJSSE");
trustManagerFactory.init(keyStore);
trustManagers = trustManagerFactory.getTrustManagers();
fileInputStream.close();
} catch (Throwable th3) {
th = th3;
if (fileInputStream != null) {
fileInputStream.close();
}
throw th;
}
} else {
TrustManagerFactory trustManagerFactory2 = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory2.init((KeyStore) null);
trustManagers = trustManagerFactory2.getTrustManagers();
}
for (int i = 0; i < trustManagers.length; i++) {
if (trustManagers[i] instanceof X509TrustManager) {
this.a = (X509TrustManager) trustManagers[i];
return;
}
}
throw new Exception("Couldn't initialize");
}
@Override // javax.net.ssl.X509TrustManager
public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
this.a.checkClientTrusted(x509CertificateArr, str);
}
@Override // javax.net.ssl.X509TrustManager
public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
this.a.checkServerTrusted(x509CertificateArr, str);
}
@Override // javax.net.ssl.X509TrustManager
public X509Certificate[] getAcceptedIssuers() {
return this.a.getAcceptedIssuers();
}
}
/* compiled from: ProGuard */
public static class c {
public final String a;
public final int b;
private c(String str, int i) {
this.a = str;
this.b = i;
}
}
private HttpUtils() {
}
private static void a(Context context, QQToken qQToken, String str) {
if (str.indexOf("add_share") > -1 || str.indexOf("upload_pic") > -1 || str.indexOf("add_topic") > -1 || str.indexOf("set_user_face") > -1 || str.indexOf("add_t") > -1 || str.indexOf("add_pic_t") > -1 || str.indexOf("add_pic_url") > -1 || str.indexOf("add_video") > -1) {
com.tencent.connect.a.a.a(context, qQToken, "requireApi", str);
}
}
private static String b(Context context) {
if (Build.VERSION.SDK_INT >= 11) {
return System.getProperty("http.proxyHost");
}
if (context == null) {
return Proxy.getDefaultHost();
}
String host = Proxy.getHost(context);
return TextUtils.isEmpty(host) ? Proxy.getDefaultHost() : host;
}
public static String encodePostBody(Bundle bundle, String str) {
if (bundle == null) {
return "";
}
StringBuilder sb = new StringBuilder();
int i = -1;
int size = bundle.size();
for (String str2 : bundle.keySet()) {
i++;
Object obj = bundle.get(str2);
if (obj instanceof String) {
sb.append("Content-Disposition: form-data; name=\"" + str2 + "\"\r\n\r\n" + ((String) obj));
if (i < size - 1) {
sb.append("\r\n--" + str + "\r\n");
}
}
}
return sb.toString();
}
public static String encodeUrl(Bundle bundle) {
if (bundle == null) {
return "";
}
StringBuilder sb = new StringBuilder();
boolean z = true;
for (String str : bundle.keySet()) {
Object obj = bundle.get(str);
if ((obj instanceof String) || (obj instanceof String[])) {
if (obj instanceof String[]) {
if (z) {
z = false;
} else {
sb.append("&");
}
sb.append(URLEncoder.encode(str) + "=");
String[] stringArray = bundle.getStringArray(str);
if (stringArray != null) {
for (int i = 0; i < stringArray.length; i++) {
if (i == 0) {
sb.append(URLEncoder.encode(stringArray[i]));
} else {
sb.append(URLEncoder.encode("," + stringArray[i]));
}
}
}
} else {
if (z) {
z = false;
} else {
sb.append("&");
}
sb.append(URLEncoder.encode(str) + "=" + URLEncoder.encode(bundle.getString(str)));
}
}
}
return sb.toString();
}
public static int getErrorCodeFromException(IOException iOException) {
if (iOException instanceof CharConversionException) {
return -20;
}
if (iOException instanceof MalformedInputException) {
return -21;
}
if (iOException instanceof UnmappableCharacterException) {
return -22;
}
if (iOException instanceof HttpResponseException) {
return -23;
}
if (iOException instanceof ClosedChannelException) {
return -24;
}
if (iOException instanceof ConnectionClosedException) {
return -25;
}
if (iOException instanceof EOFException) {
return -26;
}
if (iOException instanceof FileLockInterruptionException) {
return -27;
}
if (iOException instanceof FileNotFoundException) {
return -28;
}
if (iOException instanceof HttpRetryException) {
return -29;
}
if (iOException instanceof ConnectTimeoutException) {
return -7;
}
if (iOException instanceof SocketTimeoutException) {
return -8;
}
if (iOException instanceof InvalidPropertiesFormatException) {
return -30;
}
if (iOException instanceof MalformedChunkCodingException) {
return -31;
}
if (iOException instanceof MalformedURLException) {
return -3;
}
if (iOException instanceof NoHttpResponseException) {
return -32;
}
if (iOException instanceof InvalidClassException) {
return -33;
}
if (iOException instanceof InvalidObjectException) {
return -34;
}
if (iOException instanceof NotActiveException) {
return -35;
}
if (iOException instanceof NotSerializableException) {
return -36;
}
if (iOException instanceof OptionalDataException) {
return -37;
}
if (iOException instanceof StreamCorruptedException) {
return -38;
}
if (iOException instanceof WriteAbortedException) {
return -39;
}
if (iOException instanceof ProtocolException) {
return -40;
}
if (iOException instanceof SSLHandshakeException) {
return -41;
}
if (iOException instanceof SSLKeyException) {
return -42;
}
if (iOException instanceof SSLPeerUnverifiedException) {
return -43;
}
if (iOException instanceof SSLProtocolException) {
return -44;
}
if (iOException instanceof BindException) {
return -45;
}
if (iOException instanceof ConnectException) {
return -46;
}
if (iOException instanceof NoRouteToHostException) {
return -47;
}
if (iOException instanceof PortUnreachableException) {
return -48;
}
if (iOException instanceof SyncFailedException) {
return -49;
}
if (iOException instanceof UTFDataFormatException) {
return -50;
}
if (iOException instanceof UnknownHostException) {
return -51;
}
if (iOException instanceof UnknownServiceException) {
return -52;
}
if (iOException instanceof UnsupportedEncodingException) {
return -53;
}
return iOException instanceof ZipException ? -54 : -2;
}
public static HttpClient getHttpClient(Context context, String str, String str2) {
int i;
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
if (Build.VERSION.SDK_INT < 16) {
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
a aVar = new a(keyStore);
aVar.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
schemeRegistry.register(new Scheme("https", aVar, 443));
} catch (Exception unused) {
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
}
} else {
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
}
BasicHttpParams basicHttpParams = new BasicHttpParams();
e a2 = context != null ? e.a(context, str) : null;
int i2 = 0;
if (a2 != null) {
i2 = a2.a("Common_HttpConnectionTimeout");
i = a2.a("Common_SocketConnectionTimeout");
} else {
i = 0;
}
if (i2 == 0) {
i2 = 15000;
}
if (i == 0) {
i = BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH;
}
HttpConnectionParams.setConnectionTimeout(basicHttpParams, i2);
HttpConnectionParams.setSoTimeout(basicHttpParams, i);
HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(basicHttpParams, "UTF-8");
HttpProtocolParams.setUserAgent(basicHttpParams, "AndroidSDK_" + Build.VERSION.SDK + "_" + Build.DEVICE + "_" + Build.VERSION.RELEASE);
DefaultHttpClient defaultHttpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams);
c proxy = getProxy(context);
if (proxy != null) {
defaultHttpClient.getParams().setParameter("http.route.default-proxy", new HttpHost(proxy.a, proxy.b));
}
return defaultHttpClient;
}
public static c getProxy(Context context) {
ConnectivityManager connectivityManager;
NetworkInfo activeNetworkInfo;
if (context != null && (connectivityManager = (ConnectivityManager) context.getSystemService("connectivity")) != null && (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) != null && activeNetworkInfo.getType() == 0) {
String b2 = b(context);
int a2 = a(context);
if (!TextUtils.isEmpty(b2) && a2 >= 0) {
return new c(b2, a2);
}
}
return null;
}
public static i.a openUrl2(Context context, String str, String str2, Bundle bundle) throws MalformedURLException, IOException, NetworkUnavailableException, HttpStatusException {
ConnectivityManager connectivityManager;
NetworkInfo activeNetworkInfo;
if (context != null && (connectivityManager = (ConnectivityManager) context.getSystemService("connectivity")) != null && ((activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isAvailable())) {
throw new NetworkUnavailableException(NetworkUnavailableException.ERROR_INFO);
}
Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
String string = bundle2.getString("appid_for_getting_config");
bundle2.remove("appid_for_getting_config");
HttpClient httpClient = getHttpClient(context, string, str);
HttpUriRequest httpUriRequest = null;
int i = 0;
int i2 = -1;
if (str2.equals("GET")) {
String encodeUrl = encodeUrl(bundle2);
i = 0 + encodeUrl.length();
com.tencent.open.a.f.a("openSDK_LOG.HttpUtils", "-->openUrl2 before url =" + str);
String str3 = str.indexOf("?") == -1 ? str + "?" : str + "&";
com.tencent.open.a.f.a("openSDK_LOG.HttpUtils", "-->openUrl2 encodedParam =" + encodeUrl + " -- url = " + str3);
StringBuilder sb = new StringBuilder();
sb.append(str3);
sb.append(encodeUrl);
HttpGet httpGet = new HttpGet(sb.toString());
httpGet.addHeader("Accept-Encoding", "gzip");
httpUriRequest = httpGet;
} else if (str2.equals("POST")) {
HttpPost httpPost = new HttpPost(str);
httpPost.addHeader("Accept-Encoding", "gzip");
Bundle bundle3 = new Bundle();
for (String str4 : bundle2.keySet()) {
Object obj = bundle2.get(str4);
if (obj instanceof byte[]) {
bundle3.putByteArray(str4, (byte[]) obj);
}
}
if (!bundle2.containsKey("method")) {
bundle2.putString("method", str2);
}
httpPost.setHeader("Content-Type", "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
httpPost.setHeader("Connection", "Keep-Alive");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byteArrayOutputStream.write(i.i("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
byteArrayOutputStream.write(i.i(encodePostBody(bundle2, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f")));
if (!bundle3.isEmpty()) {
int size = bundle3.size();
byteArrayOutputStream.write(i.i("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
for (String str5 : bundle3.keySet()) {
i2++;
byteArrayOutputStream.write(i.i("Content-Disposition: form-data; name=\"" + str5 + "\"; filename=\"" + str5 + "\"\r\n"));
byteArrayOutputStream.write(i.i("Content-Type: content/unknown\r\n\r\n"));
byte[] byteArray = bundle3.getByteArray(str5);
if (byteArray != null) {
byteArrayOutputStream.write(byteArray);
}
if (i2 < size - 1) {
byteArrayOutputStream.write(i.i("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
}
}
}
byteArrayOutputStream.write(i.i("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n"));
byte[] byteArray2 = byteArrayOutputStream.toByteArray();
i = 0 + byteArray2.length;
byteArrayOutputStream.close();
httpPost.setEntity(new ByteArrayEntity(byteArray2));
httpUriRequest = httpPost;
}
HttpResponse execute = httpClient.execute(httpUriRequest);
int statusCode = execute.getStatusLine().getStatusCode();
if (statusCode == 200) {
return new i.a(a(execute), i);
}
throw new HttpStatusException(HttpStatusException.ERROR_INFO + statusCode);
}
/* JADX WARN: Removed duplicated region for block: B:47:0x0185 A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:49:? A[LOOP:0: B:8:0x00b8->B:49:?, LOOP_END, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static org.json.JSONObject request(com.tencent.connect.auth.QQToken r19, android.content.Context r20, java.lang.String r21, android.os.Bundle r22, java.lang.String r23) throws java.io.IOException, org.json.JSONException, com.tencent.open.utils.HttpUtils.NetworkUnavailableException, com.tencent.open.utils.HttpUtils.HttpStatusException {
/*
Method dump skipped, instructions count: 418
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.open.utils.HttpUtils.request(com.tencent.connect.auth.QQToken, android.content.Context, java.lang.String, android.os.Bundle, java.lang.String):org.json.JSONObject");
}
public static void requestAsync(final QQToken qQToken, final Context context, final String str, final Bundle bundle, final String str2, final IRequestListener iRequestListener) {
com.tencent.open.a.f.a("openSDK_LOG.HttpUtils", "OpenApi requestAsync");
new Thread() { // from class: com.tencent.open.utils.HttpUtils.1
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
try {
JSONObject request = HttpUtils.request(QQToken.this, context, str, bundle, str2);
if (iRequestListener != null) {
iRequestListener.a(request);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi onComplete");
}
} catch (HttpStatusException e) {
IRequestListener iRequestListener2 = iRequestListener;
if (iRequestListener2 != null) {
iRequestListener2.a(e);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync onHttpStatusException", e);
}
} catch (NetworkUnavailableException e2) {
IRequestListener iRequestListener3 = iRequestListener;
if (iRequestListener3 != null) {
iRequestListener3.a(e2);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync onNetworkUnavailableException", e2);
}
} catch (MalformedURLException e3) {
IRequestListener iRequestListener4 = iRequestListener;
if (iRequestListener4 != null) {
iRequestListener4.a(e3);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync MalformedURLException", e3);
}
} catch (SocketTimeoutException e4) {
IRequestListener iRequestListener5 = iRequestListener;
if (iRequestListener5 != null) {
iRequestListener5.a(e4);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync onSocketTimeoutException", e4);
}
} catch (ConnectTimeoutException e5) {
IRequestListener iRequestListener6 = iRequestListener;
if (iRequestListener6 != null) {
iRequestListener6.a(e5);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync onConnectTimeoutException", e5);
}
} catch (IOException e6) {
IRequestListener iRequestListener7 = iRequestListener;
if (iRequestListener7 != null) {
iRequestListener7.a(e6);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync IOException", e6);
}
} catch (JSONException e7) {
IRequestListener iRequestListener8 = iRequestListener;
if (iRequestListener8 != null) {
iRequestListener8.a(e7);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync JSONException", e7);
}
} catch (Exception e8) {
IRequestListener iRequestListener9 = iRequestListener;
if (iRequestListener9 != null) {
iRequestListener9.a(e8);
com.tencent.open.a.f.b("openSDK_LOG.HttpUtils", "OpenApi requestAsync onUnknowException", e8);
}
}
}
}.start();
}
private static String a(HttpResponse httpResponse) throws IllegalStateException, IOException {
InputStream content = httpResponse.getEntity().getContent();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Header firstHeader = httpResponse.getFirstHeader("Content-Encoding");
InputStream gZIPInputStream = (firstHeader == null || firstHeader.getValue().toLowerCase().indexOf("gzip") <= -1) ? content : new GZIPInputStream(content);
byte[] bArr = new byte[DataDecryptTool.DECRYPT_DB_FILE];
while (true) {
int read = gZIPInputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
String str = new String(byteArrayOutputStream.toByteArray(), "UTF-8");
gZIPInputStream.close();
return str;
}
}
}
private static int a(Context context) {
if (Build.VERSION.SDK_INT < 11) {
if (context != null) {
int port = Proxy.getPort(context);
return port < 0 ? Proxy.getDefaultPort() : port;
}
return Proxy.getDefaultPort();
}
String property = System.getProperty("http.proxyPort");
if (!TextUtils.isEmpty(property)) {
try {
return Integer.parseInt(property);
} catch (NumberFormatException unused) {
}
}
return -1;
}
}

View File

@@ -0,0 +1,129 @@
package com.tencent.open.utils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.ProtocolException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Properties;
import java.util.zip.ZipException;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public final class a {
private static final j a = new j(101010256);
private static final k b = new k(38651);
/* compiled from: ProGuard */
/* renamed from: com.tencent.open.utils.a$a, reason: collision with other inner class name */
private static class C0020a {
Properties a;
byte[] b;
private C0020a() {
this.a = new Properties();
}
void a(byte[] bArr) throws IOException {
if (bArr == null) {
return;
}
ByteBuffer wrap = ByteBuffer.wrap(bArr);
int length = a.b.a().length;
byte[] bArr2 = new byte[length];
wrap.get(bArr2);
if (!a.b.equals(new k(bArr2))) {
throw new ProtocolException("unknow protocl [" + Arrays.toString(bArr) + "]");
}
if (bArr.length - length <= 2) {
return;
}
byte[] bArr3 = new byte[2];
wrap.get(bArr3);
int b = new k(bArr3).b();
if ((bArr.length - length) - 2 < b) {
return;
}
byte[] bArr4 = new byte[b];
wrap.get(bArr4);
this.a.load(new ByteArrayInputStream(bArr4));
int length2 = ((bArr.length - length) - b) - 2;
if (length2 > 0) {
this.b = new byte[length2];
wrap.get(this.b);
}
}
public String toString() {
return "ApkExternalInfo [p=" + this.a + ", otherData=" + Arrays.toString(this.b) + "]";
}
}
public static String a(File file, String str) throws IOException {
RandomAccessFile randomAccessFile;
try {
randomAccessFile = new RandomAccessFile(file, "r");
} catch (Throwable th) {
th = th;
randomAccessFile = null;
}
try {
byte[] a2 = a(randomAccessFile);
if (a2 == null) {
randomAccessFile.close();
return null;
}
C0020a c0020a = new C0020a();
c0020a.a(a2);
String property = c0020a.a.getProperty(str);
randomAccessFile.close();
return property;
} catch (Throwable th2) {
th = th2;
if (randomAccessFile != null) {
randomAccessFile.close();
}
throw th;
}
}
public static String a(File file) throws IOException {
return a(file, "channelNo");
}
private static byte[] a(RandomAccessFile randomAccessFile) throws IOException {
boolean z;
long length = randomAccessFile.length() - 22;
randomAccessFile.seek(length);
byte[] a2 = a.a();
int read = randomAccessFile.read();
while (true) {
z = true;
if (read == -1) {
z = false;
break;
}
if (read == a2[0] && randomAccessFile.read() == a2[1] && randomAccessFile.read() == a2[2] && randomAccessFile.read() == a2[3]) {
break;
}
length--;
randomAccessFile.seek(length);
read = randomAccessFile.read();
}
if (z) {
randomAccessFile.seek(length + 16 + 4);
byte[] bArr = new byte[2];
randomAccessFile.readFully(bArr);
int b2 = new k(bArr).b();
if (b2 == 0) {
return null;
}
byte[] bArr2 = new byte[b2];
randomAccessFile.read(bArr2);
return bArr2;
}
throw new ZipException("archive is not a ZIP archive");
}
}

View File

@@ -0,0 +1,164 @@
package com.tencent.open.utils;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class b {
private static String c;
private String a;
private c b;
private long d;
private Handler e;
private Runnable f = new Runnable() { // from class: com.tencent.open.utils.b.2
@Override // java.lang.Runnable
public void run() {
boolean z;
com.tencent.open.a.f.a("AsynLoadImg", "saveFileRunnable:");
String str = "share_qq_" + i.f(b.this.a) + ".jpg";
String str2 = b.c + str;
File file = new File(str2);
Message obtainMessage = b.this.e.obtainMessage();
if (file.exists()) {
obtainMessage.arg1 = 0;
obtainMessage.obj = str2;
com.tencent.open.a.f.a("AsynLoadImg", "file exists: time:" + (System.currentTimeMillis() - b.this.d));
} else {
Bitmap a = b.a(b.this.a);
if (a != null) {
z = b.this.a(a, str);
} else {
com.tencent.open.a.f.a("AsynLoadImg", "saveFileRunnable:get bmp fail---");
z = false;
}
if (z) {
obtainMessage.arg1 = 0;
obtainMessage.obj = str2;
} else {
obtainMessage.arg1 = 1;
}
com.tencent.open.a.f.a("AsynLoadImg", "file not exists: download time:" + (System.currentTimeMillis() - b.this.d));
}
b.this.e.sendMessage(obtainMessage);
}
};
public b(Activity activity) {
this.e = new Handler(activity.getMainLooper()) { // from class: com.tencent.open.utils.b.1
@Override // android.os.Handler
public void handleMessage(Message message) {
com.tencent.open.a.f.a("AsynLoadImg", "handleMessage:" + message.arg1);
if (message.arg1 == 0) {
b.this.b.a(message.arg1, (String) message.obj);
} else {
b.this.b.a(message.arg1, (String) null);
}
}
};
}
public void a(String str, c cVar) {
com.tencent.open.a.f.a("AsynLoadImg", "--save---");
if (str != null && !str.equals("")) {
if (!i.b()) {
cVar.a(2, (String) null);
return;
}
c = Environment.getExternalStorageDirectory() + "/tmp/";
this.d = System.currentTimeMillis();
this.a = str;
this.b = cVar;
new Thread(this.f).start();
return;
}
cVar.a(1, (String) null);
}
public boolean a(Bitmap bitmap, String str) {
String str2 = c;
BufferedOutputStream bufferedOutputStream = null;
try {
try {
File file = new File(str2);
if (!file.exists()) {
file.mkdir();
}
com.tencent.open.a.f.a("AsynLoadImg", "saveFile:" + str);
BufferedOutputStream bufferedOutputStream2 = new BufferedOutputStream(new FileOutputStream(new File(str2 + str)));
try {
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bufferedOutputStream2);
bufferedOutputStream2.flush();
try {
bufferedOutputStream2.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return true;
}
} catch (IOException e2) {
e = e2;
bufferedOutputStream = bufferedOutputStream2;
e.printStackTrace();
com.tencent.open.a.f.b("AsynLoadImg", "saveFile bmp fail---", e);
if (bufferedOutputStream != null) {
try {
bufferedOutputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
return false;
} catch (Throwable th) {
th = th;
bufferedOutputStream = bufferedOutputStream2;
if (bufferedOutputStream != null) {
try {
bufferedOutputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
throw th;
}
} catch (Throwable th2) {
th = th2;
}
} catch (IOException e5) {
e = e5;
}
}
public static Bitmap a(String str) {
com.tencent.open.a.f.a("AsynLoadImg", "getbitmap:" + str);
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
Bitmap decodeStream = BitmapFactory.decodeStream(inputStream);
inputStream.close();
com.tencent.open.a.f.a("AsynLoadImg", "image download finished." + str);
return decodeStream;
} catch (IOException e) {
e.printStackTrace();
com.tencent.open.a.f.a("AsynLoadImg", "getbitmap bmp fail---");
return null;
} catch (OutOfMemoryError e2) {
e2.printStackTrace();
com.tencent.open.a.f.a("AsynLoadImg", "getbitmap bmp fail---");
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
package com.tencent.open.utils;
import java.util.ArrayList;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public interface c {
void a(int i, String str);
void a(int i, ArrayList<String> arrayList);
}

View File

@@ -0,0 +1,33 @@
package com.tencent.open.utils;
import android.content.Context;
import java.io.File;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public final class d {
private static Context a;
public static final Context a() {
Context context = a;
if (context == null) {
return null;
}
return context;
}
public static final String b() {
return a() == null ? "" : a().getPackageName();
}
public static final File c() {
if (a() == null) {
return null;
}
return a().getFilesDir();
}
public static final void a(Context context) {
a = context;
}
}

View File

@@ -0,0 +1,210 @@
package com.tencent.open.utils;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import com.tencent.open.SocialConstants;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class e {
private static Map<String, e> a = Collections.synchronizedMap(new HashMap());
private static String b = null;
private Context c;
private String d;
private JSONObject e = null;
private long f = 0;
private int g = 0;
private boolean h = true;
private e(Context context, String str) {
this.c = null;
this.d = null;
this.c = context.getApplicationContext();
this.d = str;
a();
b();
}
private void b() {
if (this.g != 0) {
d("update thread is running, return");
return;
}
this.g = 1;
final Bundle bundle = new Bundle();
bundle.putString(SocialConstants.PARAM_APP_ID, this.d);
bundle.putString("appid_for_getting_config", this.d);
bundle.putString("status_os", Build.VERSION.RELEASE);
bundle.putString("status_machine", Build.MODEL);
bundle.putString("status_version", Build.VERSION.SDK);
bundle.putString("sdkv", "3.3.0.lite");
bundle.putString("sdkp", "a");
new Thread() { // from class: com.tencent.open.utils.e.1
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
try {
e.this.a(i.d(HttpUtils.openUrl2(e.this.c, "http://cgi.connect.qq.com/qqconnectopen/openapi/policy_conf", "GET", bundle).a));
} catch (Exception e) {
e.printStackTrace();
}
e.this.g = 0;
}
}.start();
}
private String c(String str) {
InputStream open;
String str2;
String str3 = "";
try {
try {
if (this.d != null) {
str2 = str + "." + this.d;
} else {
str2 = str;
}
open = this.c.openFileInput(str2);
} catch (FileNotFoundException unused) {
open = this.c.getAssets().open(str);
}
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, Charset.forName("UTF-8")));
StringBuffer stringBuffer = new StringBuffer();
while (true) {
try {
try {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
stringBuffer.append(readLine);
} catch (Throwable th) {
try {
open.close();
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
throw th;
}
} catch (IOException e2) {
e2.printStackTrace();
open.close();
bufferedReader.close();
}
} catch (IOException e3) {
e3.printStackTrace();
}
}
str3 = stringBuffer.toString();
open.close();
bufferedReader.close();
return str3;
} catch (IOException e4) {
e4.printStackTrace();
return "";
}
}
private void d(String str) {
if (this.h) {
com.tencent.open.a.f.a("openSDK_LOG.OpenConfig", str + "; appid: " + this.d);
}
}
public static e a(Context context, String str) {
e eVar;
synchronized (a) {
com.tencent.open.a.f.a("openSDK_LOG.OpenConfig", "getInstance begin");
if (str != null) {
b = str;
}
if (str == null) {
str = b != null ? b : "0";
}
eVar = a.get(str);
if (eVar == null) {
eVar = new e(context, str);
a.put(str, eVar);
}
com.tencent.open.a.f.a("openSDK_LOG.OpenConfig", "getInstance end");
}
return eVar;
}
public boolean b(String str) {
d("get " + str);
c();
Object opt = this.e.opt(str);
if (opt == null) {
return false;
}
if (opt instanceof Integer) {
return !opt.equals(0);
}
if (opt instanceof Boolean) {
return ((Boolean) opt).booleanValue();
}
return false;
}
private void a() {
try {
this.e = new JSONObject(c("com.tencent.open.config.json"));
} catch (JSONException unused) {
this.e = new JSONObject();
}
}
private void a(String str, String str2) {
try {
if (this.d != null) {
str = str + "." + this.d;
}
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(this.c.openFileOutput(str, 0), Charset.forName("UTF-8"));
outputStreamWriter.write(str2);
outputStreamWriter.flush();
outputStreamWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void c() {
int optInt = this.e.optInt("Common_frequency");
if (optInt == 0) {
optInt = 1;
}
if (SystemClock.elapsedRealtime() - this.f >= optInt * 3600000) {
b();
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(JSONObject jSONObject) {
d("cgi back, do update");
this.e = jSONObject;
a("com.tencent.open.config.json", jSONObject.toString());
this.f = SystemClock.elapsedRealtime();
}
public int a(String str) {
d("get " + str);
c();
return this.e.optInt(str);
}
}

View File

@@ -0,0 +1,48 @@
package com.tencent.open.utils;
import android.content.Context;
import android.content.SharedPreferences;
import java.lang.ref.WeakReference;
import java.net.URL;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class f {
private static f a;
private volatile WeakReference<SharedPreferences> b = null;
public static synchronized f a() {
f fVar;
synchronized (f.class) {
if (a == null) {
a = new f();
}
fVar = a;
}
return fVar;
}
public String a(Context context, String str) {
if (this.b == null || this.b.get() == null) {
this.b = new WeakReference<>(context.getSharedPreferences("ServerPrefs", 0));
}
try {
String host = new URL(str).getHost();
if (host == null) {
com.tencent.open.a.f.e("openSDK_LOG.ServerSetting", "Get host error. url=" + str);
return str;
}
String string = this.b.get().getString(host, null);
if (string != null && !host.equals(string)) {
String replace = str.replace(host, string);
com.tencent.open.a.f.a("openSDK_LOG.ServerSetting", "return environment url : " + replace);
return replace;
}
com.tencent.open.a.f.a("openSDK_LOG.ServerSetting", "host=" + host + ", envHost=" + string);
return str;
} catch (Exception e) {
com.tencent.open.a.f.e("openSDK_LOG.ServerSetting", "getEnvUrl url=" + str + "error.: " + e.getMessage());
return str;
}
}
}

View File

@@ -0,0 +1,301 @@
package com.tencent.open.utils;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class g {
public static String a(int i) {
if (i == 10103) {
return "shareToQQ";
}
if (i == 10104) {
return "shareToQzone";
}
if (i == 10105) {
return "addToQQFavorites";
}
if (i == 10106) {
return "sendToMyComputer";
}
if (i == 10107) {
return "shareToTroopBar";
}
if (i == 11101) {
return "action_login";
}
if (i == 10100) {
return "action_request";
}
return null;
}
public static String a(Context context, String str) {
try {
return context.getPackageManager().getPackageInfo(str, 0).versionName;
} catch (PackageManager.NameNotFoundException unused) {
return null;
}
}
public static String b(Context context, String str) {
String str2 = "";
com.tencent.open.a.f.a("openSDK_LOG.SystemUtils", "OpenUi, getSignValidString");
try {
String packageName = context.getPackageName();
Signature[] signatureArr = context.getPackageManager().getPackageInfo(packageName, 64).signatures;
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(signatureArr[0].toByteArray());
String a = i.a(messageDigest.digest());
messageDigest.reset();
com.tencent.open.a.f.a("openSDK_LOG.SystemUtils", "-->sign: " + a);
messageDigest.update(i.i(packageName + "_" + a + "_" + str + ""));
str2 = i.a(messageDigest.digest());
messageDigest.reset();
StringBuilder sb = new StringBuilder();
sb.append("-->signEncryped: ");
sb.append(str2);
com.tencent.open.a.f.a("openSDK_LOG.SystemUtils", sb.toString());
return str2;
} catch (Exception e) {
e.printStackTrace();
com.tencent.open.a.f.b("openSDK_LOG.SystemUtils", "OpenUi, getSignValidString error", e);
return str2;
}
}
public static int c(Context context, String str) {
return a(a(context, "com.tencent.mobileqq"), str);
}
public static int d(Context context, String str) {
return a(a(context, "com.tencent.tim"), str);
}
public static int e(Context context, String str) {
return a(a(context, "com.tencent.qim"), str);
}
public static int a(String str, String str2) {
if (str == null && str2 == null) {
return 0;
}
if (str != null && str2 == null) {
return 1;
}
if (str == null && str2 != null) {
return -1;
}
String[] split = str.split("\\.");
String[] split2 = str2.split("\\.");
int i = 0;
while (i < split.length && i < split2.length) {
try {
int parseInt = Integer.parseInt(split[i]);
int parseInt2 = Integer.parseInt(split2[i]);
if (parseInt < parseInt2) {
return -1;
}
if (parseInt > parseInt2) {
return 1;
}
i++;
} catch (NumberFormatException unused) {
return str.compareTo(str2);
}
}
if (split.length > i) {
return 1;
}
return split2.length > i ? -1 : 0;
}
public static boolean a(Context context, String str, String str2) {
com.tencent.open.a.f.a("openSDK_LOG.SystemUtils", "OpenUi, validateAppSignatureForPackage");
try {
for (Signature signature : context.getPackageManager().getPackageInfo(str, 64).signatures) {
if (i.f(signature.toCharsString()).equals(str2)) {
return true;
}
}
} catch (PackageManager.NameNotFoundException unused) {
}
return false;
}
public static boolean a(Context context, Intent intent) {
return (context == null || intent == null || context.getPackageManager().queryIntentActivities(intent, 0).size() == 0) ? false : true;
}
public static String a(Context context) {
return context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();
}
/* JADX WARN: Removed duplicated region for block: B:55:0x00c5 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:61:? A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:62:0x00be A[EXC_TOP_SPLITTER, SYNTHETIC] */
@android.annotation.SuppressLint({"SdCardPath"})
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static boolean a(java.lang.String r10, java.lang.String r11, int r12) {
/*
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r1 = "-->extractSecureLib, libName: "
r0.append(r1)
r0.append(r10)
java.lang.String r0 = r0.toString()
java.lang.String r1 = "openSDK_LOG.SystemUtils"
com.tencent.open.a.f.c(r1, r0)
android.content.Context r0 = com.tencent.open.utils.d.a()
r2 = 0
if (r0 != 0) goto L23
java.lang.String r10 = "-->extractSecureLib, global context is null. "
com.tencent.open.a.f.c(r1, r10)
return r2
L23:
java.lang.String r3 = "secure_lib"
android.content.SharedPreferences r3 = r0.getSharedPreferences(r3, r2)
java.io.File r4 = new java.io.File
java.io.File r5 = r0.getFilesDir()
r4.<init>(r5, r11)
boolean r5 = r4.exists()
r6 = 1
java.lang.String r7 = "version"
if (r5 != 0) goto L50
java.io.File r5 = r4.getParentFile()
if (r5 == 0) goto L73
boolean r5 = r5.mkdirs()
if (r5 == 0) goto L73
r4.createNewFile() // Catch: java.io.IOException -> L4b
goto L73
L4b:
r4 = move-exception
r4.printStackTrace()
goto L73
L50:
int r4 = r3.getInt(r7, r2)
java.lang.StringBuilder r5 = new java.lang.StringBuilder
r5.<init>()
java.lang.String r8 = "-->extractSecureLib, libVersion: "
r5.append(r8)
r5.append(r12)
java.lang.String r8 = " | oldVersion: "
r5.append(r8)
r5.append(r4)
java.lang.String r5 = r5.toString()
com.tencent.open.a.f.c(r1, r5)
if (r12 != r4) goto L73
return r6
L73:
r4 = 0
android.content.res.AssetManager r5 = r0.getAssets() // Catch: java.lang.Throwable -> La1 java.lang.Exception -> La4
java.io.InputStream r10 = r5.open(r10) // Catch: java.lang.Throwable -> La1 java.lang.Exception -> La4
java.io.FileOutputStream r4 = r0.openFileOutput(r11, r2) // Catch: java.lang.Throwable -> L9a java.lang.Exception -> L9c
a(r10, r4) // Catch: java.lang.Throwable -> L9a java.lang.Exception -> L9c
android.content.SharedPreferences$Editor r11 = r3.edit() // Catch: java.lang.Throwable -> L9a java.lang.Exception -> L9c
r11.putInt(r7, r12) // Catch: java.lang.Throwable -> L9a java.lang.Exception -> L9c
r11.commit() // Catch: java.lang.Throwable -> L9a java.lang.Exception -> L9c
if (r10 == 0) goto L94
r10.close() // Catch: java.io.IOException -> L93
goto L94
L93:
L94:
if (r4 == 0) goto L99
r4.close() // Catch: java.io.IOException -> L99
L99:
return r6
L9a:
r11 = move-exception
goto Lbc
L9c:
r11 = move-exception
r9 = r4
r4 = r10
r10 = r9
goto La6
La1:
r11 = move-exception
r10 = r4
goto Lbc
La4:
r11 = move-exception
r10 = r4
La6:
java.lang.String r12 = "-->extractSecureLib, when copy lib execption."
com.tencent.open.a.f.b(r1, r12, r11) // Catch: java.lang.Throwable -> Lb8
if (r4 == 0) goto Lb2
r4.close() // Catch: java.io.IOException -> Lb1
goto Lb2
Lb1:
Lb2:
if (r10 == 0) goto Lb7
r10.close() // Catch: java.io.IOException -> Lb7
Lb7:
return r2
Lb8:
r11 = move-exception
r9 = r4
r4 = r10
r10 = r9
Lbc:
if (r10 == 0) goto Lc3
r10.close() // Catch: java.io.IOException -> Lc2
goto Lc3
Lc2:
Lc3:
if (r4 == 0) goto Lc8
r4.close() // Catch: java.io.IOException -> Lc8
Lc8:
throw r11
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.open.utils.g.a(java.lang.String, java.lang.String, int):boolean");
}
private static long a(InputStream inputStream, OutputStream outputStream) throws IOException {
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
long j = 0;
while (true) {
int read = inputStream.read(bArr, 0, bArr.length);
if (read != -1) {
outputStream.write(bArr, 0, read);
j += read;
} else {
com.tencent.open.a.f.c("openSDK_LOG.SystemUtils", "-->copy, copyed size is: " + j);
return j;
}
}
}
public static int a(String str) {
if ("shareToQQ".equals(str)) {
return 10103;
}
if ("shareToQzone".equals(str)) {
return 10104;
}
if ("addToQQFavorites".equals(str)) {
return 10105;
}
if ("sendToMyComputer".equals(str)) {
return 10106;
}
if ("shareToTroopBar".equals(str)) {
return 10107;
}
if ("action_login".equals(str)) {
return 11101;
}
return "action_request".equals(str) ? 10100 : -1;
}
}

View File

@@ -0,0 +1,95 @@
package com.tencent.open.utils;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public final class h {
private static Handler c;
private static HandlerThread d;
private static Object b = new Object();
public static final Executor a = c();
/* compiled from: ProGuard */
private static class a implements Executor {
final Queue<Runnable> a;
Runnable b;
private a() {
this.a = new LinkedList();
}
protected synchronized void a() {
Runnable poll = this.a.poll();
this.b = poll;
if (poll != null) {
h.a.execute(this.b);
}
}
@Override // java.util.concurrent.Executor
public synchronized void execute(final Runnable runnable) {
this.a.offer(new Runnable() { // from class: com.tencent.open.utils.h.a.1
@Override // java.lang.Runnable
public void run() {
try {
runnable.run();
} finally {
a.this.a();
}
}
});
if (this.b == null) {
a();
}
}
}
public static Handler a() {
if (c == null) {
synchronized (h.class) {
d = new HandlerThread("SDK_SUB");
d.start();
c = new Handler(d.getLooper());
}
}
return c;
}
public static Executor b() {
return new a();
}
private static Executor c() {
Executor threadPoolExecutor;
if (Build.VERSION.SDK_INT >= 11) {
threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue());
} else {
try {
Field declaredField = AsyncTask.class.getDeclaredField("sExecutor");
declaredField.setAccessible(true);
threadPoolExecutor = (Executor) declaredField.get(null);
} catch (Exception unused) {
threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue());
}
}
if (threadPoolExecutor instanceof ThreadPoolExecutor) {
((ThreadPoolExecutor) threadPoolExecutor).setCorePoolSize(3);
}
return threadPoolExecutor;
}
public static void a(Runnable runnable) {
a().post(runnable);
}
}

View File

@@ -0,0 +1,512 @@
package com.tencent.open.utils;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import com.tencent.bugly.Bugly;
import com.tencent.open.SocialConstants;
import com.ubt.jimu.base.entities.Course;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.net.URLDecoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Enumeration;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class i {
private static String a = "";
private static String b = "";
private static String c = "";
private static String d = "";
private static int e = -1;
private static String f = null;
private static String g = "0123456789ABCDEF";
/* compiled from: ProGuard */
public static class a {
public String a;
public long b;
public long c;
public a(String str, int i) {
this.a = str;
this.b = i;
if (this.a != null) {
this.c = r1.length();
}
}
}
private static char a(int i) {
int i2 = i & 15;
return (char) (i2 < 10 ? i2 + 48 : (i2 - 10) + 97);
}
public static Bundle a(String str) {
Bundle bundle = new Bundle();
if (str == null) {
return bundle;
}
try {
for (String str2 : str.split("&")) {
String[] split = str2.split("=");
if (split.length == 2) {
bundle.putString(URLDecoder.decode(split[0]), URLDecoder.decode(split[1]));
}
}
return bundle;
} catch (Exception unused) {
return null;
}
}
public static Bundle b(String str) {
try {
URL url = new URL(str.replace("auth://", "http://"));
Bundle a2 = a(url.getQuery());
a2.putAll(a(url.getRef()));
return a2;
} catch (MalformedURLException unused) {
return new Bundle();
}
}
public static JSONObject c(String str) {
try {
URL url = new URL(str.replace("auth://", "http://"));
JSONObject a2 = a((JSONObject) null, url.getQuery());
a(a2, url.getRef());
return a2;
} catch (MalformedURLException unused) {
return new JSONObject();
}
}
public static JSONObject d(String str) throws JSONException {
if (str.equals(Bugly.SDK_IS_DEV)) {
str = "{value : false}";
}
if (str.equals("true")) {
str = "{value : true}";
}
if (str.contains("allback(")) {
str = str.replaceFirst("[\\s\\S]*allback\\(([\\s\\S]*)\\);[^\\)]*\\z", "$1").trim();
}
if (str.contains("online[0]=")) {
str = "{online:" + str.charAt(str.length() - 2) + "}";
}
return new JSONObject(str);
}
public static boolean e(String str) {
return str == null || str.length() == 0;
}
private static boolean f(Context context) {
Signature[] signatureArr;
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo("com.tencent.mtt", 64);
String str = packageInfo.versionName;
if (g.a(str, "4.3") >= 0 && !str.startsWith("4.4") && (signatureArr = packageInfo.signatures) != null) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(signatureArr[0].toByteArray());
String a2 = a(messageDigest.digest());
messageDigest.reset();
if (a2.equals("d8391a394d4a179e6fe7bdb8a301258b")) {
return true;
}
} catch (NoSuchAlgorithmException e2) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "isQQBrowerAvailable has exception: " + e2.getMessage());
}
}
} catch (PackageManager.NameNotFoundException unused) {
}
return false;
}
public static final boolean g(String str) {
if (str == null) {
return false;
}
return str.startsWith("http://") || str.startsWith("https://");
}
public static boolean h(String str) {
return str != null && new File(str).exists();
}
public static byte[] i(String str) {
try {
return str.getBytes("UTF-8");
} catch (UnsupportedEncodingException unused) {
return null;
}
}
public static String e(Context context, String str) {
if (context == null) {
return "";
}
c = d(context, str);
return c;
}
public static boolean g(Context context, String str) {
boolean z = !d(context) || g.a(context, "com.tencent.minihd.qq") == null;
if (z && g.a(context, "com.tencent.tim") != null) {
z = false;
}
return z ? g.c(context, str) < 0 : z;
}
public static boolean e(Context context) {
return g.c(context, "5.9.5") >= 0 || g.a(context, "com.tencent.tim") != null;
}
public static boolean b() {
return (Environment.getExternalStorageState().equals("mounted") ? Environment.getExternalStorageDirectory() : null) != null;
}
public static String c(Context context) {
Location lastKnownLocation;
if (context == null) {
return "";
}
try {
LocationManager locationManager = (LocationManager) context.getSystemService("location");
Criteria criteria = new Criteria();
criteria.setCostAllowed(false);
criteria.setAccuracy(2);
String bestProvider = locationManager.getBestProvider(criteria, true);
if (bestProvider == null || (lastKnownLocation = locationManager.getLastKnownLocation(bestProvider)) == null) {
return "";
}
f = lastKnownLocation.getLatitude() + "*" + lastKnownLocation.getLongitude();
return f;
} catch (Exception e2) {
com.tencent.open.a.f.b("openSDK_LOG.Util", "getLocation>>>", e2);
}
return "";
}
public static JSONObject a(JSONObject jSONObject, String str) {
if (jSONObject == null) {
jSONObject = new JSONObject();
}
if (str != null) {
for (String str2 : str.split("&")) {
String[] split = str2.split("=");
if (split.length == 2) {
try {
split[0] = URLDecoder.decode(split[0]);
split[1] = URLDecoder.decode(split[1]);
} catch (Exception unused) {
}
try {
jSONObject.put(split[0], split[1]);
} catch (JSONException e2) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "decodeUrlToJson has exception: " + e2.getMessage());
}
}
}
}
return jSONObject;
}
public static boolean b(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
if (connectivityManager == null) {
return true;
}
NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
if (allNetworkInfo != null) {
for (NetworkInfo networkInfo : allNetworkInfo) {
if (networkInfo.isConnectedOrConnecting()) {
return true;
}
}
}
return false;
}
public static String d(Context context, String str) {
if (context == null) {
return "";
}
b(context, str);
return a;
}
public static boolean d(Context context) {
double d2;
try {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
d2 = Math.sqrt(Math.pow(displayMetrics.widthPixels / displayMetrics.xdpi, 2.0d) + Math.pow(displayMetrics.heightPixels / displayMetrics.ydpi, 2.0d));
} catch (Throwable unused) {
d2 = 0.0d;
}
return d2 > 6.5d;
}
public static String f(String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(i(str));
byte[] digest = messageDigest.digest();
if (digest == null) {
return str;
}
StringBuilder sb = new StringBuilder();
for (byte b2 : digest) {
sb.append(a(b2 >>> 4));
sb.append(a(b2));
}
return sb.toString();
} catch (NoSuchAlgorithmException e2) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "encrypt has exception: " + e2.getMessage());
return str;
}
}
public static void b(Context context, String str) {
if (context == null) {
return;
}
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 0);
b = packageInfo.versionName;
a = b.substring(0, b.lastIndexOf(46));
d = b.substring(b.lastIndexOf(46) + 1, b.length());
e = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e2) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e2.getMessage());
} catch (Exception e3) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "getPackageInfo has exception: " + e3.getMessage());
}
}
public static String a() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces != null && networkInterfaces.hasMoreElements()) {
Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress nextElement = inetAddresses.nextElement();
if (!nextElement.isLoopbackAddress()) {
return nextElement.getHostAddress().toString();
}
}
}
return "";
} catch (SocketException e2) {
com.tencent.open.a.f.a("openSDK_LOG.Util", "getUserIp SocketException ", e2);
return "";
}
}
public static String c(Context context, String str) {
if (context == null) {
return "";
}
b(context, str);
return b;
}
public static boolean f(Context context, String str) {
boolean z = !d(context) || g.a(context, "com.tencent.minihd.qq") == null;
if (z && g.a(context, "com.tencent.tim") != null) {
z = false;
}
if (z && g.a(context, "com.tencent.qim") != null) {
z = false;
}
return z ? g.c(context, str) < 0 : z;
}
public static boolean a(Context context, String str) {
boolean z;
try {
z = f(context);
try {
if (z) {
a(context, "com.tencent.mtt", "com.tencent.mtt.MainActivity", str);
} else {
a(context, "com.android.browser", "com.android.browser.BrowserActivity", str);
}
return true;
} catch (Exception unused) {
if (z) {
try {
try {
try {
a(context, "com.android.browser", "com.android.browser.BrowserActivity", str);
return true;
} catch (Exception unused2) {
a(context, "com.google.android.browser", "com.android.browser.BrowserActivity", str);
return true;
}
} catch (Exception unused3) {
a(context, "com.android.chrome", "com.google.android.apps.chrome.Main", str);
return true;
}
} catch (Exception unused4) {
return false;
}
}
try {
try {
a(context, "com.google.android.browser", "com.android.browser.BrowserActivity", str);
return true;
} catch (Exception unused5) {
a(context, "com.android.chrome", "com.google.android.apps.chrome.Main", str);
return true;
}
} catch (Exception unused6) {
return false;
}
}
} catch (Exception unused7) {
z = false;
}
}
private static void a(Context context, String str, String str2, String str3) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(str, str2));
intent.setAction("android.intent.action.VIEW");
intent.addFlags(1073741824);
intent.addFlags(268435456);
intent.setData(Uri.parse(str3));
context.startActivity(intent);
}
public static String a(byte[] bArr) {
if (bArr == null) {
return null;
}
StringBuilder sb = new StringBuilder(bArr.length * 2);
for (byte b2 : bArr) {
String num = Integer.toString(b2 & 255, 16);
if (num.length() == 1) {
num = "0" + num;
}
sb.append(num);
}
return sb.toString();
}
public static final String a(Context context) {
CharSequence applicationLabel;
if (context == null || (applicationLabel = context.getPackageManager().getApplicationLabel(context.getApplicationInfo())) == null) {
return null;
}
return applicationLabel.toString();
}
public static final String a(String str, int i, String str2, String str3) {
if (TextUtils.isEmpty(str)) {
return "";
}
if (TextUtils.isEmpty(str2)) {
str2 = "UTF-8";
}
try {
if (str.getBytes(str2).length <= i) {
return str;
}
int i2 = 0;
int i3 = 0;
while (i2 < str.length()) {
int i4 = i2 + 1;
i3 += str.substring(i2, i4).getBytes(str2).length;
if (i3 > i) {
String substring = str.substring(0, i2);
if (TextUtils.isEmpty(str3)) {
return substring;
}
return substring + str3;
}
i2 = i4;
}
return str;
} catch (Exception e2) {
com.tencent.open.a.f.e("openSDK_LOG.Util", "Util.subString has exception: " + e2.getMessage());
return str;
}
}
public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6) {
return a(str, str3, str4, str2, str5, str6, "", "", "", "", "", "");
}
public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, String str12) {
Bundle bundle = new Bundle();
bundle.putString(SocialConstants.PARAM_OPEN_ID, str);
bundle.putString("report_type", str2);
bundle.putString("act_type", str3);
bundle.putString("via", str4);
bundle.putString("app_id", str5);
bundle.putString(UnityActivity.RESULT, str6);
bundle.putString("type", str7);
bundle.putString("login_status", str8);
bundle.putString("need_user_auth", str9);
bundle.putString("to_uin", str10);
bundle.putString("call_source", str11);
bundle.putString("to_type", str12);
return bundle;
}
public static Bundle a(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) {
Bundle bundle = new Bundle();
bundle.putString("platform", "1");
bundle.putString(UnityActivity.RESULT, str);
bundle.putString(Course.TYPE_BLOCKLY, str2);
bundle.putString("tmcost", str3);
bundle.putString("rate", str4);
bundle.putString("cmd", str5);
bundle.putString("uin", str6);
bundle.putString(SocialConstants.PARAM_APP_ID, str7);
bundle.putString("share_type", str8);
bundle.putString("detail", str9);
bundle.putString("os_ver", Build.VERSION.RELEASE);
bundle.putString("network", com.tencent.open.b.a.a(d.a()));
bundle.putString("apn", com.tencent.open.b.a.b(d.a()));
bundle.putString("model_name", Build.MODEL);
bundle.putString("sdk_ver", "3.3.0.lite");
bundle.putString("packagename", d.b());
bundle.putString("app_ver", d(d.a(), d.b()));
return bundle;
}
public static boolean a(Context context, boolean z) {
if (!d(context) || g.a(context, "com.tencent.minihd.qq") == null) {
return !z ? (g.c(context, "4.1") < 0 && g.a(context, "com.tencent.tim") == null && g.a(context, "com.tencent.qim") == null) ? false : true : g.c(context, "4.1") >= 0 || g.a(context, "com.tencent.tim") != null;
}
return true;
}
}

View File

@@ -0,0 +1,28 @@
package com.tencent.open.utils;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public final class j implements Cloneable {
private long a;
public j(long j) {
this.a = j;
}
public byte[] a() {
long j = this.a;
return new byte[]{(byte) (255 & j), (byte) ((65280 & j) >> 8), (byte) ((16711680 & j) >> 16), (byte) ((j & 4278190080L) >> 24)};
}
public long b() {
return this.a;
}
public boolean equals(Object obj) {
return obj != null && (obj instanceof j) && this.a == ((j) obj).b();
}
public int hashCode() {
return (int) this.a;
}
}

View File

@@ -0,0 +1,37 @@
package com.tencent.open.utils;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public final class k implements Cloneable {
private int a;
public k(byte[] bArr) {
this(bArr, 0);
}
public byte[] a() {
int i = this.a;
return new byte[]{(byte) (i & 255), (byte) ((i & 65280) >> 8)};
}
public int b() {
return this.a;
}
public boolean equals(Object obj) {
return obj != null && (obj instanceof k) && this.a == ((k) obj).b();
}
public int hashCode() {
return this.a;
}
public k(byte[] bArr, int i) {
this.a = (bArr[i + 1] << 8) & 65280;
this.a += bArr[i] & 255;
}
public k(int i) {
this.a = i;
}
}