refactor(sdk): 重构项目并添加 native 代码支持
- 移除了不必要的日志库 LogUtil - 添加了高德地图服务并配置了相关权限 - 更新了 API 接口定义,统一添加了前缀 -重构了 AppConfig 类,使用 native代码获取配置信息 - 更新了项目构建配置,支持 native 代码编译 - 优化了部分代码结构,提高了代码的可维护性
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
id 'com.google.devtools.ksp'
|
||||
}
|
||||
|
||||
android {
|
||||
@ -31,6 +30,11 @@ android {
|
||||
VIVO_APPKEY : "cfd443e2a1757cf537361588c988a12a",//vivo的APPKEY
|
||||
VIVO_APPID : "105470845",//vivo的APPID
|
||||
]
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@ -50,6 +54,7 @@ android {
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false // 开启混淆
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.config
|
||||
}
|
||||
}
|
||||
@ -75,6 +80,12 @@ android {
|
||||
jniLibs.srcDirs = ["libs"]
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path file('src/main/cpp/CMakeLists.txt')
|
||||
version '3.22.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
38
app/src/main/cpp/CMakeLists.txt
Normal file
38
app/src/main/cpp/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
# For more information about using CMake with Android Studio, read the
|
||||
# documentation: https://d.android.com/studio/projects/add-native-code.html.
|
||||
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.
|
||||
|
||||
# Sets the minimum CMake version required for this project.
|
||||
cmake_minimum_required(VERSION 3.22.1)
|
||||
|
||||
# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
|
||||
# Since this is the top level CMakeLists.txt, the project name is also accessible
|
||||
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
|
||||
# build script scope).
|
||||
project("config")
|
||||
|
||||
# Creates and names a library, sets it as either STATIC
|
||||
# or SHARED, and provides the relative paths to its source code.
|
||||
# You can define multiple libraries, and CMake builds them for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
#
|
||||
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
|
||||
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
|
||||
# is preferred for the same purpose.
|
||||
#
|
||||
# In order to load a library into your app from Java/Kotlin, you must call
|
||||
# System.loadLibrary() and pass the name of the library defined here;
|
||||
# for GameActivity/NativeActivity derived applications, the same library name must be
|
||||
# used in the AndroidManifest.xml file.
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
# List C/C++ source files with relative paths to this CMakeLists.txt.
|
||||
config.cpp)
|
||||
|
||||
# Specifies libraries CMake should link to your target library. You
|
||||
# can link libraries from various origins, such as libraries defined in this
|
||||
# build script, prebuilt third-party libraries, or Android system libraries.
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
# List libraries link to the target library
|
||||
android
|
||||
log)
|
279
app/src/main/cpp/config.cpp
Normal file
279
app/src/main/cpp/config.cpp
Normal file
@ -0,0 +1,279 @@
|
||||
// Write C++ code here.
|
||||
//
|
||||
// Do not forget to dynamically load the C++ library into your application.
|
||||
//
|
||||
// For instance,
|
||||
//
|
||||
// In MainActivity.java:
|
||||
// static {
|
||||
// System.loadLibrary("demo");
|
||||
// }
|
||||
//
|
||||
// Or, in MainActivity.kt:
|
||||
// companion object {
|
||||
// init {
|
||||
// System.loadLibrary("demo")
|
||||
// }
|
||||
// }
|
||||
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_com_za_base_Config_getUrls(JNIEnv *env, jobject thiz) {
|
||||
// 创建 HashMap 类引用
|
||||
jclass hashMapClass = env->FindClass("java/util/HashMap");
|
||||
jmethodID hashMapConstructor = env->GetMethodID(hashMapClass, "<init>", "()V");
|
||||
jmethodID putMethod = env->GetMethodID(hashMapClass, "put",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
|
||||
// 创建 HashMap 实例
|
||||
jobject hashMap = env->NewObject(hashMapClass, hashMapConstructor);
|
||||
|
||||
// 插入键值对
|
||||
jstring key1 = env->NewStringUTF("release");
|
||||
jstring value1 = env->NewStringUTF("https://api.sinoassist.com");
|
||||
env->CallObjectMethod(hashMap, putMethod, key1, value1);
|
||||
|
||||
jstring key2 = env->NewStringUTF("review");
|
||||
jstring value2 = env->NewStringUTF("25");
|
||||
env->CallObjectMethod(hashMap, putMethod, key2, value2);
|
||||
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
//----------------------------------- 基础的地址配置-------------------------------------------------
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api.sinoassist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseImgBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api.sinoassist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseResourceUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://www.sinoassist.com/res";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://www.sinoassist.com/h5/supplier/dispatch/diverTrainDocment";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseDocumentUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://www.sinoassist.com/h5/supplier/dispatch/docmentList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReleaseNewDriverTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://www.sinoassist.com/h5/supplier/dispatch/driverTrainingList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "http://interface.review.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewImgBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "http://interface.review.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewResourceUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://www.sinoassist.com/res";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "http://interface.review.sino-assist.com/h5/supplier/dispatch/diverTrainDocment";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewDocumentUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "http://interface.review.sino-assist.com/h5/supplier/dispatch/docmentList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getReviewNewDriverTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "http://interface.review.sino-assist.com/h5/supplier/dispatch/driverTrainingList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1BaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api1.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1ImgBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api1.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1ResourceUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://crm1.sino-assist.com/res";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1TrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://crm1.sino-assist.com/h5/supplier/dispatch/diverTrainDocment";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1DocumentUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://crm1.sino-assist.com/h5/supplier/dispatch/docmentList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm1NewDriverTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://crm1.sino-assist.com/h5/supplier/dispatch/driverTrainingList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2BaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api2.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2ImgBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api2.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2ResourceUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://crm2.sino-assist.com/res";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2TrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api.sinoassist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2DocumentUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getCrm2NewDriverTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api-uat.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatImgBaseUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://api-uat.sino-assist.com";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatResourceUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://uat.sino-assist.com/res";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://uat.sino-assist.com/h5/supplier/dispatch/diverTrainDocment";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatDocumentUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://uat.sino-assist.com/h5/supplier/dispatch/docmentList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_base_AppConfig_getUatNewDriverTrainUrl(JNIEnv *env, jobject thiz) {
|
||||
std::string baseUrl = "https://uat.sino-assist.com/h5/supplier/dispatch/driverTrainingList";
|
||||
return env->NewStringUTF(baseUrl.c_str());
|
||||
}
|
||||
|
||||
|
||||
//-------------bugly appid---------------------
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_common_ZDManager_getBuglyAppId(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "6972a6b56d";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_net_RequestEncryptInterceptor_getPublicKey(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7UM6zdWdBuO0DZZVkxVfJioawUe6qH1p5Uz/qR9zbawl2oWyxxcBfxQyPS+HxOej/ZnyS4bu7qhh99alDqkJzk6g9oGZWs+jEF5GRWt9nChlfUsjvHQwuF2TSQMTdPtDPCByF/QgMFCAfbCqTrNmOETrZ/2GFy1Re0BTlhh6X/XzpzqtK+enikEMlQ5fIM5ljdXgyCnvDou9ptWqzw8Zmsat6LeA0UKz+bgpJAbw6KfK+8lPMqUpNFfkmJuEd5+JQOG9McH7j9pBagohkC6k3Cn92dAf9iD6NSDKSNgt1vxXhaNnfAbYJ5pqeSGy6QMSVO0TXYj4asln5OutD/284QIDAQAB";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
|
||||
//-------------------------MQTT 配置---------------------
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttInstanceId(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "mqtt-cn-oew23jbkb1f";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttEndpoint(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "mqtt-cn-oew23jbkb1f.mqtt.aliyuncs.com";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttAccessKey(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "LTAI5tKgZ9ACKorXzzWLxgg7";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttSecretKey(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "D04F0UH2GzrDsYaJ9GTfULGPjcsvvz";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttGroupId(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "GID_ZDJY";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_za_service_mqtt_MqttConfig_getMqttTopicPrefix(JNIEnv *env, jobject thiz) {
|
||||
std::string bugly = "pushBaseTopic/p2p";
|
||||
return env->NewStringUTF(bugly.c_str());
|
||||
}
|
@ -13,7 +13,6 @@ import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.za.base.view.CommonButton
|
||||
import com.za.common.log.LogUtil
|
||||
import com.za.sdk.demo.ui.theme.Zd_sdk_demoTheme
|
||||
import com.za.ui.main.ServiceLauncherActivity
|
||||
|
||||
@ -33,8 +32,7 @@ class ActionActivity : ComponentActivity() {
|
||||
val phone = intent.data?.getQueryParameter("driverPhone")
|
||||
val taskCode = intent.data?.getQueryParameter("taskCode")
|
||||
val vehicleName = intent.data?.getQueryParameter("rescueVehicle")
|
||||
LogUtil.print("参数",
|
||||
"name:$name,phone:$phone,taskCode:$taskCode,vehicleName:$vehicleName")
|
||||
|
||||
|
||||
Log.e("ActionActivity",
|
||||
"name:$name,phone:$phone,taskCode:$taskCode,vehicleName:$vehicleName")
|
||||
|
@ -27,7 +27,7 @@ class MainActivity : ComponentActivity() {
|
||||
.fillMaxSize()
|
||||
.clickable {
|
||||
val uri =
|
||||
"zd.assist://app?taskCode=ZD250521100686&driverName=宋志领&driverPhone=17630035658&rescueVehicle=沪88888".toUri()
|
||||
"zd.assist://app?taskCode=ZD250708100532&driverName=宋志领&driverPhone=17630035658&rescueVehicle=沪88888".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
Reference in New Issue
Block a user