diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-02 16:45:16 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-02 16:45:16 +0000 |
commit | 06d2cc62fcf1cb94f3fba40eeda10f4568049cfd (patch) | |
tree | a31076bbe23038632a5e93f083ca7f33a0aaff8d | |
parent | de30caf57229fc99b311aa20ef814362d84a660a (diff) | |
parent | 73895779a38055baa56747cca210f8078564a85f (diff) | |
download | qemu-06d2cc62fcf1cb94f3fba40eeda10f4568049cfd.tar.gz |
Merge "Snap for 11791273 from 80ced9932e84c7cae49dc45b122f56e86e073c6c to emu-35-1-release" into emu-35-1-release
16 files changed, 145 insertions, 43 deletions
diff --git a/android-qemu2-glue/netsim/NetsimWifiForwarder.cpp b/android-qemu2-glue/netsim/NetsimWifiForwarder.cpp index 30f20ed6af..888a3e7d9a 100644 --- a/android-qemu2-glue/netsim/NetsimWifiForwarder.cpp +++ b/android-qemu2-glue/netsim/NetsimWifiForwarder.cpp @@ -19,13 +19,16 @@ #include "backend/packet_streamer_client.h" #include "netsim.h" #include "netsim/packet_streamer.grpc.pb.h" +#include "netsim/packet_streamer.pb.h" #include <assert.h> // for assert #include <grpcpp/grpcpp.h> // for Clie... #include <condition_variable> // for cond... #include <cstring> // for NULL +#include <memory> #include <mutex> // for cond... #include <optional> // for opti... +#include <thread> #include <random> #include <string> // for string @@ -74,25 +77,32 @@ class NetsimWifiTransport public: NetsimWifiTransport(WifiService::OnReceiveCallback onRecv, WifiService::CanReceiveCallback canReceive) - : mOnRecv(onRecv), mCanReceive(canReceive) {} + : mOnRecv(onRecv), mCanReceive(canReceive), mStopped(false) { + mThread = std::thread(&NetsimWifiTransport::readThread, this); + } ~NetsimWifiTransport() {} - void Read(const PacketResponse* received) override { + void Read(const PacketResponse* read) override { DD("Forwarding %s -> %s ", mContext.peer().c_str(), - received->ShortDebugString().c_str()); - if (received->has_packet()) { - auto packet = received->packet(); - if (mCanReceive(kDefaultQueueIdx)) { - mOnRecv(reinterpret_cast<const uint8_t*>(packet.c_str()), - packet.size()); + read->ShortDebugString().c_str()); + if (read->has_packet()) { + std::lock_guard<std::mutex> guard(mMutex); + mQueue.push(ToUniqueVec(&read->packet())); + mConVar.notify_one(); + } else { + dwarning("Unexpected packet %s", + read->DebugString().c_str()); } - } else { - dwarning("Unexpected packet %s", received->DebugString().c_str()); - } } void OnDone(const grpc::Status& s) override { dwarning("Netsim Wifi %s is gone due to %s", mContext.peer().c_str(), s.error_message().c_str()); + { + std::lock_guard<std::mutex> guard(mMutex); + mStopped = true; + } + mConVar.notify_one(); + mThread.join(); } // Blocks and waits until this connection has completed. @@ -114,6 +124,43 @@ protected: grpc::ClientContext mContext; private: + // Convert a protobuf bytes field into std::unique_ptr<vec<uint8_t>>. + // + // Release ownership of the bytes field and convert it to a vector using + // move iterators. No copy when called with a mutable reference. + std::unique_ptr<std::vector<uint8_t>> ToUniqueVec( + const std::string* bytes_field) { + return std::make_unique<std::vector<uint8_t>>( + std::make_move_iterator(bytes_field->begin()), + std::make_move_iterator(bytes_field->end())); + } + + void readThread() { + while (true) { + std::vector<uint8_t> packetData; + { + std::unique_lock<std::mutex> lock(mMutex); + mConVar.wait(lock, + [&]() { return mStopped || !mQueue.empty(); }); + + if (mStopped) { + break; + } + + packetData = std::move(*mQueue.front()); + mQueue.pop(); + } + if (mCanReceive(kDefaultQueueIdx)) { + mOnRecv(packetData.data(), packetData.size()); + } + } + } + + std::queue<std::unique_ptr<std::vector<uint8_t>>> mQueue; + std::mutex mMutex; + std::thread mThread; + bool mStopped; + std::condition_variable mConVar; WifiService::OnReceiveCallback mOnRecv; WifiService::CanReceiveCallback mCanReceive; std::mutex mAwaitMutex; @@ -145,7 +192,7 @@ bool NetsimWifiForwarder::init() { PacketRequest initial_request; initial_request.mutable_initial_info()->set_name(get_netsim_device_name()); initial_request.mutable_initial_info()->mutable_chip()->set_kind( - netsim::common::ChipKind::WIFI); + netsim::common::ChipKind::WIFI); sTransport->Write(initial_request); auto* hostapd = android::emulation::HostapdController::getInstance(); if (hostapd) diff --git a/android/android-emu/android/console.cpp b/android/android-emu/android/console.cpp index 94a48fb14f..5f73036d62 100644 --- a/android/android-emu/android/console.cpp +++ b/android/android-emu/android/console.cpp @@ -4147,6 +4147,11 @@ static int do_multi_display_add(ControlClient client, char* args) { } static int do_multi_display_del(ControlClient client, char* args) { + if (!args) { + control_write(client, "KO: empty arguments\r\n"); + return -1; + } + // kMaxArgs is max number of arguments that we have to process (options + // parameters, if any, and the filename) const int kMaxArgs = 1; @@ -4168,6 +4173,13 @@ static int do_multi_display_del(ControlClient client, char* args) { return -1; } + if (!client->global->multi_display_agent->getMultiDisplay( + id, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr)) { + control_write(client, "KO: invalid display id\r\n"); + return -1; + } + if (client->global->multi_display_agent->setMultiDisplay(id, -1, -1, 0, 0, 0, 0, false) < 0) { return -1; diff --git a/android/android-emu/android/emulation/MultiDisplay.cpp b/android/android-emu/android/emulation/MultiDisplay.cpp index 78d94638d2..39a15d1637 100644 --- a/android/android-emu/android/emulation/MultiDisplay.cpp +++ b/android/android-emu/android/emulation/MultiDisplay.cpp @@ -1272,6 +1272,8 @@ void MultiDisplay::onLoad(base::Stream* stream) { mWindowAgent->updateUIMultiDisplayPage(iter); fireEvent(DisplayChangeEvent{DisplayChange::DisplayChanged, iter}); LOG(DEBUG) << "loaded display " << iter; + } + if (!ids.empty()) { notifyDisplayChanges(); } } diff --git a/android/android-ui/modules/aemu-ext-pages/car/src/android/skin/qt/extended-pages/car-data-emulation/car-property-utils.cpp b/android/android-ui/modules/aemu-ext-pages/car/src/android/skin/qt/extended-pages/car-data-emulation/car-property-utils.cpp index 5711ca35ad..b0af6826c9 100644 --- a/android/android-ui/modules/aemu-ext-pages/car/src/android/skin/qt/extended-pages/car-data-emulation/car-property-utils.cpp +++ b/android/android-ui/modules/aemu-ext-pages/car/src/android/skin/qt/extended-pages/car-data-emulation/car-property-utils.cpp @@ -459,6 +459,7 @@ map<int32_t, PropertyDescription> carpropertyutils::propMap = { { 289410884, { QObject::tr("EV Regenerative braking or one-pedal drive state") } }, { 289410885, { QObject::tr("Trailer present or not") } }, { 289410886, { QObject::tr("Vehicle curb weight") } }, + { 289476424, { QObject::tr("Supported property ids") } }, }; QString carpropertyutils::getDetailedDescription(int32_t propId) { diff --git a/android/android-ui/modules/aemu-ext-pages/display/src/android/skin/qt/extended-pages/multi-display-page.cpp b/android/android-ui/modules/aemu-ext-pages/display/src/android/skin/qt/extended-pages/multi-display-page.cpp index 759a2ae167..e02e9aabd0 100644 --- a/android/android-ui/modules/aemu-ext-pages/display/src/android/skin/qt/extended-pages/multi-display-page.cpp +++ b/android/android-ui/modules/aemu-ext-pages/display/src/android/skin/qt/extended-pages/multi-display-page.cpp @@ -97,7 +97,7 @@ MultiDisplayPage::MultiDisplayPage(QWidget* parent) MultiDisplayItem* item = new MultiDisplayItem(i, w, h, d, this); LOG(DEBUG) << "add MultiDisplayItem " << i << " and insert widget"; - mUi->verticalLayout_5->insertWidget(i - 1, item); + mUi->verticalLayout_5->insertWidget(-1, item); mItem[i] = item; ++mSecondaryItemCount; setSecondaryDisplaysTitle(mSecondaryItemCount); @@ -143,7 +143,7 @@ void MultiDisplayPage::on_addSecondaryDisplay_clicked() { } MultiDisplayItem* item = new MultiDisplayItem(i, this); LOG(DEBUG) << "add MultiDisplayItem " << i << " and insert widget"; - mUi->verticalLayout_5->insertWidget(i - 1, item); + mUi->verticalLayout_5->insertWidget(-1, item); mItem[i] = item; setSecondaryDisplaysTitle(++mSecondaryItemCount); recomputeLayout(); @@ -190,7 +190,7 @@ void MultiDisplayPage::updateSecondaryDisplay(int i) { << " and insert widget"; MultiDisplayItem* item = new MultiDisplayItem(i, width, height, dpi, this); - mUi->verticalLayout_5->insertWidget(i - 1, item); + mUi->verticalLayout_5->insertWidget(-1, item); mItem[i] = item; ++mSecondaryItemCount; setSecondaryDisplaysTitle(mSecondaryItemCount); @@ -207,7 +207,7 @@ void MultiDisplayPage::updateSecondaryDisplay(int i) { mItem[i] = item; LOG(DEBUG) << "add MultiDisplayItem " << i << " and insert widget"; - mUi->verticalLayout_5->insertWidget(i - 1, item); + mUi->verticalLayout_5->insertWidget(-1, item); recomputeLayout(); } else { LOG(DEBUG) << "same MultiDisplayItem, not update UI"; diff --git a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page-point.cpp b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page-point.cpp index 14f8879bfa..e1a2e650f8 100644 --- a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page-point.cpp +++ b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page-point.cpp @@ -317,10 +317,11 @@ void LocationPage::pointWidget_editButtonClicked(CCListItem* listItem) { if (theAction == startRouteAction) { // Switch to routes tab with the saved point auto& pointElement = pointWidgetItem->pointElement(); - emit mMapBridge->startRouteCreatorFromPoint(QString::number(pointElement.latitude, 'g', 12), - QString::number(pointElement.longitude, 'g', 12), - pointElement.address); mUi->locationTabs->setCurrentIndex(1); + emit mRoutesMapBridge->startRouteCreatorFromPoint( + QString::number(pointElement.latitude, 'g', 12), + QString::number(pointElement.longitude, 'g', 12), + pointElement.address); } else if (theAction == editAction && editPoint(pointWidgetItem->pointElement())) { pointWidgetItem->refresh(); auto& pointElement = pointWidgetItem->pointElement(); diff --git a/android/android-ui/modules/aemu-gl-init/src/android/opengl/emugl_config.cpp b/android/android-ui/modules/aemu-gl-init/src/android/opengl/emugl_config.cpp index f7dd00eccc..6771c23658 100644 --- a/android/android-ui/modules/aemu-gl-init/src/android/opengl/emugl_config.cpp +++ b/android/android-ui/modules/aemu-gl-init/src/android/opengl/emugl_config.cpp @@ -483,8 +483,13 @@ bool emuglConfig_init(EmuglConfig* config, bitness = System::get()->getProgramBitness(); } +#ifdef __APPLE__ + if (!strcmp("host", gpu_mode)) { + use_host_vulkan = true; + } +#endif + config->bitness = bitness; - config->use_host_vulkan = use_host_vulkan; resetBackendList(bitness); // For GPU mode in software rendering: @@ -588,6 +593,9 @@ bool emuglConfig_init(EmuglConfig* config, break; case WINSYS_GLESBACKEND_PREFERENCE_NATIVEGL: gpu_mode = "host"; +#ifdef __APPLE__ + use_host_vulkan = true; +#endif break; default: gpu_mode = "host"; @@ -597,6 +605,7 @@ bool emuglConfig_init(EmuglConfig* config, __func__, gpu_mode, uiPreferredBackend); } } + config->use_host_vulkan = use_host_vulkan; const char* library_mode = gpu_mode; printf("library_mode %s gpu mode %s\n", library_mode, gpu_mode); if ((force_swiftshader_to_swangle && strstr(library_mode, "swiftshader")) diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/extended-window.cpp b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/extended-window.cpp index 2745a857d6..612b7d50c1 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/extended-window.cpp +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/extended-window.cpp @@ -497,6 +497,9 @@ void ExtendedWindow::show() { void ExtendedWindow::showPane(ExtendedWindowPane pane) { show(); + if (pane == PANE_IDX_LOCATION) { + mExtendedUi->location_page->doWebInit(); + } adjustTabs(pane); } diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.cpp b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.cpp index 1bf60ec5a0..b76db16dc6 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.cpp +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.cpp @@ -489,9 +489,8 @@ void ToolWindow::on_unfold_timer_done() { void ToolWindow::updateFoldableButtonVisibility() { mToolsUi->change_posture_button->setEnabled( android_foldable_hinge_enabled()); - if (mExtendedWindow.hasInstance()) { - mExtendedWindow.get()->getVirtualSensorsPage()->updateHingeSensorUI(); - } + mExtendedWindow.ifExists([&] { + mExtendedWindow.get()->getVirtualSensorsPage()->updateHingeSensorUI(); }); } void ToolWindow::updateButtonUiCommand(QPushButton* button, @@ -514,8 +513,10 @@ void ToolWindow::raise() { mVirtualSceneControlWindow.get()->raise(); } if (mTopSwitched) { - mExtendedWindow.get()->raise(); - mExtendedWindow.get()->activateWindow(); + mExtendedWindow.ifExists([&] { + mExtendedWindow.get()->raise(); + mExtendedWindow.get()->activateWindow(); + }); mTopSwitched = false; } } @@ -612,7 +613,7 @@ void ToolWindow::show() { } if (mIsExtendedWindowVisibleOnShow) { - mExtendedWindow.get()->show(); + mExtendedWindow.ifExists([&] { mExtendedWindow.get()->show(); }); } } @@ -1335,9 +1336,14 @@ bool ToolWindow::askWhetherToSaveSnapshot() { QMessageBox msgBox(QMessageBox::Question, tr("Save quick-boot state"), askMessage, (QMessageBox::Yes | QMessageBox::No), this); // Add a Cancel button to enable the MessageBox's X. - QPushButton* cancelButton = msgBox.addButton(QMessageBox::Cancel); - // Hide the Cancel button so X is the only way to cancel. - cancelButton->setHidden(true); + // Since embedded has already disconnected by this point, we always assume shutdown. + if(!getConsoleAgents() + ->settings->android_cmdLineOptions() + ->qt_hide_window) { + QPushButton* cancelButton = msgBox.addButton(QMessageBox::Cancel); + // Hide the Cancel button so X is the only way to cancel. + cancelButton->setHidden(true); + } // ten seconds constexpr int timeout = 10000; @@ -1404,7 +1410,7 @@ void ToolWindow::on_close_button_clicked() { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { // The user shift-clicked on the X // This counts as us asking and having the user say "don't save" - mExtendedWindow.get()->sendMetricsOnShutDown(); + mExtendedWindow.ifExists([&] { mExtendedWindow.get()->sendMetricsOnShutDown(); }); mAskedWhetherToSaveSnapshot = true; getConsoleAgents()->settings->avdParams()->flags |= AVDINFO_NO_SNAPSHOT_SAVE_ON_EXIT; @@ -1414,7 +1420,7 @@ void ToolWindow::on_close_button_clicked() { } if(shouldClose()) { - mExtendedWindow.get()->sendMetricsOnShutDown(); + mExtendedWindow.ifExists([&] { mExtendedWindow.get()->sendMetricsOnShutDown(); }); mEmulatorWindow->requestClose(); } else { mAskedWhetherToSaveSnapshot = false; @@ -1624,9 +1630,9 @@ void ToolWindow::showOrRaiseExtendedWindow(ExtendedWindowPane pane) { return; } - // Set to default location pane. + // Set to default help pane. if (!isPaneEnabled(pane)) { - pane = PANE_IDX_LOCATION; + pane = PANE_IDX_HELP; } // Show the tabbed pane mExtendedWindow.get()->showPane(pane); @@ -1642,10 +1648,6 @@ void ToolWindow::on_more_button_clicked() { } } -QRect ToolWindow::extendedWindowGeometry() { - return mExtendedWindow.get()->frameGeometry(); -} - void ToolWindow::paintEvent(QPaintEvent*) { QPainter p; QPen pen(Qt::SolidLine); diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.h b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.h index 7ee62529c9..28c00db79a 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.h +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/tool-window.h @@ -142,7 +142,6 @@ public: void hideExtendedWindow(); void waitForExtendedWindowVisibility(bool visible); - QRect extendedWindowGeometry(); void presetSizeAdvance(PresetEmulatorSizeType newSize); signals: diff --git a/android/android-ui/modules/aemu-ui-window/src/android/emulator-window.c b/android/android-ui/modules/aemu-ui-window/src/android/emulator-window.c index ee262b5240..c5b7a80ca5 100644 --- a/android/android-ui/modules/aemu-ui-window/src/android/emulator-window.c +++ b/android/android-ui/modules/aemu-ui-window/src/android/emulator-window.c @@ -720,6 +720,8 @@ bool emulator_window_rotate_90(bool clockwise) { : (max_rotation + fromState - 1) % max_rotation; assert(orientation < max_rotation && orientation >= 0); emulator_window_set_device_coarse_orientation(orientation, 0.f); + // TODO(b/337038162): We really should not be dependent on virtual sensors UI, since + // this code can be called from non-UI code. skin_winsys_touch_qt_extended_virtual_sensors(); return true; } diff --git a/android/build/tools/fetch_netsim/src/aemu/main.py b/android/build/tools/fetch_netsim/src/aemu/main.py index 5405c6c671..660c290ebd 100644 --- a/android/build/tools/fetch_netsim/src/aemu/main.py +++ b/android/build/tools/fetch_netsim/src/aemu/main.py @@ -81,9 +81,17 @@ def git_commit(bid, destination_dir, args): - reviewers: The reviewers for the commit. - artifact: The artifact to commit. """ + # Append to the header if netsim_version and canary_version are specified + commit_header = f"Update netsim to {bid}" + if args.netsim_version and args.canary_version: + commit_header += f" (Netsim {args.netsim_version} for Canary {args.canary_version})" + + # Add a commit_msg footer if buganizer_id is specified + commit_footer = f"\nBug: {args.buganizer_id}" if args.buganizer_id else "" + commit_msg = f""" -Update netsim to {bid} +{commit_header} This updates netsim with the artifacts from go/ab/{bid}. You can recreate the commit by running: @@ -98,6 +106,7 @@ You can recreate the commit by running: --re {args.reviewers} \\ --artifact {args.artifact} ``` +{commit_footer} """ run( @@ -265,6 +274,21 @@ def main(): action="store_true", help="Verbose logging", ) + parser.add_argument( + "--buganizer-id", + type=str, + help="Include Buganizer ID in the gerrit commit description " + ) + parser.add_argument( + "--netsim-version", + type=str, + help="Include Netsim version in the gerrit commit description" + ) + parser.add_argument( + "--canary-version", + type=str, + help="Include target Canary version for Netsim distribution in the gerrit commit description" + ) args = parser.parse_args() diff --git a/android/third_party/breakpad/CMakeLists.txt b/android/third_party/breakpad/CMakeLists.txt index 1b7cd00e54..52cfb949cd 100644 --- a/android/third_party/breakpad/CMakeLists.txt +++ b/android/third_party/breakpad/CMakeLists.txt @@ -79,7 +79,7 @@ elseif(LINUX) # Older glibc elf.h might not yet define the ELF compression # types. SHF_COMPRESSED=2048) - target_compile_options(breakpad_compiler_config INTERFACE -fPIC -g -UNDEBUG) + target_compile_options(breakpad_compiler_config INTERFACE -fPIC -g -UNDEBUG -Wno-fortify-source) else() target_compile_definitions( breakpad_compiler_config diff --git a/mac.source.properties b/mac.source.properties index 09fe81165f..e319ed551a 100644 --- a/mac.source.properties +++ b/mac.source.properties @@ -1,4 +1,4 @@ Pkg.UserSrc=false -Pkg.Revision=35.1.7 +Pkg.Revision=35.1.8 Pkg.Path=emulator Pkg.Desc=Android Emulator diff --git a/source.properties b/source.properties index 09fe81165f..e319ed551a 100644 --- a/source.properties +++ b/source.properties @@ -1,4 +1,4 @@ Pkg.UserSrc=false -Pkg.Revision=35.1.7 +Pkg.Revision=35.1.8 Pkg.Path=emulator Pkg.Desc=Android Emulator diff --git a/win.source.properties b/win.source.properties index 09fe81165f..e319ed551a 100644 --- a/win.source.properties +++ b/win.source.properties @@ -1,4 +1,4 @@ Pkg.UserSrc=false -Pkg.Revision=35.1.7 +Pkg.Revision=35.1.8 Pkg.Path=emulator Pkg.Desc=Android Emulator |