x86_64的prebuilt里面的library是32位的, 用不了 arm64-v8会卡住, 不知道原因
| 35 | // x86_64的prebuilt里面的library是32位的, 用不了 |
| 36 | // arm64-v8会卡住, 不知道原因 |
| 37 | bool MinicapBase::init_binary() |
| 38 | { |
| 39 | LogFunc; |
| 40 | |
| 41 | if (!binary_->init() || !library_->init("minicap.so")) { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | auto archs_opt = binary_->abilist(); |
| 46 | auto sdk_opt = binary_->sdk(); |
| 47 | |
| 48 | if (!archs_opt || !sdk_opt) { |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | auto arch_iter = std::ranges::find_first_of(*archs_opt, arch_list_); |
| 53 | if (arch_iter == archs_opt->end()) { |
| 54 | return false; |
| 55 | } |
| 56 | const std::string& target_arch = *arch_iter; |
| 57 | |
| 58 | auto sdk_iter = std::ranges::find_if(sdk_list_, [sdk_opt](int s) { return s <= sdk_opt.value(); }); |
| 59 | if (sdk_iter == sdk_list_.end()) { |
| 60 | return false; |
| 61 | } |
| 62 | int fit_sdk = *sdk_iter; |
| 63 | |
| 64 | // TODO: 确认低版本是否使用minicap-nopie |
| 65 | const auto bin_path = agent_path_ / path(target_arch) / path("bin") / path("minicap"); |
| 66 | const auto lib_path = agent_path_ / path(target_arch) / path("lib") / path(std::format("android-{}", fit_sdk)) / path("minicap.so"); |
| 67 | if (!binary_->push(bin_path) || !library_->push(lib_path)) { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | if (!binary_->chmod() || !library_->chmod()) { |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | auto resolution_opt = device_info_->request_resolution(); |
| 76 | if (!resolution_opt) { |
| 77 | LogError << "Failed to get display resolution"; |
| 78 | return false; |
| 79 | } |
| 80 | display_width_ = resolution_opt->w; |
| 81 | display_height_ = resolution_opt->h; |
| 82 | LogInfo << "Display resolution: " << display_width_ << "x" << display_height_; |
| 83 | |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | void MinicapBase::deinit_binary() |
| 88 | { |