Commit d1f9d2c7 authored by yinjiacheng's avatar yinjiacheng

update 磐石so、RSA加密Key区分正式和测试

parent 1999220e
...@@ -37,6 +37,7 @@ android { ...@@ -37,6 +37,7 @@ android {
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
buildConfigField("String", "API_URL", rootProject.ext.buildParams.debug.API_URL) buildConfigField("String", "API_URL", rootProject.ext.buildParams.debug.API_URL)
buildConfigField("String", "PROVIDER_NAME", '\"' + rootProject.ext.android.applicationId + ".debug.fileprovider" + '\"') buildConfigField("String", "PROVIDER_NAME", '\"' + rootProject.ext.android.applicationId + ".debug.fileprovider" + '\"')
buildConfigField("boolean", "IS_ENCRYPT_DEBUG_KEY", rootProject.ext.android.isEncryptDebugKey)
manifestPlaceholders = [ manifestPlaceholders = [
app_name : "B端测试", app_name : "B端测试",
file_provider: rootProject.ext.android.applicationId + ".debug.fileprovider", file_provider: rootProject.ext.android.applicationId + ".debug.fileprovider",
......
...@@ -10,12 +10,12 @@ import com.yidian.common.AppConfig ...@@ -10,12 +10,12 @@ import com.yidian.common.AppConfig
import com.yidian.common.YdBaseApplication import com.yidian.common.YdBaseApplication
import com.yidian.common.http.ApiSaveCookiesInterceptor import com.yidian.common.http.ApiSaveCookiesInterceptor
import com.yidian.common.http.ApiSetCookiesInterceptor import com.yidian.common.http.ApiSetCookiesInterceptor
import com.yidian.common.http.URLs
import com.yidian.common.services.XEventService import com.yidian.common.services.XEventService
import com.yidian.common.services.XPageService import com.yidian.common.services.XPageService
import com.yidian.common.utils.JVerificationUtils import com.yidian.common.utils.JVerificationUtils
import com.yidian.common.utils.UMConfigUtils import com.yidian.common.utils.UMConfigUtils
import com.yidian.commonutil.CommonUtilLifecycleModule import com.yidian.commonutil.CommonUtilLifecycleModule
import com.yidian.framework.mobile.xdiamond.SecretUtil
import com.yidian.http.ServiceFactory import com.yidian.http.ServiceFactory
import com.yidian.news.util.ProcessUtil import com.yidian.news.util.ProcessUtil
import com.yidian.xarc.xbrid.* import com.yidian.xarc.xbrid.*
...@@ -29,149 +29,152 @@ import org.json.JSONObject ...@@ -29,149 +29,152 @@ import org.json.JSONObject
@YacAppSpec @YacAppSpec
class YdSubwayApplication : YdBaseApplication() { class YdSubwayApplication : YdBaseApplication() {
private val module: CommonUtilLifecycleModule by lazy { private val module: CommonUtilLifecycleModule by lazy {
CommonUtilLifecycleModule( CommonUtilLifecycleModule(
BuildConfig.DEBUG, BuildConfig.DEBUG,
this, this,
".CommonInfrastructure" ".CommonInfrastructure"
) )
}
private val activityLifecycle = object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
activityList.add(activity)
} }
private val activityLifecycle = object : ActivityLifecycleCallbacks { override fun onActivityStarted(activity: Activity) {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
activityList.add(activity)
}
override fun onActivityStarted(activity: Activity) {
}
override fun onActivityResumed(activity: Activity) {
}
override fun onActivityPaused(activity: Activity) { }
} override fun onActivityResumed(activity: Activity) {
override fun onActivityStopped(activity: Activity) { }
} override fun onActivityPaused(activity: Activity) {
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { }
} override fun onActivityStopped(activity: Activity) {
override fun onActivityDestroyed(activity: Activity) { }
activityList.remove(activity)
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
} }
override fun onCreate() { override fun onActivityDestroyed(activity: Activity) {
super.onCreate() activityList.remove(activity)
UMConfigUtils.init(this)
if (ProcessUtil.isMainProcess(this)) {
context = this
FtDeviceFingerManager.init(this)
initCommonUtils()
Zap.init(this) {}
XPageManager.init(this)
initXBridManager()
loadService()
JVerificationUtils.init(this)
registerActivityLifecycleCallbacks(activityLifecycle)
}
} }
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base) }
if (ProcessUtil.isMainProcess(this)) {
module.onBaseContextAttached(base) override fun onCreate() {
} super.onCreate()
UMConfigUtils.init(this)
if (ProcessUtil.isMainProcess(this)) {
context = this
FtDeviceFingerManager.init(this)
initCommonUtils()
Zap.init(this) {}
XPageManager.init(this)
initXBridManager()
loadService()
JVerificationUtils.init(this)
registerActivityLifecycleCallbacks(activityLifecycle)
// 初始化磐石SDK
SecretUtil.init(BuildConfig.IS_ENCRYPT_DEBUG_KEY)
} }
}
override fun onConfigurationChanged(newConfig: Configuration) { override fun attachBaseContext(base: Context?) {
super.onConfigurationChanged(newConfig) super.attachBaseContext(base)
if (ProcessUtil.isMainProcess(this)) { if (ProcessUtil.isMainProcess(this)) {
module.onConfigurationChanged(newConfig) module.onBaseContextAttached(base)
}
} }
}
private fun initCommonUtils() { override fun onConfigurationChanged(newConfig: Configuration) {
module.onCreate() super.onConfigurationChanged(newConfig)
Hawk.init(this).build() if (ProcessUtil.isMainProcess(this)) {
initHttp() module.onConfigurationChanged(newConfig)
} }
}
private fun initCommonUtils() {
module.onCreate()
Hawk.init(this).build()
initHttp()
}
private fun initHttp() { private fun initHttp() {
// val header = HashMap<String, String>() // val header = HashMap<String, String>()
// header["Content-Type"] = "application/json" // header["Content-Type"] = "application/json"
// header["charset"] = "UTF-8" // header["charset"] = "UTF-8"
// ServiceFactory.getInstance().addInterceptor(HttpInterceptor(header)) // ServiceFactory.getInstance().addInterceptor(HttpInterceptor(header))
// ServiceFactory.getInstance().init(true, URLs.BASE_URL, 10, 10) // ServiceFactory.getInstance().init(true, URLs.BASE_URL, 10, 10)
ServiceFactory.getInstance().init(true, BuildConfig.API_URL, 10, 10) ServiceFactory.getInstance().init(true, BuildConfig.API_URL, 10, 10)
ServiceFactory.getInstance().addInterceptor(ApiSaveCookiesInterceptor()) ServiceFactory.getInstance().addInterceptor(ApiSaveCookiesInterceptor())
ServiceFactory.getInstance().addInterceptor(ApiSetCookiesInterceptor()) ServiceFactory.getInstance().addInterceptor(ApiSetCookiesInterceptor())
} }
private fun initXBridManager() { private fun initXBridManager() {
XBridManager.init( XBridManager.init(
XBridApp(applicationContext) { XBridApp(applicationContext) {
assetRoot = "www"//对应assets目录下存放xbrid资源对应的目录名 assetRoot = "www"//对应assets目录下存放xbrid资源对应的目录名
appId = "com.yidian.subway"//当前应用包名 appId = "com.yidian.subway"//当前应用包名
platformId = 16 //需要去平台申请 platformId = 16 //需要去平台申请
appVersion = AppConfig.cv//当前应用版本号 appVersion = AppConfig.cv//当前应用版本号
deviceFinger = FtDeviceFingerManager.getDeviceFinger()//设备指纹 deviceFinger = FtDeviceFingerManager.getDeviceFinger()//设备指纹
androidChannel = AppConfig.distribution//对应渠道名 androidChannel = AppConfig.distribution//对应渠道名
}, 20//webview缓存池数量,默认不缓存 }, 20//webview缓存池数量,默认不缓存
) )
XBridManager.registerServiceInvoker(object : OnServiceInvoke { XBridManager.registerServiceInvoker(object : OnServiceInvoke {
override fun onCall( override fun onCall(
identifier: String, // the identifier assigned when webview created identifier: String, // the identifier assigned when webview created
xWebView: XWebView, // webivew 加载的 js 发起的服务调用请求 xWebView: XWebView, // webivew 加载的 js 发起的服务调用请求
request: Request, // 具体的服务请求参数,分为 name 和 params 两个部分 request: Request, // 具体的服务请求参数,分为 name 和 params 两个部分
response: Response // 业务方需要借助 response 来回应服务调用结果 response: Response // 业务方需要借助 response 来回应服务调用结果
) { ) {
val data = request.params as JSONObject val data = request.params as JSONObject
Log.e("zhb-yd", "服务名:" + request.name) Log.e("zhb-yd", "服务名:" + request.name)
Log.e("zhb-yd", "JS传递参数:$data") Log.e("zhb-yd", "JS传递参数:$data")
val action = data.optString("action") val action = data.optString("action")
val params = data.optJSONObject("params") val params = data.optJSONObject("params")
val options = data.optJSONObject("options") val options = data.optJSONObject("options")
ZapTicket(request.name).withAction(action).withServiceParams(params).withServiceOptions(options).withIdentifier(identifier).onResult { result -> ZapTicket(request.name).withAction(action).withServiceParams(params).withServiceOptions(options).withIdentifier(identifier)
response.result(result.code, result.result!!, "") .onResult { result ->
}.onLost { result -> response.result(result.code, result.result!!, "")
response.result(result.code, "", result.mesg) }.onLost { result ->
}.ship() response.result(result.code, "", result.mesg)
} }.ship()
}) }
})
XBridManager.registerXPageInvoker(object : OnXPageInvoke {
override fun onCall(identifier: String, xWebView: XWebView, request: XPageRequest) { XBridManager.registerXPageInvoker(object : OnXPageInvoke {
val params = mutableMapOf<String, Any>() override fun onCall(identifier: String, xWebView: XWebView, request: XPageRequest) {
(request.params as JSONObject).let { reParams -> val params = mutableMapOf<String, Any>()
reParams.keys().forEach { (request.params as JSONObject).let { reParams ->
params[it] = reParams[it] reParams.keys().forEach {
} params[it] = reParams[it]
} }
when (request.action) { }
"push" -> XPageManager.push(request.name, params) when (request.action) {
"pop" -> XPageManager.pop(params) "push" -> XPageManager.push(request.name, params)
"popTo" -> XPageManager.popTo(request.name, params) "pop" -> XPageManager.pop(params)
"popToRoot" -> XPageManager.popToRoot(params) "popTo" -> XPageManager.popTo(request.name, params)
} "popToRoot" -> XPageManager.popToRoot(params)
} }
}) }
} })
}
private fun loadService() {
Zap.addService(XPageService.name, XPageService()) private fun loadService() {
Zap.addService(XEventService.name, XEventService()) Zap.addService(XPageService.name, XPageService())
} Zap.addService(XEventService.name, XEventService())
}
} }
ext { ext {
android = [ android = [
applicationId : "com.shenghuoquan.business", applicationId : "com.shenghuoquan.business",
versionCode : 100, versionCode : 100,
versionName : "1.0.0", versionName : "1.0.0",
serviceVersion: '"000100"',// 上线前需要和服务端确认并更新 serviceVersion : '"000100"', // 上线前需要和服务端确认并更新
isEncrypt : 'true',// 上线前需要开启加密 isEncrypt : 'true', // 上线前需要开启加密
isApplication : false isEncryptDebugKey: 'true', // 上线前需要使用正式加密key 置为false
isApplication : false
] ]
buildParams = [ buildParams = [
debug : [ debug : [
// API_URL: '"http://bp-dev.go2yd.com"', API_URL: '"http://bp-dev.go2yd.com"',
API_URL: '"http://bp-test.go2yd.com"', // API_URL: '"http://bp-test.go2yd.com"',
], ],
release: [ release: [
API_URL: '"http://bp-test.go2yd.com"', API_URL: '"http://bp-test.go2yd.com"',
...@@ -79,7 +80,7 @@ ext.dependencies = [ ...@@ -79,7 +80,7 @@ ext.dependencies = [
'io.reactivex.rxjava3:rxjava:3.0.9', 'io.reactivex.rxjava3:rxjava:3.0.9',
'com.yidian.framework.mobile:ydhttp:1.0.8-SNAPSHOT', 'com.yidian.framework.mobile:ydhttp:1.0.8-SNAPSHOT',
'com.yidian.framework.mobile:ydutils:1.0.1-SNAPSHOT', 'com.yidian.framework.mobile:ydutils:1.0.1-SNAPSHOT',
'com.yidian.framework.mobile:xdiamond:1.0.4-SNAPSHOT', 'com.yidian.framework.mobile:xdiamond:1.0.6',
'com.loopj.android:android-async-http:1.4.9' 'com.loopj.android:android-async-http:1.4.9'
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment