Files
Obsidian-Main/00. Inbox/vc-fwUpdate code trace(Meetup).canvas

86 lines
14 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"nodes":[
{"id":"6bfc707fe9365d07","x":-582,"y":-730,"width":250,"height":50,"type":"text","text":"`Initialize();`"},
{"id":"35301ec811a15aa2","x":-434,"y":-646,"width":283,"height":50,"type":"text","text":"`Impl::InitializeController()`"},
{"id":"58150c82625254cd","x":233,"y":-462,"width":662,"height":215,"type":"text","text":"`vc-fwUpdate\\Backends\\MeridianBackend\\registration.cpp`\n```cpp\nlogitech::fwupdate::backend::RegisterBackend(IUpdateController& controller) {\n\n}\n```\n\n這邊開始建立所有的 update task以下所列的 task 都繼承自 `class UpdateTask`\n使用 `controller.RegisterTask(...)` 來註冊各個 task"},
{"id":"e01a865b5a13d6e9","x":-247,"y":-537,"width":480,"height":51,"type":"text","text":"`controller_ = controller::CreateUpdateController();`"},
{"id":"7d8839591c30f61a","x":-247,"y":-462,"width":406,"height":60,"type":"text","text":"`backend::RegisterBackend(*controller_);`"},
{"id":"6aab61cd927b9307","x":-434,"y":-48,"width":311,"height":60,"type":"text","text":"`Impl::RegisterForPnpNotification()`"},
{"id":"dade636ce2d72147","x":-434,"y":40,"width":250,"height":60,"type":"text","text":"`Impl::InitializeTasks()`"},
{"id":"5f57db192293a0ec","x":257,"y":-537,"width":168,"height":51,"type":"text","text":"`Impl() d_`"},
{"id":"5e7c147cd533a922","x":453,"y":-537,"width":289,"height":51,"type":"text","text":"`d_->CreatePnpProvider();`"},
{"id":"7ff8bac3fc3253f1","x":-434,"y":642,"width":311,"height":55,"type":"text","text":"`Impl::InitializeDynamicControls()`"},
{"id":"c1122f185b292a7c","x":-247,"y":-227,"width":480,"height":145,"type":"text","text":"`vc-fwUpdate\\Frontends-developer\\LogiFWUpdate\\Ui\\LogiFWUpdateDlg.cpp:2761`\n\n--------------------------------------------\n\n`InitializeImageProviders()`"},
{"id":"cd7947e8636e6b51","x":779,"y":-596,"width":347,"height":110,"type":"text","text":"建立一個看不見的window背後會有一個 thread 來接收 device notification events`WM_DEVICECHANGE`"},
{"id":"5db0c6d04d6655c7","x":1007,"y":-462,"width":269,"height":60,"type":"text","text":"`AudioDeviceUpdateTask`"},
{"id":"f3ccd922e41c8fa2","x":1007,"y":-396,"width":250,"height":60,"type":"text","text":"`BLEDeviceUpdateTask`"},
{"id":"b2215d89fc0b5735","x":-600,"y":-1160,"width":3450,"height":312,"type":"group","label":"GUI Update Procedure"},
{"id":"798d72cd46e3502b","x":-579,"y":-1075,"width":398,"height":52,"type":"text","text":"`CLogiFWUpdateDlg::OnBnClickedUpdateDevice()`"},
{"id":"f6cfbfc1376ca01e","x":-121,"y":-1140,"width":424,"height":182,"type":"text","text":"`d_->PerformUpdate();`\n⬇\n```cpp\nbool CLogiFWUpdateDlg::Impl::PerformUpdate() {\n\n}\n```"},
{"id":"a659de4263799b85","x":364,"y":-1138,"width":291,"height":50,"type":"text","text":"`controller_->StartUpdate();`"},
{"id":"b398a6dd7e91ef4e","x":405,"y":-1008,"width":250,"height":50,"type":"text","text":"`d_->StartUpdate();`"},
{"id":"5d03eb8ecaadd1dd","x":-970,"y":-911,"width":339,"height":181,"type":"text","text":"`vc-fwUpdate\\Frontends-developer\\LogiFWUpdate\\Ui\\LogiFWUpdateDlg.cpp`\n\n----\n`BOOL CLogiFWUpdateDlg::OnInitDialog()`"},
{"id":"3668ba992c38b26a","x":1007,"y":-330,"width":250,"height":60,"type":"text","text":"`AudioCodecUpdateTask`"},
{"id":"aa2444242b481f93","x":1007,"y":-247,"width":250,"height":55,"type":"text","text":"`VideoDeviceUpdateTask`"},
{"id":"eca2584c45b6e6d5","x":1007,"y":-167,"width":250,"height":60,"type":"text","text":"`VideoEepromUpdateTask`"},
{"id":"bca845f9b6b579f8","x":699,"y":-1041,"width":397,"height":117,"type":"text","text":"```cpp\nfor (auto& p : tasks_) {\n task->PerformUpdate();\n task->GetUpdateResult(taskSuccessful);\n}\n```"},
{"id":"dd3394779b454c65","x":1134,"y":-1093,"width":413,"height":222,"type":"text","text":"`vc-fwUpdate\\Backends\\CommonBackend\\UpdateTask.cpp`\n\n----\n先 `DoOpenDevice()` ,確認裝置 ok。\n然後 `d_->imageProvider_->Open();`\n\n最後 `DoPerformUpdate();`"},
{"id":"1b43952d80e220e4","x":1607,"y":-1098,"width":502,"height":230,"type":"text","text":"`vc-fwUpdate\\Backends\\CommonBackend\\VideoEepromUpdateTask.cpp`\n\n----\n```cpp\nvoid\nlogitech::fwupdate::backend::VideoEepromUpdateTask::DoPerformUpdate() {\n d_->PerformUpdate();\n}\n```"},
{"id":"ed5fc2b9d34dbdd7","x":713,"y":-55,"width":1587,"height":307,"type":"group","label":"DoOpenDevice()"},
{"id":"551e749e0cf332d3","x":733,"y":-27,"width":635,"height":249,"type":"text","text":"```cpp\nDoOpenDevice()\n⬇\nd_->OpenDevice();\n⬇\nUvcDeviceFactory().CreateUvcDevice({ UsbVidLogitech, UsbVideoPid });\n⬇\nWindowsUvcDevice::FindDevice(usbId);\n⬇\nImpl::OpenUvcDevice(usbId.Vid, usbId.Pid, devicePath, friendlyName);\n```"},
{"id":"18c6dbc9cf46e214","x":1438,"y":-32,"width":333,"height":260,"type":"text","text":"`Impl::OpenUvcDevice` 會使用\n```cpp\nSetupDiGetClassDevs(...)\nSetupDiEnumDeviceInterfaces(...)\n```\n等 API 來列舉裝置。\n\n----\n在 `Impl::OpenUvcDevice` 也會打開 XU 。\n在 `uvcDevice->d_->Init();` 裡面。"},
{"id":"c0e439a5140dbceb","x":1837,"y":-35,"width":443,"height":267,"type":"text","text":"`vc-fwUpdate\\UpdateController\\WindowsUvcDevice.cpp`\n\n----\n\n`uvcDevice->d_->Init();` 也就是 `Impl::Init()`\n會呼叫 `InitExtensionUnits();`,其呼叫順序:\n```cpp\nInitExtensionUnits();\n⬇\nEnumNodePropertySets();\n⬇\nDeviceIoControl(...)\n```\n\n"},
{"id":"ce300adbc95c5a4b","x":-7,"y":40,"width":369,"height":113,"type":"text","text":"```cpp\nfor (...) {\n task->GetDeviceInfo(initialQuery)\n}\n```"},
{"id":"cb5dc2c4eb714d15","x":-7,"y":231,"width":369,"height":223,"type":"text","text":"`vc-fwUpdate\\Frontends-developer\\LogiFWUpdate\\Ui\\LogiFWUpdateDlg.cpp:2117`\n\n----\n```cpp\nfor (...) {\n task->GetImageInfo();\n}\n```"},
{"id":"b272fd16c8f236a3","x":-7,"y":499,"width":432,"height":60,"type":"text","text":"```cpp\ncontroller_->SetTaskEnabled(taskId, enable);\n```"},
{"id":"eed51d8e5331c29c","x":2160,"y":-1061,"width":664,"height":156,"type":"text","text":"```cpp\nbool\nlogitech::fwupdate::backend::VideoEepromUpdateTask::Impl::PerformUpdate() {\n SendImage(ActionProgress(progress_, 90));\n ...\n RebootDevice();\n}\n```"},
{"id":"4d601b6034046222","x":-474,"y":777,"width":861,"height":205,"type":"text","text":"```cpp\nbool silentUpdate = ci.GetOption(L\"silentupdate\") ? true : false;\nbool forceUpdate = ci.GetOption(L\"force\")? true: false;\n\nauto cli = make_unique<cliwrapper>(logfile, version, forceUpdate, recovery, launcher, restartUpdate);\n\nbool success = cli->Initialize();\ncli->InitializeTasks();\nret = cli->PerformUpdate();\n```"},
{"id":"12867a0e216a1bc9","x":-970,"y":784,"width":420,"height":192,"type":"text","text":"`vc-fwUpdate\\Frontends-developer\\LogiFWUpdate\\Ui\\LogiFWUpdate.cpp`\n\n----\n```cpp\nBOOL CLogiFWUpdateApp::InitInstance() {\n ...\n}\n```"},
{"id":"60b67cb8ae948ca8","x":-964,"y":1053,"width":855,"height":410,"type":"group","label":"namespace: clifrontend"},
{"id":"37bf2c4c95808bcf","x":-944,"y":1078,"width":533,"height":365,"type":"text","text":"```cpp\nclass cliwrapper\n{\n struct Impl;\n\npublic:\n cliwrapper(...);\n ~cliwrapper();\n\n bool Initialize();\n int\t PerformUpdate();\n void InitializeTasks();\n void InitializeTask(string taskID, string imagePath);\n void Log(string message);\nprivate:\n std::unique_ptr<Impl>\td_;\n};\n```"},
{"id":"87dcc9769cfa192f","x":-390,"y":1078,"width":256,"height":365,"type":"text","text":"```cpp\nstruct cliwrapper::Impl\n{\n\t\n};\n```"},
{"id":"28a3f76dba8f2283","x":584,"y":605,"width":544,"height":129,"type":"text","text":"```cpp\nbool cliwrapper::Impl::Initialize() {\n\tcontroller_ = controller::CreateUpdateController();\n\t...\n}\n```"},
{"id":"162f50d1dd604161","x":584,"y":777,"width":544,"height":205,"type":"text","text":"```cpp\nvoid cliwrapper::InitializeTasks()\n{\n\td_->SetImageProvider();\n\t...\n\td_->EnableTasks();\n\t...\n\td_->ListTasks();\n}\n```"},
{"id":"ac73b0f38a1fad67","x":1264,"y":555,"width":818,"height":650,"type":"text","text":"`d_->EnableTasks();`\n\n-----\n```cpp\nvoid cliwrapper::Impl::EnableTasks()\n{\n\t...\n\tconst auto tasks = controller_->GetTasks();\n\tfor (auto task : tasks)\n\t{\n\t\tbool bMiracast = false;\n\t\tconst auto& taskId = task->GetId();\n\t\t...\n\t\tconst auto deviceInfo = task->GetDeviceInfo();\n\t\tconst auto imageInfo = task->GetImageInfo();\n\n\t\t// Enable or disable the task according to the following rules:\n\t\t// - Disable the task unconditionally if there is either no device or no image.\n\t\t// - If a command-line override is present apply it.\n\t\t// - Otherwise compare the image and device versions.\n\t\tbool enable = false;\n\t\tif (deviceInfo.Present && imageInfo.Present)\n\t\t{\n\t\t\t...\n\t\t\trel = compare(deviceInfo.Version, imageInfo.Version);\n\t\t\t...\n\t\t}\n\t\tcontroller_->SetTaskEnabled(taskId, enable);\n\t}\n}\n```"},
{"id":"72f0552d9251b235","x":2197,"y":602,"width":844,"height":556,"type":"text","text":"```cpp\nconst auto tasks = controller_->GetTasks();\n```\n↓\n```cpp\nvector<const IUpdateTask *>\nlogitech::fwupdate::controller::UpdateController::GetTasks() const\n{\n return d_->GetTasks();\n}\n```\n\n-----\n以下是 `d_->GetTasks();` 的 code\n\n```cpp\nvector<const IUpdateTask *>\nlogitech::fwupdate::controller::UpdateController::Impl::GetTasks() const\n{\n\tvector<const IUpdateTask *> tasks(tasks_.size());\n\n\ttransform(cbegin(tasks_), cend(tasks_), begin(tasks),\n\t\t[] (const pair<IUpdateTask::IdType, TaskInfo>& p) { return p.second.Task.get(); });\n\n\treturn tasks;\n}\n```"}
],
"edges":[
{"id":"b621a476fd748a7d","fromNode":"35301ec811a15aa2","fromSide":"bottom","toNode":"e01a865b5a13d6e9","toSide":"left"},
{"id":"4c8321febd557726","fromNode":"35301ec811a15aa2","fromSide":"bottom","toNode":"7d8839591c30f61a","toSide":"left"},
{"id":"9189c6bb3b246620","fromNode":"e01a865b5a13d6e9","fromSide":"right","toNode":"5f57db192293a0ec","toSide":"left"},
{"id":"2e110f57dd9e5bd7","fromNode":"5f57db192293a0ec","fromSide":"right","toNode":"5e7c147cd533a922","toSide":"left"},
{"id":"532b641829d3f018","fromNode":"5e7c147cd533a922","fromSide":"right","toNode":"cd7947e8636e6b51","toSide":"left"},
{"id":"1b9ae28111c94762","fromNode":"7d8839591c30f61a","fromSide":"right","toNode":"58150c82625254cd","toSide":"left"},
{"id":"bafcfd90de5e5be7","fromNode":"58150c82625254cd","fromSide":"right","toNode":"5db0c6d04d6655c7","toSide":"left"},
{"id":"6cb9b23f0f009736","fromNode":"58150c82625254cd","fromSide":"right","toNode":"f3ccd922e41c8fa2","toSide":"left"},
{"id":"9aad0f03a71efc9c","fromNode":"58150c82625254cd","fromSide":"right","toNode":"3668ba992c38b26a","toSide":"left"},
{"id":"491802f7e6933c36","fromNode":"58150c82625254cd","fromSide":"right","toNode":"aa2444242b481f93","toSide":"left"},
{"id":"ff38d8bf4a41eb8e","fromNode":"58150c82625254cd","fromSide":"right","toNode":"eca2584c45b6e6d5","toSide":"left"},
{"id":"c9e94cf99468eddd","fromNode":"35301ec811a15aa2","fromSide":"bottom","toNode":"c1122f185b292a7c","toSide":"left"},
{"id":"91b93c94fe07a699","fromNode":"6bfc707fe9365d07","fromSide":"bottom","toNode":"35301ec811a15aa2","toSide":"left"},
{"id":"7df607f1045d8c07","fromNode":"6bfc707fe9365d07","fromSide":"bottom","toNode":"6aab61cd927b9307","toSide":"left"},
{"id":"a996f628d78564a0","fromNode":"6bfc707fe9365d07","fromSide":"bottom","toNode":"dade636ce2d72147","toSide":"left"},
{"id":"2969440a55132bf4","fromNode":"6bfc707fe9365d07","fromSide":"bottom","toNode":"7ff8bac3fc3253f1","toSide":"left"},
{"id":"59e4e9a99d0afb3b","fromNode":"5d03eb8ecaadd1dd","fromSide":"bottom","toNode":"6bfc707fe9365d07","toSide":"left"},
{"id":"8008ff58b9c0a3a0","fromNode":"ce300adbc95c5a4b","fromSide":"right","toNode":"551e749e0cf332d3","toSide":"left"},
{"id":"dbf07f00980f3a0f","fromNode":"551e749e0cf332d3","fromSide":"right","toNode":"18c6dbc9cf46e214","toSide":"left"},
{"id":"762bcd1254df7890","fromNode":"18c6dbc9cf46e214","fromSide":"right","toNode":"c0e439a5140dbceb","toSide":"left"},
{"id":"d03a2aa8290e6113","fromNode":"dade636ce2d72147","fromSide":"bottom","toNode":"ce300adbc95c5a4b","toSide":"left"},
{"id":"27e46e4e71993a05","fromNode":"dade636ce2d72147","fromSide":"bottom","toNode":"cb5dc2c4eb714d15","toSide":"left"},
{"id":"41d665388fdcd5fd","fromNode":"dade636ce2d72147","fromSide":"bottom","toNode":"b272fd16c8f236a3","toSide":"left"},
{"id":"49b718b35ea3578d","fromNode":"5d03eb8ecaadd1dd","fromSide":"top","toNode":"798d72cd46e3502b","toSide":"left"},
{"id":"88c0e726b9eb326c","fromNode":"798d72cd46e3502b","fromSide":"right","toNode":"f6cfbfc1376ca01e","toSide":"left"},
{"id":"498207d5461e35f6","fromNode":"f6cfbfc1376ca01e","fromSide":"right","toNode":"a659de4263799b85","toSide":"left"},
{"id":"46a3a7fdd1d5f6a4","fromNode":"a659de4263799b85","fromSide":"right","toNode":"b398a6dd7e91ef4e","toSide":"left"},
{"id":"d2047bc4edfdbefa","fromNode":"b398a6dd7e91ef4e","fromSide":"right","toNode":"bca845f9b6b579f8","toSide":"left"},
{"id":"743ecb415fe5fcb6","fromNode":"bca845f9b6b579f8","fromSide":"right","toNode":"dd3394779b454c65","toSide":"left"},
{"id":"c8bf7d8b482bfe48","fromNode":"dd3394779b454c65","fromSide":"right","toNode":"1b43952d80e220e4","toSide":"left"},
{"id":"04fcccc24a59d13e","fromNode":"1b43952d80e220e4","fromSide":"right","toNode":"eed51d8e5331c29c","toSide":"left"},
{"id":"1fa5f7d458e72c17","fromNode":"dd3394779b454c65","fromSide":"bottom","toNode":"ed5fc2b9d34dbdd7","toSide":"top","color":"#ffdd00","label":"DoOpenDevice()"},
{"id":"742e84e0e8003c92","fromNode":"12867a0e216a1bc9","fromSide":"right","toNode":"4d601b6034046222","toSide":"left"},
{"id":"f8737a0fce99043d","fromNode":"4d601b6034046222","fromSide":"right","toNode":"28a3f76dba8f2283","toSide":"left"},
{"id":"e88c921961a6c0e3","fromNode":"4d601b6034046222","fromSide":"right","toNode":"162f50d1dd604161","toSide":"left"},
{"id":"5ac5aaa4291a990d","fromNode":"162f50d1dd604161","fromSide":"right","toNode":"ac73b0f38a1fad67","toSide":"left"},
{"id":"753699a3a9e8f59c","fromNode":"ac73b0f38a1fad67","fromSide":"right","toNode":"72f0552d9251b235","toSide":"left"}
]
}