更新vivo的sdk至4.6.9.0

This commit is contained in:
zhl 2021-10-21 10:09:06 +08:00
parent e44feebebd
commit f580b092ea
16 changed files with 218 additions and 181 deletions

View File

@ -1,42 +1,33 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 28 compileSdkVersion 26
defaultConfig { defaultConfig {
applicationId "com.hnjc.wjtx.vivo" applicationId "com.hnjc.wjtx.vivo"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 26
versionCode 6 versionCode 9
versionName "1.0.6" versionName "1.0.9"
ndk { ndk {
abiFilters 'armeabi-v7a' abiFilters 'armeabi-v7a'
} }
} }
buildTypes { buildTypes {
release { release {
minifyEnabled true minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
sourceSets { sourceSets {
main { main {
assets.srcDirs = ['../assets'] assets.srcDirs = ['../assets']
aidl.srcDirs = ['aidl']
jniLibs.srcDirs = ['libs']//so&jar文件路径 jniLibs.srcDirs = ['libs']//so&jar文件路径
} }
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
} }
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.volley:volley:1.1.1' implementation 'com.android.volley:volley:1.1.1'
implementation 'org.greenrobot:eventbus:3.2.0' implementation 'org.greenrobot:eventbus:3.2.0'
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.hnjc.wjtx"> package="com.hnjc.wjtx">
<!--联运SDK跳转游戏中心-->
<uses-permission android:name="vivo.game.permission.OPEN_JUMP_INTENTS"/>
<!--联运SDK监听网络状态变化在支付登录过程中做一些异常处理--> <!--联运SDK监听网络状态变化在支付登录过程中做一些异常处理-->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<!--允许程序访问Wi-Fi网络状态信息--> <!--允许程序访问Wi-Fi网络状态信息-->
@ -23,7 +25,6 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="vivo.game.permission.OPEN_JUMP_INTENTS" />
<application <application
android:allowBackup="false" android:allowBackup="false"
@ -55,12 +56,17 @@
</activity> </activity>
<meta-data
android:name="vivo_union_sdk"
android:value="4.6.9.0" />
<!-- vivo sdk componets start --> <!-- vivo sdk componets start -->
<!--vivo sdk的Activity--> <!--vivo sdk的Activity-->
<activity android:name="com.vivo.unionsdk.ui.UnionActivity" <activity android:name="com.vivo.unionsdk.ui.UnionActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:theme="@android:style/Theme.Dialog" android:theme="@android:style/Theme.Dialog"
android:exported="false"> android:exported="false"
tools:ignore="AppLinkUrlError">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
@ -72,9 +78,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<!-- vivo sdk componets end --> <!-- vivo sdk componets end -->
<meta-data
android:name="vivo_union_sdk"
android:value="4.6.9.0" />
</application> </application>
</manifest> </manifest>

View File

@ -6,7 +6,6 @@ import android.util.Log;
import com.hnjc.wjtx.vivo.VivoUnionHelper; import com.hnjc.wjtx.vivo.VivoUnionHelper;
import com.vivo.unionsdk.open.MissOrderEventHandler; import com.vivo.unionsdk.open.MissOrderEventHandler;
import com.vivo.unionsdk.open.OrderResultInfo; import com.vivo.unionsdk.open.OrderResultInfo;
import com.vivo.unionsdk.open.VivoUnionSDK;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -17,8 +16,7 @@ public class JCApplication extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Log.i("JCApplication", "JCApplication onCreate"); Log.i("JCApplication", "JCApplication onCreate");
String appId = this.getString(R.string.app_id); VivoUnionHelper.initSdk(this, false);
VivoUnionSDK.initSdk(this, appId, false);
/** /**
* 掉单注册接口 需要接入掉单补单处理的一定要加 * 掉单注册接口 需要接入掉单补单处理的一定要加
@ -32,7 +30,9 @@ public class JCApplication extends Application {
/** /**
* 用户主动触发或调用queryMissOrderResult查询回调会在此做处理 * 用户主动触发或调用queryMissOrderResult查询回调会在此做处理
*/ */
private final MissOrderEventHandler mMissOrderEventHandler = orderResultInfos -> { private MissOrderEventHandler mMissOrderEventHandler = new MissOrderEventHandler() {
@Override
public void process(List orderResultInfos) {
Log.i(TAG, "registerOrderResultEventHandler: orderResultInfos = " + orderResultInfos); Log.i(TAG, "registerOrderResultEventHandler: orderResultInfos = " + orderResultInfos);
/** /**
* 注意这里是查到未核销的订单 * 注意这里是查到未核销的订单
@ -45,6 +45,7 @@ public class JCApplication extends Application {
* 游戏侧用你们自己的订单号cpOrderNumber来校验是否完成发货 发货完成上报我们的订单号transNo * 游戏侧用你们自己的订单号cpOrderNumber来校验是否完成发货 发货完成上报我们的订单号transNo
*/ */
checkOrder(orderResultInfos); checkOrder(orderResultInfos);
}
}; };
/** /**
* 校验订单是否已经完成发货游戏自己逻辑 * 校验订单是否已经完成发货游戏自己逻辑

View File

@ -12,6 +12,7 @@ import android.util.Log;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.hnjc.wjtx.net.BaseInterface;
import com.hnjc.wjtx.net.DownloadRunnable; import com.hnjc.wjtx.net.DownloadRunnable;
import com.hnjc.wjtx.net.TaskInfo; import com.hnjc.wjtx.net.TaskInfo;
import com.hnjc.wjtx.net.WebApi; import com.hnjc.wjtx.net.WebApi;
@ -163,7 +164,9 @@ public class LaunchActivity extends Activity {
* 获取远程资源的版本号 * 获取远程资源的版本号
*/ */
private void getRemoteVersionInfo() { private void getRemoteVersionInfo() {
webApi.getVersionInfo((success, message, err) -> { webApi.getVersionInfo(new BaseInterface() {
@Override
public void response(boolean success, JSONObject message, String err) {
if (success) { if (success) {
try { try {
remoteVersion = message.getString("version"); remoteVersion = message.getString("version");
@ -202,6 +205,7 @@ public class LaunchActivity extends Activity {
} else { } else {
startMain(); startMain();
} }
}
}); });
} }

View File

@ -32,6 +32,7 @@ import com.vivo.unionsdk.open.VivoRoleInfo;
import com.vivo.unionsdk.open.VivoUnionSDK; import com.vivo.unionsdk.open.VivoUnionSDK;
import org.egret.egretnativeandroid.EgretNativeAndroid; import org.egret.egretnativeandroid.EgretNativeAndroid;
import org.egret.runtime.launcherInterface.INativePlayer;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -206,15 +207,23 @@ public class MainActivity extends Activity {
} }
private void setExternalInterfaces() { private void setExternalInterfaces() {
nativeAndroid.setExternalInterface("sendToNative", message -> { nativeAndroid.setExternalInterface("sendToNative", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "Get message: " + message); Log.d(TAG, "Get message: " + message);
nativeAndroid.callExternalInterface("sendToJS", "Get message: " + message); nativeAndroid.callExternalInterface("sendToJS", "Get message: " + message);
}
}); });
nativeAndroid.setExternalInterface("removeNativeLoading", message -> { nativeAndroid.setExternalInterface("removeNativeLoading", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "removeNativeLoading: " + message); Log.d(TAG, "removeNativeLoading: " + message);
hideLoadingView(); hideLoadingView();
}
}); });
nativeAndroid.setExternalInterface("setLocalStorage", message -> { nativeAndroid.setExternalInterface("setLocalStorage", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "setLocalStorage: " + message); Log.d(TAG, "setLocalStorage: " + message);
try{ try{
JSONObject jsonObject = new JSONObject(message); JSONObject jsonObject = new JSONObject(message);
@ -226,26 +235,44 @@ public class MainActivity extends Activity {
catch (JSONException e) { catch (JSONException e) {
Log.e(TAG, " onState message failed to analyze"); Log.e(TAG, " onState message failed to analyze");
} }
}
}); });
nativeAndroid.setExternalInterface("getLocalStorage", message -> { nativeAndroid.setExternalInterface("getLocalStorage", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "getLocalStorage: " + message); Log.d(TAG, "getLocalStorage: " + message);
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
String val = StorageUtil.readString(sharedPref, message); String val = StorageUtil.readString(sharedPref, message);
nativeAndroid.callExternalInterface("getLocalStorage", val); nativeAndroid.callExternalInterface("getLocalStorage", val);
}
}); });
nativeAndroid.setExternalInterface("removeLocalStorage", message -> {
nativeAndroid.setExternalInterface("removeLocalStorage", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "removeLocalStorage: " + message); Log.d(TAG, "removeLocalStorage: " + message);
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
StorageUtil.removeString(sharedPref, message); StorageUtil.removeString(sharedPref, message);
}
});
nativeAndroid.setExternalInterface("removeLocalStorage", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "removeLocalStorage: " + message);
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
StorageUtil.removeString(sharedPref, message);
}
}); });
/** /**
* 震动须添加权限 * 震动须添加权限
* <uses-permission android:name="android.permission.VIBRATE"/> * <uses-permission android:name="android.permission.VIBRATE"/>
* @param type {int} 震动类型 0: 短震动, 1: 长震动 * @param type {int} 震动类型 0: 短震动, 1: 长震动
* */ * */
nativeAndroid.setExternalInterface("vibrate", message -> { nativeAndroid.setExternalInterface("vibrate", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "vibrate: " + message); Log.d(TAG, "vibrate: " + message);
message = StringUtil.isBlank(message) ? "0" : message; message = StringUtil.isBlank(message) ? "0" : message;
int type = Integer.getInteger(message); int type = Integer.getInteger(message);
@ -256,29 +283,45 @@ public class MainActivity extends Activity {
//deprecated in API 26 //deprecated in API 26
vibrator.vibrate(time); vibrator.vibrate(time);
} }
}
}); });
nativeAndroid.setExternalInterface("showToast", message -> { nativeAndroid.setExternalInterface("showToast", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.d(TAG, "showToast: " + message); Log.d(TAG, "showToast: " + message);
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
}
}); });
nativeAndroid.setExternalInterface("getUid", message -> { nativeAndroid.setExternalInterface("getUid", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
loginVivoAccount(); loginVivoAccount();
}
}); });
nativeAndroid.setExternalInterface("@onState", message -> { nativeAndroid.setExternalInterface("@onState", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.e(TAG, "Get @onState: " + message); Log.e(TAG, "Get @onState: " + message);
try{ try {
JSONObject jsonObject = new JSONObject(message); JSONObject jsonObject = new JSONObject(message);
String state = jsonObject.getString("state"); String state = jsonObject.getString("state");
handleStateEvent(state); handleStateEvent(state);
} } catch (JSONException e) {
catch (JSONException e) {
Log.e(TAG, " onState message failed to analyze"); Log.e(TAG, " onState message failed to analyze");
} }
}
}); });
nativeAndroid.setExternalInterface("@onError", message -> Log.e(TAG, "Get @onError: " + message)); nativeAndroid.setExternalInterface("@onError", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.e(TAG, "Get @onError: " + message);
}
});
// 支付 // 支付
nativeAndroid.setExternalInterface("pay", message -> { nativeAndroid.setExternalInterface("pay", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.i(TAG, "receive pay: " + message); Log.i(TAG, "receive pay: " + message);
try { try {
JSONObject jsonObject = new JSONObject(message); JSONObject jsonObject = new JSONObject(message);
@ -300,12 +343,13 @@ public class MainActivity extends Activity {
.setVivoSignature(sign) .setVivoSignature(sign)
.setExtUid(extuid) .setExtUid(extuid)
.build(); .build();
VivoUnionHelper.payV2(this, vivoPayInfo, mVivoPayCallback); VivoUnionHelper.payV2(MainActivity.this, vivoPayInfo, mVivoPayCallback);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} catch ( Exception e ) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
}); });
//let data = { //let data = {
// isCreateRole: isNew, // isCreateRole: isNew,
@ -322,7 +366,9 @@ public class MainActivity extends Activity {
// gameRoleGender: giant.Core.hero.gender, // gameRoleGender: giant.Core.hero.gender,
// gameRolePower: giant.Core.hero.power, // gameRolePower: giant.Core.hero.power,
// }; // };
nativeAndroid.setExternalInterface("reportRoleInfo", message -> { nativeAndroid.setExternalInterface("reportRoleInfo", new INativePlayer.INativeInterface() {
@Override
public void callback(String message) {
Log.i(TAG, "Get reportRoleInfo: " + message); Log.i(TAG, "Get reportRoleInfo: " + message);
try { try {
JSONObject jsonObject = new JSONObject(message); JSONObject jsonObject = new JSONObject(message);
@ -336,6 +382,7 @@ public class MainActivity extends Activity {
e.printStackTrace(); e.printStackTrace();
Log.e(TAG, "Error reportRoleInfo:" + e); Log.e(TAG, "Error reportRoleInfo:" + e);
} }
}
}); });
} }

View File

@ -5,6 +5,7 @@ import android.content.Context;
import com.android.volley.DefaultRetryPolicy; import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request; import com.android.volley.Request;
import com.android.volley.Response; import com.android.volley.Response;
import com.android.volley.VolleyError;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -12,11 +13,14 @@ import java.util.Map;
public class AppRequestUtil { public class AppRequestUtil {
private static final AppRequestUtil app_request_util = new AppRequestUtil(); private static final AppRequestUtil app_request_util = new AppRequestUtil();
private final Response.ErrorListener errorListener = volleyError -> { private final Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
RequestErrorEvent event = new RequestErrorEvent(); RequestErrorEvent event = new RequestErrorEvent();
event.setType(1); event.setType(1);
event.setErrorMessage(volleyError.getMessage()); event.setErrorMessage(volleyError.getMessage());
EventBus.getDefault().post(event); EventBus.getDefault().post(event);
}
}; };
private AppRequestUtil() { private AppRequestUtil() {

View File

@ -2,15 +2,11 @@
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -19,15 +15,8 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
google() google()
jcenter() jcenter()
flatDir {
dirs 'libs'
}
} }
} }

View File

@ -17,5 +17,3 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true # org.gradle.parallel=true
android.injected.testOnly=false android.injected.testOnly=false
android.useAndroidX=true
android.enableJetifier=true

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip