5 changed files with 185 additions and 4 deletions
-
31app/src/main/java/com/ouxuan/oxface/DebugActivity.java
-
50app/src/main/java/com/ouxuan/oxface/utils/PadSettingUsageExample.java
-
48app/src/main/java/com/ouxuan/oxface/utils/VenueSceneUtils.java
-
7app/src/main/res/layout/activity_debug.xml
-
53app/src/test/java/com/ouxuan/oxface/utils/VenueSceneUtilsTest.java
@ -0,0 +1,50 @@ |
|||
package com.ouxuan.oxface.utils; |
|||
|
|||
import android.content.Context; |
|||
import android.util.Log; |
|||
|
|||
/** |
|||
* PadSetting使用示例 |
|||
* 展示如何使用VenueSceneUtils.getPadSettingJson()函数 |
|||
*/ |
|||
public class PadSettingUsageExample { |
|||
private static final String TAG = "PadSettingUsageExample"; |
|||
|
|||
/** |
|||
* 示例方法:获取并使用pad_setting数据 |
|||
* @param context 上下文 |
|||
*/ |
|||
public static void exampleUsage(Context context) { |
|||
// 调用我们实现的函数获取pad_setting JSON数据 |
|||
String padSettingJson = VenueSceneUtils.getPadSettingJson(context); |
|||
|
|||
if (!padSettingJson.isEmpty()) { |
|||
Log.d(TAG, "成功获取pad_setting数据: " + padSettingJson); |
|||
|
|||
// 可以进一步解析和使用这些数据 |
|||
// 例如,检查某些配置项: |
|||
/* |
|||
try { |
|||
com.google.gson.JsonObject padSettingObject = com.google.gson.JsonParser.parseString(padSettingJson).getAsJsonObject(); |
|||
|
|||
// 检查是否启用了活体检测 |
|||
if (padSettingObject.has("living_control")) { |
|||
boolean livingControl = padSettingObject.get("living_control").getAsBoolean(); |
|||
Log.d(TAG, "活体检测功能: " + (livingControl ? "启用" : "禁用")); |
|||
} |
|||
|
|||
// 检查门禁GPIO设置 |
|||
if (padSettingObject.has("gate_ab_gpio")) { |
|||
boolean gateAbGpio = padSettingObject.get("gate_ab_gpio").getAsBoolean(); |
|||
Log.d(TAG, "门禁GPIO控制: " + (gateAbGpio ? "启用" : "禁用")); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
Log.e(TAG, "解析pad_setting数据时发生错误: " + e.getMessage(), e); |
|||
} |
|||
*/ |
|||
} else { |
|||
Log.w(TAG, "未能获取pad_setting数据"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,53 @@ |
|||
package com.ouxuan.oxface.utils; |
|||
|
|||
import static org.junit.Assert.*; |
|||
|
|||
import com.google.gson.JsonObject; |
|||
import com.google.gson.JsonParser; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
public class VenueSceneUtilsTest { |
|||
|
|||
private static final String TEST_SELECT_RESPONSE = "{\"advert_list\":[],\"hardware_id\":641,\"hardware_name\":\"测试设备6批-新版250829\",\"logo\":\"https://imgcdn.ouxuanzhineng.cn/upload/63/logo/6b36b6b89557a7b7d90904f1a943a311.png\",\"name\":\"Test门店\",\"pad_config\":{\"auto_off_time\":\"\",\"auto_on_time\":\"\",\"brand_id\":63,\"created_at\":\"2025-08-29 17:20:17\",\"credit_card_verification\":\"\",\"dev_ip\":\"\",\"dev_name\":\"\",\"device_id\":\"e77d72188e1fd394\",\"extension\":{\"pad_setting\":{\"device_detail\":\"\",\"device_type\":5,\"gate_a_close_time\":6,\"gate_ab_always_check\":false,\"gate_ab_always_check_user_enter\":false,\"gate_ab_camera_score\":0.3,\"gate_ab_close\":false,\"gate_ab_enable\":false,\"gate_ab_enter01_enable\":false,\"gate_ab_gpio\":true,\"gate_ab_people_detect_type\":1,\"gate_ab_test_on\":false,\"gate_ab_udp\":false,\"gate_camera_485_OX_on\":false,\"gate_camera_config_arr\":[{\"cameraIP\":\"192.168.1.124:80\",\"method\":\"GET\",\"password\":\"ouxuan666@\",\"uri\":\"/ISAPI/Streaming/channels/1/picture/?resolution=1280x720\",\"username\":\"admin\"},{\"cameraIP\":\"192.168.1.124:80\",\"method\":\"GET\",\"password\":\"123456\",\"uri\":\"/digest/CaptureV2\",\"username\":\"admin\"}],\"gate_camera_config_index\":0,\"gate_camera_detect_hard_level\":false,\"gateCheckLoopOn\":false,\"gate_enter_open_enable\":false,\"gate_open_enable\":false,\"is_auto_detect\":false,\"living_control\":true}},\"face_license\":\"GEXH-QSMV-3MDX-Y9XS\",\"gate_id\":608,\"gate_name\":\"pad_ab\",\"id\":154,\"id_ouxuanac\":\"\",\"is_auto_on_off\":0,\"is_check_face\":1,\"is_code_verify\":1,\"is_pay_card_verify\":0,\"is_pvface_many_leave\":0,\"is_scan_code_verify\":0,\"is_scan_verify\":0,\"is_show_advert\":0,\"is_show_gate_btn\":0,\"is_temperature_measurement\":0,\"leave_code_type\":0,\"locker_id\":0,\"mark\":\"\",\"pad_use_scene\":\"venue\",\"qr_code_verification\":\"\",\"rent_permissions\":\"\",\"show_tips\":\"\",\"stadium_hardware_id\":641,\"stadium_id\":167,\"support_verify_modules\":[1,2,3,5],\"updated_at\":\"2025-09-11 11:48:57\",\"username\":\"00167\",\"wristband_type\":\"\"},\"validUntil\":0}"; |
|||
|
|||
@Test |
|||
public void testJsonParsing() { |
|||
// 测试JSON解析逻辑是否正确 |
|||
try { |
|||
// 解析JSON数据 |
|||
JsonObject responseObject = JsonParser.parseString(TEST_SELECT_RESPONSE).getAsJsonObject(); |
|||
|
|||
// 检查是否存在pad_config字段 |
|||
assertTrue("Response should contain pad_config", responseObject.has("pad_config")); |
|||
assertTrue("pad_config should be an object", responseObject.get("pad_config").isJsonObject()); |
|||
|
|||
JsonObject padConfigObject = responseObject.getAsJsonObject("pad_config"); |
|||
|
|||
// 检查是否存在extension字段 |
|||
assertTrue("pad_config should contain extension", padConfigObject.has("extension")); |
|||
assertTrue("extension should be an object", padConfigObject.get("extension").isJsonObject()); |
|||
|
|||
JsonObject extensionObject = padConfigObject.getAsJsonObject("extension"); |
|||
|
|||
// 检查是否存在pad_setting字段 |
|||
assertTrue("extension should contain pad_setting", extensionObject.has("pad_setting")); |
|||
assertTrue("pad_setting should be an object", extensionObject.get("pad_setting").isJsonObject()); |
|||
|
|||
JsonObject padSettingObject = extensionObject.getAsJsonObject("pad_setting"); |
|||
|
|||
// 验证一些预期的字段存在 |
|||
assertTrue("pad_setting should contain device_type", padSettingObject.has("device_type")); |
|||
assertTrue("pad_setting should contain gate_ab_gpio", padSettingObject.has("gate_ab_gpio")); |
|||
assertTrue("pad_setting should contain living_control", padSettingObject.has("living_control")); |
|||
|
|||
// 验证特定值 |
|||
assertEquals("device_type should be 5", 5, padSettingObject.get("device_type").getAsInt()); |
|||
assertTrue("gate_ab_gpio should be true", padSettingObject.get("gate_ab_gpio").getAsBoolean()); |
|||
assertTrue("living_control should be true", padSettingObject.get("living_control").getAsBoolean()); |
|||
|
|||
} catch (Exception e) { |
|||
fail("JSON parsing failed: " + e.getMessage()); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue