TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c
以下内容为反编译后的 MusicGeneWebViewPlugin.java 源代码,内容仅作参考
package com.tencent.mobileqq.musicgene;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.text.TextUtils;
import com.tencent.biz.pubaccount.CustomWebView;
import com.tencent.mobileqq.app.AppConstants;
import com.tencent.mobileqq.app.ThreadManager;
import com.tencent.mobileqq.mqsafeedit.MD5;
import com.tencent.mobileqq.music.IQQPlayerCallback;
import com.tencent.mobileqq.music.IQQPlayerService;
import com.tencent.mobileqq.music.QQPlayerService;
import com.tencent.mobileqq.music.SongInfo;
import com.tencent.mobileqq.musicpendant.MusicPendantManager;
import com.tencent.mobileqq.utils.Base64Util;
import com.tencent.mobileqq.webview.swift.JsBridgeListener;
import com.tencent.mobileqq.webview.swift.WebUiBaseInterface;
import com.tencent.mobileqq.webview.swift.WebViewPlugin;
import com.tencent.mobileqq.webview.swift.WebviewPluginEventConfig;
import com.tencent.mobileqq.webviewplugin.WebUiUtils;
import com.tencent.qphone.base.util.QLog;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Timer;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MusicGeneWebViewPlugin extends WebViewPlugin {
private static final String A = "data";
private static final String B = "list";
private static final String C = "uin";
private static final String D = "geneId";
private static final String E = "index";
private static final String F = "state";
private static final String G = "code";
private static final String H = "playUrl";
private static final String I = "songPage";
private static final String J = "songId";
private static final String K = "songName";
private static final String L = "singerName";
private static final String M = "albumName";
private static final String N = "albumImg";
private static final String O = "curTime";
private static final String P = "totalTime";
private static final String Q = "type";
private static final String R = "volume";
private static final String S = "imgUrl";
private static final String T = "title";
private static final String U = "desc";
private static final String V = "src";
private static final String W = "audioUrl";
private static final String X = "appid";
private static final String Y = "iconUrl";
private static final String Z = "geneType";
public static final long f90842a = 1101244924;
public static final String f25187a = "2ua27x0nPOgcDHFM";
private static final String aA = "CALLPAGE_SHARE";
private static final String aB = "playType";
private static final String aa = "degree";
private static final String ab = "pageUrl";
private static final String ac = "0";
private static final String ad = "1";
private static final String ae = "0";
private static final String af = "webCallApp";
private static final String ag = "bindApp";
private static final String ah = "unbindApp";
private static final String ai = "SONG_PLAY";
private static final String aj = "SONG_PAUSE";
private static final String ak = "SONG_RESUME";
private static final String al = "SONG_STOP";
private static final String am = "SONG_PLAY_NEXT";
private static final String an = "SONG_PLAY_PREV";
private static final String ao = "SONG_GET_SONG_INFO";
private static final String ap = "SONG_GET_LIST_INFO";
private static final String aq = "SONG_SET_PLAYMODE";
private static final String ar = "SONG_SET_VOLUME";
private static final String as = "SONG_GET_VOLUME";
private static final String at = "DO_MACK_IMG";
private static final String au = "SHARE_SONG";
private static final String av = "SHARE_GENE";
private static final String aw = "MANUAL_INIT";
private static final String ax = "CALLPAGE_SONG_STATE_CHANGE";
private static final String ay = "CALLPAGE_SONG_TIME_UPDATE";
private static final String az = "DO_MACK_IMG_CALLBACK";
private static final long f90843b = 1000;
public static final String f25188b = "http://qzonestyle.gtimg.cn/ac/qzone/applogo/16/308/100497308_16.gif";
public static final String f90844c = "http://y.qq.com/m/recent_listen/play.html?uin=%s&_bid=266&_wv=14115";
public static final String d = "http://y.qq.com/m/gene/play.html";
public static final String e = "com.tencent.tim.BROAD_CAST_SHARE_MUSIC_GENE";
public static final String f = "com.tencent.tim.BROAD_CAST_SHARE_SONG";
public static final String g = "com.tencent.tim.BROAD_CAST_CALL_PAGE_SHARE";
public static final String h = "com.tencent.tim.BROAD_CAST_UPDATE_TITLE";
public static final String i = "BUNDLE_KEY_TITLE";
public static final String j = "BUNDLE_KEY_DESC";
public static final String k = "BUDNLE_KEY_IMG_URL";
public static final String l = "BUNDLE_KEY_SRC";
public static final String m = "BUNDLE_KEY_AUDIO_URL";
public static final String n = "BUNDKE_KEY_APP_ID";
public static final String o = "BUNDLE_KEY_ICON_URL";
public static final String p = "BUNDLE_KEY_UIN";
public static final String q = "BUNDLE_KEY_GENE_ID";
public static final String r = "BUDNLE_KEY_IS_MY_PROFILE";
public static final String s = "BUNDLE_KEY_URL";
public static final String t = "BUNDLE_KEY_FROM_PLAY_BAR";
public static final String u = "BUNDLE_KEY_JSONARRAY_SONG_LIST";
public static final String v = "BUNDLE_KEY_PLAY_TYPE";
public static final String w = "qqmusic";
private static final String x = MusicGeneWebViewPlugin.class.getSimpleName();
private static final String y = "BUNDLE_KEY_FILE_PATH";
private static final String z = "action";
private int f25189a;
private Context f25191a;
private IQQPlayerService f25195a;
private SongInfo f25196a;
private JsBridgeListener f25197a;
private boolean f25199a;
private int f25200b;
private boolean f25201b;
private int f25202c;
private Timer f25198a = new Timer();
private ServiceConnection f25192a = new smx(this);
private IQQPlayerCallback.Stub f25194a = new smy(this);
private BroadcastReceiver f25190a = new smz(this);
private Handler f25193a = new sna(this, Looper.getMainLooper());
public MusicGeneWebViewPlugin() {
this.mPluginNameSpace = w;
}
private HashMap a(JSONArray jSONArray) {
HashMap hashMap = new HashMap();
int i2 = 0;
while (true) {
try {
int i3 = i2;
if (i3 >= jSONArray.length()) {
break;
}
JSONObject jSONObject = (JSONObject) jSONArray.get(i3);
if (jSONObject != null) {
hashMap.put(jSONObject.getString(J), jSONObject);
}
i2 = i3 + 1;
} catch (JSONException e2) {
e2.printStackTrace();
}
}
return hashMap;
}
@Override
public void onCreate() {
Activity a2 = this.mRuntime.a();
if (a2 != null) {
this.f25191a = a2.getApplicationContext();
}
super.onCreate();
}
@Override
public void onWebViewCreated(CustomWebView customWebView) {
String url;
WebUiBaseInterface a2;
super.onWebViewCreated(customWebView);
if (customWebView == null) {
url = "";
} else {
try {
url = customWebView.getUrl();
} catch (Exception e2) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.onCreate exception", e2);
return;
}
}
String currentUrl = (TextUtils.isEmpty(url) && (a2 = this.mRuntime.a(this.mRuntime.a())) != null && (a2 instanceof WebUiUtils.WebUiMethodInterface)) ? ((WebUiUtils.WebUiMethodInterface) a2).getCurrentUrl() : url;
if (this.f25191a != null) {
if (m7065a(currentUrl)) {
this.f25191a.bindService(new Intent(this.f25191a, QQPlayerService.class), this.f25192a, 33);
}
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(g);
this.f25191a.registerReceiver(this.f25190a, intentFilter);
}
}
public void a(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream;
if (bitmap != null) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new ByteArrayOutputStream());
String str = "data:image\\/jpg;base64," + Base64Util.encodeToString(byteArrayOutputStream.toByteArray(), 0);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", "0");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put(S, str);
jSONObject.put("data", jSONObject2);
} catch (JSONException e2) {
e2.printStackTrace();
}
callJs(String.format("try{qqmusicBridge.appTrigger('%s', %s);}catch(e){}", az, jSONObject));
}
}
@Override
public boolean handleJsRequest(JsBridgeListener jsBridgeListener, String str, String str2, String str3, String... strArr) {
int i2;
JSONObject jSONObject;
JSONObject jSONObject2;
long j2;
String str4;
AudioManager audioManager;
int i3;
String str5;
AudioManager audioManager2;
Bundle bundle;
JSONObject jSONObject3;
String str6;
JSONArray jSONArray;
Bundle bundle2;
JSONObject jSONObject4;
int i4;
String str7;
JSONArray jSONArray2;
Intent intent;
ArrayList arrayList = new ArrayList(Arrays.asList(strArr));
if (w.equals(str2)) {
if (af.equals(str3)) {
try {
jSONObject = new JSONObject((String) arrayList.get(0));
} catch (Exception e2) {
e2.printStackTrace();
}
if (jSONObject.has("action")) {
String string = jSONObject.getString("action");
if (!jSONObject.has("data")) {
jSONObject2 = null;
} else {
jSONObject2 = jSONObject.getJSONObject("data");
}
if (jSONObject2 != null && jSONObject2.has(aB)) {
this.f25202c = jSONObject2.getInt(aB);
} else {
this.f25202c = 0;
}
if (aw.equals(string)) {
try {
QLog.e(x, 1, "MusicGeneWebViewPlugin.handle js request: MANUAL_INIT");
if (this.f25195a == null) {
this.f25197a = jsBridgeListener;
d();
} else {
JSONObject jSONObject5 = new JSONObject();
jSONObject5.put("code", "0");
jsBridgeListener.a((Object) jSONObject5);
}
} catch (Exception e3) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.handle js request get exception in ACTION_MANUAL_INIT", e3);
}
return true;
}
IQQPlayerService iQQPlayerService = this.f25195a;
if (iQQPlayerService == null) {
return false;
}
if (ai.equals(string)) {
String str8 = "1";
SongInfo[] a2 = a(jSONObject2);
if (a2 != null) {
long j3 = 0;
if (!jSONObject2.has("index")) {
i4 = 0;
} else {
i4 = jSONObject2.getInt("index");
}
if (!jSONObject2.has(D)) {
str7 = "0";
} else {
str7 = jSONObject2.getString(D);
}
if (jSONObject2.has("uin")) {
j3 = jSONObject2.getLong("uin");
}
if (jSONObject2.has(Z)) {
jSONObject2.getString(Z);
}
if (!jSONObject2.has("list")) {
jSONArray2 = null;
} else {
jSONArray2 = jSONObject2.getJSONArray("list");
}
String valueOf = String.valueOf(j3);
if (m7067c()) {
intent = MusicPendantManager.a(this.f25191a, this.mRuntime.m9632a(), valueOf, false);
} else {
intent = new Intent(this.f25191a, MusicPlayerActivity.class);
String format = String.format(f90844c, valueOf);
intent.putExtra("uin", valueOf);
intent.putExtra("url", format);
intent.putExtra(t, true);
}
if (jSONObject2.has("pageUrl")) {
String string2 = jSONObject2.getString("pageUrl");
if (!TextUtils.isEmpty(string2)) {
intent.putExtra("url", string2);
}
}
Bundle bundle3 = new Bundle();
bundle3.putLong(p, j3);
bundle3.putString(q, str7);
bundle3.putInt(v, this.f25202c);
if (jSONArray2 != null) {
bundle3.putString(u, jSONArray2.toString());
}
bundle3.putString("data", jSONObject2.toString());
try {
iQQPlayerService.a(bundle3);
iQQPlayerService.a(this.f25194a);
if (intent != null) {
iQQPlayerService.a(intent);
}
if (m7067c()) {
iQQPlayerService.a(102);
} else {
iQQPlayerService.a(103);
}
iQQPlayerService.a(m7058a(), a2, i4);
} catch (Exception e4) {
e4.printStackTrace();
}
str8 = "0";
}
JSONObject jSONObject6 = new JSONObject();
jSONObject6.put("code", str8);
jsBridgeListener.a((Object) jSONObject6);
} else if (aj.equals(string)) {
this.f25200b = iQQPlayerService.d();
iQQPlayerService.mo7009a();
JSONObject jSONObject7 = new JSONObject();
jSONObject7.put("code", "0");
jsBridgeListener.a((Object) jSONObject7);
} else if (ak.equals(string)) {
iQQPlayerService.mo7012b();
JSONObject jSONObject8 = new JSONObject();
jSONObject8.put("code", "0");
jsBridgeListener.a((Object) jSONObject8);
} else if (al.equals(string)) {
iQQPlayerService.mo7013c();
JSONObject jSONObject9 = new JSONObject();
jSONObject9.put("code", "0");
jsBridgeListener.a((Object) jSONObject9);
} else if (am.equals(string)) {
iQQPlayerService.mo7014d();
JSONObject jSONObject10 = new JSONObject();
jSONObject10.put("code", "0");
jsBridgeListener.a((Object) jSONObject10);
} else if (an.equals(string)) {
iQQPlayerService.mo7015e();
JSONObject jSONObject11 = new JSONObject();
jSONObject11.put("code", "0");
jsBridgeListener.a((Object) jSONObject11);
} else if (ao.equals(string)) {
Bundle bundle4 = null;
try {
bundle4 = iQQPlayerService.mo7006a();
if (bundle4 == null || !bundle4.containsKey("data")) {
jSONObject4 = null;
} else {
jSONObject4 = new JSONObject(bundle4.getString("data"));
}
bundle2 = bundle4;
} catch (Exception e5) {
e5.printStackTrace();
bundle2 = bundle4;
jSONObject4 = null;
}
JSONObject jSONObject12 = jSONObject4 == null ? new JSONObject() : jSONObject4;
SongInfo m7056a = m7056a();
int i5 = bundle2 != null ? bundle2.getInt(v, 0) : 0;
long j4 = (bundle2 == null || !bundle2.containsKey(p)) ? 0L : bundle2.getLong(p);
if (m7056a != null) {
JSONObject jSONObject13 = null;
if (bundle2 != null && bundle2.containsKey(u)) {
jSONObject13 = (JSONObject) a(new JSONArray(bundle2.getString(u))).get(String.valueOf(m7056a.f25176a));
}
JSONObject a3 = jSONObject13 == null ? a(m7056a) : jSONObject13;
if (a3 != null) {
Iterator<String> keys = a3.keys();
while (keys.hasNext()) {
String next = keys.next();
jSONObject12.put(next, a3.get(next));
}
}
long a4 = a();
int a5 = iQQPlayerService.a();
int b2 = b(a5);
long d2 = a5 == 3 ? this.f25200b : iQQPlayerService.d();
if (m7066b()) {
jSONObject12.put("code", "0");
} else {
jSONObject12.put("code", "0");
}
jSONObject12.put(O, d2 / 1000);
jSONObject12.put(P, a4 / 1000);
jSONObject12.put("state", b2);
jSONObject12.put(aB, i5);
} else {
jSONObject12.put("code", "1");
jSONObject12.put(aB, i5);
}
if (!jSONObject12.has("uin")) {
jSONObject12.put("uin", j4);
}
jsBridgeListener.a((Object) jSONObject12);
} else if (ap.equals(string)) {
Bundle bundle5 = null;
try {
bundle5 = iQQPlayerService.mo7006a();
if (bundle5 == null || !bundle5.containsKey("data")) {
jSONObject3 = null;
} else {
jSONObject3 = new JSONObject(bundle5.getString("data"));
}
bundle = bundle5;
} catch (Exception e6) {
e6.printStackTrace();
bundle = bundle5;
jSONObject3 = null;
}
JSONObject jSONObject14 = jSONObject3 == null ? new JSONObject() : jSONObject3;
int i6 = bundle != null ? bundle.getInt(v, 0) : 0;
long j5 = (bundle == null || !bundle.containsKey(p)) ? 0L : bundle.getLong(p);
JSONArray jSONArray3 = null;
String str9 = "0";
if (bundle != null) {
str9 = bundle.containsKey(q) ? bundle.getString(q) : "0";
if (bundle.containsKey(u)) {
jSONArray3 = new JSONArray(bundle.getString(u));
str6 = str9;
int i7 = 0;
if (jSONArray3 != null) {
JSONArray jSONArray4 = new JSONArray();
SongInfo[] mo7011a = iQQPlayerService.mo7011a();
SongInfo m7056a2 = m7056a();
if (mo7011a != null) {
for (int i8 = 0; i8 < mo7011a.length; i8++) {
SongInfo songInfo = mo7011a[i8];
if (songInfo != null) {
jSONArray4.put(i8, a(songInfo));
if (m7056a2 != null && songInfo.f25176a == m7056a2.f25176a) {
i7 = i8;
}
}
}
}
jSONArray = jSONArray4;
} else {
SongInfo[] mo7011a2 = iQQPlayerService.mo7011a();
SongInfo m7056a3 = m7056a();
if (mo7011a2 != null) {
for (int i9 = 0; i9 < mo7011a2.length; i9++) {
SongInfo songInfo2 = mo7011a2[i9];
if (songInfo2 != null && songInfo2.f25176a == m7056a3.f25176a) {
i7 = i9;
}
}
}
jSONArray = jSONArray3;
}
jSONObject14.put("index", i7);
jSONObject14.put("state", b(iQQPlayerService.a()));
if (!jSONObject14.has(D)) {
jSONObject14.put(D, str6);
}
jSONObject14.put("list", jSONArray);
if (!m7066b()) {
jSONObject14.put("code", "0");
} else {
jSONObject14.put("code", "0");
}
if (!jSONObject14.has("uin")) {
jSONObject14.put("uin", j5);
}
jSONObject14.put(aB, i6);
jsBridgeListener.a((Object) jSONObject14);
}
}
str6 = str9;
int i72 = 0;
if (jSONArray3 != null) {
}
jSONObject14.put("index", i72);
jSONObject14.put("state", b(iQQPlayerService.a()));
if (!jSONObject14.has(D)) {
}
jSONObject14.put("list", jSONArray);
if (!m7066b()) {
}
if (!jSONObject14.has("uin")) {
}
jSONObject14.put(aB, i6);
jsBridgeListener.a((Object) jSONObject14);
} else if (aq.equals(string)) {
int i10 = 103;
if (jSONObject2 != null && jSONObject2.has("type")) {
i10 = jSONObject2.getInt("type");
}
iQQPlayerService.a(a(i10));
JSONObject jSONObject15 = new JSONObject();
jSONObject15.put("code", "0");
jsBridgeListener.a((Object) jSONObject15);
} else if (ar.equals(string)) {
if (jSONObject2 == null || !jSONObject2.has(R)) {
i3 = 0;
} else {
i3 = jSONObject2.getInt(R);
}
JSONObject jSONObject16 = new JSONObject();
Context context = this.f25191a;
if (context == null || i3 < 0 || i3 > 100 || (audioManager2 = (AudioManager) context.getSystemService("audio")) == null) {
str5 = "1";
} else {
audioManager2.setStreamVolume(3, (audioManager2.getStreamMaxVolume(3) * i3) / 100, 4);
str5 = "0";
}
jSONObject16.put("code", str5);
jsBridgeListener.a((Object) jSONObject16);
} else if (at.equals(string)) {
String string3 = (jSONObject2 == null || !jSONObject2.has(S)) ? "" : jSONObject2.getString(S);
int i11 = jSONObject2.has(aa) ? jSONObject2.getInt(aa) : 0;
File file = new File(new File(AppConstants.bC + File.separator + AppConstants.cE), MD5.toMD5(string3));
if (file == null || !file.exists()) {
ThreadManager.a(new snb(this, string3, i11, file), 8, null, true);
} else {
try {
a(BitmapFactory.decodeFile(file.getPath()));
} catch (Exception e7) {
e7.printStackTrace();
} catch (OutOfMemoryError e8) {
e8.printStackTrace();
}
}
JSONObject jSONObject17 = new JSONObject();
jSONObject17.put("code", "0");
jsBridgeListener.a((Object) jSONObject17);
} else if (as.equals(string)) {
Context context2 = this.f25191a;
JSONObject jSONObject18 = new JSONObject();
if (context2 == null || (audioManager = (AudioManager) context2.getSystemService("audio")) == null) {
str4 = "1";
} else {
float streamMaxVolume = audioManager.getStreamMaxVolume(3);
float streamVolume = audioManager.getStreamVolume(3);
int i12 = (int) streamVolume;
if (streamMaxVolume > 0.0f) {
i12 = (int) ((streamVolume / streamMaxVolume) * 100.0f);
}
jSONObject18.put(R, i12);
str4 = "0";
}
jSONObject18.put("code", str4);
jsBridgeListener.a((Object) jSONObject18);
} else if (au.equals(string)) {
String string4 = jSONObject2.getString("title");
String string5 = jSONObject2.getString("desc");
String string6 = jSONObject2.getString(S);
String string7 = jSONObject2.getString("src");
String string8 = jSONObject2.getString("audioUrl");
String str10 = f25188b;
if (jSONObject2.has(Y)) {
str10 = jSONObject2.getString(Y);
}
if (this.f25191a != null) {
Intent intent2 = new Intent(f);
intent2.putExtra(i, string4);
intent2.putExtra(j, string5);
intent2.putExtra(k, string6);
intent2.putExtra(l, string7);
intent2.putExtra(m, string8);
intent2.putExtra(o, str10);
this.f25191a.sendBroadcast(intent2, "com.tencent.music.data.permission");
}
JSONObject jSONObject19 = new JSONObject();
jSONObject19.put("code", "0");
jsBridgeListener.a((Object) jSONObject19);
} else if (av.equals(string)) {
String string9 = jSONObject2.getString("title");
String string10 = jSONObject2.getString("desc");
String string11 = jSONObject2.getString(S);
String string12 = jSONObject2.getString("src");
if (!jSONObject2.has("appid")) {
j2 = 1101244924;
} else {
j2 = jSONObject2.getLong("appid");
}
String str11 = f25188b;
if (jSONObject2.has(Y)) {
str11 = jSONObject2.getString(Y);
}
if (this.f25191a != null) {
Intent intent3 = new Intent(e);
intent3.putExtra(i, string9);
intent3.putExtra(j, string10);
intent3.putExtra(k, string11);
intent3.putExtra(l, string12);
intent3.putExtra(n, j2);
intent3.putExtra(o, str11);
this.f25191a.sendBroadcast(intent3, "com.tencent.music.data.permission");
}
JSONObject jSONObject20 = new JSONObject();
jSONObject20.put("code", "0");
jsBridgeListener.a((Object) jSONObject20);
}
e2.printStackTrace();
}
} else if (ag.equals(str3)) {
try {
JSONObject jSONObject21 = new JSONObject((String) arrayList.get(0));
String str12 = null;
if (jSONObject21.has("action")) {
str12 = jSONObject21.getString("action");
}
try {
Bundle mo7006a = this.f25195a.mo7006a();
i2 = mo7006a != null ? mo7006a.getInt(v, 0) : 0;
} catch (Exception e9) {
e9.printStackTrace();
i2 = 0;
}
if (ax.equals(str12)) {
this.f25199a = true;
JSONObject jSONObject22 = new JSONObject();
jSONObject22.put(aB, i2);
jSONObject22.put("code", "0");
jsBridgeListener.a((Object) jSONObject22);
m7059a();
} else if (ay.equals(str12)) {
this.f25201b = true;
JSONObject jSONObject23 = new JSONObject();
jSONObject23.put(aB, i2);
jSONObject23.put("code", "0");
jsBridgeListener.a((Object) jSONObject23);
}
} catch (JSONException e10) {
}
} else if (ah.equals(str3)) {
}
return true;
}
return super.handleJsRequest(jsBridgeListener, str, str2, str3, strArr);
}
private void m7059a() {
this.f25198a.schedule(new snc(this), 1000L, 1000L);
}
private void b() {
this.f25198a.cancel();
}
private SongInfo m7056a() {
SongInfo songInfo = this.f25196a;
if (songInfo == null && this.f25195a != null) {
try {
return this.f25195a.mo7007a();
} catch (Exception e2) {
e2.printStackTrace();
return songInfo;
}
}
return songInfo;
}
private int a() {
if (this.f25189a <= 0 && this.f25195a != null) {
try {
this.f25189a = this.f25195a.c();
} catch (RemoteException e2) {
e2.printStackTrace();
}
}
return this.f25189a;
}
public static Bitmap a(String str) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
return BitmapFactory.decodeStream(httpURLConnection.getInputStream());
} catch (IOException e2) {
e2.printStackTrace();
return null;
} catch (OutOfMemoryError e3) {
e3.printStackTrace();
return null;
}
}
public void c() {
callJs(String.format("try{qqmusicBridge.appTrigger('%s');}catch(e){}", aA));
}
public boolean m7061a() {
Exception exc;
SongInfo songInfo;
int i2;
int i3;
SongInfo songInfo2;
int i4;
String str;
Exception exc2;
int i5;
JSONObject jSONObject;
String str2;
int i6;
JSONObject jSONObject2;
int i7;
JSONObject a2;
int d2;
if (!this.f25201b) {
return false;
}
try {
SongInfo m7056a = m7056a();
try {
d2 = this.f25195a != null ? this.f25195a.d() : 0;
} catch (Exception e2) {
songInfo = m7056a;
exc = e2;
i2 = 0;
}
try {
songInfo2 = m7056a;
i3 = d2;
i4 = a();
} catch (Exception e3) {
i2 = d2;
songInfo = m7056a;
exc = e3;
exc.printStackTrace();
i3 = i2;
songInfo2 = songInfo;
i4 = 0;
String str3 = "0";
if (this.f25195a != null) {
}
if (jSONObject == null) {
}
if (songInfo2 == null) {
}
}
} catch (Exception e4) {
exc = e4;
songInfo = null;
i2 = 0;
}
String str32 = "0";
if (this.f25195a != null) {
i6 = 0;
jSONObject = null;
str2 = "0";
} else {
try {
i6 = b(this.f25195a.a());
} catch (Exception e5) {
str = "0";
exc2 = e5;
i5 = 0;
}
try {
Bundle mo7006a = this.f25195a.mo7006a();
if (mo7006a != null) {
str32 = mo7006a.getString(q);
jSONObject2 = new JSONObject(mo7006a.getString("data"));
} else {
jSONObject2 = null;
}
str2 = str32;
jSONObject = jSONObject2;
} catch (Exception e6) {
i5 = i6;
str = str32;
exc2 = e6;
exc2.printStackTrace();
jSONObject = null;
str2 = str;
i6 = i5;
if (jSONObject == null) {
}
if (songInfo2 == null) {
}
}
}
JSONObject jSONObject3 = jSONObject == null ? new JSONObject() : jSONObject;
if (songInfo2 == null) {
return false;
}
try {
try {
} catch (Exception e7) {
e7.printStackTrace();
}
} catch (Exception e8) {
e8.printStackTrace();
}
if (this.f25195a != null) {
Bundle mo7006a2 = this.f25195a.mo7006a();
i7 = mo7006a2 != null ? mo7006a2.getInt(v, 0) : 0;
a2 = a(songInfo2);
if (a2 != null) {
Iterator<String> keys = a2.keys();
while (keys.hasNext()) {
String next = keys.next();
jSONObject3.put(next, a2.get(next));
}
}
jSONObject3.put(O, i3 / 1000);
jSONObject3.put(P, i4 / 1000);
if (!jSONObject3.has(D)) {
jSONObject3.put(D, str2);
}
jSONObject3.put("state", i6);
jSONObject3.put(aB, i7);
if (jSONObject3 == null) {
callJs(String.format("try{qqmusicBridge.appTrigger('%s', %s);}catch(e){}", ay, jSONObject3.toString()));
return true;
}
return false;
}
i7 = 0;
a2 = a(songInfo2);
if (a2 != null) {
}
jSONObject3.put(O, i3 / 1000);
jSONObject3.put(P, i4 / 1000);
if (!jSONObject3.has(D)) {
}
jSONObject3.put("state", i6);
jSONObject3.put(aB, i7);
if (jSONObject3 == null) {
}
}
private boolean m7066b() {
if (this.f25195a == null) {
return false;
}
try {
String mo7008a = this.f25195a.mo7008a();
String m7058a = m7058a();
if (TextUtils.isEmpty(mo7008a)) {
return false;
}
if (!mo7008a.equals(m7058a)) {
return false;
}
return true;
} catch (RemoteException e2) {
e2.printStackTrace();
return false;
}
}
public boolean m7062a(int i2) {
int i3;
int i4;
IQQPlayerService iQQPlayerService = this.f25195a;
if (!this.f25199a || iQQPlayerService == null) {
return false;
}
try {
i3 = iQQPlayerService.e();
} catch (RemoteException e2) {
e2.printStackTrace();
i3 = 0;
}
int b2 = b(i2);
JSONObject jSONObject = new JSONObject();
try {
try {
Bundle mo7006a = this.f25195a.mo7006a();
i4 = mo7006a != null ? mo7006a.getInt(v, 0) : 0;
} catch (JSONException e3) {
e3.printStackTrace();
}
} catch (Exception e4) {
e4.printStackTrace();
i4 = 0;
}
jSONObject.put("state", b2);
jSONObject.put("index", i3);
jSONObject.put(aB, i4);
if (m7066b()) {
jSONObject.put("code", "0");
} else {
jSONObject.put("code", "0");
}
if (jSONObject != null) {
callJs(String.format("try{qqmusicBridge.appTrigger('%s', %s);}catch(e){}", ax, jSONObject.toString()));
return true;
}
return false;
}
private int a(int i2) {
switch (i2) {
case 0:
return 102;
case 1:
case 2:
default:
return 103;
case 3:
return 101;
}
}
private JSONObject a(SongInfo songInfo) {
JSONObject jSONObject = new JSONObject();
if (songInfo != null) {
jSONObject.put(H, songInfo.f25178a);
jSONObject.put(I, songInfo.f25183e);
jSONObject.put(J, songInfo.f25176a);
jSONObject.put(K, songInfo.f25180b);
jSONObject.put(L, songInfo.f25185g);
jSONObject.put(M, songInfo.f25184f);
jSONObject.put(N, songInfo.f25182d);
}
return jSONObject;
}
private int b(int i2) {
switch (i2) {
case 0:
case 4:
case 5:
case 7:
default:
return 0;
case 1:
return 4;
case 2:
return 1;
case 3:
return 2;
case 6:
return -1001;
}
}
private SongInfo[] a(JSONObject jSONObject) {
if (jSONObject == null || !jSONObject.has("list")) {
return null;
}
JSONArray jSONArray = jSONObject.getJSONArray("list");
SongInfo[] songInfoArr = new SongInfo[jSONArray.length()];
int i2 = 0;
while (true) {
int i3 = i2;
if (i3 >= jSONArray.length()) {
return songInfoArr;
}
JSONObject jSONObject2 = (JSONObject) jSONArray.get(i3);
if (jSONObject2 != null) {
String string = jSONObject2.has(H) ? jSONObject2.getString(H) : "";
String string2 = jSONObject2.has(I) ? jSONObject2.getString(I) : "";
String string3 = jSONObject2.has(J) ? jSONObject2.getString(J) : "";
String string4 = jSONObject2.has(K) ? jSONObject2.getString(K) : "";
String string5 = jSONObject2.has(L) ? jSONObject2.getString(L) : "";
String string6 = jSONObject2.has(M) ? jSONObject2.getString(M) : "";
String string7 = jSONObject2.has(N) ? jSONObject2.getString(N) : "";
SongInfo songInfo = new SongInfo();
songInfo.f25180b = string4;
songInfo.f25178a = string;
songInfo.f25181c = string6;
songInfo.f25182d = string7;
songInfo.f25183e = string2;
songInfo.f25176a = TextUtils.isEmpty(string3) ? 0L : Long.parseLong(string3);
songInfo.f25184f = string6;
songInfo.f25185g = string5;
songInfoArr[i3] = songInfo;
}
i2 = i3 + 1;
}
}
@Override
public boolean handleEvent(String str, long j2, Map map) {
if (j2 == WebviewPluginEventConfig.n && this.f25191a != null) {
Intent intent = new Intent(h);
intent.putExtra(s, str);
this.f25191a.sendBroadcast(intent, "com.tencent.music.data.permission");
}
return super.handleEvent(str, j2, map);
}
@Override
public void onDestroy() {
int i2;
try {
b();
if (this.f25191a != null && this.f25195a != null) {
try {
i2 = this.f25195a.a();
} catch (RemoteException e2) {
e2.printStackTrace();
i2 = 4;
}
if (i2 != 2) {
if (i2 == 3) {
try {
String mo7008a = this.f25195a.mo7008a();
if (mo7008a != null && mo7008a.startsWith("music_gene_")) {
this.f25195a.mo7013c();
}
} catch (RemoteException e3) {
e3.printStackTrace();
}
}
m7062a(4);
}
this.f25191a.unbindService(this.f25192a);
this.f25191a.unregisterReceiver(this.f25190a);
}
} catch (Exception e4) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.onCreate exception", e4);
}
this.f25191a = null;
this.f25197a = null;
super.onDestroy();
}
public static boolean m7065a(String str) {
boolean z2 = false;
try {
if (!TextUtils.isEmpty(str)) {
Uri parse = Uri.parse(str);
String scheme = parse.getScheme();
if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) {
String host = parse.getHost();
if (!TextUtils.isEmpty(host) && (host.contains("y.qq.com") || host.contains("music.qq.com") || host.contains("imgcache.gtimg.cn"))) {
z2 = true;
}
} else {
QLog.e(x, 1, "MusicGeneWebViewPlugin.isURLBelongToQQMusic urlString is not url!");
}
}
} catch (Exception e2) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.isURLBelongToQQMusic exception: " + e2);
}
return z2;
}
private void d() {
try {
if (this.mRuntime != null) {
Activity a2 = this.mRuntime.a();
if (a2 != null) {
if (a2.getApplicationContext() != null) {
a2.bindService(new Intent(a2, QQPlayerService.class), this.f25192a, 33);
}
QLog.e(x, 1, "MusicGeneWebViewPlugin.bindQQPlayerService end!");
return;
}
QLog.e(x, 1, "MusicGeneWebViewPlugin.bindQQPlayerService activity is null!");
return;
}
QLog.e(x, 1, "MusicGeneWebViewPlugin.bindQQPlayerService mRuntime is null!");
} catch (Exception e2) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.bindQQPlayerService exception", e2);
}
}
@Override
public boolean handleSchemaRequest(String str, String str2) {
try {
if (this.f25195a == null && m7065a(str)) {
d();
}
} catch (Exception e2) {
QLog.e(x, 1, "MusicGeneWebViewPlugin.handleSchemaRequest exception", e2);
}
return super.handleSchemaRequest(str, str2);
}
private String m7058a() {
String str = "";
try {
if (m7067c()) {
str = MusicPendantManager.m7078a();
} else {
str = this.f25195a.a(3, x);
}
} catch (Exception e2) {
e2.printStackTrace();
}
return str;
}
private boolean m7067c() {
return 1 == this.f25202c || 2 == this.f25202c;
}
}