From: SnickerSun Date: Wed, 10 Apr 2024 00:39:50 +0000 (+0800) Subject: 修改 About页面 蓝牙地址,名称,imei的显示 X-Git-Tag: release_V1.2.70_20241020_135402~1218 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=035da55f946ab0e215f6ec8a120bde38815c9e6c;p=mirrors%2FFD230.git 修改 About页面 蓝牙地址,名称,imei的显示 优化蓝牙地址名称nv存储 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testabout.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testabout.cpp index 679706ed2..b70fd37b2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testabout.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testabout.cpp @@ -315,10 +315,13 @@ namespace OHOS } testAboutTheWatchScrollView->Add(BluetoothAddressTitle); /* -------------------------------------------------------------------------- */ - uint8_t btaddr[64]={0}; + uint8_t btaddr[6] ={0}; + uint8_t btaddr_str[64]={0}; uint32_t len = 64; - errcode_t ret = uapi_get_btaddr((uint8_t*)btaddr,&len); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btaddr %s , ret 0x%X\n",btaddr,ret); + errcode_t ret = uapi_get_nv_btaddr((uint8_t*)btaddr,&len); + sprintf((char*)btaddr_str , "%02X:%02X:%02X:%02X:%02X:%02X",btaddr[0],btaddr[1],btaddr[2],btaddr[3],btaddr[4],btaddr[5]); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btaddr %s , ret 0x%X\n",btaddr_str,ret); Config = { .left = 37, .top = 651, @@ -326,10 +329,10 @@ namespace OHOS .height = 30, .fontSize = 26, .lineHeigh = 30, - .text = (char*)btaddr, + .text = "", .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; - + Config.text = (char*)btaddr_str; BluetoothAddress = InitLabel(Config); if (BluetoothAddress == nullptr) @@ -361,7 +364,7 @@ namespace OHOS uint8_t ble_name[20] = {0}; uint32_t ble_name_len ; - ret = uapi_get_btname(ble_name, &ble_name_len); + ret = uapi_get_nv_btname(ble_name, &ble_name_len); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btname %s ,ret 0x%X\n",ble_name,ret); Config = { @@ -371,9 +374,10 @@ namespace OHOS .height = 30, .fontSize = 26, .lineHeigh = 30, - .text = (char*)ble_name, + .text ="", .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; + Config.text = (char*)ble_name; LANAddress = InitLabel(Config); if (LANAddress == nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp index 5b382316e..b8769e1b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp @@ -3,6 +3,27 @@ #include "wearable_log.h" #include "custom_utils.h" #include "config/include/ConfigModel.h" + +#define WATCH_ABOUT_TITLE_HEIGHT 50 +#define WATCH_ABOUT_VALUE_HEIGHT 80 +#define WATCH_NAME_POS_TOP 160 +#define WATCH_NAME_VALUE_POS_TOP (WATCH_NAME_POS_TOP + WATCH_ABOUT_TITLE_HEIGHT ) +#define WATCH_FIRMWARE_POS_TOP (WATCH_NAME_VALUE_POS_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_FIRMWARE_VALUE_POS_TOP (WATCH_FIRMWARE_POS_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_BT_NAME_TOP (WATCH_FIRMWARE_VALUE_POS_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_BT_NAME_VALUE_TOP (WATCH_BT_NAME_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_BT_ADDR_TOP (WATCH_BT_NAME_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_BT_ADDR_VALUE_TOP (WATCH_BT_ADDR_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_MODEM_VERSION_TOP (WATCH_BT_ADDR_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_MODEM_VERSION_VALUE_TOP (WATCH_MODEM_VERSION_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_MODEM_APP_VERSION_TOP (WATCH_MODEM_VERSION_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_MODEM_APP_VERSION_VALUE_TOP (WATCH_MODEM_APP_VERSION_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_IMEI_TOP (WATCH_MODEM_APP_VERSION_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_IMEI_VALUE_TOP (WATCH_IMEI_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_FONT_TOP (WATCH_IMEI_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_FONT_VALUE_TOP (WATCH_FONT_TOP + WATCH_ABOUT_TITLE_HEIGHT) + + namespace OHOS { @@ -145,7 +166,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 160, + .top = WATCH_NAME_POS_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -163,7 +184,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 37, - .top = 216, + .top = WATCH_NAME_VALUE_POS_TOP, .width = 400, .height = 30, .fontSize = 26, @@ -182,7 +203,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 305, + .top = WATCH_FIRMWARE_POS_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -203,7 +224,7 @@ namespace OHOS uapi_get_buildversion((uint8_t*)version_buf,version_len); Config = { .left = 37, - .top = 341, + .top = WATCH_FIRMWARE_VALUE_POS_TOP, .width = 400, .height = 30, .fontSize = 26, @@ -222,12 +243,12 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 450, + .top = WATCH_IMEI_TOP, .width = 120, .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "算法版本", + .text = "IMEI", .lineBreakMode = UILabel::LINE_BREAK_ADAPT, }; AlgorithmVersionTitle = InitLabel(Config); @@ -240,14 +261,15 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 37, - .top = 506, + .top = WATCH_IMEI_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, .lineHeigh = 30, - .text = "V02.03.01 OTA88", + .text = "", .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; + Config.text = ConfigModel::GetInstance()->Getimei(); AlgorithmVersion = InitLabel(Config); if (AlgorithmVersion == nullptr) { @@ -259,7 +281,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 595, + .top = WATCH_BT_ADDR_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -275,21 +297,24 @@ namespace OHOS } SystemAboutTheWatchScrollView->Add(BluetoothAddressTitle); /* -------------------------------------------------------------------------- */ - uint8_t btaddr[64]={0}; + uint8_t btaddr[6] ={0}; + uint8_t btaddr_str[64]={0}; uint32_t len = 64; - errcode_t ret = uapi_get_btaddr((uint8_t*)btaddr,&len); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btaddr %s , ret 0x%X\n",btaddr,ret); + errcode_t ret = uapi_get_nv_btaddr((uint8_t*)btaddr,&len); + sprintf((char*)btaddr_str , "%02X:%02X:%02X:%02X:%02X:%02X",btaddr[0],btaddr[1],btaddr[2],btaddr[3],btaddr[4],btaddr[5]); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btaddr %s , ret 0x%X\n",btaddr_str,ret); Config = { .left = 37, - .top = 651, + .top = WATCH_BT_ADDR_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, .lineHeigh = 30, - .text = (char*)btaddr, + .text = "", .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; - + Config.text = (char*)btaddr_str; BluetoothAddress = InitLabel(Config); if (BluetoothAddress == nullptr) @@ -302,7 +327,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 740, + .top = WATCH_BT_NAME_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -321,19 +346,20 @@ namespace OHOS uint8_t ble_name[20] = {0}; uint32_t ble_name_len ; - ret = uapi_get_btname(ble_name, &ble_name_len); + ret = uapi_get_nv_btname(ble_name, &ble_name_len); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"get btname %s ,ret 0x%X\n",ble_name,ret); Config = { .left = 37, - .top = 796, + .top = WATCH_BT_NAME_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, .lineHeigh = 30, - .text = (char*)ble_name, + .text = "", .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; + Config.text = (char*)ble_name; LANAddress = InitLabel(Config); if (LANAddress == nullptr) { @@ -345,7 +371,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 173, - .top = 885, + .top = WATCH_FONT_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -363,7 +389,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 37, - .top = 941, + .top = WATCH_FONT_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, @@ -382,12 +408,12 @@ namespace OHOS Config = { .left = 173, - .top = 885+145, + .top = WATCH_MODEM_VERSION_TOP, .width = 120, .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "CAT1mode", + .text = "4G Modem", .lineBreakMode = UILabel::LINE_BREAK_ADAPT, }; CAT1Title = InitLabel(Config); @@ -400,7 +426,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 37, - .top = 941+145, + .top = WATCH_MODEM_VERSION_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, @@ -420,7 +446,7 @@ namespace OHOS Config = { .left = 173, - .top = 885+145*2, + .top = WATCH_MODEM_APP_VERSION_TOP, .width = 120, .height = 35, .fontSize = 30, @@ -438,7 +464,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ Config = { .left = 37, - .top = 941+145*2, + .top = WATCH_MODEM_APP_VERSION_VALUE_TOP, .width = 400, .height = 30, .fontSize = 26, diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index ca12878e6..1d896b389 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -502,7 +502,7 @@ errcode_t uapi_set_nv_btaddr(uint8_t *buf_btaddr, uint32_t len_btaddr) return nvRet; } - printf("set nv local_addr : ******%02x%02x%02x\n", buf_btaddr[2], buf_btaddr[1], buf_btaddr[0]); + printf("set nv local_addr : ******%02x%02x%02x\n", buf_btaddr[3], buf_btaddr[4], buf_btaddr[5]); #endif @@ -592,10 +592,10 @@ errcode_t init_btaddr_btname(void) { //默认是:281106856959 printf("是默认值,修改地址\n"); - bd_addr[0] = rand() % 0xFF; - bd_addr[1] = rand() % 0xFF; - bd_addr[2] = rand() % 0xFF; - printf("uapi_set_nv_btaddr : ******%02x%02x%02x\n", bd_addr[2], bd_addr[1], bd_addr[0]); + bd_addr[5] = rand() % 0xFF; + bd_addr[4] = rand() % 0xFF; + bd_addr[3] = rand() % 0xFF; + printf("uapi_set_nv_btaddr : ******%02x%02x%02x\n", bd_addr[3], bd_addr[4], bd_addr[5]); ret = uapi_set_nv_btaddr(bd_addr, addrlen); if (ret != ERRCODE_SUCC) { @@ -619,7 +619,7 @@ errcode_t init_btaddr_btname(void) { //默认是:WatchSoar printf("是默认值,修改名称\n"); - sprintf_s((char*)(name),sizeof(name),"WatchSoar%02X%02X",bd_addr[1],bd_addr[0]); + sprintf_s((char*)(name),sizeof(name),"WSoar%02X%02X",bd_addr[4],bd_addr[5]); printf("uapi_set_nv_btname %s , namelen %d\n",name,namelen); ret = uapi_set_nv_btname(name,strlen((char*)name)); if (ret != ERRCODE_SUCC) { diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 221f7a9e5..e4abda288 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -50,6 +50,9 @@ int32_t uapi_get_screen_state(void); errcode_t uapi_get_btaddr(uint8_t *buf_btaddr, uint32_t *len_btaddr); errcode_t uapi_get_btname(uint8_t *buf_btname, uint32_t *len_btname); +errcode_t uapi_get_nv_btaddr(uint8_t *buf_btaddr, uint32_t *len_btaddr); +errcode_t uapi_get_nv_btname(uint8_t *buf_btname, uint32_t *len_btname); + errcode_t init_btaddr_btname(void); errcode_t disable_bt_service(void);