fix(android): 优化设备定位并更新原生依赖

This commit is contained in:
tongtong committed 2026-11-10 21:20:48 +08:00
1 parent 828b12d13b
commit fcbec2e075
10 files changed
+114 -83

No files matched your search

+6
View File
@@ -1057,3 +1057,9 @@ dependencies {
> **最后更新:** 2026-08-21
> **维护者:** Android Team
> **适用版本:** Android SDK 21+ / Jetpack ViewModel 2.5+ / RxJava 3.x / ViewBinding enabled
## WebRTC 依赖版本约束
- ElderlyDialer 当前固定使用 `io.github.webrtc-sdk:android:144.7559.09`,常规依赖升级时保留此版本。
- 真机复测记录(2026-11-10):升级到 `150.7871.04` 后,远程连接已建立 ICE 并打开控制通道,但 ElderlyDialer 的 WebRTC 原生线程在发送端更新 RTP 参数附近报 `vector[] index out of bounds`,随后进程因 `SIGABRT` 退出。回退到 `144.7559.09` 后,用户确认同一远程连接场景恢复正常。具体原生越界位置尚未通过符号化堆栈确认。
- `ttstd_family_care`、`ElderlyDialer` 和 `youlai-boot-ttstd` 的发布版本各自管理。升级 WebRTC 前,使用实际控制端和信令后端验证远程连接、画面、控制通道和重连。
+47 -56
View File
@@ -210,7 +210,7 @@ android {
}
ext {
jpush = [version: "5.7.0"]
jpush = [version: "6.0.7"]
AndroidPicker = [version: "4.1.15"]
}
@@ -224,7 +224,7 @@ dependencies {
implementation 'net.i2p.crypto:eddsa:0.3.0'
//sherpa-onnx https://github.com/k2-fsa/sherpa-onnx/releases
implementation files('libs/sherpa-onnx-1.13.2.aar')
implementation files('libs/sherpa-onnx-2.0.1.aar')
implementation project(path: ':niceimageview')
implementation project(path: ':iconloader')
@@ -240,57 +240,56 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.11.0'
// HiveMQ MQTT 客户端 (MQTT 3.1.1 / 5.0)
implementation 'com.hivemq:hivemq-mqtt-client:1.3.17'
implementation 'com.hivemq:hivemq-mqtt-client:1.4.2'
//保持1.3.1 更新会报错
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'androidx.appcompat:appcompat:1.8.0'
//2.0.4以上无法预览
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.2.2'
implementation "androidx.multidex:multidex:2.0.1"
implementation "androidx.recyclerview:recyclerview:1.4.0"
// For control over item selection of both touch and mouse driven selection
implementation "androidx.recyclerview:recyclerview-selection:1.2.0"
// Java language implementation
implementation "androidx.fragment:fragment:1.8.9"
implementation "androidx.fragment:fragment:1.9.1"
implementation "androidx.viewpager2:viewpager2:1.1.0"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.work:work-runtime:2.9.0"
implementation 'androidx.browser:browser:1.8.0'
implementation "androidx.webkit:webkit:1.14.0"
implementation 'androidx.startup:startup-runtime:1.0.0'
implementation "androidx.work:work-runtime:2.11.2"
implementation 'androidx.browser:browser:1.10.0'
implementation "androidx.webkit:webkit:1.15.0"
implementation 'androidx.startup:startup-runtime:1.2.0'
// Room依赖
implementation "androidx.room:room-runtime:2.8.4"
implementation "androidx.room:room-rxjava3:2.8.4"
kapt "androidx.room:room-compiler:2.8.4"
implementation "androidx.room:room-runtime:2.8.5"
implementation "androidx.room:room-rxjava3:2.8.5"
kapt "androidx.room:room-compiler:2.8.5"
// ViewModel和LiveData
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.10.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.10.0'
implementation "androidx.lifecycle:lifecycle-runtime:2.10.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.10.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.10.0"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.11.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.11.0'
implementation "androidx.lifecycle:lifecycle-runtime:2.11.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.11.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.11.0"
// 可选:RxJava3 Observable → LiveData 的桥接
implementation 'androidx.lifecycle:lifecycle-reactivestreams:2.10.0'
kapt "androidx.lifecycle:lifecycle-compiler:2.10.0"
implementation 'androidx.lifecycle:lifecycle-reactivestreams:2.11.0'
kapt "androidx.lifecycle:lifecycle-compiler:2.11.0"
// LifecycleService 核心库
implementation "androidx.lifecycle:lifecycle-service:2.10.0"
implementation "androidx.lifecycle:lifecycle-service:2.11.0"
implementation 'androidx.camera:camera-core:1.4.0'
implementation 'androidx.camera:camera-camera2:1.4.0'
implementation 'androidx.camera:camera-view:1.4.0'
implementation 'androidx.camera:camera-lifecycle:1.4.0'
implementation 'androidx.camera:camera-core:1.6.2'
implementation 'androidx.camera:camera-camera2:1.6.2'
implementation 'androidx.camera:camera-view:1.6.2'
implementation 'androidx.camera:camera-lifecycle:1.6.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
implementation 'com.google.android.material:material:1.14.0'
implementation 'com.googlecode.libphonenumber:libphonenumber:9.0.30'
implementation 'com.googlecode.libphonenumber:libphonenumber:9.0.43'
//glide
implementation 'com.github.bumptech.glide:glide:4.15.1'
kapt 'com.github.bumptech.glide:compiler:4.15.1'
implementation 'com.github.bumptech.glide:glide:5.0.9'
kapt 'com.github.bumptech.glide:compiler:5.0.9'
// SVG支持库
implementation 'com.caverock:androidsvg:1.4'
// 如果需要,添加Glide SVG模块(社区版)
@@ -301,14 +300,14 @@ dependencies {
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation 'com.squareup.moshi:moshi:1.15.2'
implementation 'com.squareup.okhttp3:okhttp:5.3.2'
implementation 'com.squareup.okhttp3:logging-interceptor:5.3.2'
implementation 'com.squareup.okhttp3:okhttp:5.5.1'
implementation 'com.squareup.okhttp3:logging-interceptor:5.5.1'
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
// implementation 'com.squareup.retrofit2:adapter-rxjava2:3.0.0'
implementation "com.squareup.retrofit2:adapter-rxjava3:3.0.0"
//Gson
implementation 'com.google.code.gson:gson:2.14.0'
implementation 'com.google.code.gson:gson:2.15.0'
implementation 'com.google.zxing:core:3.5.4'
@@ -318,7 +317,7 @@ dependencies {
implementation 'com.github.neo-turak:LiveEventBus:1.8.1'
//MMKV
implementation 'com.tencent:mmkv-static:2.4.0'
implementation 'com.tencent:mmkv-static:2.4.3'
//bugly
implementation 'com.tencent.bugly:crashreport:4.1.9.7'
@@ -332,40 +331,32 @@ dependencies {
implementation 'com.aliyun.ams:alicloud-android-push:3.10.1'
//极光
// 此处以JPush 5.6.0 版本为例,注意:从 5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置
// 6.0.7 是仍为蔚来通道发布同版本插件的最新稳定版,JCore 由 JPush 自动引入。
implementation "cn.jiguang.sdk:jpush:$jpush.version"
//若不集成厂商通道,可直接跳过以下依赖
// 极光厂商插件版本与接入 JPush 版本保持一致,下同
// 接入华为厂商
implementation 'com.huawei.hms:push:6.13.0.300'
implementation 'com.huawei.hms:push:6.13.0.301'
implementation "cn.jiguang.sdk.plugin:huawei:$jpush.version"
// 接入 FCM 厂商
implementation 'com.google.firebase:firebase-messaging:24.1.0'
implementation 'com.google.firebase:firebase-messaging:25.1.3'
implementation "cn.jiguang.sdk.plugin:fcm:$jpush.version"
// 接入魅族厂商
implementation "cn.jiguang.sdk.plugin:meizu:$jpush.version"
// JPush Android SDK v5.2.3 开始,需要单独引入 魅族 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/meizu/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
implementation files('libs/push-internal-5.0.5.aar')
// 接入 VIVO 厂商
implementation "cn.jiguang.sdk.plugin:vivo:$jpush.version"
// 接入小米厂商
implementation "cn.jiguang.sdk.plugin:xiaomi:$jpush.version"
// 接入 OPPO 厂商
implementation "cn.jiguang.sdk.plugin:oppo:$jpush.version"
// JPush Android SDK v4.6.0 开始,需要单独引入 oppo 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/oppo/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
implementation files('libs/com.heytap.msp_V3.7.1.aar')
//以下为 OPPO 3.1.0 aar需要依赖
// implementation 'com.google.code.gson:gson:2.10.1'
implementation 'commons-codec:commons-codec:1.6'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'commons-codec:commons-codec:1.23.0'
implementation 'androidx.annotation:annotation:1.10.0'
// 接入荣耀厂商
implementation "cn.jiguang.sdk.plugin:honor:$jpush.version"
//需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
implementation files('libs/HiPushSDK-8.0.12.307.aar')
// 接入蔚来厂商
implementation "cn.jiguang.sdk.plugin:nio:$jpush.version"
//JPush Android SDK v5.6.0 开始需要单独引入蔚来厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/nio/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
implementation files('libs/niopush-sdk-v1.0.aar')
//地图组件
@@ -390,11 +381,11 @@ dependencies {
implementation 'com.opencsv:opencsv:5.12.0'
// 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:20.0'
implementation 'com.github.getActivity:XXPermissions:28.3'
// implementation 'com.github.zcweng:switch-button:0.0.3@aar'
implementation "com.github.kongzue.DialogX:DialogX:0.0.50"
implementation 'cn.6tail:lunar:1.7.7'
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.4.0"
implementation 'cn.6tail:lunar:1.7.8'
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.4.2"
implementation 'io.github.youth5201314:banner:2.2.3'
// TinyPinyin核心包,约80KB
@@ -403,13 +394,13 @@ dependencies {
implementation 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.3'
// PictureSelector 基础 (必须)
implementation 'io.github.lucksiege:pictureselector:v3.11.2'
implementation 'io.github.lucksiege:pictureselector:v3.11.3'
// 图片压缩 (按需引入)
implementation 'io.github.lucksiege:compress:v3.11.2'
implementation 'io.github.lucksiege:compress:v3.11.3'
// 图片裁剪 (按需引入)
implementation 'io.github.lucksiege:ucrop:v3.11.2'
implementation 'io.github.lucksiege:ucrop:v3.11.3'
// 自定义相机 (按需引入)
implementation 'io.github.lucksiege:camerax:v3.11.2'
implementation 'io.github.lucksiege:camerax:v3.11.3'
//所有选择器的基础窗体(用于自定义弹窗)
implementation "com.github.gzu-liyujiang.AndroidPicker:Common:$AndroidPicker.version"
@@ -428,19 +419,19 @@ dependencies {
//图片选择器
implementation "com.github.gzu-liyujiang.AndroidPicker:ImagePicker:$AndroidPicker.version"
//阴影布局
implementation 'com.github.lihangleo2:ShadowLayout:3.4.5'
implementation 'com.github.lihangleo2:ShadowLayout:3.4.6'
// ---- WebRTC 远程控制(移植自 WebRTCControlled)----
// WebRTC SDK(屏幕采集 + PeerConnection + DataChannel)
implementation 'io.github.webrtc-sdk:android:144.7559.09'
// Protobuf(DataChannel 控制指令二进制)
implementation 'com.google.protobuf:protobuf-java:3.25.1'
implementation 'com.google.protobuf:protobuf-java:4.36.2'
}
// WebRTC 远程控制:protobuf 编译配置(control_message.proto 位于 src/main/proto/)
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.25.1'
artifact = 'com.google.protobuf:protoc:4.36.2'
}
generateProtoTasks {
all().configureEach { task ->
@@ -11,7 +11,7 @@ import java.io.Serializable;
* 字段与后端 {@code SnOtherInfoReq} 一一对应。
* <p>
* 注意:后端 install_time / update_time_app 为 {@code LocalDateTime},
* Jackson 默认接受 "yyyy-MM-dd'T'HH:mm:ss" 格式的字符串,
* 后端 JacksonConfig 使用 "yyyy-MM-dd HH:mm:ss" 格式的字符串,
* 因此这里用 String 承载,由采集器负责格式化,避免时间戳数字反序列化失败。
*/
public class SnOtherInfoReq implements Serializable {
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.text.TextUtils;
@@ -29,6 +31,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class MapManager {
private static final String TAG = "MapManager";
private static final long LOCATION_TIMEOUT_MS = 30_000L;
private static final String[] REQUIRED_PERMISSIONS = {
android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_COARSE_LOCATION
@@ -41,6 +44,15 @@ public class MapManager {
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private LocationClient mLocationClient;
private LocationClientOption mOption;
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
private boolean mLocationActive;
private final Runnable mLocationTimeout = () -> {
if (mLocationActive) {
stopLocation();
saveLocationError("定位超时");
notifyLocationFailure("定位超时");
}
};
// 线程安全的回调列表
private final List<OnLocationListener> mListeners = new CopyOnWriteArrayList<>();
@@ -110,11 +122,22 @@ public class MapManager {
public void startLocation() {
// 确保先停止再启动,避免重复启动
if (mLocationClient.isStarted()) {
mLocationClient.stop();
if (Looper.myLooper() != Looper.getMainLooper()) {
mMainHandler.post(this::startLocation);
return;
}
mLocationClient.start();
if (mLocationActive) {
return;
}
LocationClient client = getLocationClient();
if (client == null) {
return;
}
mLocationActive = true;
if (mOption.isOnceLocation()) {
mMainHandler.postDelayed(mLocationTimeout, LOCATION_TIMEOUT_MS);
}
client.start();
}
/**
@@ -178,7 +201,9 @@ public class MapManager {
if (mOption == null) {
mOption = new LocationClientOption();
mOption.setCoorType("bd09ll"); // 百度坐标系(配合百度地图使用)
mOption.setScanSpan(0); // 仅定位一次(0表示单次定位)
// SDK 9.7.0 clamps setScanSpan(0) to 1000 ms.
mOption.setOnceLocation(true);
mOption.setFirstLocType(LocationClientOption.FirstLocType.ACCURACY_IN_FIRST_LOC);
mOption.setIsNeedAddress(true); // 需要地址信息
mOption.setIsNeedLocationDescribe(true); // 需要地址描述
mOption.setNeedDeviceDirect(false); // 不需要设备方向
@@ -296,12 +321,18 @@ public class MapManager {
private final BDAbstractLocationListener mLocationListener = new BDAbstractLocationListener() {
@Override
public void onReceiveLocation(BDLocation location) {
if (!mLocationActive) {
return;
}
// Finish a single request before notifying consumers or receiving queued SDK callbacks.
if (location == null || mOption.isOnceLocation()) {
stopLocation();
}
if (location == null) {
String error = "定位结果为空";
Logger.e(TAG, "onReceiveLocation", error);
saveLocationError(error);
notifyLocationFailure(error);
stopLocation();
return;
}
@@ -338,11 +369,6 @@ public class MapManager {
notifyLocationFailure(unknownError);
break;
}
// 单次定位完成后停止(如果是单次定位模式)
if (mOption != null && mOption.getScanSpan() == 0) {
stopLocation();
}
}
@Override
@@ -350,8 +376,6 @@ public class MapManager {
super.onLocDiagnosticMessage(locType, diagnosticType, diagnosticMessage);
String errorMsg = "定位诊断: " + diagnosticMessage;
Logger.e(TAG, "onLocDiagnosticMessage", errorMsg);
saveLocationError(errorMsg);
notifyLocationFailure(errorMsg);
}
};
@@ -359,7 +383,13 @@ public class MapManager {
* 停止定位并释放资源
*/
public void stopLocation() {
if (mLocationClient != null && mLocationClient.isStarted()) {
if (Looper.myLooper() != Looper.getMainLooper()) {
mMainHandler.post(this::stopLocation);
return;
}
mLocationActive = false;
mMainHandler.removeCallbacks(mLocationTimeout);
if (mLocationClient != null) {
mLocationClient.stop();
}
}
@@ -368,6 +398,10 @@ public class MapManager {
* 销毁定位客户端(建议在Application退出时调用)
*/
public void destroy() {
if (Looper.myLooper() != Looper.getMainLooper()) {
mMainHandler.post(this::destroy);
return;
}
stopLocation();
if (mLocationClient != null) {
mLocationClient.unRegisterLocationListener(mLocationListener);
@@ -78,7 +78,7 @@ public class DeviceInfoCollector {
/**
* 后端 LocalDateTime 默认接受的 ISO 格式。
*/
private static final String DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
private static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**
* 常见的 su 二进制路径,用于 Root 检测。
@@ -225,7 +225,7 @@ public class SherpaOnnxTtsManager {
mAudioTrack.flush();
mAudioTrack.play();
GenerationConfig genConfig = new GenerationConfig(sid, speed, 0, null, 0, null, 5, null);
GenerationConfig genConfig = new GenerationConfig(sid, speed, 0, null, 0, null, 5, null, null, null);
if (mSupertonic) {
Map<String, String> extra = new HashMap<>();
extra.put("lang", supertonicLang);
@@ -268,7 +268,7 @@ public class SherpaOnnxTtsManager {
if (mOfflineTts == null) initTts(context.getApplicationContext());
File output = new File(context.getCacheDir(), "hourly-chime.wav");
GeneratedAudio audio = mOfflineTts.generateWithConfigAndCallback(text,
new GenerationConfig(0, 1.0f, 0, null, 0, null, 5, null),
new GenerationConfig(0, 1.0f, 0, null, 0, null, 5, null, null, null),
samples -> 1);
if (!audio.save(output.getAbsolutePath())) throw new IOException("语音生成失败");
callback.onCompleted(output.getAbsolutePath());
+1 -1
View File
@@ -2,7 +2,7 @@
apply from: "config.gradle"
buildscript {
ext.kotlin_version = '2.4.0'
ext.kotlin_version = '2.4.21'
repositories {
google()
+5 -5
View File
@@ -7,7 +7,7 @@ android {
// buildToolsVersion "36.0.0"
defaultConfig {
minSdk = 14
minSdk = 23
targetSdk = 36
versionCode = 1
versionName = "1.0"
@@ -30,11 +30,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.appcompat:appcompat:1.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
//磁盘缓存
implementation 'com.jakewharton:disklrucache:2.0.2'
+3 -3
View File
@@ -3,10 +3,10 @@ apply plugin: 'com.android.library'
android {
namespace = "com.shehuan.niv"
compileSdk = 28
compileSdk = 36
defaultConfig {
minSdk = 14
minSdk = 23
targetSdk = 28
}
@@ -24,5 +24,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.8.0'
}