|
@ -31,6 +31,7 @@ import com.google.gson.Gson; |
|
|
import com.ouxuan.oxface.data.DeviceSelectDataManager; |
|
|
import com.ouxuan.oxface.data.DeviceSelectDataManager; |
|
|
import com.ouxuan.oxface.data.LoginDataManager; |
|
|
import com.ouxuan.oxface.data.LoginDataManager; |
|
|
import com.ouxuan.oxface.device.DeviceUtils; |
|
|
import com.ouxuan.oxface.device.DeviceUtils; |
|
|
|
|
|
import com.ouxuan.oxface.device.RelayController; |
|
|
import com.ouxuan.oxface.network.api.PadApiService; |
|
|
import com.ouxuan.oxface.network.api.PadApiService; |
|
|
import com.ouxuan.oxface.network.api.UserApiService; |
|
|
import com.ouxuan.oxface.network.api.UserApiService; |
|
|
import com.ouxuan.oxface.network.callback.CompleteApiResponseCallback; |
|
|
import com.ouxuan.oxface.network.callback.CompleteApiResponseCallback; |
|
@ -60,6 +61,7 @@ public class MainActivity extends AppCompatActivity { |
|
|
private DeviceSelectDataManager deviceSelectDataManager; // 设备选择数据管理器 |
|
|
private DeviceSelectDataManager deviceSelectDataManager; // 设备选择数据管理器 |
|
|
private KeepAliveManager keepAliveManager; // 保持活跃管理器 |
|
|
private KeepAliveManager keepAliveManager; // 保持活跃管理器 |
|
|
private AutoStartManager autoStartManager; // 自启动管理器 |
|
|
private AutoStartManager autoStartManager; // 自启动管理器 |
|
|
|
|
|
private RelayController relayController; // 继电器控制器 |
|
|
private Dialog currentDialog; // 用于跟踪当前显示的Dialog,防止WindowLeaked错误 |
|
|
private Dialog currentDialog; // 用于跟踪当前显示的Dialog,防止WindowLeaked错误 |
|
|
|
|
|
|
|
|
// 添加设备ID和版本号TextView引用 |
|
|
// 添加设备ID和版本号TextView引用 |
|
@ -94,6 +96,9 @@ public class MainActivity extends AppCompatActivity { |
|
|
// 初始化设备选择数据管理器 |
|
|
// 初始化设备选择数据管理器 |
|
|
deviceSelectDataManager = DeviceSelectDataManager.getInstance(this); |
|
|
deviceSelectDataManager = DeviceSelectDataManager.getInstance(this); |
|
|
|
|
|
|
|
|
|
|
|
// 初始化继电器控制器 |
|
|
|
|
|
relayController = RelayController.getInstance(); |
|
|
|
|
|
|
|
|
// 初始化保持活跃管理器并启动(用于24小时无人值守) |
|
|
// 初始化保持活跃管理器并启动(用于24小时无人值守) |
|
|
keepAliveManager = KeepAliveManager.getInstance(this); |
|
|
keepAliveManager = KeepAliveManager.getInstance(this); |
|
|
keepAliveManager.startKeepAlive(this); |
|
|
keepAliveManager.startKeepAlive(this); |
|
@ -895,13 +900,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
", Hardware ID: " + hardwareId + |
|
|
", Hardware ID: " + hardwareId + |
|
|
", API Code: " + apiResponse.getCode()); |
|
|
", API Code: " + apiResponse.getCode()); |
|
|
|
|
|
|
|
|
// 动态获取设备类型并切换相机配置 |
|
|
|
|
|
|
|
|
// 动态获取设备类型并统一初始化相关模块 |
|
|
int deviceType = deviceSelectDataManager.getDeviceType(); |
|
|
int deviceType = deviceSelectDataManager.getDeviceType(); |
|
|
Log.d(TAG, "选择设备后获取设备类型: " + deviceType); |
|
|
Log.d(TAG, "选择设备后获取设备类型: " + deviceType); |
|
|
switchCameraByDeviceType(deviceType); |
|
|
|
|
|
|
|
|
|
|
|
// 根据设备类型切换485串口路径 |
|
|
|
|
|
com.ouxuan.oxface.device.Ox485.switch485ByDeviceType(deviceType); |
|
|
|
|
|
|
|
|
setDeviceInitByType(deviceType); |
|
|
|
|
|
|
|
|
// 新增:调用获取小程序码接口和上传人脸小程序码接口 |
|
|
// 新增:调用获取小程序码接口和上传人脸小程序码接口 |
|
|
// 使用计数器确保两个请求都完成后再进入人脸识别界面 |
|
|
// 使用计数器确保两个请求都完成后再进入人脸识别界面 |
|
@ -1355,6 +1357,52 @@ public class MainActivity extends AppCompatActivity { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据设备类型统一初始化所有相关模块 |
|
|
|
|
|
* @param deviceType 设备类型(5=第6批,6=第7批等) |
|
|
|
|
|
*/ |
|
|
|
|
|
private void setDeviceInitByType(int deviceType) { |
|
|
|
|
|
try { |
|
|
|
|
|
LogManager.logInfo("MainActivity", "开始根据设备类型(" + deviceType + ")初始化相关模块"); |
|
|
|
|
|
|
|
|
|
|
|
// 1. 切换相机配置 |
|
|
|
|
|
switchCameraByDeviceType(deviceType); |
|
|
|
|
|
|
|
|
|
|
|
// 2. 根据设备类型切换485串口路径 |
|
|
|
|
|
com.ouxuan.oxface.device.Ox485.switch485ByDeviceType(deviceType); |
|
|
|
|
|
|
|
|
|
|
|
// 3. 设置继电器控制器的设备类型 |
|
|
|
|
|
if (relayController != null) { |
|
|
|
|
|
relayController.setDeviceType(deviceType); |
|
|
|
|
|
LogManager.logInfo("MainActivity", "继电器控制器设备类型已设置为: " + deviceType); |
|
|
|
|
|
} else { |
|
|
|
|
|
LogManager.logError("MainActivity", "继电器控制器未初始化"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 4. 初始化第七批设备管理器(如果设备类型为6或7) |
|
|
|
|
|
if (deviceType == 6 || deviceType == 7) { |
|
|
|
|
|
if (relayController != null) { |
|
|
|
|
|
boolean initSuccess = relayController.initDeviceType7Manager(this); |
|
|
|
|
|
if (initSuccess) { |
|
|
|
|
|
LogManager.logInfo("MainActivity", "第七批设备管理器初始化成功"); |
|
|
|
|
|
} else { |
|
|
|
|
|
LogManager.logError("MainActivity", "第七批设备管理器初始化失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: 5. 初始化状态栏开关管理模块(待实现) |
|
|
|
|
|
// StatusBarManager.initByDeviceType(deviceType); |
|
|
|
|
|
|
|
|
|
|
|
LogManager.logInfo("MainActivity", "设备类型相关模块初始化完成"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String errorMessage = "设备类型初始化失败: " + e.getMessage(); |
|
|
|
|
|
android.util.Log.e("MainActivity", errorMessage, e); |
|
|
|
|
|
LogManager.logError("MainActivity", errorMessage, e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onResume() { |
|
|
protected void onResume() { |
|
|
super.onResume(); |
|
|
super.onResume(); |
|
|