淘歌音乐 v2.0.49版本的 MD5 值为:49b2dab2d28afd9ea0c9c8648d644406
以下内容为反编译后的 UzWx.java 源代码,内容仅作参考
package com.uzmap.pkg.uzmodules.uzWx;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import com.alipay.sdk.cons.a;
import com.apicloud.wxcardpackage.utils.CBReceiver;
import com.apicloud.wxcardpackage.utils.HttpUtils;
import com.deepe.sdk.ViewEntity;
import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
import com.tencent.mm.opensdk.modelbiz.SubscribeMessage;
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXMusicVideoObject;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.uzmap.pkg.uzcore.UZWebView;
import com.uzmap.pkg.uzcore.uzmodule.UZModule;
import com.uzmap.pkg.uzcore.uzmodule.UZModuleContext;
import com.uzmap.pkg.uzkit.UZUtility;
import com.uzmap.pkg.uzmodules.uzWx.method.WxAuth;
import com.uzmap.pkg.uzmodules.uzWx.method.WxShare;
import com.uzmap.pkg.uzmodules.uzWx.tasks.AccessTokenTask;
import com.uzmap.pkg.uzmodules.uzWx.utils.JsParamsUtil;
import com.uzmap.pkg.uzmodules.uzWx.utils.ShareUtils;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class UzWx extends UZModule {
public static String APP_ID = "wx8b8e88944bd7f27f";
public static String access_token = "9_AS9rjr5EkU78OogyNQnV2fT6yydnEkxVA1ISEtTqXeY1yWRUqB_bvHBkKdw4ztctPaKncsz1mydOk1P7hQ9ST2-Bm0oHnY15QbrdRQ0eMgvPtoIFzDesH2Y2cZt8prHdk9WtySgJzaMicISfLEVdABAEXO";
private static WxReceiver mShareReceiver;
public static UZModuleContext miniToApp;
private String APPSECRET;
private IWXAPI api;
private String jsapi_ticket;
private WxAuth mWxAuth;
private WxShare mWxShare;
private String noncestr;
private CBReceiver receiver;
private String timestamp;
private UZModuleContext uzWxCardContext;
public UzWx(UZWebView uZWebView) {
super(uZWebView);
this.APPSECRET = "97bcbcb30b66e46e9ab33f26c55d15d9";
this.jsapi_ticket = "";
this.timestamp = "";
this.noncestr = "noncestr";
String featureValue = getFeatureValue("wxPlus", "androidApiKey");
APP_ID = featureValue;
if (TextUtils.isEmpty(featureValue)) {
APP_ID = getFeatureValue("wxPlus", "apiKey");
}
String featureValue2 = getFeatureValue("wxPlus", "androidApiSecret");
this.APPSECRET = featureValue2;
if (TextUtils.isEmpty(featureValue2)) {
this.APPSECRET = getFeatureValue("wxPlus", "apiSecret");
}
}
public void jsmethod_isInstalled(UZModuleContext uZModuleContext) {
isInstalled(uZModuleContext, false, -1);
}
public void jsmethod_shareText(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(0);
}
}
public void jsmethod_shareMutableImg(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
String str = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "wxShare";
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
String optString = uZModuleContext.optString("description");
ArrayList arrayList = new ArrayList();
JsParamsUtil jsParamsUtil = JsParamsUtil.getInstance();
if (uZModuleContext.isNull("imgs")) {
return;
}
JSONArray optJSONArray = uZModuleContext.optJSONArray("imgs");
for (int i = 0; i < optJSONArray.length(); i++) {
String str2 = (String) optJSONArray.opt(i);
if (str2.startsWith("fs://")) {
arrayList.add(makeRealPath(str2));
} else {
arrayList.add(saveBitmapFile(str + File.separator + str2.substring(str2.lastIndexOf(47)), jsParamsUtil.getBitmap(makeRealPath(str2))).getAbsolutePath());
}
}
ShareUtils.share9PicsToWXCircle(context(), optString, arrayList);
}
}
public File saveBitmapFile(String str, Bitmap bitmap) {
File file = new File(str);
try {
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
if (str.endsWith("jpg")) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bufferedOutputStream);
} else {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bufferedOutputStream);
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return file;
}
public void jsmethod_shareImage(UZModuleContext uZModuleContext) {
uZModuleContext.makeRealPath("cache://");
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(1);
}
}
public void jsmethod_shareMusic(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(2);
}
}
public void jsmethod_shareVideo(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(3);
}
}
public void jsmethod_shareWebpage(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(4);
}
}
public void jsmethod_shareProgram(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
this.mWxShare.share(5);
}
}
public void jsmethod_launchMiniProgram(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
initWxShare(uZModuleContext);
registReciver(uZModuleContext);
miniToApp = uZModuleContext;
this.mWxShare.share(6);
}
}
public void jsmethod_auth(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 3)) {
Log.e("jsmethod_auth", "isInstalled");
initWxAuth(uZModuleContext);
registReciver(uZModuleContext);
this.mWxAuth.auth(uZModuleContext.optString("state"));
}
}
public void jsmethod_getToken(UZModuleContext uZModuleContext) {
initWxAuth(uZModuleContext);
this.mWxAuth.getAccessToken(AccessTokenTask.AccessTokenType.GET_TOKEN);
}
public void jsmethod_refreshToken(UZModuleContext uZModuleContext) {
initWxAuth(uZModuleContext);
this.mWxAuth.getAccessToken(AccessTokenTask.AccessTokenType.REFRESH_TOKEN);
}
public void jsmethod_getUserInfo(UZModuleContext uZModuleContext) {
initWxAuth(uZModuleContext);
this.mWxAuth.getUserInfo();
}
private void initWxShare(UZModuleContext uZModuleContext) {
if (this.mWxShare == null) {
this.mWxShare = new WxShare(this, context());
}
this.mWxShare.setModuleContext(uZModuleContext);
}
private void initWxAuth(UZModuleContext uZModuleContext) {
if (this.mWxAuth == null) {
this.mWxAuth = new WxAuth(this, context());
}
this.mWxAuth.setModuleContext(uZModuleContext);
}
public void jsmethod_listenerMiniLanuchApp(UZModuleContext uZModuleContext) {
miniToApp = uZModuleContext;
}
private void registReciver(UZModuleContext uZModuleContext) {
if (mShareReceiver == null) {
mShareReceiver = new WxReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.setPriority(1000);
intentFilter.addAction(context().getPackageName() + ".weixinshare");
context().registerReceiver(mShareReceiver, intentFilter);
}
mShareReceiver.setModuleContext(uZModuleContext);
}
private boolean isInstalled(UZModuleContext uZModuleContext, boolean z, int i) {
boolean isWXAppInstalled = WXAPIFactory.createWXAPI(context(), "").isWXAppInstalled();
if (!z) {
callBack(uZModuleContext, isWXAppInstalled);
} else if (!isWXAppInstalled) {
callBack(uZModuleContext, i);
}
return isWXAppInstalled;
}
private void callBack(UZModuleContext uZModuleContext, boolean z) {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject.put("installed", z);
jSONObject2.put("code", 0);
uZModuleContext.error(jSONObject, new JSONObject(), false);
} catch (JSONException e) {
e.printStackTrace();
}
}
private void callBack(UZModuleContext uZModuleContext, int i) {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject.put("status", false);
jSONObject2.put("code", 3);
uZModuleContext.error(jSONObject, jSONObject2, false);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onClean() {
super.onClean();
}
public void jsmethod_subscribeMsg(UZModuleContext uZModuleContext) {
if (isInstalled(uZModuleContext, true, 6)) {
String optString = uZModuleContext.optString("apiKey");
int optInt = uZModuleContext.optInt("scene");
String optString2 = uZModuleContext.optString("templateId");
String optString3 = uZModuleContext.optString("reserved");
if (TextUtils.isEmpty(optString)) {
String featureValue = getFeatureValue("wxPlus", "androidApiKey");
optString = TextUtils.isEmpty(featureValue) ? getFeatureValue("wxPlus", "apiKey") : featureValue;
}
registReciver(uZModuleContext);
IWXAPI createWXAPI = WXAPIFactory.createWXAPI(context(), optString, false);
SubscribeMessage.Req req = new SubscribeMessage.Req();
req.scene = optInt;
req.templateID = optString2;
req.reserved = optString3;
if (createWXAPI.sendReq(req)) {
subscribeMsgCallBack(uZModuleContext, "start");
return;
} else {
subscribeMsgCallBack(uZModuleContext, "error");
return;
}
}
subscribeMsgCallBack(uZModuleContext, "error");
}
private void subscribeMsgCallBack(UZModuleContext uZModuleContext, String str) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("eventType", str);
uZModuleContext.success(jSONObject, false);
} catch (JSONException e) {
e.printStackTrace();
}
}
public void jsmethod_openCustomerService(UZModuleContext uZModuleContext) {
String featureValue = getFeatureValue("wxPlus", "androidApiKey");
if (TextUtils.isEmpty(featureValue)) {
featureValue = getFeatureValue("wxPlus", "apiKey");
}
IWXAPI createWXAPI = WXAPIFactory.createWXAPI(context(), featureValue);
String optString = uZModuleContext.optString("corpId");
String optString2 = uZModuleContext.optString(ViewEntity.KEY_URL);
registReciver(uZModuleContext);
if (createWXAPI.getWXAppSupportAPI() >= 671090490) {
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
req.corpId = optString;
req.url = optString2;
createWXAPI.sendReq(req);
}
}
public void jsmethod_shareMusicVideo(UZModuleContext uZModuleContext) {
String featureValue = getFeatureValue("wxPlus", "androidApiKey");
if (TextUtils.isEmpty(featureValue)) {
featureValue = getFeatureValue("wxPlus", "apiKey");
}
IWXAPI createWXAPI = WXAPIFactory.createWXAPI(context(), featureValue);
WXMusicVideoObject wXMusicVideoObject = new WXMusicVideoObject();
wXMusicVideoObject.musicUrl = uZModuleContext.optString("musicUrl");
wXMusicVideoObject.musicDataUrl = uZModuleContext.optString("musicDataUrl");
wXMusicVideoObject.songLyric = uZModuleContext.optString("songLyric");
wXMusicVideoObject.singerName = uZModuleContext.optString("singerName");
wXMusicVideoObject.albumName = uZModuleContext.optString("albumName");
wXMusicVideoObject.musicGenre = uZModuleContext.optString("musicGenre");
wXMusicVideoObject.issueDate = uZModuleContext.optLong("issueDate");
wXMusicVideoObject.identification = uZModuleContext.optString("identification");
wXMusicVideoObject.duration = uZModuleContext.optInt("duration");
WXMediaMessage wXMediaMessage = new WXMediaMessage();
wXMediaMessage.mediaObject = wXMusicVideoObject;
wXMediaMessage.title = uZModuleContext.optString("title");
wXMediaMessage.description = uZModuleContext.optString("description");
wXMediaMessage.messageExt = uZModuleContext.optString("messageExt");
wXMediaMessage.thumbData = bmpToByteArray(UZUtility.getLocalImage(uZModuleContext.makeRealPath(uZModuleContext.optString("thumb"))), true);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("musicVideo");
req.message = wXMediaMessage;
String optString = uZModuleContext.optString("scene", "timeline");
char c = 65535;
int hashCode = optString.hashCode();
if (hashCode != -2076650431) {
if (hashCode != 1050790300) {
if (hashCode == 1984987798 && optString.equals("session")) {
c = 0;
}
} else if (optString.equals("favorite")) {
c = 2;
}
} else if (optString.equals("timeline")) {
c = 1;
}
if (c == 0) {
req.scene = 0;
} else if (c == 1) {
req.scene = 1;
} else if (c == 2) {
req.scene = 2;
}
createWXAPI.sendReq(req);
}
private String buildTransaction(String str) {
if (str == null) {
return String.valueOf(System.currentTimeMillis());
}
return str + System.currentTimeMillis();
}
public static byte[] bmpToByteArray(Bitmap bitmap, boolean z) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
if (z) {
bitmap.recycle();
}
byte[] byteArray = byteArrayOutputStream.toByteArray();
try {
byteArrayOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
return byteArray;
}
public void jsmethod_startWeiXinCard(UZModuleContext uZModuleContext) {
this.uzWxCardContext = uZModuleContext;
if (this.receiver != null) {
context().unregisterReceiver(this.receiver);
}
this.receiver = new CBReceiver(this.uzWxCardContext);
IntentFilter intentFilter = new IntentFilter();
intentFilter.setPriority(1000);
intentFilter.addAction(context().getPackageName() + ".CBReceiver");
context().registerReceiver(this.receiver, intentFilter);
Log.i("xDebug", "getCard");
this.api = WXAPIFactory.createWXAPI(context(), APP_ID, false);
getToken();
Log.d("_xDebug_", "startWeiXinCard uzContext id: " + uZModuleContext.hashCode());
}
private void getToken() {
Log.i("xDebug", "getToken entered");
this.timestamp = String.valueOf(System.currentTimeMillis() / 1000);
HttpUtils.doGetAsyn("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + APP_ID + "&secret=" + this.APPSECRET, new HttpUtils.CallBack() {
@Override
public void onRequestComplete(String str) {
Log.i("xDebug", "getToken onRequestComplete -> " + str);
try {
UzWx.access_token = new JSONObject(str).getString("access_token");
if (!TextUtils.isEmpty(UzWx.access_token)) {
if (TextUtils.isEmpty(UzWx.this.jsapi_ticket)) {
UzWx.this.getticket();
} else {
UzWx.this.getToWx();
}
}
} catch (JSONException e) {
e.printStackTrace();
try {
new JSONObject(str);
} catch (JSONException e2) {
e2.printStackTrace();
}
}
}
@Override
public void onError() {
Log.i("xDebug", "getToken onError");
Log.e(getClass().getSimpleName(), "response");
}
});
}
public void getticket() {
Log.i("xDebug", "getticket entered");
HttpUtils.doGetAsyn("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + access_token + "&type=jsapi", new HttpUtils.CallBack() {
@Override
public void onRequestComplete(String str) {
Log.i("xDebug", "getticket onRequestComplete" + str);
try {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.optInt("errcode") == 0) {
UzWx.this.jsapi_ticket = jSONObject.getString("ticket");
UzWx.this.getToWx();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError() {
Log.i("xDebug", "getticket onError");
}
});
}
public void getToWx() {
Log.i("xDebug", "getToWx entered");
ChooseCardFromWXCardPackage.Req req = new ChooseCardFromWXCardPackage.Req();
req.cardType = "INVOICE";
req.appId = APP_ID;
req.nonceStr = this.noncestr;
req.signType = "SHA1";
req.timeStamp = this.timestamp;
req.cardSign = getSign();
req.canMultiSelect = a.d;
this.api.sendReq(req);
}
private String getSign() {
this.noncestr = "noncestr";
return SHA1("jsapi_ticket=" + this.jsapi_ticket + "&noncestr=noncestr×tamp=" + this.timestamp + "&url=" + (APP_ID + "://"));
}
public static String SHA1(String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
messageDigest.update(str.getBytes());
byte[] digest = messageDigest.digest();
StringBuffer stringBuffer = new StringBuffer();
for (byte b : digest) {
String hexString = Integer.toHexString(b & 255);
if (hexString.length() < 2) {
stringBuffer.append(0);
}
stringBuffer.append(hexString);
}
return stringBuffer.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
}
}