This commit is contained in:
wangcongtao
2020-04-10 10:16:19 +08:00
13 changed files with 133 additions and 22 deletions

View File

@@ -56,7 +56,7 @@ android {
flavorDimensions "product", "env"
productFlavors {
//诺威达
// 诺威达
nwd {
dimension "product"
sourceSets {
@@ -64,6 +64,16 @@ android {
manifest.srcFile 'src/nwd/AndroidManifest.xml'
}
}
applicationId rootProject.ext.android.applicationId
}
d80x {
dimension "product"
sourceSets {
main {
manifest.srcFile 'src/d80x/AndroidManifest.xml'
}
}
applicationId rootProject.ext.android.zhidadoApplicationId
}
zhidao {
dimension "product"
@@ -72,6 +82,7 @@ android {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
applicationId rootProject.ext.android.applicationId
}
qa {
dimension "env"

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mogo.launcher"
android:sharedUserId="android.uid.system">
<application
android:name=".MogoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_shell_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.App"
tools:replace="android:label">
<!-- 高德地图 -->
<meta-data
tools:replace="android:value"
android:name="com.amap.api.v2.apikey"
android:value="40e2e7e773c7562b1f2b13699a93992c" />
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

View File

@@ -1,10 +1,11 @@
ext {
android = [
applicationId : "com.mogo.launcher",
compileSdkVersion: 28,
buildToolsVersion: "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 22,
applicationId : "com.mogo.launcher",
zhidadoApplicationId: "com.zhidao.launcher",
compileSdkVersion : 28,
buildToolsVersion : "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 22,
versionName : "8.0.4",
]

View File

@@ -5,5 +5,6 @@
<string name="module_apps_str_guide_warning">为了您的安全,导航中不可播放视频</string>
<string-array name="module_apps_array_filter_packages">
<item>com.mogo.launcher</item>
<item>com.zhidao.launcher</item>
</string-array>
</resources>

View File

@@ -1,10 +1,10 @@
package com.mogo.module.authorize.authprovider.biz
import com.google.gson.Gson
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.IMogoAuthorizeModel
import com.mogo.module.authorize.model.bean.Agreement
import com.mogo.module.authorize.model.bean.AgreementData
import com.mogo.module.authorize.model.bean.*
import com.mogo.module.authorize.net.request
import com.mogo.module.authorize.util.DateUtil.parseDateToTime
import com.mogo.module.authorize.util.SharedPreferenceUtil.getAuthorizeVersion
@@ -31,7 +31,7 @@ open class IMogoAuthorizeController {
}
}, { msg: String ->
onError.invoke(msg)
})
}, true)
}
fun invokeAuthorizeContent(tag: String, agreementType: Int) {
@@ -62,12 +62,12 @@ open class IMogoAuthorizeController {
})
}
private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse<AgreementData>) -> Unit), onError: ((String) -> Unit)) {
private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse<AgreementData>) -> Unit), onError: ((String) -> Unit), needContent: Boolean = false) {
onStart.invoke()
try {
request<BaseResponse<AgreementData>> {
loader {
authorizeModel.invokeAuthorizeContent(agreementType)
authorizeModel.invokeAuthorizeContent(agreementType, needContent)
}
onSuccess {
onSuccess.invoke(it)
@@ -116,4 +116,25 @@ open class IMogoAuthorizeController {
val oldVersion = getAuthorizeVersion()
return currentTime > oldVersion
}
fun checkIfNeedAuthorize(agreementType: Int) {
request<BaseResponse<AgreementStatus>> {
loader {
authorizeModel.invokeIfNeedAuthorize(agreementType)
}
onSuccess {
Logger.d(TAG,"result : ${it.result}")
val result = it.result
when (result.agreementStatus) {
AGREEMENT_EFFECT -> setAuthorizeStatus(agreementType, true)
AGREEMENT_NOT_EFFECT -> setAuthorizeStatus(agreementType, false)
else -> Logger.d(TAG, "agreementStatus is not match any case")
}
}
onError {
Logger.d(TAG, it.message ?: "checkIfNeedAuthorize onError, message is null")
setAuthorizeStatus(agreementType, true)
}
}
}
}

View File

@@ -6,6 +6,7 @@ import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListen
import com.mogo.module.authorize.model.proxy.AuthorizeProxy
import com.mogo.module.authorize.model.proxy.toAuthorizeType
import com.mogo.module.authorize.util.SharedPreferenceUtil.needAuthorization
import com.mogo.module.authorize.util.SharedPreferenceUtil.setAuthorizeStatus
import com.mogo.module.authorize.util.isDeviceOfD
import com.mogo.utils.logger.Logger
@@ -19,14 +20,18 @@ open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
override fun needAuthorize(tag: String): Boolean {
return if (isDeviceOfD()) {
Logger.d(TAG, "needAuthorize update agreement in background")
baseController.updateAgreementVersion(tag.toAuthorizeType())
Logger.d(TAG, "===== needAuthorize update agreement in background")
baseController.checkIfNeedAuthorize(tag.toAuthorizeType())
needAuthorization(tag.toAuthorizeType())
} else {
false
}
}
override fun updateAuthorizeStatus(tag: String) {
baseController.checkIfNeedAuthorize(tag.toAuthorizeType())
}
override fun invokeAuthorizeContent(tag: String) {
//todo 后面动态代理统一处理校验问题
Logger.d(TAG, "tag:$tag")

View File

@@ -67,6 +67,8 @@ class MogoAuthorizeProvider : IMogoModuleProvider {
if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
mogoAuthShow.invokeAuthorizeForShow()
} else {
//首次进入Launcher同步一下授权状态防止由于用户清除数据造成首次加载还会出现授权状态不同步问题
mogoAuthShow.updateAuthorizeStatus(AUTHORIZE_TYPE_LAUNCHER_MAIN)
Logger.d(TAG, "not do match self startUp condition ,wait for someone invoke")
}
}

View File

@@ -15,4 +15,12 @@ interface IMogoAuthorizeInvoke : IMogoAuthorizeRegister {
* tag:模块ID
*/
fun invokeAuthorizeContent(tag: String)
/**
* 更新授权状态
* tag:模块ID
*/
fun updateAuthorizeStatus(tag:String){
}
}

View File

@@ -15,6 +15,10 @@ import com.mogo.module.authorize.voice.IVoiceCommandListener
import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener
import com.mogo.module.authorize.voice.VoiceUtil
import com.mogo.utils.logger.Logger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.withContext
class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener {
@@ -105,7 +109,12 @@ class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter
clLoadAuthorizeContainer?.visibility = View.GONE
clContainer?.visibility = View.VISIBLE
tvTitle?.text = Html.fromHtml(agreementTitle)
tvContent?.text = Html.fromHtml(agreementContent)
GlobalScope.async(Dispatchers.IO) {
val spannable = Html.fromHtml(agreementContent)
withContext(Dispatchers.Main){
tvContent?.text = spannable
}
}
tvButtonContent?.text = Html.fromHtml(agreementBottom)
tvLastContent?.text = Html.fromHtml(agreementLast)
}

View File

@@ -2,9 +2,9 @@ package com.mogo.module.authorize.model
import com.google.gson.Gson
import com.mogo.commons.network.Utils.getSn
import com.mogo.module.authorize.model.bean.RequestUserAgreement
import com.mogo.module.authorize.model.bean.Agreement
import com.mogo.module.authorize.model.bean.AgreementData
import com.mogo.module.authorize.model.bean.AgreementStatus
import com.mogo.module.authorize.model.bean.RequestUserAgreement
open class IMogoAuthorizeModel : BaseRepository() {
@@ -12,9 +12,15 @@ open class IMogoAuthorizeModel : BaseRepository() {
const val TAG = "IMogoAuthorizeModel"
}
suspend fun invokeAuthorizeContent(agreementType: Int): BaseResponse<AgreementData> {
val requestUserAgreement = Gson().toJson(RequestUserAgreement(agreementType))
suspend fun invokeAuthorizeContent(agreementType: Int, needContent: Boolean = false): BaseResponse<AgreementData> {
val requestUserAgreement = Gson().toJson(RequestUserAgreement(agreementType, needContent))
val map = mapOf("sn" to getSn(), "data" to requestUserAgreement)
return apiCall { getNetWorkApi().getAuthorizeContent(map) }
}
suspend fun invokeIfNeedAuthorize(agreementType: Int): BaseResponse<AgreementStatus> {
val requestUserAgreement = Gson().toJson(RequestUserAgreement(agreementType))
val map = mapOf("sn" to getSn(), "data" to requestUserAgreement)
return apiCall { getNetWorkApi().checkIfNeedAuthorize(map) }
}
}

View File

@@ -3,7 +3,21 @@ package com.mogo.module.authorize.model.bean
const val AGREEMENT_EFFECT = 1 //用户协议生效
const val AGREEMENT_NOT_EFFECT = 2 //用户协议不生效
class RequestUserAgreement(val agreementType: Int)
class RequestUserAgreement{
var agreementType:Int
var want:Boolean = false
constructor(agreementType:Int){
this.agreementType = agreementType
}
constructor(agreementType: Int, want: Boolean) {
this.agreementType = agreementType
this.want = want
}
}
data class AgreementStatus(val agreementStatus:Int)
data class AgreementData(val agreement: Agreement)

View File

@@ -1,8 +1,8 @@
package com.mogo.module.authorize.net
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.bean.Agreement
import com.mogo.module.authorize.model.bean.AgreementData
import com.mogo.module.authorize.model.bean.AgreementStatus
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
@@ -19,4 +19,9 @@ interface AuthorizeApi {
@POST("yycp-channelManager/agreement/updateStatus")
suspend fun updateAuthorize(@FieldMap updateStatus: Map<String, String>): BaseResponse<Any>
//查询是否要授权
@FormUrlEncoded
@POST("yycp-channelManager/agreement/queryUserAuthorizeStatusByType")
suspend fun checkIfNeedAuthorize(@FieldMap needAuthorize: Map<String, String>): BaseResponse<AgreementStatus>
}

View File

@@ -172,7 +172,7 @@ public class VolumeManager {
}
/*
判断是否future渠道
判断是否future渠道F系列
*/
private boolean isFuture() {
@@ -181,7 +181,8 @@ public class VolumeManager {
Class<?> buildConfig = Class.forName("com.mogo.launcher.BuildConfig");
Field flavor = buildConfig.getDeclaredField("FLAVOR");
//String descriptor= Modifier.toString(flavor.getModifiers());
return TextUtils.equals((CharSequence) flavor.get(null),"zhidao");
String val = (String) flavor.get(null);
return val.toLowerCase().contains( "zhidao" );
} catch (ClassNotFoundException e) {
e.printStackTrace();
@@ -189,6 +190,8 @@ public class VolumeManager {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
return false;