龙将斩千 v5.5.5.39856版本的 MD5 值为:5c05b1d6f8d872ca3fe0343d6ff07caf
以下内容为反编译后的 UmarkGameSdk.java 源代码,内容仅作参考
package com.umarkgame.umarksdk;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import com.bytedance.applog.AppLog;
import com.bytedance.applog.ILogger;
import com.bytedance.applog.InitConfig;
import com.bytedance.applog.game.WhalerGameHelper;
import com.bytedance.hume.readapk.HumeSDK;
import com.qiyukf.nimlib.sdk.StatusBarNotificationConfig;
import com.qiyukf.unicorn.api.ImageLoaderListener;
import com.qiyukf.unicorn.api.Unicorn;
import com.qiyukf.unicorn.api.UnicornImageLoader;
import com.qiyukf.unicorn.api.YSFOptions;
import com.umarkgame.umarksdk.activity.AccountListActivity;
import com.umarkgame.umarksdk.activity.BindIDCardDialog;
import com.umarkgame.umarksdk.activity.InitActivity;
import com.umarkgame.umarksdk.activity.PayActivity;
import com.umarkgame.umarksdk.activity.RegisterActivity;
import com.umarkgame.umarksdk.asynchttpstack.base.Request;
import com.umarkgame.umarksdk.asynchttpstack.core.RequestQueue;
import com.umarkgame.umarksdk.asynchttpstack.core.SimpleNet;
import com.umarkgame.umarksdk.asynchttpstack.requests.StringRequest;
import com.umarkgame.umarksdk.bean.InitConfigure;
import com.umarkgame.umarksdk.bean.LoginResult;
import com.umarkgame.umarksdk.bean.PayInfo;
import com.umarkgame.umarksdk.bean.PayResult;
import com.umarkgame.umarksdk.bean.RechargeParams;
import com.umarkgame.umarksdk.bean.RoleInfo;
import com.umarkgame.umarksdk.bean.RoleLevelParams;
import com.umarkgame.umarksdk.bean.RoleLoginParams;
import com.umarkgame.umarksdk.bean.SwitchAccountResult;
import com.umarkgame.umarksdk.constant.FinalValue;
import com.umarkgame.umarksdk.constant.HttpConstant;
import com.umarkgame.umarksdk.floatviews.FloatManager;
import com.umarkgame.umarksdk.global.PhoneInfo;
import com.umarkgame.umarksdk.interfaces.OnSdkBindListener;
import com.umarkgame.umarksdk.interfaces.OnSdkCountriesListener;
import com.umarkgame.umarksdk.interfaces.OnSdkCreateRoleListener;
import com.umarkgame.umarksdk.interfaces.OnSdkInitListener;
import com.umarkgame.umarksdk.interfaces.OnSdkLoginListener;
import com.umarkgame.umarksdk.interfaces.OnSdkLogoutListener;
import com.umarkgame.umarksdk.interfaces.OnSdkPayListener;
import com.umarkgame.umarksdk.interfaces.OnSdkRoleLevelListener;
import com.umarkgame.umarksdk.interfaces.OnSdkRoleLoginListener;
import com.umarkgame.umarksdk.interfaces.OnSdkShareListener;
import com.umarkgame.umarksdk.interfaces.OnSdkSwitchAccountListener;
import com.umarkgame.umarksdk.utils.FloatingPermissonUtil;
import com.umarkgame.umarksdk.utils.HttpUtils;
import com.umarkgame.umarksdk.utils.LogUtils;
import com.umarkgame.umarksdk.utils.MD5;
import com.umarkgame.umarksdk.utils.PreferenceUtils;
import com.umarkgame.umarksdk.utils.ProgressCircleUtils;
import com.umarkgame.umarksdk.utils.ResourcesUtils;
import com.umarkgame.umarksdk.utils.TimerUtils;
import com.umarkgame.umarksdk.utils.ToastUtils;
import com.umarkgame.umarksdk.utils.UdidUtils;
import com.umarkgame.umarksdk.utils.Utils;
import com.umarkgame.umarksdk.view.FloatBall;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.json.JSONException;
import org.json.JSONObject;
@SuppressLint({"HandlerLeak"})
public class UmarkGameSdk {
public static final int PERMISSON_READ_PHONE_STATE_REQUEST_CODE = 541886;
private String country;
private String countryCode;
private FloatBall mFloatBall;
private InitConfigure mInitConfigure;
private OnSdkBindListener mSdkBindListener;
private OnSdkCountriesListener mSdkCountriesListener;
private OnSdkCreateRoleListener mSdkCreateRoleListener;
private OnSdkInitListener mSdkInitListener;
private OnSdkLoginListener mSdkLoginListener;
private OnSdkLogoutListener mSdkLogoutListener;
private OnSdkPayListener mSdkPayListener;
private OnSdkRoleLevelListener mSdkRoleLevelListener;
private OnSdkRoleLoginListener mSdkRoleLoginListener;
private OnSdkSwitchAccountListener mSdkSwitchAccountListener;
private OnSdkShareListener onSdkShareListener;
private Boolean onlinePay;
public String player_id;
public String player_level;
public String player_name;
public String player_server;
private boolean showRequestPermission;
private static UmarkGameSdk mInstance = null;
public static int umark_douyin_appid = 0;
private static int umark_appid = 0;
private static int umark_channel = 0;
public String sdk_version = "1.3.5";
private Activity mContext = null;
private Application application = null;
private boolean isRegisterHomeReceiver = false;
private RequestQueue mQueue = SimpleNet.newRequestQueue();
private int isopen = 0;
public Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
int i = msg.what;
if (i != 220) {
switch (i) {
case 101:
if (UmarkGameSdk.this.mSdkInitListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkInitListener.onSuccess();
}
});
}
boolean isMiui = !TextUtils.isEmpty(UmarkGameSdk.getSystemProperty("ro.miui.ui.version.name"));
if (isMiui && PhoneInfo.HW == 0) {
FloatingPermissonUtil.checkMobileModel(UmarkGameSdk.this.mContext);
break;
}
break;
case 102:
if (UmarkGameSdk.this.mSdkInitListener != null) {
final String message = (String) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkInitListener.onFailed(message);
}
});
break;
}
}
break;
case 103:
UmarkGameSdk.this.isRegisterHomeReceiver = true;
UmarkGameSdk.this.mContext.registerReceiver(UmarkGameSdk.this.mHomeKeyEventReceiver, new IntentFilter("android.intent.action.CLOSE_SYSTEM_DIALOGS"));
FloatManager.getFloatManager(UmarkGameSdk.this.mContext).createView();
PhoneInfo.LOGINTYPE = -1;
final LoginResult loginResult = new LoginResult();
loginResult.message = FinalValue.LOGIN_SUCCESS_MSG;
loginResult.token = PhoneInfo.SIGN;
loginResult.time = PhoneInfo.TIME;
loginResult.userId = PhoneInfo.USERID;
if (UmarkGameSdk.this.mSdkLoginListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkLoginListener.onSuccess(loginResult);
}
});
break;
}
break;
case 104:
if (UmarkGameSdk.this.mSdkLoginListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkLoginListener.onFailed(FinalValue.LOGIN_FAIL_MSG);
}
});
break;
}
break;
case 105:
UmarkGameSdk.this.isRegisterHomeReceiver = false;
if (UmarkGameSdk.this.mSdkLogoutListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkLogoutListener.onSuccess();
}
});
break;
}
break;
case 106:
if (UmarkGameSdk.this.mSdkLogoutListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkLogoutListener.onFailed();
}
});
break;
}
break;
case 107:
if (UmarkGameSdk.this.mSdkSwitchAccountListener != null) {
final SwitchAccountResult message2 = (SwitchAccountResult) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkSwitchAccountListener.onSuccess(message2);
}
});
break;
}
}
break;
case 108:
if (UmarkGameSdk.this.mSdkSwitchAccountListener != null) {
final String message3 = (String) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkSwitchAccountListener.onFailed(message3);
}
});
break;
}
}
break;
case 109:
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.PAY_SUCESS_MSG);
final PayResult payResult = new PayResult();
payResult.message = FinalValue.PAY_SUCESS_MSG;
if (UmarkGameSdk.this.mSdkPayListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkPayListener.onSuccess(payResult);
}
});
}
if (PayActivity.getActivty() != null) {
PayActivity.getActivty().finish();
break;
}
break;
case 110:
if (UmarkGameSdk.this.mSdkPayListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkPayListener.onFailed(-1);
}
});
}
if (PayActivity.getActivty() != null) {
PayActivity.getActivty().finish();
break;
}
break;
case 111:
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.PAY_CONFIRM_MSG);
if (UmarkGameSdk.this.mSdkPayListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkPayListener.onFailed(1114);
}
});
}
if (PayActivity.getActivty() != null) {
PayActivity.getActivty().finish();
break;
}
break;
case 112:
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.PAY_CANCEL_MSG);
if (UmarkGameSdk.this.mSdkPayListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkPayListener.onFailed(1115);
}
});
}
if (PayActivity.getActivty() != null) {
PayActivity.getActivty().finish();
break;
}
break;
case 113:
case 114:
break;
case 115:
if (UmarkGameSdk.this.mSdkCreateRoleListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkCreateRoleListener.onSuccess();
}
});
break;
}
break;
case 116:
if (UmarkGameSdk.this.mSdkCreateRoleListener != null) {
final String message4 = (String) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkCreateRoleListener.onFailed(message4);
}
});
break;
}
}
break;
case 117:
if (UmarkGameSdk.this.mSdkRoleLoginListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkRoleLoginListener.onSuccess();
}
});
break;
}
break;
case 118:
if (UmarkGameSdk.this.mSdkRoleLoginListener != null) {
final String message5 = (String) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkRoleLoginListener.onFailed(message5);
}
});
break;
}
}
break;
case 119:
if (UmarkGameSdk.this.mSdkRoleLevelListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkRoleLevelListener.onSuccess();
}
});
break;
}
break;
default:
switch (i) {
case FinalValue.BIND_SUCCESS_CODE:
if (UmarkGameSdk.this.mSdkBindListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkBindListener.onSuccess();
}
});
break;
}
break;
case FinalValue.BIND_FAIL_CODE:
if (UmarkGameSdk.this.mSdkBindListener != null && UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkBindListener.onFailed("failed:1114");
}
});
break;
}
break;
}
}
} else if (UmarkGameSdk.this.mSdkRoleLevelListener != null) {
final String message6 = (String) msg.obj;
if (UmarkGameSdk.this.mContext != null) {
UmarkGameSdk.this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
UmarkGameSdk.this.mSdkRoleLevelListener.onFailed(message6);
}
});
}
}
super.handleMessage(msg);
}
};
private BroadcastReceiver mHomeKeyEventReceiver = new BroadcastReceiver() {
String SYSTEM_REASON = "reason";
String SYSTEM_HOME_KEY = "homekey";
String SYSTEM_HOME_KEY_LONG = "recentapps";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("android.intent.action.CLOSE_SYSTEM_DIALOGS")) {
String reason = intent.getStringExtra(this.SYSTEM_REASON);
if (TextUtils.equals(reason, this.SYSTEM_HOME_KEY)) {
FloatManager.getFloatManager(UmarkGameSdk.this.mContext).destroyFloat();
} else {
TextUtils.equals(reason, this.SYSTEM_HOME_KEY_LONG);
}
}
}
};
public static synchronized UmarkGameSdk getInstance() {
UmarkGameSdk umarkGameSdk;
synchronized (UmarkGameSdk.class) {
if (mInstance == null) {
mInstance = new UmarkGameSdk();
}
umarkGameSdk = mInstance;
}
return umarkGameSdk;
}
public static String getLogicChannel(Context context, String prefix) {
ApplicationInfo appInfo = context.getApplicationInfo();
String sourceDir = appInfo.sourceDir;
String key = "META-INF/" + prefix;
ZipFile zip = null;
try {
try {
zip = new ZipFile(sourceDir);
Enumeration<?> entries = zip.entries();
String ret = null;
while (true) {
if (!entries.hasMoreElements()) {
break;
}
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
if (entryName.startsWith(key)) {
ret = entryName;
break;
}
}
if (TextUtils.isEmpty(ret)) {
try {
zip.close();
} catch (Exception var19) {
var19.printStackTrace();
}
return null;
}
String[] split = ret.split("_");
if (split != null && split.length >= 2) {
String entryName2 = ret.substring(split[0].length() + 1);
try {
zip.close();
} catch (Exception var192) {
var192.printStackTrace();
}
return entryName2;
}
try {
zip.close();
} catch (Exception var193) {
var193.printStackTrace();
}
return null;
} catch (Throwable th) {
if (zip != null) {
try {
zip.close();
} catch (Exception var194) {
var194.printStackTrace();
}
}
throw th;
}
} catch (Exception var20) {
var20.printStackTrace();
if (zip != null) {
try {
zip.close();
} catch (Exception var195) {
var195.printStackTrace();
}
}
return null;
}
}
public String getFileContent(Context context) {
ApplicationInfo appinfo = context.getApplicationInfo();
String sourceDir = appinfo.sourceDir;
ZipFile zipfile = null;
String res = null;
try {
try {
zipfile = new ZipFile(sourceDir);
Enumeration<?> entries = zipfile.entries();
while (true) {
if (!entries.hasMoreElements()) {
break;
}
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
if (entryName.startsWith("META-INF/channel")) {
res = entryName;
break;
}
}
if (TextUtils.isEmpty(res)) {
try {
zipfile.close();
} catch (IOException e) {
e.printStackTrace();
}
return "0";
}
String[] split = res.split("_");
if (split.length < 2) {
try {
zipfile.close();
} catch (IOException e2) {
e2.printStackTrace();
}
return "0";
}
if (!split[2].equals("umarkgame")) {
try {
zipfile.close();
} catch (IOException e3) {
e3.printStackTrace();
}
return "0";
}
String filename = split[1];
try {
zipfile.close();
} catch (IOException e4) {
e4.printStackTrace();
}
return filename;
} catch (Throwable th) {
if (zipfile != null) {
try {
zipfile.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
throw th;
}
} catch (IOException e6) {
e6.printStackTrace();
if (zipfile == null) {
return "0";
}
try {
zipfile.close();
return "0";
} catch (IOException e7) {
e7.printStackTrace();
return "0";
}
}
}
public void setContext(Activity context) {
this.mContext = context;
}
private boolean getAppOps(Context context) {
try {
Object object = context.getSystemService("appops");
if (object == null) {
return false;
}
Class localClass = object.getClass();
Class[] arrayOfClass = {Integer.TYPE, Integer.TYPE, String.class};
Method method = localClass.getMethod("checkOp", arrayOfClass);
if (method == null) {
return false;
}
Object[] arrayOfObject1 = {24, Integer.valueOf(Binder.getCallingUid()), context.getPackageName()};
int m = ((Integer) method.invoke(object, arrayOfObject1)).intValue();
return m == 0;
} catch (Exception e) {
return false;
}
}
private void initYongHuYinSi(final Activity context) {
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Map<String, String> message = new HashMap<>();
PhoneInfo.APPID = UmarkGameSdk.umark_appid + "";
PhoneInfo.CHANNEL = UmarkGameSdk.umark_channel + "";
PhoneInfo.OSTYPE = "6";
message.put("appid", PhoneInfo.APPID);
message.put("type", "0");
message.put("channel", PhoneInfo.CHANNEL);
message.put("ostype", PhoneInfo.OSTYPE);
LogUtils.output("协议请求", message.toString());
ProgressCircleUtils.showProgress(UmarkGameSdk.getInstance().getActivity(), "", "");
HttpUtils.post(HttpConstant.URL, message, new HttpUtils.RequestListener() {
@Override
public void success(String response) {
ProgressCircleUtils.closeProgress();
LogUtils.output("协议获取", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
if (status == 1 && response.contains("isOpenPrivacy")) {
int is_open = jsonObject.getInt("isOpenPrivacy");
if (is_open == 1) {
String privacyContent = jsonObject.getString("privacyContent");
String policyUrl = jsonObject.getString("policyUrl");
String agreementUrl = jsonObject.getString("agreementUrl");
if (Utils.getPlayerInfo(context)) {
Utils.showUpgradeDialog(context, privacyContent, policyUrl, agreementUrl);
} else {
Utils.setPlyaerInfo(context);
}
return;
}
Utils.setPlyaerInfo(context);
}
} catch (JSONException e) {
e.printStackTrace();
LogUtils.output("协议获取", "失败");
}
}
@Override
public void fail(String error) {
ProgressCircleUtils.closeProgress();
LogUtils.output("协议获取", error);
Message msg = new Message();
msg.what = 102;
msg.obj = FinalValue.INIT_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg);
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.INIT_FAIL_MSG);
}
});
}
});
}
public void initSdk(final Activity context) {
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Map<String, String> message = new HashMap<>();
PhoneInfo.CLIENTUA = UdidUtils.getClientUA(context);
PhoneInfo.YMKEY = "e53050c2f103504a8fd97a6368b40939";
PhoneInfo.MAC = UdidUtils.getPhoneMac(UmarkGameSdk.getInstance().getActivity());
message.put("appid", PhoneInfo.APPID);
message.put("type", "1");
message.put("channel", PhoneInfo.CHANNEL);
message.put("ostype", PhoneInfo.OSTYPE);
message.put("mac", PhoneInfo.MAC);
message.put("clientUA", PhoneInfo.CLIENTUA);
message.put("ymkey", PhoneInfo.YMKEY);
String agentgame = UmarkGameSdk.this.getFileContent(context);
String douyinChannel = UmarkGameSdk.this.getDouYinChildChannel(context);
LogUtils.output("get agentgame:", agentgame + ",dy appid:" + UmarkGameSdk.umark_douyin_appid + ",douyin channel:" + douyinChannel);
if (UmarkGameSdk.umark_douyin_appid != 0) {
if (douyinChannel.length() > 1) {
LogUtils.output("agentgame:", "is douyin channel");
PhoneInfo.AGENTGAME = UmarkGameSdk.this.getDouYinChildChannel(context);
} else {
LogUtils.output("agentgame:", "is douyin mian");
PhoneInfo.AGENTGAME = agentgame;
}
} else {
LogUtils.output("agentgame:", "is official");
PhoneInfo.AGENTGAME = agentgame;
}
message.put("agentGame", PhoneInfo.AGENTGAME);
LogUtils.output("URL:", HttpConstant.URL);
ProgressCircleUtils.showProgress(UmarkGameSdk.getInstance().getActivity(), "", "");
HttpUtils.post(HttpConstant.URL, message, new HttpUtils.RequestListener() {
@Override
public void success(String response) {
ProgressCircleUtils.closeProgress();
LogUtils.output("初始化响应", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
int i = 1;
if (status == 1) {
if (response.contains("is_send_reyun_data")) {
PhoneInfo.ENABLEDREYUNSDK = jsonObject.getInt("is_send_reyun_data");
}
if (response.contains("floating_window")) {
int enabledFloating = jsonObject.getInt("floating_window");
PhoneInfo.ENABLEDFLOATING = enabledFloating;
}
if (response.contains("isOpenPreventionOfAddiction")) {
PhoneInfo.ISOPENPREVEMTIONOfADDICTION = jsonObject.getInt("isOpenPreventionOfAddiction");
}
if (response.contains("pollingTime")) {
PhoneInfo.POLLINGTIME = jsonObject.getInt("pollingTime");
}
if (response.contains("isHoliday")) {
PhoneInfo.ISHOLIDAY = jsonObject.getInt("isHoliday");
}
LogUtils.output("未成年开关:", "" + PhoneInfo.ISOPENPREVEMTIONOfADDICTION);
LogUtils.output("轮询时间:", "" + PhoneInfo.POLLINGTIME);
LogUtils.output("节假日:", "" + PhoneInfo.ISHOLIDAY);
if (response.contains("floating_window_features")) {
String enabledFeatures = jsonObject.getString("floating_window_features");
String[] split = enabledFeatures.split(",");
if (split != null && split.length == 5) {
PhoneInfo.ENABLEDGIFTBAG = split[0].trim().matches("[0-9]") ? Integer.parseInt(split[0].trim()) : 0;
PhoneInfo.ENABLEDACCOUNTSERVICE = split[1].trim().matches("[0-9]") ? Integer.parseInt(split[1].trim()) : 1;
PhoneInfo.ENABLEDAHIDEFLOATING = split[2].trim().matches("[0-9]") ? Integer.parseInt(split[2].trim()) : 1;
PhoneInfo.ENABLED_ONLINE = split[3].trim().matches("[0-9]") ? Integer.parseInt(split[3].trim()) : 1;
if (split[4].trim().matches("[0-9]")) {
i = Integer.parseInt(split[4].trim());
}
PhoneInfo.ENABLED_GIFT = i;
}
}
if (response.contains("number")) {
PhoneInfo.KEFUPHONE = jsonObject.getString("number");
}
if (response.contains("qq")) {
PhoneInfo.KEFUQQ = jsonObject.getString("qq");
}
if (response.contains("isOpenSmsAuth")) {
PhoneInfo.ISOPENSMS = jsonObject.getInt("isOpenSmsAuth");
}
if (response.contains("largeAmountLimit")) {
PhoneInfo.LARGEAMOUNTLIMIT = jsonObject.getString("largeAmountLimit");
}
if (response.contains("discount")) {
String temp = jsonObject.getString("discount");
PhoneInfo.DISCOUNT = Double.parseDouble(temp);
}
UmarkGameSdk.this.mHandler.sendEmptyMessage(101);
return;
}
Message msg = new Message();
msg.what = 102;
msg.obj = jsonObject.getString("message");
UmarkGameSdk.this.mHandler.sendMessage(msg);
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.INIT_FAIL_MSG);
} catch (JSONException e) {
e.printStackTrace();
LogUtils.output("初始化响应", "失败");
Message msg2 = new Message();
msg2.what = 102;
msg2.obj = FinalValue.INIT_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg2);
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.INIT_FAIL_MSG);
}
}
@Override
public void fail(String error) {
ProgressCircleUtils.closeProgress();
LogUtils.output("初始化响应", "失败");
Message msg = new Message();
msg.what = 102;
msg.obj = FinalValue.INIT_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg);
ToastUtils.ToastMsg(UmarkGameSdk.this.mContext, FinalValue.INIT_FAIL_MSG);
}
});
}
});
}
private void initAppidWithChannel(Activity context) {
try {
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
umark_appid = appInfo.metaData.getInt("umark_appid");
umark_channel = appInfo.metaData.getInt("umark_channel");
umark_douyin_appid = appInfo.metaData.getInt("umark_douyin_appid");
LogUtils.output("init appid", "appid=" + umark_appid + ",channel=" + umark_channel);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
public String getDouYinChildChannel(Context context) {
String child_channel = HumeSDK.getChannel(context);
LogUtils.output("umark", "child channel:" + child_channel);
return child_channel;
}
private void init(Activity context, InitConfigure initConfigure) {
if (context == null || initConfigure == null) {
return;
}
if (!getAppOps(context) && PhoneInfo.HW == 0) {
setFl(context);
}
PhoneInfo.SCREENDIRECTION = initConfigure.screenDirection;
LogUtils.output("sdk version:", this.sdk_version);
initAppidWithChannel(context);
initYongHuYinSi(context);
}
public boolean getSdkVersionSix() {
return Build.VERSION.SDK_INT >= 23;
}
public void setFl(Activity context) {
Intent intent = new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION");
intent.setData(Uri.parse("package:" + context.getPackageName()));
context.startActivityForResult(intent, 1);
Toast.makeText(this.mContext, this.mContext.getString(ResourcesUtils.getIdByName(this.mContext, "string", "floating_ball")), 0).show();
}
public void init(Activity context, InitConfigure initConfigure, OnSdkInitListener l) {
if (context == null || initConfigure == null) {
return;
}
this.mContext = context;
this.mInitConfigure = initConfigure;
this.mSdkInitListener = l;
PhoneInfo.HW = initConfigure.hw;
boolean isMiui = !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
if (isMiui) {
init(context, initConfigure);
return;
}
try {
if (getSdkVersionSix()) {
String[] permissions = {"android.permission.SYSTEM_ALERT_WINDOW"};
List<String> mPermissionList = new ArrayList<>();
for (int i = 0; i < permissions.length; i++) {
if (ContextCompat.checkSelfPermission(context, permissions[i]) != 0) {
mPermissionList.add(permissions[i]);
}
}
if (mPermissionList.isEmpty()) {
init(context, initConfigure);
} else {
ActivityCompat.requestPermissions(getInstance().getActivity(), new String[]{"android.permission.SYSTEM_ALERT_WINDOW"}, 10114);
}
return;
}
init(context, initConfigure);
} catch (Exception e) {
init(context, initConfigure);
}
}
public void statReYunRegister(String accountId) {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public void statReYunLogin(String accountId) {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public void statReYunPaymentStart(String transactionId, String paymentType, float currencyAmount) {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public void statReYunPayment(String transactionId, String paymentType, float currencyAmount) {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public void statReYunEvent(String eventName) {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public void statReYunExitSdk() {
if (this.mContext == null) {
return;
}
this.mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
if (PhoneInfo.ENABLEDREYUNSDK != 1) {
}
}
});
}
public Activity getActivity() {
return this.mContext;
}
public Application getApplication() {
return this.application;
}
public void login(Activity context, OnSdkLoginListener l, OnSdkLogoutListener l1) {
if (context == null) {
return;
}
this.mSdkLoginListener = l;
this.mSdkLogoutListener = l1;
logingame(context, l, l1);
}
private void logingame(final Activity context, OnSdkLoginListener l, OnSdkLogoutListener l1) {
if (getSdkVersionSix()) {
this.isopen = PreferenceUtils.getInt(context, "isopen", 0);
String[] permissions = {"android.permission.WRITE_EXTERNAL_STORAGE"};
List<String> mPermissionList = new ArrayList<>();
for (int i = 0; i < permissions.length; i++) {
if (ContextCompat.checkSelfPermission(context, permissions[i]) != 0) {
mPermissionList.add(permissions[i]);
}
}
LogUtils.output("login game", "");
LogUtils.output("权限:", "" + mPermissionList.toString());
if (!mPermissionList.isEmpty() && this.isopen == 0) {
Intent intent = new Intent(context, (Class<?>) InitActivity.class);
context.startActivity(intent);
PreferenceUtils.putInt(context, "isopen", 1);
return;
}
}
context.runOnUiThread(new Runnable() {
@Override
public void run() {
String userName = PreferenceUtils.getString(UmarkGameSdk.getInstance().getActivity(), FinalValue.USERNAME, "");
String passWord = PreferenceUtils.getString(UmarkGameSdk.getInstance().getActivity(), FinalValue.PASSWORD, "");
if (TextUtils.equals(userName, "") && TextUtils.equals(passWord, "")) {
Intent intent2 = new Intent(UmarkGameSdk.getInstance().getActivity(), (Class<?>) RegisterActivity.class);
context.startActivity(intent2);
} else if (PreferenceUtils.getInt(UmarkGameSdk.getInstance().getActivity(), FinalValue.USERTYPE, 0) == 4) {
Intent intent3 = new Intent(UmarkGameSdk.getInstance().getActivity(), (Class<?>) RegisterActivity.class);
context.startActivity(intent3);
} else {
context.startActivity(new Intent(context, (Class<?>) AccountListActivity.class));
}
}
});
}
public void logout(final Activity context, OnSdkLogoutListener l) {
if (context == null) {
return;
}
TimerUtils.getInstance().stop();
this.mSdkLogoutListener = l;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
FloatManager.getFloatManager(context).destroyFloat();
UmarkGameSdk.this.mHandler.sendEmptyMessage(105);
}
});
}
private void payInit(Activity context, RechargeParams params, OnSdkPayListener l) {
}
private void gamePlaceOrder(final Activity context, final RechargeParams params, final OnSdkPayListener l) {
if (context == null || params == null) {
return;
}
if (PhoneInfo.ISOPENPREVEMTIONOfADDICTION == 1) {
LogUtils.output("下单成年没有:", "" + PreferenceUtils.getInt(getInstance().getActivity(), FinalValue.ISADULT, 0));
if (PreferenceUtils.getInt(getInstance().getActivity(), FinalValue.ISADULT, 0) == 2) {
Intent intent1 = new Intent(getInstance().getActivity(), (Class<?>) BindIDCardDialog.class);
context.startActivity(intent1);
return;
}
}
double price_temp = Double.parseDouble(params.goodsPrice) * PhoneInfo.DISCOUNT;
LogUtils.output("商品打折:", PhoneInfo.DISCOUNT + ",原始价格:" + params.goodsPrice + ",折后价:" + price_temp);
int temp_price = (int) price_temp;
params.goodsPrice = Integer.toString(temp_price);
Map<String, String> message = new HashMap<>();
message.put("appid", PhoneInfo.APPID);
message.put("type", "1");
message.put("money", params.goodsPrice == null ? "" : params.goodsPrice);
message.put("roleid", params.roleId == null ? "" : params.roleId);
message.put("serverid", params.serverId == null ? "" : params.serverId);
message.put(FinalValue.CPEXPANSION, params.cpExpansion == null ? "" : params.cpExpansion);
message.put("orderTitle", params.goodsName == null ? "" : params.goodsName);
message.put("orderDesc", params.goodsDesc == null ? "" : params.goodsDesc);
message.put(FinalValue.GOODSID, params.productId == null ? "" : params.productId);
message.put("cpOrderId", params.cpOrderId == null ? "" : params.cpOrderId);
message.put("currency", "CNY");
message.put("username", PhoneInfo.USERID);
StringBuilder sb = new StringBuilder();
sb.append("username=");
sb.append(PhoneInfo.USERID);
sb.append("&cpOrderId=");
sb.append(params.cpOrderId == null ? "" : params.cpOrderId);
sb.append("&roleId=");
sb.append(params.roleId == null ? "" : params.roleId);
sb.append("&money=");
sb.append(params.goodsPrice == null ? "" : params.goodsPrice);
sb.append("¤cy=CNY");
String md5Str = sb.toString();
message.put("sign", MD5.sign(md5Str, params.orderKey == null ? "" : params.orderKey));
message.put("agentGame", PhoneInfo.AGENTGAME);
LogUtils.output("游戏下单请求:", message.toString());
LogUtils.output("key:", params.orderKey);
ProgressCircleUtils.showProgress(context, "", "");
HttpUtils.post("https://yht.umarkgame.com/umarkpay/pay", message, new HttpUtils.RequestListener() {
@Override
public void success(String response) {
ProgressCircleUtils.closeProgress();
LogUtils.output("游戏下单响应", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
if (status == 1) {
String orderNumber = jsonObject.getString(FinalValue.ORDERNUMBER);
PayInfo payInfo = new PayInfo();
payInfo.goodsName = params.goodsName;
payInfo.goodsPrice = params.goodsPrice;
payInfo.roleid = params.roleId;
payInfo.serverid = params.serverId;
payInfo.orderNumber = orderNumber;
payInfo.cpExpansion = params.cpExpansion;
payInfo.goodsDesc = params.goodsDesc;
payInfo.goodsId = params.productId;
PayActivity.itemDesc = params.goodsDesc;
PayActivity.itemName = params.goodsName;
PayActivity.itemId = params.productId;
UmarkGameSdk.this.pay(context, payInfo, l);
} else {
LogUtils.output("游戏下单响应", "失败");
Message msg = new Message();
msg.what = 110;
msg.obj = jsonObject.getString("message");
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
} catch (JSONException e) {
e.printStackTrace();
LogUtils.output("游戏下单响应", "失败");
Message msg2 = new Message();
msg2.what = 110;
msg2.obj = "获取订单失败";
UmarkGameSdk.this.mHandler.sendMessage(msg2);
}
}
@Override
public void fail(String error) {
ProgressCircleUtils.closeProgress();
LogUtils.output("游戏下单响应", "失败");
Message msg = new Message();
msg.what = 110;
msg.obj = "网络异常,获取订单失败";
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
});
}
public void pay(Activity context, RechargeParams params, OnSdkPayListener l) {
gamePlaceOrder(context, params, l);
}
public void countries(Activity context, OnSdkCountriesListener l) {
this.mSdkCountriesListener = l;
}
public void overseasPay(Activity context, RechargeParams params, OnSdkPayListener l) {
this.mSdkPayListener = l;
payInit(context, params, l);
}
public void bindGF(Activity context, OnSdkBindListener l) {
this.mSdkBindListener = l;
}
public void share(Activity context, String Url, OnSdkShareListener l) {
}
public void share(Activity context, Bitmap image) {
}
public void pay(Activity context, final PayInfo payInfo, OnSdkPayListener l) {
if (context == null || payInfo == null || TextUtils.equals("", payInfo.goodsName) || TextUtils.equals("", payInfo.goodsPrice) || TextUtils.equals("", payInfo.orderNumber) || !payInfo.goodsPrice.matches("^\\d*[1-9]\\d*$")) {
return;
}
try {
Integer.parseInt(payInfo.goodsPrice);
this.mSdkPayListener = l;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(UmarkGameSdk.this.mContext, (Class<?>) PayActivity.class);
intent.putExtra(FinalValue.GOODSNAME, payInfo.goodsName);
intent.putExtra(FinalValue.GOODSPRICE, payInfo.goodsPrice);
intent.putExtra(FinalValue.ROLEID, payInfo.roleid);
intent.putExtra(FinalValue.SERVERID, payInfo.serverid);
intent.putExtra(FinalValue.ORDERNUMBER, payInfo.orderNumber);
intent.putExtra(FinalValue.CPEXPANSION, payInfo.cpExpansion);
intent.putExtra(FinalValue.GOODSDESC, payInfo.goodsDesc);
intent.putExtra(FinalValue.GOODSID, payInfo.goodsId);
UmarkGameSdk.this.mContext.startActivity(intent);
}
});
} catch (Exception e) {
}
}
public void createRole(Activity context, RoleInfo info, OnSdkCreateRoleListener l) {
asyncRoleCreate(context, info, l);
}
private void asyncRoleCreate(final Activity context, final RoleInfo info, OnSdkCreateRoleListener l) {
if (context == null || info == null) {
return;
}
this.mSdkCreateRoleListener = l;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
final String userId = PreferenceUtils.getString(UmarkGameSdk.this.getActivity(), FinalValue.USERID, "");
StringRequest request = new StringRequest(Request.HttpMethod.POST, HttpConstant.DATACENTER, new Request.RequestListener<String>() {
@Override
public void onComplete(int stCode, String response, String errMsg) {
if (stCode == 200) {
ProgressCircleUtils.closeProgress();
LogUtils.output("角色创建响应", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
if (status == 1) {
UmarkGameSdk.this.mHandler.sendEmptyMessage(115);
WhalerGameHelper.startPlay(info.playerName, null);
UmarkGameSdk.this.statReYunRegister(userId);
} else {
Message msg = new Message();
msg.what = 116;
msg.obj = jsonObject.getString("message");
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
return;
} catch (JSONException e) {
e.printStackTrace();
Message msg2 = new Message();
msg2.what = 116;
msg2.obj = FinalValue.CREATEROLE_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg2);
return;
}
}
ProgressCircleUtils.closeProgress();
Message msg3 = new Message();
msg3.what = 116;
msg3.obj = FinalValue.CREATEROLE_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg3);
}
});
request.setShouldCache(false);
Map<String, String> params = request.getParams();
params.put("appid", PhoneInfo.APPID);
params.put("channel", PhoneInfo.CHANNEL);
params.put("type", "1");
params.put("playerId", info.playerId);
params.put("playerName", info.playerName);
params.put(FinalValue.USERID, userId);
params.put("areaId", info.areaId == null ? "0" : info.areaId);
params.put("areaName", info.areaName == null ? "0" : info.areaName);
params.put(FinalValue.SERVERID, info.serverId == null ? "0" : info.serverId);
params.put("serverName", info.serverName == null ? "0" : info.serverName);
params.put("childChannel", info.childChannel == null ? "0" : info.childChannel);
params.put("eventTime", info.eventTime);
params.put("isTest", info.isTest + "");
params.put("agentGame", PhoneInfo.AGENTGAME);
LogUtils.output("角色创建请求", params.toString());
context.runOnUiThread(new Runnable() {
@Override
public void run() {
ProgressCircleUtils.showProgress(UmarkGameSdk.this.getActivity(), "", "");
}
});
if (UmarkGameSdk.this.mQueue != null) {
UmarkGameSdk.this.mQueue.addRequest(request);
}
}
});
}
public void roleLogin(Activity context, RoleLoginParams params, OnSdkRoleLoginListener l) {
this.player_id = params.playerId;
this.player_level = params.playerLevel;
this.player_server = params.serverName;
this.player_name = params.playerName;
asyncRoleLogin(context, params, l);
}
private void asyncRoleLogin(final Activity context, final RoleLoginParams params, OnSdkRoleLoginListener l) {
if (context == null || params == null) {
return;
}
this.mSdkRoleLoginListener = l;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
String userId = PreferenceUtils.getString(UmarkGameSdk.this.getActivity(), FinalValue.USERID, "");
StringRequest request = new StringRequest(Request.HttpMethod.POST, HttpConstant.DATACENTER, new Request.RequestListener<String>() {
@Override
public void onComplete(int stCode, String response, String errMsg) {
if (stCode == 200) {
ProgressCircleUtils.closeProgress();
LogUtils.output("角色登录响应", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
if (status == 1) {
UmarkGameSdk.this.mHandler.sendEmptyMessage(117);
int level = Integer.parseInt(params.playerLevel);
WhalerGameHelper.levelUp(level, 0, "lev", 1, null);
} else {
Message msg = new Message();
msg.what = 118;
msg.obj = jsonObject.getString("message");
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
return;
} catch (JSONException e) {
e.printStackTrace();
Message msg2 = new Message();
msg2.what = 118;
msg2.obj = FinalValue.ROLELOGIN_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg2);
return;
}
}
ProgressCircleUtils.closeProgress();
Message msg3 = new Message();
msg3.what = 118;
msg3.obj = FinalValue.ROLELOGIN_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg3);
}
});
request.setShouldCache(false);
Map<String, String> message = request.getParams();
message.put("appid", PhoneInfo.APPID);
message.put("channel", PhoneInfo.CHANNEL);
message.put("type", "2");
message.put("playerId", params.playerId);
message.put("playerName", params.playerName);
message.put(FinalValue.USERID, userId);
message.put("areaId", params.areaId == null ? "0" : params.areaId);
message.put("areaName", params.areaName == null ? "0" : params.areaName);
message.put(FinalValue.SERVERID, params.serverId == null ? "0" : params.serverId);
message.put("serverName", params.serverName == null ? "0" : params.serverName);
message.put("childChannel", params.childChannel == null ? "0" : params.childChannel);
message.put("eventTime", params.eventTime);
message.put("isTest", params.isTest + "");
message.put("agentGame", PhoneInfo.AGENTGAME);
LogUtils.output("角色登录请求", message.toString());
context.runOnUiThread(new Runnable() {
@Override
public void run() {
ProgressCircleUtils.showProgress(UmarkGameSdk.this.getActivity(), "", "");
}
});
if (UmarkGameSdk.this.mQueue != null) {
UmarkGameSdk.this.mQueue.addRequest(request);
}
}
});
}
public void roleLevel(final Activity context, final RoleLevelParams params, OnSdkRoleLevelListener l) {
if (context == null || params == null) {
return;
}
this.mSdkRoleLevelListener = l;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Map<String, String> message = new HashMap<>();
message.put("appid", PhoneInfo.APPID);
message.put("channel", PhoneInfo.CHANNEL);
message.put("type", "3");
message.put("playerId", params.playerId);
message.put("playerName", params.playerName);
message.put("playerLevel", params.playerLevel + "");
String userId = PreferenceUtils.getString(UmarkGameSdk.this.getActivity(), FinalValue.USERID, "");
message.put(FinalValue.USERID, userId);
message.put("areaId", params.areaId == null ? "0" : params.areaId);
message.put("areaName", params.areaName == null ? "0" : params.areaName);
message.put(FinalValue.SERVERID, params.serverId == null ? "0" : params.serverId);
message.put("serverName", params.serverName == null ? "0" : params.serverName);
message.put("childChannel", params.childChannel == null ? "0" : params.childChannel);
message.put("eventTime", params.eventTime);
message.put("isTest", params.isTest + "");
message.put("agentGame", PhoneInfo.AGENTGAME);
LogUtils.output("角色等级提升请求", message.toString());
context.runOnUiThread(new Runnable() {
@Override
public void run() {
ProgressCircleUtils.showProgress(UmarkGameSdk.this.getActivity(), "", "");
}
});
HttpUtils.post(HttpConstant.DATACENTER, message, new HttpUtils.RequestListener() {
@Override
public void success(String response) {
ProgressCircleUtils.closeProgress();
LogUtils.output("角色等级提升响应", response);
try {
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt(NotificationCompat.CATEGORY_STATUS);
if (status == 1) {
UmarkGameSdk.this.mHandler.sendEmptyMessage(119);
} else {
Message msg = new Message();
msg.what = FinalValue.ROLELEVEL_FAIL_CODE;
msg.obj = jsonObject.getString("message");
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
} catch (JSONException e) {
e.printStackTrace();
Message msg2 = new Message();
msg2.what = FinalValue.ROLELEVEL_FAIL_CODE;
msg2.obj = FinalValue.ROLELEVEL_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg2);
}
}
@Override
public void fail(String error) {
ProgressCircleUtils.closeProgress();
Message msg = new Message();
msg.what = FinalValue.ROLELEVEL_FAIL_CODE;
msg.obj = FinalValue.ROLELEVEL_FAIL_MSG;
UmarkGameSdk.this.mHandler.sendMessage(msg);
}
});
}
});
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode != 101) {
if (requestCode == 10114) {
init(this.mContext, this.mInitConfigure);
return;
}
return;
}
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != 0) {
this.showRequestPermission = ActivityCompat.shouldShowRequestPermissionRationale(this.mContext, permissions[i]);
if (this.showRequestPermission) {
Toast.makeText(this.mContext, "需要开启,存储权限才能登陆游戏", 1).show();
} else {
Toast.makeText(this.mContext, "请去检查存储权限是否开启", 1).show();
return;
}
}
}
}
public void onStart(final Activity context) {
if (context == null) {
return;
}
this.mContext = context;
TimerUtils.getInstance().start();
TimerUtils.getInstance().startTime();
if (isForeground(context, "com.umarkgame.umarksdk.activity.CustomerFindAccountActivity")) {
return;
}
context.runOnUiThread(new Runnable() {
@Override
public void run() {
if (UmarkGameSdk.this.mFloatBall != null) {
UmarkGameSdk.this.mFloatBall.show();
}
if (UmarkGameSdk.this.isRegisterHomeReceiver) {
FloatManager.getFloatManager(context).createView();
}
}
});
}
public void onRestart(Activity context) {
if (context == null) {
return;
}
context.runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
}
private boolean isForeground(Context context, String className) {
if (context == null || TextUtils.isEmpty(className)) {
return false;
}
ActivityManager am = (ActivityManager) context.getSystemService("activity");
List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(1);
if (list != null && list.size() > 0) {
ComponentName cpn = list.get(0).topActivity;
if (className.equals(cpn.getClassName())) {
return true;
}
}
return false;
}
public void onResume(final Activity context) {
if (context == null) {
return;
}
AppLog.onResume(context);
context.runOnUiThread(new Runnable() {
@Override
public void run() {
if (UmarkGameSdk.this.mFloatBall != null) {
UmarkGameSdk.this.mFloatBall.show();
}
if (UmarkGameSdk.this.isRegisterHomeReceiver) {
FloatManager.getFloatManager(context).createView();
}
}
});
}
public void onPause(final Activity context) {
if (context == null) {
return;
}
Log.e("umarkgame", "onPause");
AppLog.onPause(context);
TimerUtils.getInstance().stop();
context.runOnUiThread(new Runnable() {
@Override
public void run() {
FloatManager.getFloatManager(context).destroyFloat();
}
});
}
public void onStop(Activity context) {
if (context == null) {
return;
}
TimerUtils.getInstance().stop();
context.runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
}
public void initUnicorn(Context context) {
this.application = (Application) context;
Unicorn.init(context, "eedd7d4c324768dc11c257c7d6b542c0", options(), new UnicornImageLoader() {
@Override
public Bitmap loadImageSync(String s, int i, int i1) {
return null;
}
@Override
public void loadImage(String s, int i, int i1, ImageLoaderListener imageLoaderListener) {
}
});
getInstance().getDouYinChildChannel(context);
}
private YSFOptions options() {
YSFOptions option = new YSFOptions();
option.statusBarNotificationConfig = new StatusBarNotificationConfig();
return option;
}
public static String getSystemProperty(String propName) {
String line = "";
BufferedReader input = null;
try {
try {
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
input.close();
} catch (IOException e) {
}
} catch (IOException e2) {
e2.printStackTrace();
if (input != null) {
input.close();
}
}
return line;
} catch (Throwable th) {
if (input != null) {
try {
input.close();
} catch (IOException e3) {
}
}
throw th;
}
}
public void onDestroy(final Activity context) {
if (context == null) {
return;
}
context.runOnUiThread(new Runnable() {
@Override
public void run() {
LogUtils.output("", "退出游戏");
if (UmarkGameSdk.this.mQueue != null) {
UmarkGameSdk.this.mQueue.stop();
}
FloatManager.getFloatManager(context).destroyFloat();
UmarkGameSdk.this.statReYunExitSdk();
if (UmarkGameSdk.this.mContext != null && UmarkGameSdk.this.mHomeKeyEventReceiver != null && UmarkGameSdk.this.isRegisterHomeReceiver) {
UmarkGameSdk.this.isRegisterHomeReceiver = false;
UmarkGameSdk.this.mContext.unregisterReceiver(UmarkGameSdk.this.mHomeKeyEventReceiver);
}
Process.killProcess(Process.myPid());
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
int i = PhoneInfo.HW;
}
public void initRangersapp(Activity context) {
InitConfig config = new InitConfig(umark_douyin_appid + "", "ljzq001");
config.setUriConfig(0);
ILogger logger = new ILogger() {
@Override
public void log(String s, Throwable throwable) {
Log.e("AppLog", s);
}
};
config.setLogger(logger);
config.setEnablePlay(true);
config.setAbEnable(true);
config.setAutoStart(true);
AppLog.init(this.application, config);
Map headerMap = new HashMap();
headerMap.put("level", 1);
headerMap.put("gender", "female");
AppLog.setHeaderInfo((HashMap) headerMap);
Log.e("umarkgame", "init rangersapp");
}
}