Compare commits
1 Commits
gong_dev_a
...
gong_dev_g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1deb197af6 |
@@ -1,26 +0,0 @@
|
||||
package com.yunbao.faceunity;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.Instrimport com.yunbao.common.utils.MobclickAgent;ntationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.yunbao.faceunity.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -75,99 +75,6 @@ android {
|
||||
exclude 'lib/arm64-v8a/libfuai.so'
|
||||
}
|
||||
|
||||
//声网 rtc
|
||||
exclude 'lib/arm64-v8a/libagora_ai_echo_cancellation_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_ai_noise_suppression_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_audio_beauty_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_clear_vision_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_content_inspect_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_face_capture_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_face_detection_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_lip_sync_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_screen_capture_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_segmentation_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_spatial_audio_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_video_av1_decoder_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_video_decoder_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_video_encoder_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora_video_quality_analyzer_extension.so'
|
||||
exclude 'lib/arm64-v8a/libagora-core.so'
|
||||
exclude 'lib/arm64-v8a/libagora-fdkaac.so'
|
||||
exclude 'lib/arm64-v8a/libagora-ffmpeg.so'
|
||||
exclude 'lib/arm64-v8a/libagora-rtc-sdk.so'
|
||||
exclude 'lib/arm64-v8a/libagora-soundtouch.so'
|
||||
exclude 'lib/arm64-v8a/libvideo_dec.so'
|
||||
exclude 'lib/arm64-v8a/libvideo_enc.so'
|
||||
|
||||
exclude 'lib/armeabi-v7a/libagora_ai_echo_cancellation_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_ai_noise_suppression_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_audio_beauty_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_clear_vision_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_content_inspect_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_face_capture_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_face_detection_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_lip_sync_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_screen_capture_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_segmentation_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_spatial_audio_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_video_av1_decoder_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_video_decoder_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_video_encoder_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora_video_quality_analyzer_extension.so'
|
||||
exclude 'lib/armeabi-v7a/libagora-core.so'
|
||||
exclude 'lib/armeabi-v7a/libagora-fdkaac.so'
|
||||
exclude 'lib/armeabi-v7a/libagora-ffmpeg.so'
|
||||
exclude 'lib/armeabi-v7a/libagora-rtc-sdk.so'
|
||||
exclude 'lib/armeabi-v7a/libagora-soundtouch.so'
|
||||
exclude 'lib/armeabi-v7a/libvideo_dec.so'
|
||||
exclude 'lib/armeabi-v7a/libvideo_enc.so'
|
||||
|
||||
exclude 'lib/x86/libagora_ai_echo_cancellation_extension.so'
|
||||
exclude 'lib/x86/libagora_ai_noise_suppression_extension.so'
|
||||
exclude 'lib/x86/libagora_audio_beauty_extension.so'
|
||||
exclude 'lib/x86/libagora_clear_vision_extension.so'
|
||||
exclude 'lib/x86/libagora_content_inspect_extension.so'
|
||||
exclude 'lib/x86/libagora_face_capture_extension.so'
|
||||
exclude 'lib/x86/libagora_face_detection_extension.so'
|
||||
exclude 'lib/x86/libagora_lip_sync_extension.so'
|
||||
exclude 'lib/x86/libagora_screen_capture_extension.so'
|
||||
exclude 'lib/x86/libagora_segmentation_extension.so'
|
||||
exclude 'lib/x86/libagora_spatial_audio_extension.so'
|
||||
exclude 'lib/x86/libagora_video_av1_decoder_extension.so'
|
||||
exclude 'lib/x86/libagora_video_decoder_extension.so'
|
||||
exclude 'lib/x86/libagora_video_encoder_extension.so'
|
||||
exclude 'lib/x86/libagora_video_quality_analyzer_extension.so'
|
||||
exclude 'lib/x86/libagora-core.so'
|
||||
exclude 'lib/x86/libagora-fdkaac.so'
|
||||
exclude 'lib/x86/libagora-ffmpeg.so'
|
||||
exclude 'lib/x86/libagora-rtc-sdk.so'
|
||||
exclude 'lib/x86/libagora-soundtouch.so'
|
||||
exclude 'lib/x86/libvideo_dec.so'
|
||||
exclude 'lib/x86/libvideo_enc.so'
|
||||
|
||||
exclude 'lib/x86_64/libagora_ai_echo_cancellation_extension.so'
|
||||
exclude 'lib/x86_64/libagora_ai_noise_suppression_extension.so'
|
||||
exclude 'lib/x86_64/libagora_audio_beauty_extension.so'
|
||||
exclude 'lib/x86_64/libagora_clear_vision_extension.so'
|
||||
exclude 'lib/x86_64/libagora_content_inspect_extension.so'
|
||||
exclude 'lib/x86_64/libagora_face_capture_extension.so'
|
||||
exclude 'lib/x86_64/libagora_face_detection_extension.so'
|
||||
exclude 'lib/x86_64/libagora_lip_sync_extension.so'
|
||||
exclude 'lib/x86_64/libagora_screen_capture_extension.so'
|
||||
exclude 'lib/x86_64/libagora_segmentation_extension.so'
|
||||
exclude 'lib/x86_64/libagora_spatial_audio_extension.so'
|
||||
exclude 'lib/x86_64/libagora_video_av1_decoder_extension.so'
|
||||
exclude 'lib/x86_64/libagora_video_decoder_extension.so'
|
||||
exclude 'lib/x86_64/libagora_video_encoder_extension.so'
|
||||
exclude 'lib/x86_64/libagora_video_quality_analyzer_extension.so'
|
||||
exclude 'lib/x86_64/libagora-core.so'
|
||||
exclude 'lib/x86_64/libagora-fdkaac.so'
|
||||
exclude 'lib/x86_64/libagora-ffmpeg.so'
|
||||
exclude 'lib/x86_64/libagora-rtc-sdk.so'
|
||||
exclude 'lib/x86_64/libagora-soundtouch.so'
|
||||
exclude 'lib/x86_64/libvideo_dec.so'
|
||||
exclude 'lib/x86_64/libvideo_enc.so'
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_18
|
||||
@@ -381,6 +288,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs', '../libs'
|
||||
@@ -398,7 +306,6 @@ dependencies {
|
||||
api project(':main')
|
||||
//短视频
|
||||
api project(':video')
|
||||
implementation project(path: ':lib_so')
|
||||
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@ import com.blankj.utilcode.util.Utils;
|
||||
import com.facebook.appevents.AppEventsLogger;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.google.gson.Gson;
|
||||
import com.pdlive.lib_so.DynamicSoLauncher;
|
||||
import com.yunbao.common.utils.LogUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.BuildConfig;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
@@ -37,7 +39,6 @@ import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.AnchorStartLiveBean;
|
||||
import com.yunbao.common.bean.CrashSaveBean;
|
||||
import com.yunbao.common.event.SudGameSocketImEvent;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
||||
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
@@ -47,9 +48,6 @@ import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LoadSoUtil;
|
||||
import com.yunbao.common.utils.LogUtils;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.live.socket.SocketReceiveBean;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
@@ -146,17 +144,6 @@ public class AppContext extends CommonAppContext {
|
||||
if (!isMainProcess()) {
|
||||
return;
|
||||
}
|
||||
//如果第三方的SDK自己不支持动态加载so文件时,需要自己主动加载so
|
||||
String path = LoadSoUtil.so_path + "/";
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
}
|
||||
// 在合适的时候将自定义路径插入so检索路径 需要使用者自己负责在这个路径上有写入权限
|
||||
DynamicSoLauncher.INSTANCE.initDynamicSoConfig(this, path, s -> {
|
||||
// 处理一些自定义逻辑
|
||||
return true;
|
||||
});
|
||||
CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis());
|
||||
//注册全局异常捕获
|
||||
registerError();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shayu.phonelive.activity;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
@@ -21,6 +22,7 @@ import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
@@ -48,12 +50,14 @@ import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DownloadUtil;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.views.LauncherAdViewHolder;
|
||||
import com.yunbao.main.activity.EntryActivity;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
@@ -77,9 +81,9 @@ import myname.pdlive.shayu.R;
|
||||
@Route(path = RouteUtil.PATH_LAUNCHER)
|
||||
public class LauncherActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = "LauncherActivity";
|
||||
private static final int WHAT_GET_CONFIG = 0;
|
||||
private static final int WHAT_COUNT_DOWN = 1;
|
||||
private final String TAG = "LauncherActivity";
|
||||
private final int WHAT_GET_CONFIG = 0;
|
||||
private final int WHAT_COUNT_DOWN = 1;
|
||||
protected Context mContext;
|
||||
private Handler mHandler;
|
||||
private ViewGroup mRoot;
|
||||
@@ -588,5 +592,4 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ allprojects {
|
||||
ext {
|
||||
IS_PUBLISH_LOCAL=true
|
||||
LIB_VERSION="1.0.6"
|
||||
AGORA_RTC_SDK= 'io.agora.rtc:agora-special-full:4.2.6.14'
|
||||
AGORA_RTC_SDK= 'io.agora.rtc:agora-special-full:4.2.6.12'
|
||||
// AGORA_RTC_SDK= "${rootProject.rootDir.absolutePath}/sdk"
|
||||
// AGORA_RTC_SDK="io.agora.rtc:full-sdk:4.2.6"
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ repositories {
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation project(':lib_so')
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
api files('libs/jcc-bate-0.7.3.jar')
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CommonHttpConsts {
|
||||
public static final String DOWNLOAD_GIF = "downloadGif";
|
||||
public static final String GET_BALANCE = "getBalance";
|
||||
public static final String CHECK_TOKEN_INVALID = "checkTokenInvalid";
|
||||
public static final String NOTIFY_GOOGLE = "Charge.google_pay";
|
||||
public static final String NOTIFY_GOOGLE = "Charge.goole_validate_pd";
|
||||
public static final String COMMUNITY_SETREPORT = "Community.setReport";
|
||||
|
||||
public static final String GET_USER_HOME = "getUserHome";
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.lzy.okgo.request.PostRequest;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.ErrorActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
@@ -400,8 +399,12 @@ public class CommonHttpUtil {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE).params("purchaseToken", purchaseToken).params("productId", productId).params("orderno", orderno).params("package_name", "com.pdlive.shayu").execute(callback);
|
||||
}
|
||||
|
||||
public static void notifyGoogle(String purchaseToken, String orderNo, String tradeNo, String allData, String gps_adid, HttpCallback callback) {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE).params("purchaseToken", purchaseToken).params("orderno", orderNo).params("trade_no", tradeNo).params("allData", allData).params("gps_adid", gps_adid).params("package_name", "com.pdlive.shayu").execute(callback);
|
||||
public static void notifyGoogle(String purchaseToken, String productId, HttpCallback callback) {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE)
|
||||
.params("purchaseToken", purchaseToken)
|
||||
.params("productId", productId)
|
||||
.params("package_name", "com.pdlive.shayu")
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
public static void Google_sec_pay(String purchaseToken, String orderNo, String tradeNo, HttpCallback callback) {
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.yunbao.common.pay.google;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingClientStateListener;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.BillingResult;
|
||||
import com.android.billingclient.api.ConsumeParams;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.PurchasesUpdatedListener;
|
||||
import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
import com.android.billingclient.api.QueryPurchasesParams;
|
||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//谷歌支付
|
||||
public class GooglePlay implements PurchasesUpdatedListener {
|
||||
|
||||
private String TAG = "mLog";
|
||||
private BillingClient billingClient;
|
||||
private GoogleBillingListener billingListener;
|
||||
|
||||
private GooglePlay() {
|
||||
init();
|
||||
}
|
||||
|
||||
private boolean init() {
|
||||
if (getGoogleService() && billingClient == null) {
|
||||
billingClient = BillingClient.newBuilder(CommonAppContext.sInstance)
|
||||
.setListener(this)
|
||||
.enablePendingPurchases()
|
||||
.build();
|
||||
startConnection();
|
||||
return true;
|
||||
}
|
||||
if (billingClient != null && !billingClient.isReady()) {//没有连接的话去连接
|
||||
startConnection();
|
||||
}
|
||||
if (billingClient == null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startConnection() {
|
||||
if (!billingClient.isReady()) {
|
||||
//请求连接到GooglePay
|
||||
billingClient.startConnection(new BillingClientStateListener() {
|
||||
@Override
|
||||
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "连接到GooglePay失败 code = " + code + " msg = " + msg);
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "连接到GooglePay成功");
|
||||
}
|
||||
|
||||
//连接失败
|
||||
@Override
|
||||
public void onBillingServiceDisconnected() {
|
||||
Log.e(TAG, "连接到GooglePay失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点击商品,先查询商品 然后出来支付界面,调用下单
|
||||
public void purchase(Activity activity, String orderNumber, String id) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
ImmutableList<QueryProductDetailsParams.Product> productList = ImmutableList.of(QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductId(id)
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.build());
|
||||
QueryProductDetailsParams queryProductDetailsParams =
|
||||
QueryProductDetailsParams.newBuilder()
|
||||
.setProductList(productList)
|
||||
.build();
|
||||
billingClient.queryProductDetailsAsync(
|
||||
queryProductDetailsParams,
|
||||
(billingResult, list) -> {
|
||||
//查询商品成功
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK || list == null || list.isEmpty()) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "查询商品失败 code = " + code + " msg = " + msg);
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "查询商品成功");
|
||||
buyIt(activity, orderNumber, list.get(0));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//开始下单,准备生成订单了
|
||||
private void buyIt(Activity activity, String orderNumber, ProductDetails productDetails) {
|
||||
List<BillingFlowParams.ProductDetailsParams> productDetailsParamsList = new ArrayList<>();
|
||||
productDetailsParamsList.add(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
// retrieve a value for "productDetails" by calling queryProductDetailsAsync()
|
||||
.setProductDetails(productDetails)
|
||||
// For one-time products, "setOfferToken" method shouldn't be called.
|
||||
// For subscriptions, to get an offer token, call
|
||||
// ProductDetails.subscriptionOfferDetails() for a list of offers
|
||||
// that are available to the user.
|
||||
//一次性商品不需要传token
|
||||
// .setOfferToken(selectedOfferToken)
|
||||
.build());
|
||||
|
||||
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
|
||||
.setProductDetailsParamsList(productDetailsParamsList)
|
||||
.setObfuscatedAccountId(orderNumber)//好像是账号id
|
||||
.build();
|
||||
|
||||
BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "购买商品失败 code = " + code + " msg = " + msg);
|
||||
// ToastUtil.show(getString(R.string.pay_suc));
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "购买商品 " + productDetails.toString());
|
||||
}
|
||||
|
||||
//消耗商品 支付成功之后,调用我们后台下发商品成功之后,调用消耗
|
||||
public void consume(List<Purchase> list) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
for (Purchase purchase : list) {
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗所有商品
|
||||
*/
|
||||
public void consumeAll() {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
//以下示例展示了如何提取用户的订阅购买交易。请注意,queryPurchasesAsync() 仅返回有效订阅和非消耗型一次性购买交易。
|
||||
QueryPurchasesParams inAppPurchasesQuery = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build();
|
||||
billingClient.queryPurchasesAsync(inAppPurchasesQuery, (billingResult, list) -> {
|
||||
if (BillingClient.BillingResponseCode.OK == billingResult.getResponseCode()) {
|
||||
for (Purchase purchase : list) {
|
||||
//0:PurchaseState.UNSPECIFIED_STATE:未知状态
|
||||
//1:PurchaseState.PURCHASED:付款完成
|
||||
//2:PurchaseState.PENDING:购买正在等待付款完成。
|
||||
if (Purchase.PurchaseState.PURCHASED == purchase.getPurchaseState()) {
|
||||
//调用google去消费
|
||||
//如果之后有问题再研究怎么解决掉单的问题
|
||||
CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(),
|
||||
purchase.getProducts().get(0), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共消费商品接口
|
||||
*/
|
||||
private void getConsumeGoods(Purchase purchase) {
|
||||
if (purchase != null) {
|
||||
Log.i(TAG, "-----开始消耗商品:" + purchase.toString());
|
||||
ConsumeParams.Builder consumeParams = ConsumeParams.newBuilder();
|
||||
consumeParams.setPurchaseToken(purchase.getPurchaseToken());
|
||||
//调用消耗商品方法
|
||||
consumeAsync(consumeParams.build(), purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗商品
|
||||
* int SERVICE_TIMEOUT = -3; //服务超时
|
||||
* int FEATURE_NOT_SUPPORTED = -2; //不支持功能
|
||||
* int SERVICE_DISCONNECTED = -1; //服务单元已断开
|
||||
* int OK = 0; //成功
|
||||
* int USER_CANCELED = 1; //用户按上一步或取消对话框
|
||||
* int SERVICE_UNAVAILABLE = 2; //网络连接断开
|
||||
* int BILLING_UNAVAILABLE = 3; //所请求的类型不支持 Google Play 结算服务 AIDL 版本
|
||||
* int ITEM_UNAVAILABLE = 4; //请求的商品已不再出售。
|
||||
* int DEVELOPER_ERROR = 5; //提供给 API 的参数无效。此错误也可能说明应用未针对结算服务正确签名或设置,或者在其清单中缺少必要的权限。
|
||||
* int ERROR = 6; //API 操作期间出现严重错误
|
||||
* int ITEM_ALREADY_OWNED = 7; //未能购买,因为已经拥有此商品
|
||||
* int ITEM_NOT_OWNED = 8; //未能消费,因为尚未拥有此商品
|
||||
*/
|
||||
private void consumeAsync(ConsumeParams consumeParams, Purchase purchase) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
billingClient.consumeAsync(consumeParams, (billingResult, purchaseToken) -> {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
Log.i(TAG, "-----消耗商品成功");
|
||||
} else {
|
||||
Log.i(TAG, "-----消耗商品失败" + billingResult.toString() + "---" + purchaseToken + "--code:" + billingResult.getResponseCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
|
||||
&& purchases != null) {
|
||||
//支付成功
|
||||
if (billingListener != null)//消耗掉商品放到外面调用我们服务器成功的时候去消耗 todo 暂时注释掉 这样可以模拟掉单的问题
|
||||
billingListener.onPaySuccess(purchases);
|
||||
/*
|
||||
* 一旦您验证了购买交易,您的应用就可以向用户授予使用权了。若要确认与购买交易相关联的用户账号,
|
||||
* 您可以使用 Purchases.products:get 返回的 ProductPurchase.obfuscatedExternalAccountId(适用于应用内商品的购买交易)
|
||||
* 和 Purchases.subscriptions:get 返回的 SubscriptionPurchase.obfuscatedExternalAccountId(适用于服务器端的订阅),
|
||||
* 或者 Purchase.getAccountIdentifiers() 在客户端返回的 obfuscatedAccountId(如果在交易时已使用 setObfuscatedAccountId 设置该 ID)。
|
||||
* */
|
||||
// purchases.get(0).getAccountIdentifiers()
|
||||
for (Purchase purchase : purchases) {
|
||||
Log.d("mLog", "谷歌支付的回调 " + purchase);
|
||||
}
|
||||
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
|
||||
//取消支付了
|
||||
if (billingListener != null)
|
||||
billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_cancel));
|
||||
} else {
|
||||
//支付失败
|
||||
if (billingListener != null)
|
||||
billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_fail));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测GooglePlay服务是否可用(需要导入包api "com.google.android.gms:play-services-location:11.8.0",也可以不检查,跳过这个代码)
|
||||
*/
|
||||
public boolean getGoogleService() {
|
||||
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
|
||||
if (googleApiAvailability != null) {
|
||||
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(CommonAppContext.sInstance);
|
||||
return resultCode == ConnectionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getAdId() {
|
||||
try {
|
||||
return AdvertisingIdClient.getAdvertisingIdInfo(CommonAppContext.sInstance).getId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("GooglePlay", "获取谷歌的id错误了");
|
||||
}
|
||||
return "google_default_id";
|
||||
}
|
||||
|
||||
public void setBillingListener(GoogleBillingListener listener) {
|
||||
billingListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义接口返回支付结果
|
||||
*/
|
||||
public interface GoogleBillingListener {
|
||||
void onPaySuccess(List<Purchase> purchases);
|
||||
|
||||
void onPayFailed(String msg);
|
||||
}
|
||||
|
||||
public static class GooglePlayHelper {
|
||||
static GooglePlay googlePlay = new GooglePlay();
|
||||
}
|
||||
|
||||
public static GooglePlay getInstance() {
|
||||
return GooglePlayHelper.googlePlay;
|
||||
}
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.pdlive.lib_so.DynamicSoLauncher;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class LoadSoUtil {
|
||||
|
||||
//so保存的路径
|
||||
public static final String so_path = CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + "/" + LoadSoUtil.so_path;
|
||||
|
||||
/**
|
||||
* 先加载so文件,再去做初始化的操作
|
||||
* 1.正常的流程,判断手机的类型 加载不同的so(SUPPORTED_ABIS[0].contains("64"),代码中还未实现 )
|
||||
* 2.通过不同的url去下载对应的so的zip文件
|
||||
* 3.解压zip到指定位置
|
||||
* 4.加载解压完成的so文件
|
||||
*/
|
||||
public static void downloadSoAndLoad(Context context, onLoadSoListener listener) {
|
||||
//检查本地是否创建了zip的缓存文件
|
||||
String path = context.getFilesDir().getAbsolutePath() + "/so_zip";
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
} else if (isLoadSo()) {//这里去验证so文件是否已经下载过了
|
||||
loadSo(listener);
|
||||
return;
|
||||
}
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10 * 5, TimeUnit.SECONDS)
|
||||
.cookieJar(new CookieJar() {
|
||||
private final HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void saveFromResponse(@NotNull HttpUrl httpUrl, @NotNull List<Cookie> list) {
|
||||
cookieStore.put(httpUrl.host(), list);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Cookie> loadForRequest(@NotNull HttpUrl httpUrl) {
|
||||
List<Cookie> cookies = cookieStore.get(httpUrl.host());
|
||||
return cookies != null ? cookies : new ArrayList<>();
|
||||
}
|
||||
});
|
||||
builder.hostnameVerifier((hostname, session) -> true);
|
||||
//开始下载文件
|
||||
downloadFile(builder.build(), "https://downs.yaoulive.com/x86.zip", new File(path + "/" + "libSo.zip"), new onLoadSoListener() {
|
||||
@Override
|
||||
public void ok() {
|
||||
//下载完成开始解压 解压完成之后 区初始化声网数据
|
||||
zip(path + "/" + "libSo.zip", listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error() {
|
||||
listener.error();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载完成解压zip文件
|
||||
*/
|
||||
private static void zip(String path, onLoadSoListener listener) {
|
||||
ZipInputStream zis = null;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
zis = new ZipInputStream(new FileInputStream(path));
|
||||
ZipEntry ze;
|
||||
String soPath = so_path;
|
||||
File file = new File(soPath);
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
}
|
||||
while ((ze = zis.getNextEntry()) != null) {
|
||||
String fileName = ze.getName();
|
||||
File newFile = new File(soPath + File.separator + fileName);
|
||||
fos = new FileOutputStream(newFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
zis.closeEntry();
|
||||
}
|
||||
loadSo(listener);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
listener.error();
|
||||
} finally {
|
||||
try {
|
||||
if (zis != null) zis.close();
|
||||
if (fos != null) fos.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 去下载so的zip文件
|
||||
* 可以在下载之前去做zip是否已经下载的验证,还可以根据版本做区分(是否是最新版本,要不要做断点续传)
|
||||
*/
|
||||
private static void downloadFile(OkHttpClient mOkHttpClient, String url, File file, onLoadSoListener listener) {
|
||||
Request request = new Request.Builder()
|
||||
.get()
|
||||
.url(url)
|
||||
.build();
|
||||
mOkHttpClient.newCall(request)
|
||||
.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
if (listener != null) listener.error();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) {
|
||||
if (response.isSuccessful()) {
|
||||
InputStream is = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
is = response.body().byteStream();
|
||||
bos = new BufferedOutputStream(new FileOutputStream(file));
|
||||
byte[] bytes = new byte[10240];
|
||||
int len;
|
||||
while ((len = is.read(bytes)) != -1) {
|
||||
bos.write(bytes, 0, len);
|
||||
}
|
||||
bos.flush();
|
||||
if (listener != null) listener.ok();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (listener != null) listener.error();
|
||||
} finally {
|
||||
try {
|
||||
if (bos != null) bos.close();
|
||||
if (is != null) is.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isLoadSo() {
|
||||
File fileSo = new File(so_path);
|
||||
if (!fileSo.exists()) {
|
||||
fileSo.mkdir();
|
||||
}
|
||||
if (fileSo.listFiles().length == 22) {//说明之前已经保存了
|
||||
Log.i("mLog", "已经下载了so 所有直接加载就行 ");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用自己实现的加载so的方式
|
||||
*/
|
||||
public static void loadSo(onLoadSoListener listener) {
|
||||
File fileSo = new File(so_path);
|
||||
if (!fileSo.exists()) {
|
||||
fileSo.mkdir();
|
||||
}
|
||||
File file[] = fileSo.listFiles();
|
||||
for (int i = 0; i < file.length; i++) {
|
||||
DynamicSoLauncher.INSTANCE.loadSoDynamically(file[i]);
|
||||
}
|
||||
listener.ok();
|
||||
}
|
||||
|
||||
public interface onLoadSoListener {
|
||||
void ok();
|
||||
|
||||
void error();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
@@ -108,23 +106,6 @@ public class ToastUtil {
|
||||
Log.i("ts", "ll");
|
||||
Toast.makeText(CommonAppContext.sInstance, s, Toast.LENGTH_SHORT).show();
|
||||
Log.i("ts", "22");
|
||||
|
||||
// long curTime = System.currentTimeMillis();
|
||||
// if (curTime - sLastTime > 2000) {
|
||||
// sLastTime = curTime;
|
||||
// sLastString = s;
|
||||
//// sToast.setText(s);
|
||||
//// sToast.show();
|
||||
// } else {
|
||||
// if (!s.equals(sLastString)) {
|
||||
// sLastTime = curTime;
|
||||
// sLastString = s;
|
||||
// sToast = makeToast();
|
||||
// sToast.setText(s);
|
||||
// sToast.show();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,18 +2,34 @@ package io.agora.beautyapi.faceunity.agora;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.opengl.EGL14;
|
||||
import android.opengl.EGLConfig;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.opengl.GLES20;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.manager.MicUserManager;
|
||||
import com.yunbao.common.manager.MicedUserManager;
|
||||
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.agora.rtc2.ChannelMediaOptions;
|
||||
@@ -23,6 +39,15 @@ import io.agora.rtc2.RtcConnection;
|
||||
import io.agora.rtc2.RtcEngineConfig;
|
||||
import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 声网主播管理类
|
||||
@@ -37,7 +62,6 @@ public class SWAuManager extends BaseCacheManager {
|
||||
private FrameLayout pkContainer2; //pk主播视图2
|
||||
private FrameLayout pkContainer3; //pk主播视图3
|
||||
private FrameLayout linkUserContainer;//连麦用户视图
|
||||
private List<LiveBean> mDatas=new ArrayList<>();//保存数据 如果还没初始化的时候就把这个数据保存起来,等加载完so再来添加
|
||||
|
||||
private int liveMicUid;
|
||||
|
||||
@@ -417,21 +441,9 @@ public class SWAuManager extends BaseCacheManager {
|
||||
}
|
||||
|
||||
public void preloadChannel(List<LiveBean> uids) {
|
||||
if (mRtcEngine==null){
|
||||
mDatas.addAll(uids);
|
||||
}else {
|
||||
for (int i = 0; i < uids.size(); i++) {
|
||||
int code = mRtcEngine.preloadChannel(CommonAppConfig.SWToken, getChannelName(uids.get(i).getUid()), Integer.parseInt(CommonAppConfig.getInstance().getUid()));
|
||||
L.eSw("设置秒开数据 uid" + uids.get(i).getUid() + " --- userName:" + uids.get(i).getUserNiceName() + " code " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void preloadChannel() {
|
||||
if (mRtcEngine!=null && mDatas.size()>0){
|
||||
for (int i = 0; i < mDatas.size(); i++) {
|
||||
int code = mRtcEngine.preloadChannel(CommonAppConfig.SWToken, getChannelName(mDatas.get(i).getUid()), Integer.parseInt(CommonAppConfig.getInstance().getUid()));
|
||||
L.eSw("设置秒开数据 uid" + mDatas.get(i).getUid() + " --- userName:" + mDatas.get(i).getUserNiceName() + " code " + code);
|
||||
}
|
||||
for (int i = 0; i < uids.size(); i++) {
|
||||
int code = mRtcEngine.preloadChannel(CommonAppConfig.SWToken, getChannelName(uids.get(i).getUid()), Integer.parseInt(CommonAppConfig.getInstance().getUid()));
|
||||
L.eSw("设置秒开数据 uid" + uids.get(i).getUid() + " --- userName:" + uids.get(i).getUserNiceName() + " code " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
|
||||
|
||||
public GoogleBillingManage(Activity activity) {
|
||||
this.mContext = activity;
|
||||
queryFailOrder();
|
||||
}
|
||||
|
||||
public void initGooglePay() {
|
||||
@@ -117,6 +118,82 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询失败的订单
|
||||
* skuType :,BillingClient.SkuType.INAPP 内购 BillingClient.SkuType.SUBS订阅
|
||||
* 0:PurchaseState.UNSPECIFIED_STATE:未知状态
|
||||
* 1:PurchaseState.PURCHASED:付款完成
|
||||
* 2:PurchaseState.PENDING:购买正在等待付款完成。
|
||||
*/
|
||||
public void queryFailOrder(/*String skuType*/) {
|
||||
Log.i(TAG, "-查询失败订单(支付成功未消耗)");
|
||||
if (billingClient != null) {
|
||||
billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, new PurchasesResponseListener() {
|
||||
@Override
|
||||
public void onQueryPurchasesResponse(@NonNull BillingResult result, @NonNull List<Purchase> list) {
|
||||
if (BillingClient.BillingResponseCode.OK == result.getResponseCode()) {
|
||||
for (Purchase purchase : list) {
|
||||
//PURCHASED --已购买
|
||||
if (Purchase.PurchaseState.PURCHASED == purchase.getPurchaseState()) {
|
||||
//todo 这里可以同步发送消息到后台 看订单是否下发了 没有就下发一下
|
||||
//调用google去消费
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共消费商品接口
|
||||
*/
|
||||
private void getConsumeGoods(Purchase purchase) {
|
||||
if (purchase != null) {
|
||||
Log.i(TAG, "-----开始消耗商品:" + purchase.toString());
|
||||
ConsumeParams.Builder consumeParams = ConsumeParams.newBuilder();
|
||||
consumeParams.setPurchaseToken(purchase.getPurchaseToken());
|
||||
//调用消耗商品方法
|
||||
consumeAsync(consumeParams.build(), purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗商品
|
||||
* int SERVICE_TIMEOUT = -3; //服务超时
|
||||
* int FEATURE_NOT_SUPPORTED = -2; //不支持功能
|
||||
* int SERVICE_DISCONNECTED = -1; //服务单元已断开
|
||||
* int OK = 0; //成功
|
||||
* int USER_CANCELED = 1; //用户按上一步或取消对话框
|
||||
* int SERVICE_UNAVAILABLE = 2; //网络连接断开
|
||||
* int BILLING_UNAVAILABLE = 3; //所请求的类型不支持 Google Play 结算服务 AIDL 版本
|
||||
* int ITEM_UNAVAILABLE = 4; //请求的商品已不再出售。
|
||||
* int DEVELOPER_ERROR = 5; //提供给 API 的参数无效。此错误也可能说明应用未针对结算服务正确签名或设置,或者在其清单中缺少必要的权限。
|
||||
* int ERROR = 6; //API 操作期间出现严重错误
|
||||
* int ITEM_ALREADY_OWNED = 7; //未能购买,因为已经拥有此商品
|
||||
* int ITEM_NOT_OWNED = 8; //未能消费,因为尚未拥有此商品
|
||||
*/
|
||||
public void consumeAsync(ConsumeParams consumeParams, Purchase purchase) {
|
||||
if (billingClient == null) {
|
||||
return;
|
||||
}
|
||||
billingClient.consumeAsync(consumeParams, new ConsumeResponseListener() {
|
||||
@Override
|
||||
public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String s) {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
Log.i(TAG, "-----消耗商品成功");
|
||||
String pId = purchase.getSkus().get(0);
|
||||
// String price = CommonOkHttpUtils.INSTANCE.getPayPrice(pId);
|
||||
Log.i(TAG, "-----消耗商品成功 ");
|
||||
String productToken = purchase.getPurchaseToken();
|
||||
} else {
|
||||
Log.i(TAG, "-----消耗商品失败" + billingResult.toString() + "---" + s + "--code:" + billingResult.getResponseCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean getGoogleService() {
|
||||
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mContext);
|
||||
return code == 0;
|
||||
|
||||
1
lib_so/.gitignore
vendored
1
lib_so/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,31 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.pdlive.lib_so'
|
||||
compileSdk rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdk rootProject.ext.android.minSdkVersion
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_18
|
||||
targetCompatibility JavaVersion.VERSION_18
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api rootProject.ext.dependencies["appcompat-androidx"]
|
||||
}
|
||||
21
lib_so/proguard-rules.pro
vendored
21
lib_so/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.pdlive.lib_so
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
|
||||
@Keep
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class DynamicLoad()
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.pdlive.lib_so;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.pdlive.lib_so.elf.ElfParser;
|
||||
import com.pdlive.lib_so.pathinsert.LoadLibraryUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
class DynamicSo {
|
||||
public static void loadSoDynamically(File soFIle, String path) {
|
||||
try {
|
||||
ElfParser parser = null;
|
||||
final List<String> dependencies;
|
||||
try {
|
||||
parser = new ElfParser(soFIle);
|
||||
dependencies = parser.parseNeededDependencies();
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
//如果nativecpp3->nativecpptwo->nativecpp 则先加载 DynamicSo.loadStaticSo(nativecpptwo),此时nativecpp作为nativecpptwo的直接依赖被加载了
|
||||
//不能直接加载nativecpp3,导致加载直接依赖nativetwo的时候nativecpp没加载导致错误。 这个可以优化,比如递归
|
||||
for (final String dependency : dependencies) {
|
||||
|
||||
try {
|
||||
File file = new File(path + dependency);
|
||||
if (file.exists()) {
|
||||
//递归查找
|
||||
loadSoDynamically(file, path);
|
||||
} else {
|
||||
// so文件不存在这个文件夹,代表是ndk中的so,如liblog.so,则直接加载
|
||||
// 把本来lib前缀和.so后缀去掉即可
|
||||
String dependencySo = dependency.substring(3, dependency.length() - 3);
|
||||
//在application已经注入了路径DynamicSo.insertPathToNativeSystem(this,file) 所以采用系统的加载就行
|
||||
System.loadLibrary(dependencySo);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
// 先把依赖项加载完,再加载本身
|
||||
// System.loadLibrary(soFIle.getName().substring(3, soFIle.getName().length() - 3));
|
||||
Log.i("mLog","通过库加载so "+soFIle.getAbsolutePath());
|
||||
System.load(soFIle.getAbsolutePath());
|
||||
}
|
||||
|
||||
public static void insertPathToNativeSystem(Context context, File file) {
|
||||
try {
|
||||
LoadLibraryUtils.installNativeLibraryPath(context.getClassLoader(), file);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.pdlive.lib_so
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.annotation.Keep
|
||||
import java.io.File
|
||||
|
||||
@Keep
|
||||
object DynamicSoLauncher {
|
||||
private var soPath = ""
|
||||
private var beforeSoLoadListener: ((soName: String) -> Boolean)? = null
|
||||
fun initDynamicSoConfig(context: Context, soPath: String,beforeLoadListener: ((soName: String) -> Boolean)?=null) {
|
||||
DynamicSoLauncher.soPath = soPath
|
||||
beforeSoLoadListener = beforeLoadListener
|
||||
DynamicSo.insertPathToNativeSystem(context, File(soPath))
|
||||
}
|
||||
|
||||
fun loadSoDynamically(file: File) {
|
||||
if (soPath.isEmpty()) {
|
||||
throw RuntimeException("you must call initDynamicSoConfig first. The soPath is empty")
|
||||
}
|
||||
if(beforeSoLoadListener?.invoke(file.name) == false){
|
||||
return
|
||||
}
|
||||
DynamicSo.loadSoDynamically(file, soPath)
|
||||
}
|
||||
|
||||
fun loadSoDynamically(fileName: String) {
|
||||
if (soPath.isEmpty()) {
|
||||
throw RuntimeException("you must call initDynamicSoConfig first. The soPath is empty")
|
||||
}
|
||||
if(beforeSoLoadListener?.invoke(fileName) == false){
|
||||
return
|
||||
}
|
||||
DynamicSo.loadSoDynamically(File(soPath + fileName), soPath)
|
||||
}
|
||||
|
||||
|
||||
// 插件调用
|
||||
@JvmStatic
|
||||
fun loadLibrary(soName: String) {
|
||||
Log.e("hello", soName)
|
||||
val wrapSoName = "lib${soName}.so"
|
||||
loadSoDynamically(wrapSoName)
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Dynamic32Structure extends Elf.DynamicStructure {
|
||||
public Dynamic32Structure(final ElfParser parser, final Elf.Header header,
|
||||
long baseOffset, final int index) throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(4);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
baseOffset = baseOffset + (index * 8);
|
||||
tag = parser.readWord(buffer, baseOffset);
|
||||
val = parser.readWord(buffer, baseOffset + 0x4);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Dynamic64Structure extends Elf.DynamicStructure {
|
||||
public Dynamic64Structure(final ElfParser parser, final Elf.Header header,
|
||||
long baseOffset, final int index) throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
baseOffset = baseOffset + (index * 16);
|
||||
tag = parser.readLong(buffer, baseOffset);
|
||||
val = parser.readLong(buffer, baseOffset + 0x8);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Elf {
|
||||
abstract class Header {
|
||||
public static final int ELFCLASS32 = 1; // 32 Bit ELF
|
||||
public static final int ELFCLASS64 = 2; // 64 Bit ELF
|
||||
public static final int ELFDATA2MSB = 2; // Big Endian, 2s complement
|
||||
|
||||
public boolean bigEndian;
|
||||
public int type;
|
||||
public long phoff;
|
||||
public long shoff;
|
||||
public int phentsize;
|
||||
public int phnum;
|
||||
public int shentsize;
|
||||
public int shnum;
|
||||
public int shstrndx;
|
||||
|
||||
abstract public SectionHeader getSectionHeader(int index) throws IOException;
|
||||
abstract public ProgramHeader getProgramHeader(long index) throws IOException;
|
||||
abstract public DynamicStructure getDynamicStructure(long baseOffset, int index)
|
||||
throws IOException;
|
||||
}
|
||||
|
||||
abstract class ProgramHeader {
|
||||
public static final int PT_LOAD = 1; // Loadable segment
|
||||
public static final int PT_DYNAMIC = 2; // Dynamic linking information
|
||||
|
||||
public long type;
|
||||
public long offset;
|
||||
public long vaddr;
|
||||
public long memsz;
|
||||
}
|
||||
|
||||
abstract class SectionHeader {
|
||||
public long info;
|
||||
}
|
||||
|
||||
abstract class DynamicStructure {
|
||||
public static final int DT_NULL = 0; // Marks end of structure list
|
||||
public static final int DT_NEEDED = 1; // Needed library
|
||||
public static final int DT_STRTAB = 5; // String table
|
||||
|
||||
public long tag;
|
||||
public long val; // Union with d_ptr
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Elf32Header extends Elf.Header {
|
||||
private final ElfParser parser;
|
||||
|
||||
public Elf32Header(final boolean bigEndian, final ElfParser parser) throws IOException {
|
||||
this.bigEndian = bigEndian;
|
||||
this.parser = parser;
|
||||
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(4);
|
||||
buffer.order(bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
type = parser.readHalf(buffer, 0x10);
|
||||
phoff = parser.readWord(buffer, 0x1C);
|
||||
shoff = parser.readWord(buffer, 0x20);
|
||||
phentsize = parser.readHalf(buffer, 0x2A);
|
||||
phnum = parser.readHalf(buffer, 0x2C);
|
||||
shentsize = parser.readHalf(buffer, 0x2E);
|
||||
shnum = parser.readHalf(buffer, 0x30);
|
||||
shstrndx = parser.readHalf(buffer, 0x32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.SectionHeader getSectionHeader(final int index) throws IOException {
|
||||
return new Section32Header(parser, this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.ProgramHeader getProgramHeader(final long index) throws IOException {
|
||||
return new Program32Header(parser, this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.DynamicStructure getDynamicStructure(final long baseOffset, final int index)
|
||||
throws IOException {
|
||||
return new Dynamic32Structure(parser, this, baseOffset, index);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Elf64Header extends Elf.Header {
|
||||
private final ElfParser parser;
|
||||
|
||||
public Elf64Header(final boolean bigEndian, final ElfParser parser) throws IOException {
|
||||
this.bigEndian = bigEndian;
|
||||
this.parser = parser;
|
||||
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
type = parser.readHalf(buffer, 0x10);
|
||||
phoff = parser.readLong(buffer, 0x20);
|
||||
shoff = parser.readLong(buffer, 0x28);
|
||||
phentsize = parser.readHalf(buffer, 0x36);
|
||||
phnum = parser.readHalf(buffer, 0x38);
|
||||
shentsize = parser.readHalf(buffer, 0x3A);
|
||||
shnum = parser.readHalf(buffer, 0x3C);
|
||||
shstrndx = parser.readHalf(buffer, 0x3E);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.SectionHeader getSectionHeader(final int index) throws IOException {
|
||||
return new Section64Header(parser, this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.ProgramHeader getProgramHeader(final long index) throws IOException {
|
||||
return new Program64Header(parser, this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Elf.DynamicStructure getDynamicStructure(final long baseOffset, final int index)
|
||||
throws IOException {
|
||||
return new Dynamic64Structure(parser, this, baseOffset, index);
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ElfParser implements Closeable, Elf {
|
||||
private final int MAGIC = 0x464C457F;
|
||||
private final FileChannel channel;
|
||||
|
||||
public ElfParser(File file) throws FileNotFoundException {
|
||||
if (file == null || !file.exists()) {
|
||||
throw new IllegalArgumentException("File is null or does not exist "+file.getAbsolutePath());
|
||||
}
|
||||
|
||||
final FileInputStream inputStream = new FileInputStream(file);
|
||||
this.channel = inputStream.getChannel();
|
||||
}
|
||||
|
||||
public Header parseHeader() throws IOException {
|
||||
channel.position(0L);
|
||||
|
||||
// Read in ELF identification to determine file class and endianness
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (readWord(buffer, 0) != MAGIC) {
|
||||
throw new IllegalArgumentException("Invalid ELF Magic!");
|
||||
}
|
||||
|
||||
final short fileClass = readByte(buffer, 0x4);
|
||||
final boolean bigEndian = (readByte(buffer, 0x5) == Header.ELFDATA2MSB);
|
||||
if (fileClass == Header.ELFCLASS32) {
|
||||
return new Elf32Header(bigEndian, this);
|
||||
} else if (fileClass == Header.ELFCLASS64) {
|
||||
return new Elf64Header(bigEndian, this);
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Invalid class type!");
|
||||
}
|
||||
|
||||
public List<String> parseNeededDependencies() throws IOException {
|
||||
channel.position(0);
|
||||
final List<String> dependencies = new ArrayList<String>();
|
||||
final Header header = parseHeader();
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
long numProgramHeaderEntries = header.phnum;
|
||||
if (numProgramHeaderEntries == 0xFFFF) {
|
||||
/**
|
||||
* Extended Numbering
|
||||
*
|
||||
* If the real number of program header table entries is larger than
|
||||
* or equal to PN_XNUM(0xffff), it is set to sh_info field of the
|
||||
* section header at index 0, and PN_XNUM is set to e_phnum
|
||||
* field. Otherwise, the section header at index 0 is zero
|
||||
* initialized, if it exists.
|
||||
**/
|
||||
final SectionHeader sectionHeader = header.getSectionHeader(0);
|
||||
numProgramHeaderEntries = sectionHeader.info;
|
||||
}
|
||||
|
||||
long dynamicSectionOff = 0;
|
||||
for (long i = 0; i < numProgramHeaderEntries; ++i) {
|
||||
final ProgramHeader programHeader = header.getProgramHeader(i);
|
||||
if (programHeader.type == ProgramHeader.PT_DYNAMIC) {
|
||||
dynamicSectionOff = programHeader.offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicSectionOff == 0) {
|
||||
// No dynamic linking info, nothing to load
|
||||
return Collections.unmodifiableList(dependencies);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
final List<Long> neededOffsets = new ArrayList<Long>();
|
||||
long vStringTableOff = 0;
|
||||
DynamicStructure dynStructure;
|
||||
do {
|
||||
dynStructure = header.getDynamicStructure(dynamicSectionOff, i);
|
||||
if (dynStructure.tag == DynamicStructure.DT_NEEDED) {
|
||||
neededOffsets.add(dynStructure.val);
|
||||
} else if (dynStructure.tag == DynamicStructure.DT_STRTAB) {
|
||||
vStringTableOff = dynStructure.val; // d_ptr union
|
||||
}
|
||||
++i;
|
||||
} while (dynStructure.tag != DynamicStructure.DT_NULL);
|
||||
|
||||
if (vStringTableOff == 0) {
|
||||
throw new IllegalStateException("String table offset not found!");
|
||||
}
|
||||
|
||||
// Map to file offset
|
||||
final long stringTableOff = offsetFromVma(header, numProgramHeaderEntries, vStringTableOff);
|
||||
for (final Long strOff : neededOffsets) {
|
||||
dependencies.add(readString(buffer, stringTableOff + strOff));
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
private long offsetFromVma(final Header header, final long numEntries, final long vma)
|
||||
throws IOException {
|
||||
for (long i = 0; i < numEntries; ++i) {
|
||||
final ProgramHeader programHeader = header.getProgramHeader(i);
|
||||
if (programHeader.type == ProgramHeader.PT_LOAD) {
|
||||
// Within memsz instead of filesz to be more tolerant
|
||||
if (programHeader.vaddr <= vma
|
||||
&& vma <= programHeader.vaddr + programHeader.memsz) {
|
||||
return vma - programHeader.vaddr + programHeader.offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Could not map vma to file offset!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
this.channel.close();
|
||||
}
|
||||
|
||||
protected String readString(final ByteBuffer buffer, long offset) throws IOException {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
short c;
|
||||
while ((c = readByte(buffer, offset++)) != 0) {
|
||||
builder.append((char) c);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected long readLong(final ByteBuffer buffer, final long offset) throws IOException {
|
||||
read(buffer, offset, 8);
|
||||
return buffer.getLong();
|
||||
}
|
||||
|
||||
protected long readWord(final ByteBuffer buffer, final long offset) throws IOException {
|
||||
read(buffer, offset, 4);
|
||||
return buffer.getInt() & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
protected int readHalf(final ByteBuffer buffer, final long offset) throws IOException {
|
||||
read(buffer, offset, 2);
|
||||
return buffer.getShort() & 0xFFFF;
|
||||
}
|
||||
|
||||
protected short readByte(final ByteBuffer buffer, final long offset) throws IOException {
|
||||
read(buffer, offset, 1);
|
||||
return (short) (buffer.get() & 0xFF);
|
||||
}
|
||||
|
||||
protected void read(final ByteBuffer buffer, long offset, final int length) throws IOException {
|
||||
buffer.position(0);
|
||||
buffer.limit(length);
|
||||
long bytesRead = 0;
|
||||
while (bytesRead < length) {
|
||||
final int read = channel.read(buffer, offset + bytesRead);
|
||||
if (read == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
bytesRead += read;
|
||||
}
|
||||
buffer.position(0);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Program32Header extends Elf.ProgramHeader {
|
||||
public Program32Header(final ElfParser parser, final Elf.Header header, final long index)
|
||||
throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(4);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
final long baseOffset = header.phoff + (index * header.phentsize);
|
||||
type = parser.readWord(buffer, baseOffset);
|
||||
offset = parser.readWord(buffer, baseOffset + 0x4);
|
||||
vaddr = parser.readWord(buffer, baseOffset + 0x8);
|
||||
memsz = parser.readWord(buffer, baseOffset + 0x14);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Program64Header extends Elf.ProgramHeader {
|
||||
public Program64Header(final ElfParser parser, final Elf.Header header, final long index)
|
||||
throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
final long baseOffset = header.phoff + (index * header.phentsize);
|
||||
type = parser.readWord(buffer, baseOffset);
|
||||
offset = parser.readLong(buffer, baseOffset + 0x8);
|
||||
vaddr = parser.readLong(buffer, baseOffset + 0x10);
|
||||
memsz = parser.readLong(buffer, baseOffset + 0x28);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Section32Header extends Elf.SectionHeader {
|
||||
public Section32Header(final ElfParser parser, final Elf.Header header, final int index)
|
||||
throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(4);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
info = parser.readWord(buffer, header.shoff + (index * header.shentsize) + 0x1C);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 - 2016 KeepSafe Software, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.pdlive.lib_so.elf;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class Section64Header extends Elf.SectionHeader {
|
||||
public Section64Header(final ElfParser parser, final Elf.Header header, final int index)
|
||||
throws IOException {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(header.bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
info = parser.readWord(buffer, header.shoff + (index * header.shentsize) + 0x2C);
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Tinker available.
|
||||
*
|
||||
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pdlive.lib_so.pathinsert;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class LoadLibraryUtils {
|
||||
private static final String TAG = "LoadLibrary";
|
||||
|
||||
public static void installNativeLibraryPath(ClassLoader classLoader, File folder)
|
||||
throws Throwable {
|
||||
if (folder == null || !folder.exists()) {
|
||||
Log.e(TAG, "installNativeLibraryPath, folder is illegal");
|
||||
return;
|
||||
}
|
||||
// android o sdk_int 26
|
||||
// for android o preview sdk_int 25
|
||||
if ((Build.VERSION.SDK_INT == 25 && Build.VERSION.PREVIEW_SDK_INT != 0)
|
||||
|| Build.VERSION.SDK_INT > 25) {
|
||||
try {
|
||||
V25.install(classLoader, folder);
|
||||
} catch (Throwable throwable) {
|
||||
// install fail, try to treat it as v23
|
||||
// some preview N version may go here
|
||||
Log.e(TAG, String.format("installNativeLibraryPath, v25 fail, sdk: %d, error: %s, try to fallback to V23",
|
||||
Build.VERSION.SDK_INT, throwable.getMessage()));
|
||||
V23.install(classLoader, folder);
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= 23) {
|
||||
try {
|
||||
V23.install(classLoader, folder);
|
||||
} catch (Throwable throwable) {
|
||||
// install fail, try to treat it as v14
|
||||
Log.e(TAG, String.format("installNativeLibraryPath, v23 fail, sdk: %d, error: %s, try to fallback to V14",
|
||||
Build.VERSION.SDK_INT, throwable.getMessage()));
|
||||
|
||||
V14.install(classLoader, folder);
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= 14) {
|
||||
V14.install(classLoader, folder);
|
||||
} else {
|
||||
V4.install(classLoader, folder);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class V4 {
|
||||
private static void install(ClassLoader classLoader, File folder) throws Throwable {
|
||||
String addPath = folder.getPath();
|
||||
Field pathField = ShareReflectUtil.findField(classLoader, "libPath");
|
||||
final String origLibPaths = (String) pathField.get(classLoader);
|
||||
final String[] origLibPathSplit = origLibPaths.split(":");
|
||||
final StringBuilder newLibPaths = new StringBuilder(addPath);
|
||||
|
||||
for (String origLibPath : origLibPathSplit) {
|
||||
if (origLibPath == null || addPath.equals(origLibPath)) {
|
||||
continue;
|
||||
}
|
||||
newLibPaths.append(':').append(origLibPath);
|
||||
}
|
||||
pathField.set(classLoader, newLibPaths.toString());
|
||||
|
||||
final Field libraryPathElementsFiled = ShareReflectUtil.findField(classLoader, "libraryPathElements");
|
||||
final List<String> libraryPathElements = (List<String>) libraryPathElementsFiled.get(classLoader);
|
||||
final Iterator<String> libPathElementIt = libraryPathElements.iterator();
|
||||
while (libPathElementIt.hasNext()) {
|
||||
final String libPath = libPathElementIt.next();
|
||||
if (addPath.equals(libPath)) {
|
||||
libPathElementIt.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
libraryPathElements.add(0, addPath);
|
||||
libraryPathElementsFiled.set(classLoader, libraryPathElements);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class V14 {
|
||||
private static void install(ClassLoader classLoader, File folder) throws Throwable {
|
||||
final Field pathListField = ShareReflectUtil.findField(classLoader, "pathList");
|
||||
final Object dexPathList = pathListField.get(classLoader);
|
||||
|
||||
final Field nativeLibDirField = ShareReflectUtil.findField(dexPathList, "nativeLibraryDirectories");
|
||||
final File[] origNativeLibDirs = (File[]) nativeLibDirField.get(dexPathList);
|
||||
|
||||
final List<File> newNativeLibDirList = new ArrayList<>(origNativeLibDirs.length + 1);
|
||||
newNativeLibDirList.add(folder);
|
||||
for (File origNativeLibDir : origNativeLibDirs) {
|
||||
if (!folder.equals(origNativeLibDir)) {
|
||||
newNativeLibDirList.add(origNativeLibDir);
|
||||
}
|
||||
}
|
||||
nativeLibDirField.set(dexPathList, newNativeLibDirList.toArray(new File[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private static final class V23 {
|
||||
private static void install(ClassLoader classLoader, File folder) throws Throwable {
|
||||
final Field pathListField = ShareReflectUtil.findField(classLoader, "pathList");
|
||||
final Object dexPathList = pathListField.get(classLoader);
|
||||
|
||||
final Field nativeLibraryDirectories = ShareReflectUtil.findField(dexPathList, "nativeLibraryDirectories");
|
||||
|
||||
List<File> origLibDirs = (List<File>) nativeLibraryDirectories.get(dexPathList);
|
||||
if (origLibDirs == null) {
|
||||
origLibDirs = new ArrayList<>(2);
|
||||
}
|
||||
final Iterator<File> libDirIt = origLibDirs.iterator();
|
||||
while (libDirIt.hasNext()) {
|
||||
final File libDir = libDirIt.next();
|
||||
if (folder.equals(libDir)) {
|
||||
libDirIt.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
origLibDirs.add(0, folder);
|
||||
|
||||
final Field systemNativeLibraryDirectories = ShareReflectUtil.findField(dexPathList, "systemNativeLibraryDirectories");
|
||||
List<File> origSystemLibDirs = (List<File>) systemNativeLibraryDirectories.get(dexPathList);
|
||||
if (origSystemLibDirs == null) {
|
||||
origSystemLibDirs = new ArrayList<>(2);
|
||||
}
|
||||
|
||||
final List<File> newLibDirs = new ArrayList<>(origLibDirs.size() + origSystemLibDirs.size() + 1);
|
||||
newLibDirs.addAll(origLibDirs);
|
||||
newLibDirs.addAll(origSystemLibDirs);
|
||||
|
||||
final Method makeElements = ShareReflectUtil.findMethod(dexPathList,
|
||||
"makePathElements", List.class, File.class, List.class);
|
||||
final ArrayList<IOException> suppressedExceptions = new ArrayList<>();
|
||||
|
||||
final Object[] elements = (Object[]) makeElements.invoke(dexPathList, newLibDirs, null, suppressedExceptions);
|
||||
|
||||
final Field nativeLibraryPathElements = ShareReflectUtil.findField(dexPathList, "nativeLibraryPathElements");
|
||||
nativeLibraryPathElements.set(dexPathList, elements);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class V25 {
|
||||
private static void install(ClassLoader classLoader, File folder) throws Throwable {
|
||||
final Field pathListField = ShareReflectUtil.findField(classLoader, "pathList");
|
||||
final Object dexPathList = pathListField.get(classLoader);
|
||||
|
||||
final Field nativeLibraryDirectories = ShareReflectUtil.findField(dexPathList, "nativeLibraryDirectories");
|
||||
|
||||
List<File> origLibDirs = (List<File>) nativeLibraryDirectories.get(dexPathList);
|
||||
if (origLibDirs == null) {
|
||||
origLibDirs = new ArrayList<>(2);
|
||||
}
|
||||
final Iterator<File> libDirIt = origLibDirs.iterator();
|
||||
while (libDirIt.hasNext()) {
|
||||
final File libDir = libDirIt.next();
|
||||
if (folder.equals(libDir)) {
|
||||
libDirIt.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
origLibDirs.add(0, folder);
|
||||
|
||||
final Field systemNativeLibraryDirectories = ShareReflectUtil.findField(dexPathList, "systemNativeLibraryDirectories");
|
||||
List<File> origSystemLibDirs = (List<File>) systemNativeLibraryDirectories.get(dexPathList);
|
||||
if (origSystemLibDirs == null) {
|
||||
origSystemLibDirs = new ArrayList<>(2);
|
||||
}
|
||||
|
||||
final List<File> newLibDirs = new ArrayList<>(origLibDirs.size() + origSystemLibDirs.size() + 1);
|
||||
newLibDirs.addAll(origLibDirs);
|
||||
newLibDirs.addAll(origSystemLibDirs);
|
||||
|
||||
final Method makeElements = ShareReflectUtil.findMethod(dexPathList, "makePathElements", List.class);
|
||||
|
||||
final Object[] elements = (Object[]) makeElements.invoke(dexPathList, newLibDirs);
|
||||
|
||||
final Field nativeLibraryPathElements = ShareReflectUtil.findField(dexPathList, "nativeLibraryPathElements");
|
||||
nativeLibraryPathElements.set(dexPathList, elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
package com.pdlive.lib_so.pathinsert;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ShareReflectUtil {
|
||||
|
||||
/**
|
||||
* Locates a given field anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the field into.
|
||||
* @param name field name
|
||||
* @return a field object
|
||||
* @throws NoSuchFieldException if the field cannot be located
|
||||
*/
|
||||
public static Field findField(Object instance, String name) throws NoSuchFieldException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchFieldException("Field " + name + " not found in " + instance.getClass());
|
||||
}
|
||||
|
||||
public static Field findField(Class<?> originClazz, String name) throws NoSuchFieldException {
|
||||
for (Class<?> clazz = originClazz; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchFieldException("Field " + name + " not found in " + originClazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a given method anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the method into.
|
||||
* @param name method name
|
||||
* @param parameterTypes method parameter types
|
||||
* @return a method object
|
||||
* @throws NoSuchMethodException if the method cannot be located
|
||||
*/
|
||||
public static Method findMethod(Object instance, String name, Class<?>... parameterTypes)
|
||||
throws NoSuchMethodException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Method method = clazz.getDeclaredMethod(name, parameterTypes);
|
||||
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchMethodException("Method "
|
||||
+ name
|
||||
+ " with parameters "
|
||||
+ Arrays.asList(parameterTypes)
|
||||
+ " not found in " + instance.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a given method anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param clazz a class to search the method into.
|
||||
* @param name method name
|
||||
* @param parameterTypes method parameter types
|
||||
* @return a method object
|
||||
* @throws NoSuchMethodException if the method cannot be located
|
||||
*/
|
||||
public static Method findMethod(Class<?> clazz, String name, Class<?>... parameterTypes)
|
||||
throws NoSuchMethodException {
|
||||
for (; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Method method = clazz.getDeclaredMethod(name, parameterTypes);
|
||||
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchMethodException("Method "
|
||||
+ name
|
||||
+ " with parameters "
|
||||
+ Arrays.asList(parameterTypes)
|
||||
+ " not found in " + clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a given constructor anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the constructor into.
|
||||
* @param parameterTypes constructor parameter types
|
||||
* @return a constructor object
|
||||
* @throws NoSuchMethodException if the constructor cannot be located
|
||||
*/
|
||||
public static Constructor<?> findConstructor(Object instance, Class<?>... parameterTypes)
|
||||
throws NoSuchMethodException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Constructor<?> ctor = clazz.getDeclaredConstructor(parameterTypes);
|
||||
|
||||
if (!ctor.isAccessible()) {
|
||||
ctor.setAccessible(true);
|
||||
}
|
||||
|
||||
return ctor;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchMethodException("Constructor"
|
||||
+ " with parameters "
|
||||
+ Arrays.asList(parameterTypes)
|
||||
+ " not found in " + instance.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the value of a field containing a non null array, by a new array containing the
|
||||
* elements of the original array plus the elements of extraElements.
|
||||
*
|
||||
* @param instance the instance whose field is to be modified.
|
||||
* @param fieldName the field to modify.
|
||||
* @param extraElements elements to append at the end of the array.
|
||||
*/
|
||||
public static void expandFieldArray(Object instance, String fieldName, Object[] extraElements)
|
||||
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Field jlrField = findField(instance, fieldName);
|
||||
|
||||
Object[] original = (Object[]) jlrField.get(instance);
|
||||
Object[] combined = (Object[]) Array.newInstance(original.getClass().getComponentType(), original.length + extraElements.length);
|
||||
|
||||
// NOTE: changed to copy extraElements first, for patch load first
|
||||
|
||||
System.arraycopy(extraElements, 0, combined, 0, extraElements.length);
|
||||
System.arraycopy(original, 0, combined, extraElements.length, original.length);
|
||||
|
||||
jlrField.set(instance, combined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the value of a field containing a non null array, by a new array containing the
|
||||
* elements of the original array plus the elements of extraElements.
|
||||
*
|
||||
* @param instance the instance whose field is to be modified.
|
||||
* @param fieldName the field to modify.
|
||||
*/
|
||||
public static void reduceFieldArray(Object instance, String fieldName, int reduceSize)
|
||||
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
if (reduceSize <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Field jlrField = findField(instance, fieldName);
|
||||
|
||||
Object[] original = (Object[]) jlrField.get(instance);
|
||||
int finalLength = original.length - reduceSize;
|
||||
|
||||
if (finalLength <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object[] combined = (Object[]) Array.newInstance(original.getClass().getComponentType(), finalLength);
|
||||
|
||||
System.arraycopy(original, reduceSize, combined, 0, finalLength);
|
||||
|
||||
jlrField.set(instance, combined);
|
||||
}
|
||||
|
||||
public static Object getActivityThread(Context context,
|
||||
Class<?> activityThread) {
|
||||
try {
|
||||
if (activityThread == null) {
|
||||
activityThread = Class.forName("android.app.ActivityThread");
|
||||
}
|
||||
Method m = activityThread.getMethod("currentActivityThread");
|
||||
m.setAccessible(true);
|
||||
Object currentActivityThread = m.invoke(null);
|
||||
if (currentActivityThread == null && context != null) {
|
||||
// In older versions of Android (prior to frameworks/base 66a017b63461a22842)
|
||||
// the currentActivityThread was built on thread locals, so we'll need to try
|
||||
// even harder
|
||||
Field mLoadedApk = context.getClass().getField("mLoadedApk");
|
||||
mLoadedApk.setAccessible(true);
|
||||
Object apk = mLoadedApk.get(context);
|
||||
Field mActivityThreadField = apk.getClass().getDeclaredField("mActivityThread");
|
||||
mActivityThreadField.setAccessible(true);
|
||||
currentActivityThread = mActivityThreadField.get(apk);
|
||||
}
|
||||
return currentActivityThread;
|
||||
} catch (Throwable ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy method for fetching hidden integer constant value in system classes.
|
||||
*
|
||||
* @param clazz
|
||||
* @param fieldName
|
||||
* @return
|
||||
*/
|
||||
public static int getValueOfStaticIntField(Class<?> clazz, String fieldName, int defVal) {
|
||||
try {
|
||||
final Field field = findField(clazz, fieldName);
|
||||
return field.getInt(null);
|
||||
} catch (Throwable thr) {
|
||||
return defVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -16,29 +13,31 @@ import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.pay.google.GooglePlay;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class GoogleFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
private String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
String adid = null;
|
||||
|
||||
GoogleUtils googleUtils;
|
||||
private GooglePlay googlePlay;
|
||||
|
||||
boolean isGoogleService = true;
|
||||
|
||||
@@ -62,17 +61,16 @@ public class GoogleFragment extends Fragment {
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
googlePlay = GooglePlay.getInstance();
|
||||
|
||||
// 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本
|
||||
if (googleUtils.getGoogleService()) {
|
||||
if (googlePlay.getGoogleService()) {
|
||||
isGoogleService = true;
|
||||
// 支持Google服务
|
||||
initGooglePay();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
adid = googleUtils.getAdid();
|
||||
adid = googlePlay.getAdId();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@@ -100,13 +98,6 @@ public class GoogleFragment extends Fragment {
|
||||
|
||||
String TAG = "GooglePay";
|
||||
|
||||
private void initGooglePay() {
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
googleUtils.initGooglePay();
|
||||
}
|
||||
|
||||
private Handler payHandler = new Handler();
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
@@ -117,54 +108,32 @@ public class GoogleFragment extends Fragment {
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
|
||||
googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
|
||||
googlePlay.setBillingListener(new GooglePlay.GoogleBillingListener() {
|
||||
@Override
|
||||
public void onPaySuccess(String token, String orderId) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
|
||||
public void onPaySuccess(List<Purchase> purchases) {
|
||||
CommonHttpUtil.notifyGoogle(purchases.get(0).getPurchaseToken(),
|
||||
purchases.get(0).getProducts().get(0), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "HKD");
|
||||
params.putString("money", MoneyUsds);
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "HKD");
|
||||
google_params.putString("product_id", mProductId);
|
||||
google_params.putString("transaction_id", mOrderid);
|
||||
google_params.putString("value", MoneyUsds);
|
||||
google_params.putString("price", MoneyUsds);
|
||||
google_params.putString("quantity", "1");
|
||||
dis();
|
||||
googlePlay.consume(purchases);
|
||||
getActivity().finish();
|
||||
ToastUtil.show(getString(R.string.pay_suc));
|
||||
}else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPayFailed(String msg) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
googleUtils.purchase(mProductId);
|
||||
googlePlay.purchase(getActivity(),mOrderid, mProductId);
|
||||
lastClickTime = currentTime;
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
}
|
||||
|
||||
@@ -180,9 +149,5 @@ public class GoogleFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
@SuppressLint("ValidFragment")
|
||||
public class HuaWeiFragment extends Fragment {
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
public String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
|
||||
@@ -51,6 +51,11 @@ import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSDKConfig;
|
||||
import com.tencent.imsdk.v2.V2TIMSDKListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.bean.QiniuLog;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
@@ -63,7 +68,6 @@ import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LiveSvgGiftBean;
|
||||
import com.yunbao.common.bean.QiniuLog;
|
||||
import com.yunbao.common.bean.SwTokenModel;
|
||||
import com.yunbao.common.bean.UpdataListBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
@@ -80,7 +84,6 @@ import com.yunbao.common.event.NoviceInstructorEvent;
|
||||
import com.yunbao.common.event.RongIMConnectionStatusEvent;
|
||||
import com.yunbao.common.event.SudGameUserEvent;
|
||||
import com.yunbao.common.event.UpdateTablePointMe;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@@ -94,16 +97,12 @@ import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.GiftCacheUtil;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.LoadSoUtil;
|
||||
import com.yunbao.common.utils.LocationUtil;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
@@ -226,16 +225,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
OpenAdManager.getInstance().dismiss();
|
||||
}
|
||||
|
||||
public static boolean isLoadSo = false;
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
//初始化声网
|
||||
if (LoadSoUtil.isLoadSo()) {
|
||||
//说明已经有了可以直接初始化
|
||||
isLoadSo = true;
|
||||
SWAuManager.get().initRtcEngine(this);
|
||||
}
|
||||
SWAuManager.get().initRtcEngine(this);
|
||||
ActivityCompat.postponeEnterTransition(this);
|
||||
ConversationIMListManager.get(this);
|
||||
//在请求一下这个接口给我后台版本号
|
||||
@@ -287,8 +280,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -502,8 +495,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -876,12 +869,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ConnectionErrorCode e) {
|
||||
ToastUtil.show(R.string.net_error + "" + e.toString());
|
||||
ToastUtil.show(R.string.net_error+""+e.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseOpened(RongIMClient.DatabaseOpenStatus code) {
|
||||
ToastUtil.show(R.string.net_error + "" + code);
|
||||
ToastUtil.show(R.string.net_error+""+code);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1167,9 +1160,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
public void watchLive(LiveBean liveBean, String key, int position) {
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
|
||||
MobclickAgent.onEvent(mContext, "home_page_enter_room", "首页点击直播间");
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1605,7 +1598,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveFloatEvent(LiveFloatEvent event) {
|
||||
if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())) {
|
||||
new Handler().post(() -> LiveFloatView.getInstance().cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK() == Constants.LIVE_SDK_SW, event.getmLiveTypeVal()).builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
|
||||
new Handler().post(() -> LiveFloatView.getInstance().cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK() ==Constants.LIVE_SDK_SW, event.getmLiveTypeVal()).builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1655,13 +1648,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initLogUpdate() {
|
||||
private void initLogUpdate(){
|
||||
LiveNetManager.get(mContext)
|
||||
.getLogUpdateStatus("1", new com.yunbao.common.http.base.HttpCallback<QiniuLog>() {
|
||||
@Override
|
||||
public void onSuccess(QiniuLog data) {
|
||||
if (data.getLog_type() == 1) {
|
||||
if(data.getLog_type()==1){
|
||||
LogUtil.shareFile(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,24 +11,22 @@ import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.fragment.LoadingDialog;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.pay.google.GooglePlay;
|
||||
import com.yunbao.common.pay.hw.HwBuilder;
|
||||
import com.yunbao.common.pay.samsung.SamsungUtil;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
@@ -45,24 +43,20 @@ import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTit
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Route(path = RouteUtil.PATH_COIN)
|
||||
public class MyWalletActivity extends AbsActivity {
|
||||
ViewPager vp_content;
|
||||
static MyWalletActivity mw;
|
||||
Fragment[] fragments = null;
|
||||
private Handler payHandler = new Handler();
|
||||
public static String orderId;
|
||||
|
||||
HwBuilder hwBuilder;
|
||||
GoogleUtils googleUtils;
|
||||
GooglePlay googlePlay;
|
||||
|
||||
LoadingDialog loadingDialog;
|
||||
SamsungUtil samsungUtil;
|
||||
@@ -72,26 +66,53 @@ public class MyWalletActivity extends AbsActivity {
|
||||
return R.layout.activity_my_wallet;
|
||||
}
|
||||
|
||||
protected void main() {
|
||||
private WalletFragment getWalletFragment(String url) {
|
||||
WalletFragment walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
walletFragment.setArguments(bundle);
|
||||
return walletFragment;
|
||||
}
|
||||
|
||||
private GoogleFragment getGoogleFragment(String url) {
|
||||
GoogleFragment fragment = new GoogleFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private HuaWeiFragment getHuaWeiFragment(String url) {
|
||||
HuaWeiFragment fragment = new HuaWeiFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private SamsungFragment getSamsungFragment(String url) {
|
||||
SamsungFragment fragment = new SamsungFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
protected void main() {
|
||||
super.main();
|
||||
mw = MyWalletActivity.this;
|
||||
setTitle(mContext.getString(R.string.wallet));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder = new HwBuilder(MyWalletActivity.this);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
samsungUtil = SamsungUtil.newInstance(mContext);
|
||||
samsungUtil.init();
|
||||
}else{
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
} else {
|
||||
googlePlay = GooglePlay.getInstance();
|
||||
//消耗所有商品
|
||||
googlePlay.consumeAll();
|
||||
}
|
||||
|
||||
|
||||
vp_content = (ViewPager) findViewById(R.id.vp_content);
|
||||
TextView rView = (TextView) findViewById(R.id.rView);
|
||||
findViewById(R.id.redPacketMain).setVisibility(View.VISIBLE);
|
||||
@@ -102,52 +123,9 @@ public class MyWalletActivity extends AbsActivity {
|
||||
loadingDialog = new LoadingDialog();
|
||||
loadingDialog.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
loadingDialog.setShowText(getString(R.string.order_query));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils.setQueryPurchaseListener(mContext, new GoogleUtils.QueryPurchasesListener() {
|
||||
@Override
|
||||
public void onResult(JSONObject obj) {
|
||||
try {
|
||||
int code = obj.getInt("querySize");
|
||||
if (code == 0) {
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 1000);
|
||||
} else {
|
||||
JSONArray tokenList = obj.getJSONArray("tokenList");
|
||||
JSONArray orderList = obj.getJSONArray("orderList");
|
||||
String tradeNo = obj.getString("tradeNo");
|
||||
|
||||
for (int i = 0; i < tokenList.length(); i++) {
|
||||
int finalI = i;
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//谷歌掉单处理
|
||||
try {
|
||||
CommonHttpUtil.Google_sec_pay(tokenList.getString(finalI), orderList.getString(finalI), tradeNo, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (finalI == tokenList.length() - 1) {
|
||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
ToastUtil.show("充值已到账");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
googleUtils.queryPurchasesAsync();
|
||||
//消耗所有商品
|
||||
googlePlay.consumeAll();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder.consume();
|
||||
payHandler.post(runnable1);
|
||||
@@ -162,168 +140,36 @@ public class MyWalletActivity extends AbsActivity {
|
||||
}
|
||||
});
|
||||
|
||||
WalletFragment walletFragment = null;
|
||||
|
||||
GoogleFragment googleFragment1 = null;
|
||||
GoogleFragment googleFragment2 = null;
|
||||
|
||||
HuaWeiFragment huaWeiFragment1 = null;
|
||||
HuaWeiFragment huaWeiFragment2 = null;
|
||||
|
||||
SamsungFragment samsungFragment1 = null;
|
||||
SamsungFragment samsungFragment2 = null;
|
||||
|
||||
WalletFragment walletFragment;
|
||||
Fragment fragment1;
|
||||
Fragment fragment2;
|
||||
final String[] titles = {mContext.getString(R.string.diamond), mContext.getString(R.string.coins), mContext.getString(R.string.golden_beans)};
|
||||
if (getIntent().getStringExtra("tag") != null) {
|
||||
Log.i("tss", "首充");
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
//google
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
//华为
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
} else {
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
walletFragment = getWalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getHuaWeiFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
fragment2 = getHuaWeiFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getSamsungFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getSamsungFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
if (getIntent().getStringExtra("tag") != null) {
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else {
|
||||
Log.i("tss", "不是首充");
|
||||
//链接版本
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
}
|
||||
}
|
||||
fragments = new Fragment[]{fragment1, fragment2, walletFragment};
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
fragments = new Fragment[]{huaWeiFragment1, huaWeiFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
fragments = new Fragment[]{samsungFragment1, samsungFragment2, walletFragment};
|
||||
} else {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
}
|
||||
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
|
||||
CommonNavigator commonNavigator = new CommonNavigator(this);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
@@ -422,16 +268,6 @@ public class MyWalletActivity extends AbsActivity {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
CommonHttpUtil.cancel("Charge.Google_sec_pay");
|
||||
if (payHandler != null) {
|
||||
payHandler.removeCallbacks(runnable1);
|
||||
payHandler.removeCallbacks(runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -496,8 +332,4 @@ public class MyWalletActivity extends AbsActivity {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dis() {
|
||||
mw.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
public class SamsungFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
public String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
@@ -99,9 +99,7 @@ public class SamsungFragment extends Fragment {
|
||||
@Override
|
||||
public void onPaymentSuccess(String purchaseVo) {
|
||||
SamsungUtil.newInstance(getActivity()).consume(purchaseVo);
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
payHandler.post(() -> {
|
||||
// CommonHttpUtil.notifySamsung(_purchaseVO.getPurchaseId(), mOrderid, new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -111,18 +109,12 @@ public class SamsungFragment extends Fragment {
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPaymentFailed(String errorVo) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(errorVo);
|
||||
}
|
||||
});
|
||||
payHandler.post(() -> ToastUtil.show(errorVo));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
@@ -30,6 +29,7 @@ import com.bumptech.glide.request.target.DrawableImageViewTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.ms.banner.Banner;
|
||||
import com.ms.banner.listener.OnBannerClickListener;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
@@ -46,14 +46,14 @@ import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.LiveClassManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.LoadSoUtil;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.CustomViewHolder;
|
||||
import com.yunbao.live.utils.LiveStorge;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
@@ -211,7 +211,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
});
|
||||
} else {
|
||||
pp = 0;
|
||||
if (select == 0) {
|
||||
if(select==0){
|
||||
select = list.get(0).getId();
|
||||
}
|
||||
MainHttpUtil.getClassLive(select, p, callback);
|
||||
@@ -409,8 +409,8 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
liveBean.setParams(gotoRoomKey);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -488,35 +488,6 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
|
||||
@Override
|
||||
public void onItemClick(LiveBean bean, int position) {
|
||||
if (MainActivity.isLoadSo) {
|
||||
onItemClick2(bean, position);
|
||||
} else {
|
||||
Toast.makeText(mContext, "正在下载so文件,请稍后。。。", Toast.LENGTH_LONG).show();
|
||||
LoadSoUtil.downloadSoAndLoad(mContext, new LoadSoUtil.onLoadSoListener() {
|
||||
@Override
|
||||
public void ok() {
|
||||
MainActivity.isLoadSo = true;
|
||||
SWAuManager.get().initRtcEngine((MainActivity) mContext);
|
||||
SWAuManager.get().preloadChannel();
|
||||
onItemClick2(bean, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error() {
|
||||
mRefreshView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, "下载so文件失败了", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
Log.e("mLog", "加载so文件的时候错误了 ****************** ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemClick2(LiveBean bean, int position) {
|
||||
//到这里判断是否需要加载so
|
||||
if ("1".equals(bean.getIslive())) {
|
||||
intoIndex = 1;
|
||||
watchLive(bean, Constants.LIVE_HOME, position);
|
||||
@@ -533,7 +504,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
}
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
|
||||
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
@@ -545,7 +516,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
}
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
|
||||
} else {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk), isSw);
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,6 +537,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
if (mAdapter != null) {
|
||||
|
||||
@@ -82,6 +82,4 @@ android{
|
||||
}
|
||||
|
||||
}
|
||||
// 设置默认的flavor
|
||||
defaultPublishConfig "link_test"
|
||||
}
|
||||
@@ -8,4 +8,3 @@ include ':lib_huawei'
|
||||
include ':lib_google'
|
||||
include ':IAP6Helper'
|
||||
include ':lib_faceunity'
|
||||
include ':lib_so'
|
||||
|
||||
Reference in New Issue
Block a user