mirror of
https://github.com/RxReader/wechat_kit.git
synced 2025-08-06 15:20:24 +08:00
升级 Android 微信 SDK
This commit is contained in:
31
.drone.yml
31
.drone.yml
@ -62,10 +62,6 @@ steps:
|
|||||||
from_secret: CODECOV_TOKEN
|
from_secret: CODECOV_TOKEN
|
||||||
files:
|
files:
|
||||||
- ./coverage/lcov.info
|
- ./coverage/lcov.info
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish-check
|
- name: publish-check
|
||||||
image: v7lin/flutter:1.7.8-hotfix.3-stable
|
image: v7lin/flutter:1.7.8-hotfix.3-stable
|
||||||
@ -91,9 +87,10 @@ steps:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: pub-cache
|
- name: pub-cache
|
||||||
path: /opt/flutter/.pub-cache
|
path: /opt/flutter/.pub-cache
|
||||||
|
environment:
|
||||||
|
PUB_CACHE: /opt/flutter/.pub-cache
|
||||||
commands:
|
commands:
|
||||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
- wget -P $PUB_CACHE https://raw.githubusercontent.com/v7lin/pub_credentials/master/credentials.json.enc
|
||||||
- wget -P $FLUTTER_HOME https://raw.githubusercontent.com/v7lin/pub_credentials/master/credentials.json.enc
|
|
||||||
|
|
||||||
- name: restore-cache-openssl
|
- name: restore-cache-openssl
|
||||||
image: v7lin/openssl:1.1.1b
|
image: v7lin/openssl:1.1.1b
|
||||||
@ -101,14 +98,14 @@ steps:
|
|||||||
- name: pub-cache
|
- name: pub-cache
|
||||||
path: /opt/flutter/.pub-cache
|
path: /opt/flutter/.pub-cache
|
||||||
environment:
|
environment:
|
||||||
|
PUB_CACHE: /opt/flutter/.pub-cache
|
||||||
ENC_METHOD:
|
ENC_METHOD:
|
||||||
from_secret: ENC_METHOD
|
from_secret: ENC_METHOD
|
||||||
ENC_PASSWORD:
|
ENC_PASSWORD:
|
||||||
from_secret: ENC_PASSWORD
|
from_secret: ENC_PASSWORD
|
||||||
commands:
|
commands:
|
||||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
- openssl enc -d -$ENC_METHOD -k $ENC_PASSWORD -in $PUB_CACHE/credentials.json.enc -out $PUB_CACHE/credentials.json
|
||||||
- openssl enc -d -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json.enc -out $FLUTTER_HOME/credentials.json
|
- rm $PUB_CACHE/credentials.json.enc
|
||||||
- rm $FLUTTER_HOME/credentials.json.enc
|
|
||||||
|
|
||||||
- name: publish
|
- name: publish
|
||||||
image: v7lin/flutter:1.7.8-hotfix.3-stable
|
image: v7lin/flutter:1.7.8-hotfix.3-stable
|
||||||
@ -124,14 +121,14 @@ steps:
|
|||||||
- name: pub-cache
|
- name: pub-cache
|
||||||
path: /opt/flutter/.pub-cache
|
path: /opt/flutter/.pub-cache
|
||||||
environment:
|
environment:
|
||||||
|
PUB_CACHE: /opt/flutter/.pub-cache
|
||||||
ENC_METHOD:
|
ENC_METHOD:
|
||||||
from_secret: ENC_METHOD
|
from_secret: ENC_METHOD
|
||||||
ENC_PASSWORD:
|
ENC_PASSWORD:
|
||||||
from_secret: ENC_PASSWORD
|
from_secret: ENC_PASSWORD
|
||||||
commands:
|
commands:
|
||||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
- openssl enc -e -$ENC_METHOD -k $ENC_PASSWORD -in $PUB_CACHE/credentials.json -out $PUB_CACHE/credentials.json.enc
|
||||||
- openssl enc -e -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json -out $FLUTTER_HOME/credentials.json.enc
|
- rm $PUB_CACHE/credentials.json
|
||||||
- rm /opt/flutter/.pub-cache/credentials.json
|
|
||||||
|
|
||||||
- name: save-cache
|
- name: save-cache
|
||||||
image: docker:git
|
image: docker:git
|
||||||
@ -139,6 +136,7 @@ steps:
|
|||||||
- name: pub-cache
|
- name: pub-cache
|
||||||
path: /opt/flutter/.pub-cache
|
path: /opt/flutter/.pub-cache
|
||||||
environment:
|
environment:
|
||||||
|
PUB_CACHE: /opt/flutter/.pub-cache
|
||||||
GIT_USER_EMAIL:
|
GIT_USER_EMAIL:
|
||||||
from_secret: GIT_USER_EMAIL
|
from_secret: GIT_USER_EMAIL
|
||||||
GIT_USER_NAME:
|
GIT_USER_NAME:
|
||||||
@ -146,14 +144,13 @@ steps:
|
|||||||
GIT_USER_PASSWORD:
|
GIT_USER_PASSWORD:
|
||||||
from_secret: GIT_USER_PASSWORD # 密码含'@',用'%40'替换 -> URLEncoder.encode("@","utf-8");
|
from_secret: GIT_USER_PASSWORD # 密码含'@',用'%40'替换 -> URLEncoder.encode("@","utf-8");
|
||||||
commands:
|
commands:
|
||||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
|
||||||
- git config --global user.email $GIT_USER_EMAIL
|
- git config --global user.email $GIT_USER_EMAIL
|
||||||
- git config --global user.name $GIT_USER_NAME
|
- git config --global user.name $GIT_USER_NAME
|
||||||
- git config --global credential.helper store
|
- git config --global credential.helper store
|
||||||
- git clone -b master https://$GIT_USER_NAME:$GIT_USER_PASSWORD@github.com/v7lin/pub_credentials.git $FLUTTER_HOME/pub_credentials
|
- git clone -b master https://$GIT_USER_NAME:$GIT_USER_PASSWORD@github.com/v7lin/pub_credentials.git $PUB_CACHE/pub_credentials
|
||||||
- rm $FLUTTER_HOME/pub_credentials/credentials.json.enc
|
- rm $PUB_CACHE/pub_credentials/credentials.json.enc
|
||||||
- mv $FLUTTER_HOME/credentials.json.enc $FLUTTER_HOME/pub_credentials/credentials.json.enc
|
- mv $PUB_CACHE/credentials.json.enc $PUB_CACHE/pub_credentials/credentials.json.enc
|
||||||
- cd $FLUTTER_HOME/pub_credentials
|
- cd $PUB_CACHE/pub_credentials
|
||||||
- git commit -am "update credentials by ci/cd tools"
|
- git commit -am "update credentials by ci/cd tools"
|
||||||
- git push
|
- git push
|
||||||
|
|
||||||
|
@ -28,15 +28,18 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
|
|
||||||
|
// library 混淆 -> 随 library 引用,自动添加到 apk 打包混淆
|
||||||
|
consumerProguardFiles 'consumer-proguard-rules.txt'
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'InvalidPackage'
|
disable 'InvalidPackage'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.4.3'
|
||||||
|
|
||||||
implementation 'io.github.v7lin:wechat-android:5.3.1+1'
|
|
||||||
}
|
}
|
||||||
|
5
android/consumer-proguard-rules.txt
Normal file
5
android/consumer-proguard-rules.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# 微信
|
||||||
|
|
||||||
|
-keep class com.tencent.mm.opensdk.** {*;}
|
||||||
|
-keep class com.tencent.wxop.** {*;}
|
||||||
|
-keep class com.tencent.mm.sdk.** {*;}
|
@ -2,25 +2,30 @@
|
|||||||
package="io.github.v7lin.fakewechat">
|
package="io.github.v7lin.fakewechat">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<activity
|
<activity
|
||||||
android:name=".WechatCallbackActivity"
|
android:name=".WechatCallbackActivity"
|
||||||
android:launchMode="singleTop"
|
android:theme="@style/fake_wechat.Theme.Transparent"
|
||||||
android:theme="@style/fake_wechat.Theme.Transparent" />
|
android:exported="true"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:taskAffinity="${applicationId}" />
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name="${applicationId}.wxapi.WXEntryActivity"
|
android:name="${applicationId}.wxapi.WXEntryActivity"
|
||||||
|
android:theme="@style/fake_wechat.Theme.Transparent"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:taskAffinity="${applicationId}"
|
||||||
android:targetActivity=".WechatCallbackActivity" />
|
android:targetActivity=".WechatCallbackActivity" />
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name="${applicationId}.wxapi.WXPayEntryActivity"
|
android:name="${applicationId}.wxapi.WXPayEntryActivity"
|
||||||
|
android:theme="@style/fake_wechat.Theme.Transparent"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:taskAffinity="${applicationId}"
|
||||||
android:targetActivity=".WechatCallbackActivity" />
|
android:targetActivity=".WechatCallbackActivity" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package io.github.v7lin.fakewechat;
|
package io.github.v7lin.fakewechat;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.tencent.mm.opensdk.constants.Build;
|
import com.tencent.mm.opensdk.constants.Build;
|
||||||
|
import com.tencent.mm.opensdk.constants.ConstantsAPI;
|
||||||
import com.tencent.mm.opensdk.diffdev.DiffDevOAuthFactory;
|
import com.tencent.mm.opensdk.diffdev.DiffDevOAuthFactory;
|
||||||
import com.tencent.mm.opensdk.diffdev.IDiffDevOAuth;
|
import com.tencent.mm.opensdk.diffdev.IDiffDevOAuth;
|
||||||
import com.tencent.mm.opensdk.diffdev.OAuthErrCode;
|
import com.tencent.mm.opensdk.diffdev.OAuthErrCode;
|
||||||
@ -124,7 +128,7 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
private static final String ARGUMENT_KEY_RESERVED = "reserved";
|
private static final String ARGUMENT_KEY_RESERVED = "reserved";
|
||||||
private static final String ARGUMENT_KEY_PARTNERID = "partnerId";
|
private static final String ARGUMENT_KEY_PARTNERID = "partnerId";
|
||||||
private static final String ARGUMENT_KEY_PREPAYID = "prepayId";
|
private static final String ARGUMENT_KEY_PREPAYID = "prepayId";
|
||||||
// private static final String ARGUMENT_KEY_NONCESTR = "noncestr";
|
// private static final String ARGUMENT_KEY_NONCESTR = "noncestr";
|
||||||
// private static final String ARGUMENT_KEY_TIMESTAMP = "timestamp";
|
// private static final String ARGUMENT_KEY_TIMESTAMP = "timestamp";
|
||||||
private static final String ARGUMENT_KEY_PACKAGE = "package";
|
private static final String ARGUMENT_KEY_PACKAGE = "package";
|
||||||
private static final String ARGUMENT_KEY_SIGN = "sign";
|
private static final String ARGUMENT_KEY_SIGN = "sign";
|
||||||
@ -151,6 +155,7 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
private final AtomicBoolean register = new AtomicBoolean(false);
|
private final AtomicBoolean register = new AtomicBoolean(false);
|
||||||
|
|
||||||
private IWXAPI iwxapi;
|
private IWXAPI iwxapi;
|
||||||
|
private BroadcastReceiver refreshWxappReceiver;
|
||||||
|
|
||||||
private FakeWechatPlugin(Registrar registrar, MethodChannel channel) {
|
private FakeWechatPlugin(Registrar registrar, MethodChannel channel) {
|
||||||
this.registrar = registrar;
|
this.registrar = registrar;
|
||||||
@ -187,7 +192,9 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
private WechatReceiver wechatReceiver = new WechatReceiver() {
|
private WechatReceiver wechatReceiver = new WechatReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void handleIntent(Intent intent) {
|
public void handleIntent(Intent intent) {
|
||||||
iwxapi.handleIntent(intent, iwxapiEventHandler);
|
if (iwxapi != null) {
|
||||||
|
iwxapi.handleIntent(intent, iwxapiEventHandler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -242,10 +249,7 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
@Override
|
@Override
|
||||||
public void onMethodCall(MethodCall call, Result result) {
|
public void onMethodCall(MethodCall call, Result result) {
|
||||||
if (METHOD_REGISTERAPP.equals(call.method)) {
|
if (METHOD_REGISTERAPP.equals(call.method)) {
|
||||||
String appId = call.argument(ARGUMENT_KEY_APPID);
|
registerApp(call, result);
|
||||||
iwxapi = WXAPIFactory.createWXAPI(registrar.context().getApplicationContext(), appId);
|
|
||||||
iwxapi.registerApp(appId);
|
|
||||||
result.success(null);
|
|
||||||
} else if (METHOD_ISWECHATINSTALLED.equals(call.method)) {
|
} else if (METHOD_ISWECHATINSTALLED.equals(call.method)) {
|
||||||
result.success(iwxapi.isWXAppInstalled());
|
result.success(iwxapi.isWXAppInstalled());
|
||||||
} else if (METHOD_ISWECHATSUPPORTAPI.equals(call.method)) {
|
} else if (METHOD_ISWECHATSUPPORTAPI.equals(call.method)) {
|
||||||
@ -285,6 +289,26 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerApp(MethodCall call, Result result) {
|
||||||
|
final String appId = call.argument(ARGUMENT_KEY_APPID);
|
||||||
|
iwxapi = WXAPIFactory.createWXAPI(registrar.context().getApplicationContext(), appId);
|
||||||
|
iwxapi.registerApp(appId);
|
||||||
|
if (refreshWxappReceiver != null) {
|
||||||
|
registrar.context().unregisterReceiver(refreshWxappReceiver);
|
||||||
|
refreshWxappReceiver = null;
|
||||||
|
}
|
||||||
|
refreshWxappReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (iwxapi != null) {
|
||||||
|
iwxapi.registerApp(appId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
registrar.context().registerReceiver(refreshWxappReceiver, new IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP));
|
||||||
|
result.success(null);
|
||||||
|
}
|
||||||
|
|
||||||
private void handleAuthCall(MethodCall call, Result result) {
|
private void handleAuthCall(MethodCall call, Result result) {
|
||||||
SendAuth.Req req = new SendAuth.Req();
|
SendAuth.Req req = new SendAuth.Req();
|
||||||
req.scope = call.argument(ARGUMENT_KEY_SCOPE);
|
req.scope = call.argument(ARGUMENT_KEY_SCOPE);
|
||||||
@ -450,6 +474,10 @@ public class FakeWechatPlugin implements MethodCallHandler, PluginRegistry.ViewD
|
|||||||
WechatReceiver.unregisterReceiver(registrar.context(), wechatReceiver);
|
WechatReceiver.unregisterReceiver(registrar.context(), wechatReceiver);
|
||||||
}
|
}
|
||||||
qrauth.removeAllListeners();
|
qrauth.removeAllListeners();
|
||||||
|
if (refreshWxappReceiver != null) {
|
||||||
|
registrar.context().unregisterReceiver(refreshWxappReceiver);
|
||||||
|
refreshWxappReceiver = null;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "io.github.v7lin.fakewechatexample"
|
applicationId "io.github.v7lin.fakewechatexample"
|
||||||
minSdkVersion 16
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
|
@ -16,7 +16,7 @@ dependencies:
|
|||||||
image: ^2.0.7
|
image: ^2.0.7
|
||||||
|
|
||||||
path: ^1.6.2
|
path: ^1.6.2
|
||||||
fake_path_provider: ^0.0.1+1
|
fake_path_provider: ^0.1.2
|
||||||
|
|
||||||
fake_wechat:
|
fake_wechat:
|
||||||
path: ../
|
path: ../
|
||||||
|
10
pubspec.yaml
10
pubspec.yaml
@ -11,12 +11,12 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
meta: '>=1.1.6 <2.0.0'
|
meta: ^1.1.6
|
||||||
uuid: '>=1.0.0 <3.0.0'
|
uuid: '>=1.0.0 <3.0.0'
|
||||||
convert: '>=2.0.2 <3.0.0'
|
convert: ^2.0.2
|
||||||
crypto: '>=2.0.6 <3.0.0'
|
crypto: ^2.0.6
|
||||||
|
|
||||||
jaguar_serializer: '>=2.2.12 <3.0.0'
|
jaguar_serializer: ^2.2.12
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -27,7 +27,7 @@ dev_dependencies:
|
|||||||
image: ^2.0.7
|
image: ^2.0.7
|
||||||
|
|
||||||
path: ^1.6.2
|
path: ^1.6.2
|
||||||
fake_path_provider: ^0.0.1+1
|
fake_path_provider: ^0.1.2
|
||||||
|
|
||||||
build_runner:
|
build_runner:
|
||||||
jaguar_serializer_cli:
|
jaguar_serializer_cli:
|
||||||
|
Reference in New Issue
Block a user