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,33 @@
package com.tencent.mm.opensdk.openapi;
import android.content.Intent;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.utils.ILog;
/* loaded from: classes.dex */
public interface IWXAPI {
void detach();
int getWXAppSupportAPI();
boolean handleIntent(Intent intent, IWXAPIEventHandler iWXAPIEventHandler);
boolean isWXAppInstalled();
boolean isWXAppSupportAPI();
boolean openWXApp();
boolean registerApp(String str);
boolean registerApp(String str, long j);
boolean sendReq(BaseReq baseReq);
boolean sendResp(BaseResp baseResp);
void setLogImpl(ILog iLog);
void unregisterApp();
}

View File

@@ -0,0 +1,11 @@
package com.tencent.mm.opensdk.openapi;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
/* loaded from: classes.dex */
public interface IWXAPIEventHandler {
void onReq(BaseReq baseReq);
void onResp(BaseResp baseResp);
}

View File

@@ -0,0 +1,307 @@
package com.tencent.mm.opensdk.openapi;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import com.liulishuo.filedownloader.model.FileDownloadModel;
import com.tencent.mm.opensdk.utils.Log;
import com.tencent.mm.opensdk.utils.c;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
class MMSharedPreferences implements SharedPreferences {
private static final String TAG = "MicroMsg.SDK.SharedPreferences";
private final ContentResolver cr;
private final String[] columns = {FileDownloadModel.ID, "key", "type", "value"};
private final HashMap<String, Object> values = new HashMap<>();
private REditor editor = null;
private static class REditor implements SharedPreferences.Editor {
private ContentResolver cr;
private Map<String, Object> values = new HashMap();
private Set<String> remove = new HashSet();
private boolean clear = false;
public REditor(ContentResolver contentResolver) {
this.cr = contentResolver;
}
@Override // android.content.SharedPreferences.Editor
public void apply() {
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor clear() {
this.clear = true;
return this;
}
/* JADX WARN: Removed duplicated region for block: B:17:0x0097 */
/* JADX WARN: Removed duplicated region for block: B:19:0x00ae A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:23:0x003f A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:24:0x0099 */
@Override // android.content.SharedPreferences.Editor
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public boolean commit() {
/*
r10 = this;
android.content.ContentValues r0 = new android.content.ContentValues
r0.<init>()
boolean r1 = r10.clear
r2 = 0
if (r1 == 0) goto L14
android.content.ContentResolver r1 = r10.cr
android.net.Uri r3 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
r4 = 0
r1.delete(r3, r4, r4)
r10.clear = r2
L14:
java.util.Set<java.lang.String> r1 = r10.remove
java.util.Iterator r1 = r1.iterator()
L1a:
boolean r3 = r1.hasNext()
java.lang.String r4 = "key = ?"
r5 = 1
if (r3 == 0) goto L35
java.lang.Object r3 = r1.next()
java.lang.String r3 = (java.lang.String) r3
android.content.ContentResolver r6 = r10.cr
android.net.Uri r7 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
java.lang.String[] r5 = new java.lang.String[r5]
r5[r2] = r3
r6.delete(r7, r4, r5)
goto L1a
L35:
java.util.Map<java.lang.String, java.lang.Object> r1 = r10.values
java.util.Set r1 = r1.entrySet()
java.util.Iterator r1 = r1.iterator()
L3f:
boolean r3 = r1.hasNext()
if (r3 == 0) goto Lc1
java.lang.Object r3 = r1.next()
java.util.Map$Entry r3 = (java.util.Map.Entry) r3
java.lang.Object r6 = r3.getValue()
java.lang.String r7 = "MicroMsg.SDK.PluginProvider.Resolver"
if (r6 != 0) goto L5a
java.lang.String r8 = "unresolve failed, null value"
L55:
com.tencent.mm.opensdk.utils.Log.e(r7, r8)
r7 = 0
goto L95
L5a:
boolean r8 = r6 instanceof java.lang.Integer
if (r8 == 0) goto L60
r7 = 1
goto L95
L60:
boolean r8 = r6 instanceof java.lang.Long
if (r8 == 0) goto L66
r7 = 2
goto L95
L66:
boolean r8 = r6 instanceof java.lang.String
if (r8 == 0) goto L6c
r7 = 3
goto L95
L6c:
boolean r8 = r6 instanceof java.lang.Boolean
if (r8 == 0) goto L72
r7 = 4
goto L95
L72:
boolean r8 = r6 instanceof java.lang.Float
if (r8 == 0) goto L78
r7 = 5
goto L95
L78:
boolean r8 = r6 instanceof java.lang.Double
if (r8 == 0) goto L7e
r7 = 6
goto L95
L7e:
java.lang.StringBuilder r8 = new java.lang.StringBuilder
java.lang.String r9 = "unresolve failed, unknown type="
r8.<init>(r9)
java.lang.Class r9 = r6.getClass()
java.lang.String r9 = r9.toString()
r8.append(r9)
java.lang.String r8 = r8.toString()
goto L55
L95:
if (r7 != 0) goto L99
r6 = 0
goto Lac
L99:
java.lang.Integer r7 = java.lang.Integer.valueOf(r7)
java.lang.String r8 = "type"
r0.put(r8, r7)
java.lang.String r6 = r6.toString()
java.lang.String r7 = "value"
r0.put(r7, r6)
r6 = 1
Lac:
if (r6 == 0) goto L3f
android.content.ContentResolver r6 = r10.cr
android.net.Uri r7 = com.tencent.mm.opensdk.utils.c.b.CONTENT_URI
java.lang.String[] r8 = new java.lang.String[r5]
java.lang.Object r3 = r3.getKey()
java.lang.String r3 = (java.lang.String) r3
r8[r2] = r3
r6.update(r7, r0, r4, r8)
goto L3f
Lc1:
return r5
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.opensdk.openapi.MMSharedPreferences.REditor.commit():boolean");
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putBoolean(String str, boolean z) {
this.values.put(str, Boolean.valueOf(z));
this.remove.remove(str);
return this;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putFloat(String str, float f) {
this.values.put(str, Float.valueOf(f));
this.remove.remove(str);
return this;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putInt(String str, int i) {
this.values.put(str, Integer.valueOf(i));
this.remove.remove(str);
return this;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putLong(String str, long j) {
this.values.put(str, Long.valueOf(j));
this.remove.remove(str);
return this;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putString(String str, String str2) {
this.values.put(str, str2);
this.remove.remove(str);
return this;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor putStringSet(String str, Set<String> set) {
return null;
}
@Override // android.content.SharedPreferences.Editor
public SharedPreferences.Editor remove(String str) {
this.remove.add(str);
return this;
}
}
public MMSharedPreferences(Context context) {
this.cr = context.getContentResolver();
}
private Object getValue(String str) {
try {
Cursor query = this.cr.query(c.b.CONTENT_URI, this.columns, "key = ?", new String[]{str}, null);
if (query == null) {
return null;
}
Object a = query.moveToFirst() ? c.a.a(query.getInt(query.getColumnIndex("type")), query.getString(query.getColumnIndex("value"))) : null;
query.close();
return a;
} catch (Exception e) {
Log.e(TAG, "getValue exception:" + e.getMessage());
return null;
}
}
@Override // android.content.SharedPreferences
public boolean contains(String str) {
return getValue(str) != null;
}
@Override // android.content.SharedPreferences
public SharedPreferences.Editor edit() {
if (this.editor == null) {
this.editor = new REditor(this.cr);
}
return this.editor;
}
@Override // android.content.SharedPreferences
public Map<String, ?> getAll() {
try {
Cursor query = this.cr.query(c.b.CONTENT_URI, this.columns, null, null, null);
if (query == null) {
return null;
}
int columnIndex = query.getColumnIndex("key");
int columnIndex2 = query.getColumnIndex("type");
int columnIndex3 = query.getColumnIndex("value");
while (query.moveToNext()) {
this.values.put(query.getString(columnIndex), c.a.a(query.getInt(columnIndex2), query.getString(columnIndex3)));
}
query.close();
return this.values;
} catch (Exception e) {
Log.e(TAG, "getAll exception:" + e.getMessage());
return this.values;
}
}
@Override // android.content.SharedPreferences
public boolean getBoolean(String str, boolean z) {
Object value = getValue(str);
return (value == null || !(value instanceof Boolean)) ? z : ((Boolean) value).booleanValue();
}
@Override // android.content.SharedPreferences
public float getFloat(String str, float f) {
Object value = getValue(str);
return (value == null || !(value instanceof Float)) ? f : ((Float) value).floatValue();
}
@Override // android.content.SharedPreferences
public int getInt(String str, int i) {
Object value = getValue(str);
return (value == null || !(value instanceof Integer)) ? i : ((Integer) value).intValue();
}
@Override // android.content.SharedPreferences
public long getLong(String str, long j) {
Object value = getValue(str);
return (value == null || !(value instanceof Long)) ? j : ((Long) value).longValue();
}
@Override // android.content.SharedPreferences
public String getString(String str, String str2) {
Object value = getValue(str);
return (value == null || !(value instanceof String)) ? str2 : (String) value;
}
@Override // android.content.SharedPreferences
public Set<String> getStringSet(String str, Set<String> set) {
return null;
}
@Override // android.content.SharedPreferences
public void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
}
@Override // android.content.SharedPreferences
public void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
}
}

View File

@@ -0,0 +1,22 @@
package com.tencent.mm.opensdk.openapi;
import android.content.Context;
import com.tencent.mm.opensdk.utils.Log;
/* loaded from: classes.dex */
public class WXAPIFactory {
private static final String TAG = "MicroMsg.PaySdk.WXFactory";
private WXAPIFactory() {
throw new RuntimeException(WXAPIFactory.class.getSimpleName() + " should not be instantiated");
}
public static IWXAPI createWXAPI(Context context, String str) {
return createWXAPI(context, str, false);
}
public static IWXAPI createWXAPI(Context context, String str, boolean z) {
Log.d(TAG, "createWXAPI, appId = " + str + ", checkSignature = " + z);
return new WXApiImplV10(context, str, z);
}
}

View File

@@ -0,0 +1,52 @@
package com.tencent.mm.opensdk.openapi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.utils.Log;
/* loaded from: classes.dex */
class WXApiImplComm {
private static final String TAG = "MicroMsg.SDK.WXMsgImplComm";
private static final String WX_APP_SIGNATURE = "308202eb30820254a00302010202044d36f7a4300d06092a864886f70d01010505003081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e74301e170d3131303131393134333933325a170d3431303131313134333933325a3081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e7430819f300d06092a864886f70d010101050003818d0030818902818100c05f34b231b083fb1323670bfbe7bdab40c0c0a6efc87ef2072a1ff0d60cc67c8edb0d0847f210bea6cbfaa241be70c86daf56be08b723c859e52428a064555d80db448cdcacc1aea2501eba06f8bad12a4fa49d85cacd7abeb68945a5cb5e061629b52e3254c373550ee4e40cb7c8ae6f7a8151ccd8df582d446f39ae0c5e930203010001300d06092a864886f70d0101050500038181009c8d9d7f2f908c42081b4c764c377109a8b2c70582422125ce545842d5f520aea69550b6bd8bfd94e987b75a3077eb04ad341f481aac266e89d3864456e69fba13df018acdc168b9a19dfd7ad9d9cc6f6ace57c746515f71234df3a053e33ba93ece5cd0fc15f3e389a3f365588a9fcb439e069d3629cd7732a13fff7b891499";
private WXApiImplComm() {
throw new RuntimeException(WXApiImplComm.class.getSimpleName() + " should not be instantiated");
}
public static boolean isIntentFromWx(Intent intent, String str) {
String stringExtra;
return (intent == null || (stringExtra = intent.getStringExtra(ConstantsAPI.Token.WX_TOKEN_KEY)) == null || !stringExtra.equals(str)) ? false : true;
}
public static boolean validateAppSignature(Context context, Signature[] signatureArr, boolean z) {
String str;
if (z) {
for (Signature signature : signatureArr) {
String lowerCase = signature.toCharsString().toLowerCase();
Log.d(TAG, "check signature:" + lowerCase);
if (lowerCase.equals(WX_APP_SIGNATURE)) {
str = "pass";
}
}
return false;
}
str = "ignore wechat app signature validation";
Log.d(TAG, str);
return true;
}
public static boolean validateAppSignatureForPackage(Context context, String str, boolean z) {
if (z) {
try {
return validateAppSignature(context, context.getPackageManager().getPackageInfo(str, 64).signatures, z);
} catch (PackageManager.NameNotFoundException unused) {
return false;
}
}
Log.d(TAG, "ignore wechat app signature validation");
return true;
}
}

View File

@@ -0,0 +1,704 @@
package com.tencent.mm.opensdk.openapi;
import android.app.Activity;
import android.app.Application;
import android.app.Service;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.tencent.mm.opensdk.channel.MMessageActV2;
import com.tencent.mm.opensdk.channel.a.a;
import com.tencent.mm.opensdk.channel.a.b;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelbiz.AddCardToWXCardPackage;
import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
import com.tencent.mm.opensdk.modelbiz.CreateChatroom;
import com.tencent.mm.opensdk.modelbiz.HandleScanResult;
import com.tencent.mm.opensdk.modelbiz.JoinChatroom;
import com.tencent.mm.opensdk.modelbiz.OpenWebview;
import com.tencent.mm.opensdk.modelbiz.SubscribeMessage;
import com.tencent.mm.opensdk.modelmsg.GetMessageFromWX;
import com.tencent.mm.opensdk.modelmsg.LaunchFromWX;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX;
import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
import com.tencent.mm.opensdk.modelpay.PayResp;
import com.tencent.mm.opensdk.utils.ILog;
import com.tencent.mm.opensdk.utils.d;
import com.tencent.open.SocialConstants;
import com.tencent.wxop.stat.MtaSDkException;
import com.tencent.wxop.stat.StatConfig;
import com.tencent.wxop.stat.StatReportStrategy;
import com.tencent.wxop.stat.StatService;
import com.tencent.wxop.stat.common.StatConstants;
import com.ubtrobot.jimu.robotapi.PeripheralType;
/* loaded from: classes.dex */
final class WXApiImplV10 implements IWXAPI {
private static final String TAG = "MicroMsg.SDK.WXApiImplV10";
private static ActivityLifecycleCb activityCb;
private static String wxappPayEntryClassname;
private String appId;
private boolean checkSignature;
private Context context;
private boolean detached = false;
private static final class ActivityLifecycleCb implements Application.ActivityLifecycleCallbacks {
private static final int DELAYED = 800;
private static final String TAG = "MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb";
private Context context;
private Handler handler;
private boolean isForeground;
private Runnable onPausedRunnable;
private Runnable onResumedRunnable;
private ActivityLifecycleCb(Context context) {
this.isForeground = false;
this.handler = new Handler(Looper.getMainLooper());
this.onPausedRunnable = new Runnable() { // from class: com.tencent.mm.opensdk.openapi.WXApiImplV10.ActivityLifecycleCb.1
@Override // java.lang.Runnable
public void run() {
if (WXApiImplV10.activityCb == null || !ActivityLifecycleCb.this.isForeground) {
return;
}
Log.v(ActivityLifecycleCb.TAG, "WXStat trigger onBackground");
StatService.trackCustomKVEvent(ActivityLifecycleCb.this.context, "onBackground_WX", null);
ActivityLifecycleCb.this.isForeground = false;
}
};
this.onResumedRunnable = new Runnable() { // from class: com.tencent.mm.opensdk.openapi.WXApiImplV10.ActivityLifecycleCb.2
@Override // java.lang.Runnable
public void run() {
if (WXApiImplV10.activityCb == null || ActivityLifecycleCb.this.isForeground) {
return;
}
Log.v(ActivityLifecycleCb.TAG, "WXStat trigger onForeground");
StatService.trackCustomKVEvent(ActivityLifecycleCb.this.context, "onForeground_WX", null);
ActivityLifecycleCb.this.isForeground = true;
}
};
this.context = context;
}
public final void detach() {
this.handler.removeCallbacks(this.onResumedRunnable);
this.handler.removeCallbacks(this.onPausedRunnable);
this.context = null;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityDestroyed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityPaused(Activity activity) {
Log.v(TAG, activity.getComponentName().getClassName() + " onActivityPaused");
this.handler.removeCallbacks(this.onResumedRunnable);
this.handler.postDelayed(this.onPausedRunnable, 800L);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityResumed(Activity activity) {
Log.v(TAG, activity.getComponentName().getClassName() + " onActivityResumed");
this.handler.removeCallbacks(this.onPausedRunnable);
this.handler.postDelayed(this.onResumedRunnable, 800L);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityStarted(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public final void onActivityStopped(Activity activity) {
}
}
WXApiImplV10(Context context, String str, boolean z) {
this.checkSignature = false;
com.tencent.mm.opensdk.utils.Log.d(TAG, "<init>, appId = " + str + ", checkSignature = " + z);
this.context = context;
this.appId = str;
this.checkSignature = z;
}
private boolean checkSumConsistent(byte[] bArr, byte[] bArr2) {
String str;
if (bArr == null || bArr.length == 0 || bArr2 == null || bArr2.length == 0) {
str = "checkSumConsistent fail, invalid arguments";
} else {
if (bArr.length == bArr2.length) {
for (int i = 0; i < bArr.length; i++) {
if (bArr[i] != bArr2[i]) {
return false;
}
}
return true;
}
str = "checkSumConsistent fail, length is different";
}
com.tencent.mm.opensdk.utils.Log.e(TAG, str);
return false;
}
private boolean createChatroom(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/createChatroom"), null, null, new String[]{this.appId, bundle.getString("_wxapi_basereq_transaction", ""), bundle.getString("_wxapi_create_chatroom_group_id", ""), bundle.getString("_wxapi_create_chatroom_chatroom_name", ""), bundle.getString("_wxapi_create_chatroom_chatroom_nickname", ""), bundle.getString("_wxapi_create_chatroom_ext_msg", ""), bundle.getString("_wxapi_basereq_openid", "")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean handleWxInternalRespType(String str, IWXAPIEventHandler iWXAPIEventHandler) {
Uri parse;
String queryParameter;
com.tencent.mm.opensdk.utils.Log.i(TAG, "handleWxInternalRespType, extInfo = " + str);
try {
parse = Uri.parse("http://www.qq.com/s?" + str);
queryParameter = parse.getQueryParameter("wx_internal_resptype");
com.tencent.mm.opensdk.utils.Log.i(TAG, "handleWxInternalRespType, respType = " + queryParameter);
} catch (Exception e) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "handleWxInternalRespType fail, ex = " + e.getMessage());
}
if (d.h(queryParameter)) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "handleWxInternalRespType fail, respType is null");
return false;
}
if (!queryParameter.equals("subscribemessage")) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "handleWxInternalRespType fail, unknown resptype = " + queryParameter);
return false;
}
SubscribeMessage.Resp resp = new SubscribeMessage.Resp();
resp.openId = parse.getQueryParameter(SocialConstants.PARAM_OPEN_ID);
resp.templateID = parse.getQueryParameter("template_id");
resp.scene = d.i(parse.getQueryParameter("scene"));
resp.action = parse.getQueryParameter("action");
resp.reserved = parse.getQueryParameter("reserved");
iWXAPIEventHandler.onResp(resp);
return true;
}
private void initMta(Context context, String str) {
String str2 = "AWXOP" + str;
StatConfig.setAppKey(context, str2);
StatConfig.setEnableSmartReporting(true);
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(60);
StatConfig.setInstallChannel(context, "Wechat_Sdk");
try {
StatService.startStatService(context, str2, StatConstants.VERSION);
} catch (MtaSDkException e) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "initMta exception:" + e.getMessage());
}
}
private boolean joinChatroom(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/joinChatroom"), null, null, new String[]{this.appId, bundle.getString("_wxapi_basereq_transaction", ""), bundle.getString("_wxapi_join_chatroom_group_id", ""), bundle.getString("_wxapi_join_chatroom_chatroom_nickname", ""), bundle.getString("_wxapi_join_chatroom_ext_msg", ""), bundle.getString("_wxapi_basereq_openid", "")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendAddCardToWX(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/addCardToWX"), null, null, new String[]{this.appId, bundle.getString("_wxapi_add_card_to_wx_card_list"), bundle.getString("_wxapi_basereq_transaction")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendChooseCardFromWX(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/chooseCardFromWX"), null, null, new String[]{bundle.getString("_wxapi_choose_card_from_wx_card_app_id"), bundle.getString("_wxapi_choose_card_from_wx_card_location_id"), bundle.getString("_wxapi_choose_card_from_wx_card_sign_type"), bundle.getString("_wxapi_choose_card_from_wx_card_card_sign"), bundle.getString("_wxapi_choose_card_from_wx_card_time_stamp"), bundle.getString("_wxapi_choose_card_from_wx_card_nonce_str"), bundle.getString("_wxapi_choose_card_from_wx_card_card_id"), bundle.getString("_wxapi_choose_card_from_wx_card_card_type"), bundle.getString("_wxapi_choose_card_from_wx_card_can_multi_select"), bundle.getString("_wxapi_basereq_transaction")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendHandleScanResult(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/handleScanResult"), null, null, new String[]{this.appId, bundle.getString("_wxapi_scan_qrcode_result")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendJumpToBizProfileReq(Context context, Bundle bundle) {
ContentResolver contentResolver = context.getContentResolver();
Uri parse = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizProfile");
StringBuilder sb = new StringBuilder();
sb.append(bundle.getInt("_wxapi_jump_to_biz_profile_req_scene"));
StringBuilder sb2 = new StringBuilder();
sb2.append(bundle.getInt("_wxapi_jump_to_biz_profile_req_profile_type"));
Cursor query = contentResolver.query(parse, null, null, new String[]{this.appId, bundle.getString("_wxapi_jump_to_biz_profile_req_to_user_name"), bundle.getString("_wxapi_jump_to_biz_profile_req_ext_msg"), sb.toString(), sb2.toString()}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendJumpToBizTempSessionReq(Context context, Bundle bundle) {
ContentResolver contentResolver = context.getContentResolver();
Uri parse = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizTempSession");
StringBuilder sb = new StringBuilder();
sb.append(bundle.getInt("_wxapi_jump_to_biz_webview_req_show_type"));
Cursor query = contentResolver.query(parse, null, null, new String[]{this.appId, bundle.getString("_wxapi_jump_to_biz_webview_req_to_user_name"), bundle.getString("_wxapi_jump_to_biz_webview_req_session_from"), sb.toString()}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendJumpToBizWebviewReq(Context context, Bundle bundle) {
ContentResolver contentResolver = context.getContentResolver();
Uri parse = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizProfile");
StringBuilder sb = new StringBuilder();
sb.append(bundle.getInt("_wxapi_jump_to_biz_webview_req_scene"));
Cursor query = contentResolver.query(parse, null, null, new String[]{this.appId, bundle.getString("_wxapi_jump_to_biz_webview_req_to_user_name"), bundle.getString("_wxapi_jump_to_biz_webview_req_ext_msg"), sb.toString()}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendOpenBusiLuckyMoney(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/openBusiLuckyMoney"), null, null, new String[]{this.appId, bundle.getString("_wxapi_open_busi_lucky_money_timeStamp"), bundle.getString("_wxapi_open_busi_lucky_money_nonceStr"), bundle.getString("_wxapi_open_busi_lucky_money_signType"), bundle.getString("_wxapi_open_busi_lucky_money_signature"), bundle.getString("_wxapi_open_busi_lucky_money_package")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendOpenRankListReq(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/openRankList"), null, null, new String[0], null);
if (query == null) {
return true;
}
query.close();
return true;
}
private boolean sendOpenWebview(Context context, Bundle bundle) {
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/openWebview"), null, null, new String[]{this.appId, bundle.getString("_wxapi_jump_to_webview_url"), bundle.getString("_wxapi_basereq_transaction")}, null);
if (query != null) {
query.close();
}
return true;
}
private boolean sendPayReq(Context context, Bundle bundle) {
if (wxappPayEntryClassname == null) {
wxappPayEntryClassname = new MMSharedPreferences(context).getString("_wxapp_pay_entry_classname_", null);
com.tencent.mm.opensdk.utils.Log.d(TAG, "pay, set wxappPayEntryClassname = " + wxappPayEntryClassname);
if (wxappPayEntryClassname == null) {
try {
wxappPayEntryClassname = context.getPackageManager().getApplicationInfo("com.tencent.mm", PeripheralType.SERVO).metaData.getString("com.tencent.mm.BuildInfo.OPEN_SDK_PAY_ENTRY_CLASSNAME", null);
} catch (Exception e) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "get from metaData failed : " + e.getMessage());
}
}
if (wxappPayEntryClassname == null) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "pay fail, wxappPayEntryClassname is null");
return false;
}
}
MMessageActV2.Args args = new MMessageActV2.Args();
args.bundle = bundle;
args.targetPkgName = "com.tencent.mm";
args.targetClassName = wxappPayEntryClassname;
return MMessageActV2.send(context, args);
}
private boolean sendSubscribeMessage(Context context, BaseReq baseReq) {
SubscribeMessage.Req req = (SubscribeMessage.Req) baseReq;
Cursor query = context.getContentResolver().query(Uri.parse("content://com.tencent.mm.sdk.comm.provider/openTypeWebview"), null, null, new String[]{this.appId, "1", String.valueOf(req.scene), req.templateID, req.reserved}, null);
if (query != null) {
query.close();
}
return true;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final void detach() {
Application application;
com.tencent.mm.opensdk.utils.Log.d(TAG, "detach");
this.detached = true;
if (activityCb != null && Build.VERSION.SDK_INT >= 14) {
Context context = this.context;
if (context instanceof Activity) {
application = ((Activity) context).getApplication();
} else {
if (context instanceof Service) {
application = ((Service) context).getApplication();
}
activityCb.detach();
}
application.unregisterActivityLifecycleCallbacks(activityCb);
activityCb.detach();
}
this.context = null;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final int getWXAppSupportAPI() {
if (this.detached) {
throw new IllegalStateException("getWXAppSupportAPI fail, WXMsgImpl has been detached");
}
if (!isWXAppInstalled()) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "open wx app failed, not installed or signature check failed");
return 0;
}
int i = new MMSharedPreferences(this.context).getInt("_build_info_sdk_int_", 0);
if (i != 0) {
return i;
}
try {
return this.context.getPackageManager().getApplicationInfo("com.tencent.mm", PeripheralType.SERVO).metaData.getInt("com.tencent.mm.BuildInfo.OPEN_SDK_VERSION", 0);
} catch (Exception e) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "get from metaData failed : " + e.getMessage());
return i;
}
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean handleIntent(Intent intent, IWXAPIEventHandler iWXAPIEventHandler) {
try {
} catch (Exception e) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "handleIntent fail, ex = " + e.getMessage());
}
if (!WXApiImplComm.isIntentFromWx(intent, ConstantsAPI.Token.WX_TOKEN_VALUE_MSG)) {
com.tencent.mm.opensdk.utils.Log.i(TAG, "handleIntent fail, intent not from weixin msg");
return false;
}
if (this.detached) {
throw new IllegalStateException("handleIntent fail, WXMsgImpl has been detached");
}
String stringExtra = intent.getStringExtra(ConstantsAPI.CONTENT);
int intExtra = intent.getIntExtra(ConstantsAPI.SDK_VERSION, 0);
String stringExtra2 = intent.getStringExtra(ConstantsAPI.APP_PACKAGE);
if (stringExtra2 != null && stringExtra2.length() != 0) {
if (!checkSumConsistent(intent.getByteArrayExtra(ConstantsAPI.CHECK_SUM), b.a(stringExtra, intExtra, stringExtra2))) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "checksum fail");
return false;
}
int intExtra2 = intent.getIntExtra("_wxapi_command_type", 0);
com.tencent.mm.opensdk.utils.Log.i(TAG, "handleIntent, cmd = " + intExtra2);
switch (intExtra2) {
case 1:
iWXAPIEventHandler.onResp(new SendAuth.Resp(intent.getExtras()));
return true;
case 2:
iWXAPIEventHandler.onResp(new SendMessageToWX.Resp(intent.getExtras()));
return true;
case 3:
iWXAPIEventHandler.onReq(new GetMessageFromWX.Req(intent.getExtras()));
return true;
case 4:
ShowMessageFromWX.Req req = new ShowMessageFromWX.Req(intent.getExtras());
String str = req.message.messageExt;
if (str == null || !str.contains("wx_internal_resptype")) {
iWXAPIEventHandler.onReq(req);
return true;
}
boolean handleWxInternalRespType = handleWxInternalRespType(str, iWXAPIEventHandler);
com.tencent.mm.opensdk.utils.Log.i(TAG, "handleIntent, extInfo contains wx_internal_resptype, ret = " + handleWxInternalRespType);
return handleWxInternalRespType;
case 5:
iWXAPIEventHandler.onResp(new PayResp(intent.getExtras()));
return true;
case 6:
iWXAPIEventHandler.onReq(new LaunchFromWX.Req(intent.getExtras()));
return true;
case 7:
case 8:
case 10:
case 11:
case 13:
default:
com.tencent.mm.opensdk.utils.Log.e(TAG, "unknown cmd = " + intExtra2);
return false;
case 9:
iWXAPIEventHandler.onResp(new AddCardToWXCardPackage.Resp(intent.getExtras()));
return true;
case 12:
iWXAPIEventHandler.onResp(new OpenWebview.Resp(intent.getExtras()));
return true;
case 14:
iWXAPIEventHandler.onResp(new CreateChatroom.Resp(intent.getExtras()));
return true;
case 15:
iWXAPIEventHandler.onResp(new JoinChatroom.Resp(intent.getExtras()));
return true;
case 16:
iWXAPIEventHandler.onResp(new ChooseCardFromWXCardPackage.Resp(intent.getExtras()));
return true;
case 17:
iWXAPIEventHandler.onResp(new HandleScanResult.Resp(intent.getExtras()));
return true;
}
}
com.tencent.mm.opensdk.utils.Log.e(TAG, "invalid argument");
return false;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean isWXAppInstalled() {
if (this.detached) {
throw new IllegalStateException("isWXAppInstalled fail, WXMsgImpl has been detached");
}
try {
PackageInfo packageInfo = this.context.getPackageManager().getPackageInfo("com.tencent.mm", 64);
if (packageInfo == null) {
return false;
}
return WXApiImplComm.validateAppSignature(this.context, packageInfo.signatures, this.checkSignature);
} catch (PackageManager.NameNotFoundException unused) {
return false;
}
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean isWXAppSupportAPI() {
if (this.detached) {
throw new IllegalStateException("isWXAppSupportAPI fail, WXMsgImpl has been detached");
}
return getWXAppSupportAPI() >= 620756998;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean openWXApp() {
String str;
if (this.detached) {
throw new IllegalStateException("openWXApp fail, WXMsgImpl has been detached");
}
if (isWXAppInstalled()) {
try {
this.context.startActivity(this.context.getPackageManager().getLaunchIntentForPackage("com.tencent.mm"));
return true;
} catch (Exception e) {
str = "startActivity fail, exception = " + e.getMessage();
}
} else {
str = "open wx app failed, not installed or signature check failed";
}
com.tencent.mm.opensdk.utils.Log.e(TAG, str);
return false;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean registerApp(String str) {
return registerApp(str, 0L);
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean registerApp(String str, long j) {
Application application;
if (this.detached) {
throw new IllegalStateException("registerApp fail, WXMsgImpl has been detached");
}
if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "register app failed for wechat app signature check failed");
return false;
}
com.tencent.mm.opensdk.utils.Log.d(TAG, "registerApp, appId = " + str);
if (str != null) {
this.appId = str;
}
if (activityCb == null && Build.VERSION.SDK_INT >= 14) {
Context context = this.context;
if (context instanceof Activity) {
initMta(context, str);
activityCb = new ActivityLifecycleCb(this.context);
application = ((Activity) this.context).getApplication();
} else if (context instanceof Service) {
initMta(context, str);
activityCb = new ActivityLifecycleCb(this.context);
application = ((Service) this.context).getApplication();
} else {
com.tencent.mm.opensdk.utils.Log.w(TAG, "context is not instanceof Activity or Service, disable WXStat");
}
application.registerActivityLifecycleCallbacks(activityCb);
}
com.tencent.mm.opensdk.utils.Log.d(TAG, "registerApp, appId = " + str);
if (str != null) {
this.appId = str;
}
com.tencent.mm.opensdk.utils.Log.d(TAG, "register app " + this.context.getPackageName());
a.C0015a c0015a = new a.C0015a();
c0015a.W = "com.tencent.mm";
c0015a.action = ConstantsAPI.ACTION_HANDLE_APP_REGISTER;
c0015a.content = "weixin://registerapp?appid=" + this.appId;
c0015a.X = j;
return a.a(this.context, c0015a);
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean sendReq(BaseReq baseReq) {
StringBuilder sb;
String str;
String str2;
if (this.detached) {
throw new IllegalStateException("sendReq fail, WXMsgImpl has been detached");
}
if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
str2 = "sendReq failed for wechat app signature check failed";
} else {
if (baseReq.checkArgs()) {
com.tencent.mm.opensdk.utils.Log.i(TAG, "sendReq, req type = " + baseReq.getType());
Bundle bundle = new Bundle();
baseReq.toBundle(bundle);
if (baseReq.getType() == 5) {
return sendPayReq(this.context, bundle);
}
if (baseReq.getType() == 7) {
return sendJumpToBizProfileReq(this.context, bundle);
}
if (baseReq.getType() == 8) {
return sendJumpToBizWebviewReq(this.context, bundle);
}
if (baseReq.getType() == 10) {
return sendJumpToBizTempSessionReq(this.context, bundle);
}
if (baseReq.getType() == 9) {
return sendAddCardToWX(this.context, bundle);
}
if (baseReq.getType() == 16) {
return sendChooseCardFromWX(this.context, bundle);
}
if (baseReq.getType() == 11) {
return sendOpenRankListReq(this.context, bundle);
}
if (baseReq.getType() == 12) {
return sendOpenWebview(this.context, bundle);
}
if (baseReq.getType() == 13) {
return sendOpenBusiLuckyMoney(this.context, bundle);
}
if (baseReq.getType() == 14) {
return createChatroom(this.context, bundle);
}
if (baseReq.getType() == 15) {
return joinChatroom(this.context, bundle);
}
if (baseReq.getType() == 17) {
return sendHandleScanResult(this.context, bundle);
}
if (baseReq.getType() == 18) {
return sendSubscribeMessage(this.context, baseReq);
}
if (baseReq.getType() == 2 && bundle.getInt("_wxapi_sendmessagetowx_req_media_type") == 36) {
SendMessageToWX.Req req = (SendMessageToWX.Req) baseReq;
if (getWXAppSupportAPI() < 620756993) {
WXWebpageObject wXWebpageObject = new WXWebpageObject();
wXWebpageObject.webpageUrl = bundle.getString("_wxminiprogram_webpageurl");
req.message.mediaObject = wXWebpageObject;
} else {
WXMiniProgramObject wXMiniProgramObject = (WXMiniProgramObject) req.message.mediaObject;
wXMiniProgramObject.userName += "@app";
String str3 = wXMiniProgramObject.path;
if (!d.h(str3)) {
String[] split = str3.split("\\?");
if (split.length > 1) {
sb = new StringBuilder();
sb.append(split[0]);
sb.append(".html?");
str = split[1];
} else {
sb = new StringBuilder();
sb.append(split[0]);
str = ".html";
}
sb.append(str);
wXMiniProgramObject.path = sb.toString();
}
}
req.scene = 0;
baseReq.toBundle(bundle);
}
MMessageActV2.Args args = new MMessageActV2.Args();
args.bundle = bundle;
args.content = "weixin://sendreq?appid=" + this.appId;
args.targetPkgName = "com.tencent.mm";
args.targetClassName = "com.tencent.mm.plugin.base.stub.WXEntryActivity";
return MMessageActV2.send(this.context, args);
}
str2 = "sendReq checkArgs fail";
}
com.tencent.mm.opensdk.utils.Log.e(TAG, str2);
return false;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final boolean sendResp(BaseResp baseResp) {
String str;
if (this.detached) {
throw new IllegalStateException("sendResp fail, WXMsgImpl has been detached");
}
if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
str = "sendResp failed for wechat app signature check failed";
} else {
if (baseResp.checkArgs()) {
Bundle bundle = new Bundle();
baseResp.toBundle(bundle);
MMessageActV2.Args args = new MMessageActV2.Args();
args.bundle = bundle;
args.content = "weixin://sendresp?appid=" + this.appId;
args.targetPkgName = "com.tencent.mm";
args.targetClassName = "com.tencent.mm.plugin.base.stub.WXEntryActivity";
return MMessageActV2.send(this.context, args);
}
str = "sendResp checkArgs fail";
}
com.tencent.mm.opensdk.utils.Log.e(TAG, str);
return false;
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final void setLogImpl(ILog iLog) {
com.tencent.mm.opensdk.utils.Log.setLogImpl(iLog);
}
@Override // com.tencent.mm.opensdk.openapi.IWXAPI
public final void unregisterApp() {
if (this.detached) {
throw new IllegalStateException("unregisterApp fail, WXMsgImpl has been detached");
}
if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "unregister app failed for wechat app signature check failed");
return;
}
com.tencent.mm.opensdk.utils.Log.d(TAG, "unregisterApp, appId = " + this.appId);
String str = this.appId;
if (str == null || str.length() == 0) {
com.tencent.mm.opensdk.utils.Log.e(TAG, "unregisterApp fail, appId is empty");
return;
}
com.tencent.mm.opensdk.utils.Log.d(TAG, "unregister app " + this.context.getPackageName());
a.C0015a c0015a = new a.C0015a();
c0015a.W = "com.tencent.mm";
c0015a.action = ConstantsAPI.ACTION_HANDLE_APP_UNREGISTER;
c0015a.content = "weixin://unregisterapp?appid=" + this.appId;
a.a(this.context, c0015a);
}
}