package com.tencent.mm.plugin.game; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; import com.google.android.gms.common.Scopes; import com.tencent.mm.R; import com.tencent.mm.app.y0; import com.tencent.mm.ipcinvoker.type.IPCString; import com.tencent.mm.plugin.appbrand.service.d1; import com.tencent.mm.plugin.game.autogen.chatroom.HalfScreen; import com.tencent.mm.plugin.game.autogen.chatroom.JumpInfo; import com.tencent.mm.plugin.game.autogen.chatroom.WeappJumpInfo; import com.tencent.mm.plugin.game.commlib.c; import com.tencent.mm.plugin.game.model.a0; import com.tencent.mm.plugin.game.model.w; import com.tencent.mm.protocal.GeneralControlWrapper; import com.tencent.mm.protocal.JsapiPermissionWrapper; import com.tencent.mm.sdk.platformtools.Log; import com.tencent.mm.sdk.platformtools.MMApplicationContext; import com.tencent.mm.sdk.platformtools.Util; import com.tencent.mm.sdk.platformtools.WeChatProcess; import com.tencent.mm.storage.w1; import com.tencent.mm.ui.MMFragmentActivity; import com.tencent.mm.vfs.VFSStrategy; import com.tencent.mm.vfs.u1; import d60.z; import h92.v0; import h92.w0; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import k92.d; import l92.b3; import l92.c3; import l92.k1; import l92.n3; import l92.o3; import l92.s2; import l92.u2; import l92.w5; import lh4.f0; import lh4.m; import ln.t; import n72.n; import n72.q; import om0.o; import org.json.JSONException; import org.json.JSONObject; import p64.i0; import q82.a; import t72.h; import uz3.f; import wg4.b0; import y82.e; import y82.g; import yz3.e; import yz3.j; import zz3.b; @b(onProcess = {y0.MATCH_MM}) public class l extends e implements n { @Override // n72.n public int D60(Context context, String str, String str2) { s2 s2Var; u2 u2Var; o3 o3Var; String str3; Log.i("MicroMsg.GameExternalService", "fromUsername:%s, toUsername:%s", str, str2); if (context != null && !Util.isNullOrNil(str) && !Util.isNullOrNil(str2)) { k1 i15 = c.i(); if (i15 == null || (s2Var = i15.f251503h) == null || (u2Var = s2Var.f251684d) == null) { Log.i("MicroMsg.GameExternalService", "no Gift info"); } else { Log.i("MicroMsg.GameExternalService", "GiftEntranceType:%d", Integer.valueOf(u2Var.f251727d)); u2 u2Var2 = i15.f251503h.f251684d; int i16 = u2Var2.f251727d; if (i16 != 1) { if (i16 == 2 && (o3Var = u2Var2.f251729f) != null && !Util.isNullOrNil(o3Var.f251604d)) { String str4 = i15.f251503h.f251684d.f251729f.f251605e; if (Util.isNullOrNil(str4)) { str3 = "?from_username=" + URLEncoder.encode(str) + "&to_username=" + URLEncoder.encode(str2); } else { HashMap hashMap = new HashMap(); hashMap.put("from_username", str); hashMap.put("to_username", str2); str3 = q92.c.a(str4, hashMap); } Log.i("MicroMsg.GameExternalService", "Gift Weapp, AppId:%s, Path:%s", i15.f251503h.f251684d.f251729f.f251604d, str3); o3 o3Var2 = i15.f251503h.f251684d.f251729f; String str5 = o3Var2.f251604d; int i17 = o3Var2.f251606f; boolean z15 = q92.c.f287962a; o oVar = new o(); oVar.f277592b = str5; oVar.f277596f = str3; oVar.f277593c = i17; oVar.f277601k = 1079; ((d1) j.c(d1.class)).r80(context, oVar); return 71; } } else if (!Util.isNullOrNil(u2Var2.f251728e)) { HashMap hashMap2 = new HashMap(); hashMap2.put("from_username", str); hashMap2.put("to_username", str2); String a15 = q92.c.a(i15.f251503h.f251684d.f251728e, hashMap2); Log.i("MicroMsg.GameExternalService", "Gift jumpUrl:%s", a15); q92.c.s(context, a15); return 40; } return -1; } } return -1; } @Override // n72.n public void Ez(Context context, n.h hVar, n.f fVar) { m92.b.b(hVar.f269492a, 3, 103, 2, 0, hVar.f269495d, hVar.f269499h, hVar.f269498g); ((xc4.j) xc4.j.f338034d).f(new l$$g(this, hVar, fVar, context)); } @Override // n72.n public void L1(String str, String str2, String str3) { JSONObject jSONObject; Log.i("MicroMsg.GameExternalService", "businessType:%s; appid:%s; extInfo:%s", str, str2, str3); try { JSONObject jSONObject2 = new JSONObject(str3); String optString = jSONObject2.optString("gameMethodName"); String str4 = "1"; if (TextUtils.equals(optString, "openGameCenter")) { String optString2 = jSONObject2.optString("gameParams"); if (Util.isNullOrNil(optString2)) { WN0(Scopes.PROFILE, null, "1", str2, str); return; } try { JSONObject jSONObject3 = new JSONObject(optString2); String optString3 = jSONObject3.optString("fromGameParam"); String optString4 = jSONObject3.optString("profileTabType", str4); String optString5 = jSONObject3.optString("tabKey"); if (Util.isNullOrNil(optString5)) { WN0(Scopes.PROFILE, optString3, optString4, str2, str); } else { WN0(optString5, optString3, optString4, str2, str); } } catch (JSONException unused) { ((t) j.c(t.class)).bc0(str, "json is invalid gameParams is not json", str2, -3, "json is invalid gameParams is not jso"); } } else if (TextUtils.equals(optString, "openGameLifeProfile")) { StringBuilder sb5 = new StringBuilder("https://game.weixin.qq.com/cgi-bin/h5/static/gamelife/homepage.html"); sb5.append("?"); sb5.append("from_appid="); sb5.append(str2); String optString6 = jSONObject2.optString("gameParams"); if (!Util.isNullOrNil(optString6)) { try { jSONObject = new JSONObject(optString6); } catch (JSONException e15) { Log.e("MicroMsg.GameExternalService", e15.getMessage()); jSONObject = null; } if (jSONObject != null) { if (jSONObject.optBoolean("withPkgid", false)) { sb5.append("&wechat_pkgid=gamelife_homepage"); } String optString7 = jSONObject.optString("fromGameParam"); if (!Util.isNullOrNil(optString7)) { try { String encode = URLEncoder.encode(optString7, "UTF-8"); sb5.append("&fromGameParam="); sb5.append(encode); } catch (UnsupportedEncodingException e16) { Log.e("MicroMsg.GameExternalService", e16.getMessage()); } } String optString8 = jSONObject.optString("profileTabType"); if (!Util.isNullOrNil(optString8)) { str4 = optString8; } sb5.append("&tab_type="); sb5.append(str4); } sb5.append("&game_tab_key="); sb5.append(str2); sb5.append("&jump_from=game"); } String sb6 = sb5.toString(); Log.i("MicroMsg.GameExternalService", "before GameJumpUtil.jumpWebView url :%s", sb6); Context context = MMApplicationContext.getContext(); Bundle bundle = new Bundle(); bundle.putBoolean("key_open_by_sdk", true); bundle.putString("key_back_appid", str2); bundle.putString("key_open_business_type", str); Intent intent = new Intent(); intent.putExtra("key_bundle_ext_data", bundle); intent.putExtra("rawUrl", sb6); intent.putExtra("showShare", false); intent.putExtra("show_bottom", false); intent.putExtra("needRedirect", false); intent.putExtra("neverGetA8Key", false); intent.putExtra("hardcode_jspermission", JsapiPermissionWrapper.f173510h); intent.putExtra("hardcode_general_ctrl", GeneralControlWrapper.f173507e); if (!Util.isNullOrNil((String) null)) { intent.putExtra("KGamePreloadData", (String) null); } sv3.b.j(context, "webview", ".ui.tools.WebViewUI", intent, null); } else { ((t) j.c(t.class)).bc0(str, "json is invalid unSupport gameMethodName", str2, -3, "json is invalid unSupport gameMethodName"); } } catch (JSONException unused2) { ((t) j.c(t.class)).bc0(str, "json is invalid", str2, -3, "json is invalid"); } } public final void VN0(Context context, n.h hVar, int i15, n.f fVar) { if (i15 == 2) { m92.b.b(hVar.f269492a, 3, 102, 2, 0, hVar.f269495d, hVar.f269499h, hVar.f269498g); } else { m92.b.b(hVar.f269492a, 3, 101, 2, 0, hVar.f269495d, hVar.f269499h, hVar.f269498g); } if (u1.k(hVar.f269494c)) { d dVar = new d(hVar, i15); i0 e15 = i0.e(context, context.getString(R.string.fnv), true, 3, new l$$c(dVar)); ((xc4.j) xc4.j.f338034d).f(new l$$d(this, dVar, context, e15, fVar, i15, hVar)); } else if (fVar != null) { fVar.a("file not exist"); } } public final void WN0(String str, String str2, String str3, String str4, String str5) { Intent intent = new Intent(); intent.putExtra("start_time", System.currentTimeMillis()); intent.putExtra("default_game_tab_key", str); intent.putExtra("key_game_url_ext_param", str2); Bundle bundle = new Bundle(); bundle.putBoolean("key_open_by_sdk", true); bundle.putString("key_back_appid", str4); bundle.putString("key_open_business_type", str5); intent.putExtra("key_bundle_ext_data", bundle); intent.putExtra("key_game_profile_tab_type", "tab_type=" + str3 + "&game_tab_key=" + str4 + "&jump_from=game"); sv3.b.j(MMApplicationContext.getContext(), "game", ".ui.GameCenterUI", intent, null); } @Override // n72.n public List<n.e> Wx0() { List<a> sb5 = ((q82.c) ((q) j.c(q.class)).DC()).sb(z.b().i()); if (Util.isNullOrNil(sb5)) { return null; } ArrayList arrayList = new ArrayList(); Iterator it = ((ArrayList) sb5).iterator(); while (it.hasNext()) { arrayList.add(XN0((a) it.next())); } return arrayList; } public final n.e XN0(a aVar) { n.e eVar = new n.e(); eVar.f269483b = aVar.field_appId; eVar.f269482a = aVar.field_fileId; eVar.f269485d = aVar.field_filePath; eVar.f269486e = aVar.field_createTime; eVar.f269484c = aVar.field_appName; eVar.f269489h = aVar.field_title; eVar.f269490i = aVar.field_desc; eVar.f269487f = aVar.field_durationSec; eVar.f269488g = aVar.field_coverPath; eVar.f269491j = aVar.field_extJsonData; return eVar; } @Override // n72.n public boolean Xr() { int i15 = m72.a.f258363b; return i15 == 1 || i15 == 3; } @Override // n72.n public void ZK0(w20.b bVar) { m92.b.c(bVar); } @Override // n72.n public void bC(Context context, n.h hVar, n.g gVar) { if (u1.k(hVar.f269494c)) { d dVar = new d(hVar, 3); i0 e15 = i0.e(context, context.getString(R.string.fnv), true, 3, new l$$a(dVar)); ((xc4.j) xc4.j.f338034d).f(new l$$b(this, dVar, context, gVar, e15)); } else if (gVar != null) { gVar.a("file not exist"); } } @Override // n72.n public int dB0(int i15) { int i16 = 2; if (i15 == 1) { i16 = 1; } else if (i15 != 2) { return 0; } return ((q) j.c(q.class)).lw0().Rl(i16); } @Override // n72.n public void di(String str) { ArrayList arrayList = new ArrayList(); arrayList.add(str); ((q82.c) ((q) j.c(q.class)).DC()).Sa(arrayList); } @Override // n72.n public void fX(MMFragmentActivity mMFragmentActivity, n.h hVar, n.f fVar) { VN0(mMFragmentActivity, hVar, 1, fVar); } /* JADX WARNING: Removed duplicated region for block: B:10:0x004b A[Catch:{ all -> 0x0046, all -> 0x005a }] */ /* JADX WARNING: Removed duplicated region for block: B:11:0x0050 A[Catch:{ all -> 0x0046, all -> 0x005a }] */ @Override // n72.n public int gz0() { long j15; q82.b DC = ((q) j.c(q.class)).DC(); String i15 = z.b().i(); q82.c cVar = (q82.c) DC; cVar.getClass(); m.g(i15, "userId"); Cursor rawQuery = cVar.f287799d.rawQuery("SELECT count(*) FROM GameLocalVideoInfo WHERE userId = " + f.e(i15), null, 2); boolean z15 = true; if (rawQuery != null) { try { if (rawQuery.moveToNext()) { if (!z15) { j15 = rawQuery.getLong(0); } else { j15 = 0; } b0 b0Var = b0.f332794a; hh4.b.a(rawQuery, null); return (int) j15; } } catch (Throwable th5) { hh4.b.a(rawQuery, th); throw th5; } } z15 = false; if (!z15) { } b0 b0Var2 = b0.f332794a; hh4.b.a(rawQuery, null); return (int) j15; } @Override // n72.n public void h30(String str, n.d dVar) { boolean z15; boolean z16 = false; if (str == null || str.length() == 0) { z15 = true; } else { z15 = false; } if (!z15) { Uri parse = Uri.parse(str); String str2 = parse.getHost() + parse.getPath(); if (str2 == null || str2.length() == 0) { z16 = true; } if (z16 && dVar != null) { dVar.a(null); } com.tencent.mm.ipcinvoker.o.d(WeChatProcess.PROCESS_MAIN, new IPCString(str2), e.a.class, new g(dVar)); } else if (dVar != null) { dVar.a(null); } } @Override // n72.n public void mH(List<n.h> list, int i15, n.f fVar) { w0 w0Var = new w0(); m.g(list, "videoFiles"); if (!list.isEmpty()) { for (T t15 : list) { String str = t15.f269492a; String str2 = t15.f269495d; m92.b.c(new w20.b(str, 0, 1, 2, 2, 0, t15.f269498g, t15.f269499h, str2, 34, null)); } String b15 = VFSStrategy.b("gameCenterVideos"); ArrayList arrayList = new ArrayList(); ((xc4.j) xc4.j.f338034d).f(new v0(list, b15, w0Var, arrayList, i15, fVar)); } else if (fVar != null) { fVar.a("videoFiles is empty"); } } @Override // n72.n public void n10() { w0 w0Var = new w0(); String i15 = z.b().i(); q82.b DC = ((q) j.c(q.class)).DC(); m.f(i15, "userId"); List<a> sb5 = ((q82.c) DC).sb(i15); ArrayList arrayList = (ArrayList) sb5; if (!arrayList.isEmpty()) { long currentTimeMillis = System.currentTimeMillis(); ArrayList arrayList2 = new ArrayList(); Iterator it = arrayList.iterator(); while (it.hasNext()) { a aVar = (a) it.next(); if (currentTimeMillis - aVar.field_createTime > 2592000000L) { arrayList2.add(aVar.field_fileId); } } if (arrayList2.isEmpty()) { w0Var.b(sb5, 3); return; } ((q82.c) ((q) j.c(q.class)).DC()).Sa(arrayList2); w0Var.b(((q82.c) ((q) j.c(q.class)).DC()).sb(i15), 3); Log.i("MicroMsg.MiniGameVideoProcessor", "gamelog.init , manage video , clearExpiredVideo, expiredVideoIdList size = " + arrayList2.size()); } } @Override // n72.n public void np0() { z.s().i().L(w1.a.U9, Boolean.TRUE); ((xc4.j) xc4.j.f338034d).f(new l$$f(this)); } @Override // n72.n public void oM0(Context context) { c3 c3Var; k1 i15 = c.i(); if (i15 != null && (c3Var = i15.f251500e) != null && !Util.isNullOrNil(c3Var.f251279d)) { q92.c.s(context, i15.f251500e.f251279d); } } @Override // n72.n public void p90(n.a aVar) { if (!((Boolean) z.s().i().f(w1.a.U9, Boolean.FALSE)).booleanValue()) { ((xc4.j) xc4.j.f338034d).f(new l$$e(this, aVar)); } else if (aVar != null) { aVar.a(null); } } @Override // n72.n public void pb() { HalfScreen halfScreen; n3 n3Var = m72.a.f258364c; if (n3Var == null) { Log.e("MicroMsg.GameExternalService", "gamelog.account , manage , jumpAccountPage error ,JumpInfo is null"); return; } Context context = MMApplicationContext.getContext(); JumpInfo jumpInfo = new JumpInfo(); jumpInfo.jump_type = n3Var.f251582d; jumpInfo.jump_url = n3Var.f251583e; b3 b3Var = n3Var.f251585g; WeappJumpInfo weappJumpInfo = null; if (b3Var != null) { halfScreen = new HalfScreen(); halfScreen.type = b3Var.f251251d; halfScreen.screen_height_dp = b3Var.f251252e; halfScreen.screen_height_percent = b3Var.f251253f; } else { halfScreen = null; } jumpInfo.half_screen = halfScreen; w5 w5Var = n3Var.f251584f; if (w5Var != null) { weappJumpInfo = new WeappJumpInfo(); weappJumpInfo.appid = w5Var.f251783d; weappJumpInfo.path = w5Var.f251784e; } jumpInfo.weapp_jump_info = weappJumpInfo; h.h(context, jumpInfo); } /* JADX WARNING: Code restructure failed: missing block: B:17:0x005a, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:18:0x005b, code lost: hh4.b.a(r5, r0); */ /* JADX WARNING: Code restructure failed: missing block: B:19:0x005e, code lost: throw r1; */ @Override // n72.n public n.e q00(String str) { T t15; q82.c cVar = (q82.c) ((q) j.c(q.class)).DC(); cVar.getClass(); if (str == null) { t15 = null; } else { f0 f0Var = new f0(); Cursor rawQuery = cVar.f287799d.rawQuery("SELECT * FROM GameLocalVideoInfo WHERE fileId = " + f.e(str), null, 2); if (rawQuery.moveToFirst()) { T t16 = (T) new a(); t16.convertFrom(rawQuery); f0Var.f253292d = t16; } b0 b0Var = b0.f332794a; hh4.b.a(rawQuery, null); t15 = f0Var.f253292d; } if (t15 != null) { return XN0(t15); } return null; } @Override // n72.n public void q90(int i15) { Log.i("GameAccountManager", "gamelog.account, manage ,jsapi handleAccountStateChanged state = " + i15); if (i15 == 1) { m72.a.a(); z.s().i().L(w1.a.B3, Long.valueOf(System.currentTimeMillis() / ((long) 1000))); m72.a.f258363b = 1; } else if (i15 == 2) { a0 lw02 = ((q) j.c(q.class)).lw0(); lw02.getClass(); lw02.execSQL("GameRawMessage", "update GameRawMessage set isHidden = 0 where isHidden = 2 and showType = 1"); m72.a.f258363b = 0; } else if (i15 == 3) { m72.a.b(); m72.a.f258363b = 0; } else { Log.e("GameAccountManager", "gamelog.account, manage , notify AccountStateChanged state = " + i15); } } @Override // n72.n public String vB(int i15) { String str; int i16; if (i15 == 1) { str = MMApplicationContext.getContext().getString(R.string.fmn); i16 = 1; } else if (i15 != 2) { return ""; } else { str = MMApplicationContext.getContext().getString(R.string.foq); i16 = 2; } Cursor Hh = ((q) j.c(q.class)).lw0().Hh(i16); w wVar = null; if (Hh != null) { if (Hh.moveToFirst()) { wVar = new w(); wVar.convertFrom(Hh); } Hh.close(); } if (wVar == null) { return str; } wVar.q2(); String str2 = wVar.f126113z1.f126142c; if (Util.isNullOrNil(str2)) { str2 = wVar.B1.f126138b; } if (Util.isNullOrNil(str2)) { str2 = MMApplicationContext.getContext().getString(R.string.flm); } int Rl = ((q) j.c(q.class)).lw0().Rl(i16); if (Rl <= 1) { return str2; } return MMApplicationContext.getContext().getString(R.string.fnz, Integer.valueOf(Rl), str2); } @Override // n72.n public void x00(Context context, n.h hVar, n.f fVar) { VN0(context, hVar, 2, fVar); } }