Merge remote-tracking branch 'origin/master'
# Conflicts: # app/build.gradle
This commit is contained in:
@@ -23,7 +23,6 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -32,5 +31,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
implementation project(path: ':foudations:mogo-commons')
|
||||
// implementation 'com.mogo.cloud:passport:1.0.0'
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
package="com.mogo.cloud">
|
||||
|
||||
<application
|
||||
android:name=".MoGoApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
37
app/src/main/java/com/mogo/cloud/MoGoApplication.java
Normal file
37
app/src/main/java/com/mogo/cloud/MoGoApplication.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class MoGoApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Random random = new Random();
|
||||
double randomLat = random.nextDouble();
|
||||
double randomLon = random.nextDouble();
|
||||
|
||||
MoGoAiCloudClientConfig clientConfig = new MoGoAiCloudClientConfig();
|
||||
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_QA);
|
||||
clientConfig.setThirdLogin(true);
|
||||
clientConfig.setShowDebugLog(true);
|
||||
clientConfig.setThirdPartyAppKey("bydauto");
|
||||
clientConfig.setThirdPartyDeviceId("bydauto");
|
||||
clientConfig.setLat(randomLat);
|
||||
clientConfig.setLon(randomLon);
|
||||
clientConfig.setCityCode("010");
|
||||
clientConfig.setLoopCheckDelay(15 * 1000);
|
||||
|
||||
MoGoAiCloudClient.getInstance().init(this, clientConfig);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,13 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.mogo.cloud.passport.IMoGoTokenCallback;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.NET_MODE_QA;
|
||||
|
||||
/**
|
||||
* 鉴权sdk测试页面
|
||||
@@ -27,8 +22,6 @@ public class PassPortActivity extends AppCompatActivity {
|
||||
private TextView tvSn;
|
||||
private TextView tvToken;
|
||||
|
||||
private MoGoAiCloudClient mMoGoAiCloudClient;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -41,26 +34,10 @@ public class PassPortActivity extends AppCompatActivity {
|
||||
tvSn = findViewById(R.id.tvSn);
|
||||
tvToken = findViewById(R.id.tvToken);
|
||||
|
||||
MoGoAiCloudClientConfig clientConfig = new MoGoAiCloudClientConfig();
|
||||
clientConfig.setNetMode(NET_MODE_QA);
|
||||
clientConfig.setThirdLogin(true);
|
||||
clientConfig.setThirdPartyAppKey("bydauto");
|
||||
clientConfig.setThirdPartyDeviceId("bydauto");
|
||||
|
||||
mMoGoAiCloudClient = MoGoAiCloudClient.getInstance().init(this,clientConfig);
|
||||
|
||||
btnRefreshToken.setOnClickListener(v -> mMoGoAiCloudClient.refreshToken(new IMoGoTokenCallback() {
|
||||
@Override
|
||||
public void onTokenGot(String token, String sn) {
|
||||
tvSn.setText(sn);
|
||||
tvToken.setText(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
}));
|
||||
btnRefreshToken.setOnClickListener(v -> {
|
||||
tvSn.setText(MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn());
|
||||
tvToken.setText(MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getToken());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
GROUP=com.mogo.httpdns
|
||||
POM_ARTIFACT_ID=httpdns-helper
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=httpdns
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.18
|
||||
VERSION_NAME=1.0.0
|
||||
@@ -32,4 +32,9 @@ dependencies {
|
||||
|
||||
// passport
|
||||
implementation 'com.zhidao.tcloginsdk:tclogin:1.1.5.1'
|
||||
}
|
||||
api project(path: ':foudations:mogo-httpdns')
|
||||
// api 'com.mogo.cloud:httpdns:1.0.0'
|
||||
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
4
foudations/mogo-passport/gradle.properties
Normal file
4
foudations/mogo-passport/gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=passport
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.0
|
||||
@@ -5,6 +5,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation;
|
||||
import com.zhidao.tcloginsdk.LoginManager;
|
||||
import com.zhidao.tcloginsdk.model.ThirdLoginParam;
|
||||
import com.zhidao.tcloginsdk.model.TokenData;
|
||||
@@ -18,7 +21,8 @@ public class MoGoAiCloudClient {
|
||||
private static final String TAG = "MoGoAiCloudClient";
|
||||
private static volatile MoGoAiCloudClient sInstance;
|
||||
|
||||
private MoGoAiCloudClientConfig mConfig;
|
||||
private MoGoAiCloudClientConfig mAiCloudClientConfig;
|
||||
private MogoHttpDnsConfig mHttpDnsConfig;
|
||||
private Context mContext;
|
||||
|
||||
|
||||
@@ -41,31 +45,35 @@ public class MoGoAiCloudClient {
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param config 配置信息
|
||||
* @param context 上下文
|
||||
* @param aiCloudClientConfig 配置信息
|
||||
*/
|
||||
public MoGoAiCloudClient init(Context context, MoGoAiCloudClientConfig config) {
|
||||
public MoGoAiCloudClient init(Context context,
|
||||
MoGoAiCloudClientConfig aiCloudClientConfig
|
||||
) {
|
||||
mContext = context;
|
||||
mConfig = config;
|
||||
// 设置网络环境
|
||||
LoginManager.getInstance(context).setNetEnviron(config.getNetMode());
|
||||
mAiCloudClientConfig = aiCloudClientConfig;
|
||||
// 设置鉴权的网络环境
|
||||
LoginManager.getInstance(context).setNetEnviron(aiCloudClientConfig.getNetMode());
|
||||
// 刷新令牌
|
||||
refreshToken(null);
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public MoGoAiCloudClientConfig getConfig() {
|
||||
return mConfig;
|
||||
public MoGoAiCloudClientConfig getAiCloudClientConfig() {
|
||||
return mAiCloudClientConfig;
|
||||
}
|
||||
|
||||
public void refreshToken(final IMoGoTokenCallback tokenCallback) {
|
||||
if (mConfig != null) {
|
||||
if (mAiCloudClientConfig != null) {
|
||||
ThirdLoginParam thirdLoginParam = ThirdLoginParam.of(
|
||||
mConfig.getThirdPartyDeviceId(),
|
||||
mConfig.getThirdPartyAppKey(),
|
||||
mConfig.getThirdPartySignSecret()
|
||||
mAiCloudClientConfig.getThirdPartyDeviceId(),
|
||||
mAiCloudClientConfig.getThirdPartyAppKey(),
|
||||
mAiCloudClientConfig.getThirdPartySignSecret()
|
||||
);
|
||||
|
||||
LoginManager.getInstance(mContext).login(
|
||||
mConfig.isThirdLogin(),
|
||||
mAiCloudClientConfig.isThirdLogin(),
|
||||
thirdLoginParam,
|
||||
new LoginCallback() {
|
||||
@Override
|
||||
@@ -74,10 +82,25 @@ public class MoGoAiCloudClient {
|
||||
tokenCallback.onTokenGot(result.token, result.sn);
|
||||
}
|
||||
|
||||
if (mConfig != null) {
|
||||
mConfig.sn = result.sn;
|
||||
mConfig.token = result.token;
|
||||
// 变量赋值
|
||||
if (mAiCloudClientConfig != null) {
|
||||
mAiCloudClientConfig.sn = result.sn;
|
||||
mAiCloudClientConfig.token = result.token;
|
||||
}
|
||||
|
||||
// 初始化HttpDNS
|
||||
mHttpDnsConfig =
|
||||
new MogoHttpDnsConfig()
|
||||
.setContext(mContext)
|
||||
.setSn(mAiCloudClientConfig.sn)
|
||||
.setEnv(mAiCloudClientConfig.getNetMode())
|
||||
.setShowDebugLog(mAiCloudClientConfig.isShowDebugLog())
|
||||
.setCurrentLocation(() -> new HttpDnsSimpleLocation(
|
||||
mAiCloudClientConfig.getCityCode(),
|
||||
mAiCloudClientConfig.getLat(),
|
||||
mAiCloudClientConfig.getLon()))
|
||||
.setLoopCheckDelay(mAiCloudClientConfig.getLoopCheckDelay());
|
||||
MogoHttpDnsClient.INSTANCE.init(mHttpDnsConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,34 +1,16 @@
|
||||
package com.mogo.cloud.passport;
|
||||
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
|
||||
/**
|
||||
* SDK 中的参数
|
||||
*/
|
||||
public class MoGoAiCloudClientConfig {
|
||||
|
||||
/**
|
||||
* 研发环境
|
||||
*/
|
||||
public static final int NET_MODE_DEV = 1;
|
||||
|
||||
/**
|
||||
* 测试环境
|
||||
*/
|
||||
public static final int NET_MODE_QA = 2;
|
||||
|
||||
/**
|
||||
* 演示环境
|
||||
*/
|
||||
public static final int NET_MODE_DEMO = 4;
|
||||
|
||||
/**
|
||||
* 生产环境
|
||||
*/
|
||||
public static final int NET_MODE_RELEASE = 3;
|
||||
|
||||
/**
|
||||
* 网络模式
|
||||
*/
|
||||
private int sNetMode = NET_MODE_RELEASE;
|
||||
private int sNetMode = MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
@@ -49,6 +31,11 @@ public class MoGoAiCloudClientConfig {
|
||||
*/
|
||||
private boolean thirdLogin;
|
||||
|
||||
/**
|
||||
* 是否打印日志
|
||||
*/
|
||||
private boolean isShowDebugLog = true;
|
||||
|
||||
/**
|
||||
* 服务器分配给应用的令牌,用于网络请求校验
|
||||
*/
|
||||
@@ -59,6 +46,23 @@ public class MoGoAiCloudClientConfig {
|
||||
*/
|
||||
String sn = "";
|
||||
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
private String cityCode;
|
||||
/**
|
||||
* 当前的纬度
|
||||
*/
|
||||
private double lat;
|
||||
/**
|
||||
* 当前的经度
|
||||
*/
|
||||
private double lon;
|
||||
/**
|
||||
* 循环检测延时时间
|
||||
*/
|
||||
private long mLoopCheckDelay;
|
||||
|
||||
public String getThirdPartyDeviceId() {
|
||||
return thirdPartyDeviceId;
|
||||
}
|
||||
@@ -106,4 +110,62 @@ public class MoGoAiCloudClientConfig {
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public boolean isShowDebugLog() {
|
||||
return isShowDebugLog;
|
||||
}
|
||||
|
||||
public void setShowDebugLog(boolean showDebugLog) {
|
||||
isShowDebugLog = showDebugLog;
|
||||
}
|
||||
|
||||
public long getLoopCheckDelay() {
|
||||
return mLoopCheckDelay;
|
||||
}
|
||||
|
||||
public void setLoopCheckDelay(long loopCheckDelay) {
|
||||
mLoopCheckDelay = loopCheckDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MoGoAiCloudClientConfig{" +
|
||||
"sNetMode=" + sNetMode +
|
||||
", thirdPartyDeviceId='" + thirdPartyDeviceId + '\'' +
|
||||
", thirdPartyAppKey='" + thirdPartyAppKey + '\'' +
|
||||
", thirdPartySignSecret='" + thirdPartySignSecret + '\'' +
|
||||
", thirdLogin=" + thirdLogin +
|
||||
", isShowDebugLog=" + isShowDebugLog +
|
||||
", token='" + token + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", cityCode='" + cityCode + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", mLoopCheckDelay=" + mLoopCheckDelay +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,15 @@ apply plugin: 'maven-publish'
|
||||
|
||||
task loggerSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
if (plugins.hasPlugin("java-library")) {
|
||||
from sourceSets.main.java.srcDirs
|
||||
} else if (plugins.hasPlugin("com.android.library")) {
|
||||
from android.sourceSets.main.java.sourceFiles
|
||||
} else if (plugins.hasPlugin('groovy')) {
|
||||
from sourceSets.main.groovy.srcDirs
|
||||
}
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
// if (plugins.hasPlugin("java-library")) {
|
||||
// from sourceSets.main.java.srcDirs
|
||||
// }
|
||||
// else if (plugins.hasPlugin("com.android.library")) {
|
||||
// from android.sourceSets.main.java.sourceFiles
|
||||
// } else if (plugins.hasPlugin('groovy')) {
|
||||
// from sourceSets.main.groovy.srcDirs
|
||||
// }
|
||||
}
|
||||
|
||||
artifacts {
|
||||
|
||||
Reference in New Issue
Block a user