DEFAULT_APPLICATION_NAME=brandy-native-js
DEFAULT_TARGET_PACK_NAME_USER=pack_brandy_native_js_user
DEFAULT_APPLICATION_NAME_USER=brandy-native-js-user
-DEFAULT_CUSTOM_FW_VERSION=1.1.59
+DEFAULT_CUSTOM_FW_VERSION=1.1.501
TARGET_PACK_NAME=$DEFAULT_TARGET_PACK_NAME
APPLICATION_NAME=$DEFAULT_APPLICATION_NAME
APPLICATION_NAME=brandy-native-js-z1
BUILD_NAME=_Z1
fi
+if [ "$1" == "leakcheck" ]
+then
+TARGET_PACK_NAME=pack_brandy_native_js_leakcheck
+APPLICATION_NAME=brandy-native-js-leakcheck
+BUILD_NAME=_LEAKCHECK
+fi
+if [ "$1" == "autoota" ]
+then
+TARGET_PACK_NAME=pack_brandy_native_js_autoota
+APPLICATION_NAME=brandy-native-autoota
+BUILD_NAME=_AUTOOTA
+
+fi
+if [ "$1" == "autootacli" ]
+then
+TARGET_PACK_NAME=pack_brandy_native_js_autootacli
+APPLICATION_NAME=brandy-native-js-autootacli
+BUILD_NAME=_AUTOOTACLI
+fi
if [ "$1" == "obu" ]
then
TARGET_PACK_NAME=pack_brandy_native_js_obu
return;
}
*/
-
- if (type == TransitionType::TRANSITION_INVALID) {
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId,
- type, priority));
- } else {
- if (osal_atomic_read(&transitionCount_) <= 0) {
- osal_atomic_inc(&transitionCount_);
- // onStop释放当前页面需要和当前页面的事件监听异步执行,否则会出现自己杀掉自己的情况
- // 使用图形服务的PostGraphicEvent方法异步执行PostChangeSlice,以避免在页面事件监听时出现当前页面自我销毁的情况。
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId,
- type, priority));
- } else {
- GRAPHIC_LOGE("ChangeSlice failed! targetSliceId = %u, transitionCount_ = %d",
- targetSliceId, osal_atomic_read(&transitionCount_));
- }
- }
+ if (osal_atomic_read(&transitionCount_) <= 0)
+ {
+ osal_atomic_inc(&transitionCount_);
+ // onStop释放当前页面需要和当前页面的事件监听异步执行,否则会出现自己杀掉自己的情况
+ // 使用图形服务的PostGraphicEvent方法异步执行PostChangeSlice,以避免在页面事件监听时出现当前页面自我销毁的情况。
+#ifdef DO_MEMLEAK_CHECK
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId,
+ TransitionType::TRANSITION_INVALID, priority));
+#else
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&Ability::PostChangeSlice, this, targetSliceId,
+ type, priority));
+#endif
+ }
}
void Ability::PostChangeSlice(const uint16_t targetSliceId, TransitionType type, const uint16_t priority)
{
sliceTransition_.Transition(prevSlice_.slice->GetSliceContainer(), curSlice_.slice->GetSliceContainer());
}
- }
+ }
+ else
+ {
+ osal_atomic_dec(&transitionCount_);
+ }
+ #ifdef DO_MEMLEAK_CHECK
+ MemCheck::GetInstance()->DumpMemInfo(); // 检测UI Malloc内存泄漏,确认进退页面count是否一直增加。
+ #endif
}
void Ability::OnTransitionEnd()
'fs_image_path':'fd230',
'defines': ['-:SW_UART_DEBUG', '-:DUMP_MEM_SUPPORT', '-:DUMP_REG_SUPPORT', '-:SUPPORT_DFX_EXCEPTION'],
},
- 'brandy-native-js-fd230': {
+ 'brandy-native-js-leakcheck': {
'base_target_name': 'brandy-native-js',
'fs_image_path':'fd230',
- # 'defines': ['-:SW_UART_DEBUG'],
+ 'defines': ['DO_MEMLEAK_CHECK'],
},
'brandy-native-js-z1': {
'base_target_name': 'brandy-native-js',
'defines': ['SUPPORT_CHINA_MOBILE_DMP'], #移动
'fs_image_path':'fd230',
},
+ 'brandy-native-js-autoota': {
+ 'base_target_name': 'brandy-native-js',
+ 'defines': ['SUPPORT_AUTO_OTA_SERVER', 'CONFIG_DFX_SUPPORT_DIAG_UP_MACHINE=1'],
+ 'fs_image_path':'fd230',
+ # 'ram_component': ['auto_ota']
+ },
+ 'brandy-native-js-autootacli': {
+ 'base_target_name': 'brandy-native-js',
+ 'defines': ['SUPPORT_AUTO_OTA_SERVER', 'SUPPORT_AUTO_OTA', 'CONFIG_DFX_SUPPORT_DIAG_UP_MACHINE=1'],
+ 'fs_image_path':'fd230',
+ 'ram_component': ['auto_ota']
+ },
'brandy-native-js-obu': {
'base_target_name': 'brandy-native-js',
'defines': ['SUPPORT_A5133_SERVICE'
'ram_component':["driver_a5133","a5133_service"],
'fs_image_path':'fd230',
},
+
#auto-ota-server
'brandy-auto-ota-ser': {
'base_target_name': 'brandy-native-js',
'pack_brandy_target5': ['brandy-ssb', 'brandy-target5-r', 'brandy-target5'],
'pack_brandy_native_js': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js'],
'pack_brandy_native_js_user': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-user'],
- 'pack_brandy_native_js_fd230': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-fd230'],
+ 'pack_brandy_native_js_leakcheck': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-leakcheck'],
+ 'pack_brandy_native_js_autoota': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-autoota'],
+ 'pack_brandy_native_js_autootacli': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-autootacli'],
'pack_brandy_native_js_z1': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-z1'],
'pack_brandy_native_js_obu': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-obu'],
'pack_brandy_native_js_ct': ['brandy-ssb', 'brandy-native-js-r', 'brandy-native-js-ct'],
printf("current malloc/new memory:\n");
printf("total count: %d\n", osal_atomic_read(&totalCnt_));
printf("--------\n");
- GrallocEngines::GetInstance()->DumpMem();
+ //此处打印比较多,需要请自行打开。
+ // GrallocEngines::GetInstance()->DumpMem();
+#endif
+}
+
+#ifndef VERSION_IOT
+bool MemCheck::isBeyondTime()
+{
+ time_t currTime = time((time_t *)nullptr);
+ if (currTime - setTime_ > delayTime_) {
+ return true;
+ }
+ return false;
+}
+
+bool MemCheck::InsertRecord(uintptr_t address, Opt opt, int32_t size, int32_t total)
+{
+ MemRecord* recordNote = (MemRecord*)malloc(sizeof(MemRecord));
+ if (recordNote == nullptr) {
+ GRAPHIC_LOGE("MemAdd malloc failed\n");
+ return false;
+ }
+ recordNote->address = address;
+ recordNote->opt = opt;
+ recordNote->size = size;
+ recordNote->time = time(0);
+ recordNote->total = total;
+ recordNote->next = nullptr;
+ recordTail->next = recordNote;
+ recordTail = recordNote;
+ return true;
+}
+
+static void* SaveMemInfo(void* arg)
+{
+ MemCheck::GetInstance()->SaveRecordInfo();
+ return nullptr;
+}
+
+void MemCheck::SaveRecordInfo()
+{
+ // sleep 1s, wait main thread set delaytime
+ sleep(1);
+ time_t currTime = time((time_t *)nullptr);
+ while ((currTime - setTime_) < (delayTime_ + OFFSET_TIME)) {
+ MemRecord* recordPtr = recordHead;
+ while (recordPtr->next != nullptr) {
+ MemRecord* recordNote = recordPtr->next;
+ recordPtr->next = recordPtr->next->next;
+ struct tm *sttm = localtime(&(recordNote->time));
+ // 1900: year
+ fprintf(fp, "%04u-%02u-%02u %02u:%02u:%02u addr=0x%x %s size:%d total:%d\n", sttm->tm_year + 1900,
+ sttm->tm_mon+1, sttm->tm_mday, sttm->tm_hour, sttm->tm_min, sttm->tm_sec, recordNote->address,
+ recordNote->opt == Opt::ADD ? "add" : "del", recordNote->size, recordNote->total);
+ free(recordNote);
+ recordNote = nullptr;
+ }
+ recordTail = recordHead;
+ fflush(fp);
+
+ sleep(2); // 2: sleep time
+ currTime = time((time_t *)nullptr);
+ }
+ fclose(fp);
+ fp = nullptr;
+ recordThreadId = nullptr;
+}
+
+bool MemCheck::CreateRecordFile()
+{
+ char currPath[16] = "/user/mem/";
+ if (access(currPath, F_OK) == -1) {
+ GRAPHIC_LOGD("dir %s not exist, create dir\n", currPath);
+ if (mkdir(currPath, 0777) != 0) { // 0777: permission mode
+ GRAPHIC_LOGE("create dir %s failed , errno = %d : %s\n", currPath, errno, strerror(errno));
+ return false;
+ }
+ }
+ char path[20] = "";
+ if (sprintf_s(path, sizeof(path), "%s%d", currPath, getpid()) == -1) {
+ GRAPHIC_LOGE("MemCheckInit sprintf_s failed\n");
+ return false;
+ }
+ fp = fopen(path, "w+");
+ if (fp == nullptr) {
+ GRAPHIC_LOGE("open mem file %s failed ,errno = %d : %s\n", path, errno, strerror(errno));
+ return false;
+ }
+ return true;
}
} // namespace OHOS
#endif