diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-26 16:06:33 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-26 16:06:33 +0000 |
commit | 75d5a27101fbba0c0edaca377b92e804e0074592 (patch) | |
tree | 686396cb599aa1bd3d46fca816cb33cde4197868 | |
parent | a2ead23312831b9d2317d1ee6d918d7a8c4426d9 (diff) | |
parent | 8d8611020551a7247d8eecc374a0bf729417de70 (diff) | |
download | qemu-snap-temp-L26800030003463399.tar.gz |
Merge "Add geocode API metrics." into snap-temp-L26800030003463399snap-temp-L26800030003463399
8 files changed, 57 insertions, 0 deletions
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 53934d10d1..801220a594 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 @@ -561,6 +561,24 @@ void LocationPage::setUpWebEngine() { // Send the current location to each page appendString.append( + "\n" + "var gGeocodeCount = 0;"); + if (isPoint) { + appendString.append( + "\n" + "function incGeocodeCount() {\n" + "\t++gGeocodeCount;\n" + "\tconsole.log(`POINT: geocode() called ${gGeocodeCount} times`);\n" + "}\n"); + } else { + appendString.append( + "\n" + "function incGeocodeCount() {\n" + "\t++gGeocodeCount;\n" + "\tconsole.log(`ROUTES: geocode() called ${gGeocodeCount} times`);\n" + "}\n"); + } + appendString.append( "\n" "var initialLat = '"); appendString.append(QString::number(initialLat, 'g', 12)); @@ -595,6 +613,11 @@ void LocationPage::setUpWebEngine() { "channel.objects.emulocationserver.resetPointsMap.connect(function() {" "if (resetPointsMap) resetPointsMap();" "});"); + appendString.append( + "\t\tchannel.objects.emulocationserver.showMetrics.connect(function() {\n" + "\t\t\tconsole.debug('showMetrics called!');\n" + "\t\t\tconsole.debug(`************ POINTS: total geocode calls: ${gGeocodeCount}`);\n" + "\t\t});\n"); } else { // Define Routes-specific interfaces appendString.append( @@ -613,6 +636,11 @@ void LocationPage::setUpWebEngine() { "channel.objects.emulocationserver.showGpxKmlRouteOnMap.connect(function(routeJson, title, subtitle) {" "if (showGpxKmlRouteOnMap) showGpxKmlRouteOnMap(routeJson, title, subtitle);" "});"); + appendString.append( + "\t\tchannel.objects.emulocationserver.showMetrics.connect(function() {\n" + "\t\t\tconsole.debug('showMetrics called!');\n" + "\t\t\tconsole.debug(`************ ROUTES: total geocode calls: ${gGeocodeCount}`);\n" + "\t\t});\n"); } appendString.append( "});" @@ -746,6 +774,9 @@ void LocationPage::sendMetrics() { ->mutable_location_v2() ->CopyFrom(metrics); }); + if (mMapBridge) { + emit mMapBridge->showMetrics(); + } } void RouteSenderThread::sendRouteToMap(const LocationPage::RouteListElement* const routeElement, diff --git a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page.h b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page.h index 78228df177..f2af233c8d 100644 --- a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page.h +++ b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/extended-pages/location-page.h @@ -494,6 +494,9 @@ signals: // given point. void startRouteCreatorFromPoint(QString lat, QString lng, QString addr); + // Show Google Maps API and other metrics. + void showMetrics(); + private: LocationPage* const mLocationPage; }; diff --git a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/geocoder.js b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/geocoder.js index 4be21ff1f8..7784fde54d 100644 --- a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/geocoder.js +++ b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/geocoder.js @@ -15,6 +15,7 @@ class Geocoder { const geocoder = this.geocoder; return new Promise((resolve, reject) => { geocoder.geocode(request, (results, status) => { + incGeocodeCount(); if (status === google.maps.GeocoderStatus.OK) { resolve({ address: results[0].formatted_address, diff --git a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/location-point.js b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/location-point.js index 9f944f5d2b..b254036292 100644 --- a/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/location-point.js +++ b/android/android-ui/modules/aemu-ext-pages/location/src/android/skin/qt/html/js/location-point.js @@ -98,6 +98,7 @@ function showPendingLocation(lat, lng, addr) { gSearchBox.showSpinner(); // Try to fetch the address for this location. gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { @@ -157,6 +158,7 @@ function setDeviceLocation(lat, lng) { } gCurrentMarker.setIcon(image); gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); const latitude = latLng.lat().toFixed(4); const longitude = latLng.lng().toFixed(4); var address = `${latitude}, ${longitude}`; @@ -198,6 +200,7 @@ function showPin(latLng) { function sendAddress(latLng) { gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/geocoder.js b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/geocoder.js index 4be21ff1f8..7784fde54d 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/geocoder.js +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/geocoder.js @@ -15,6 +15,7 @@ class Geocoder { const geocoder = this.geocoder; return new Promise((resolve, reject) => { geocoder.geocode(request, (results, status) => { + incGeocodeCount(); if (status === google.maps.GeocoderStatus.OK) { resolve({ address: results[0].formatted_address, diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-point.js b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-point.js index 9f944f5d2b..b254036292 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-point.js +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-point.js @@ -98,6 +98,7 @@ function showPendingLocation(lat, lng, addr) { gSearchBox.showSpinner(); // Try to fetch the address for this location. gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { @@ -157,6 +158,7 @@ function setDeviceLocation(lat, lng) { } gCurrentMarker.setIcon(image); gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); const latitude = latLng.lat().toFixed(4); const longitude = latLng.lng().toFixed(4); var address = `${latitude}, ${longitude}`; @@ -198,6 +200,7 @@ function showPin(latLng) { function sendAddress(latLng) { gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { diff --git a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-routes.js b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-routes.js index 92fea51bdc..757cfcc11d 100644 --- a/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-routes.js +++ b/android/android-ui/modules/aemu-ui-qt/src/android/skin/qt/html/js/location-routes.js @@ -81,6 +81,7 @@ function startRouteCreatorFromPoint(lat, lng, address) { if (address === "") { gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { @@ -213,6 +214,7 @@ function addSearchResultItem(name, address, placeId) { var address = this.getAttribute("data-address"); if (placeid != null) { gGeocoder.geocode({ 'placeId': placeid }, function (results, status) { + incGeocodeCount(); if (status !== 'OK' || !results[0]) { return; } @@ -300,6 +302,7 @@ function setWaypointForEmptyAddressBox(latLng) { gFocusedWaypoint.setLatLng(latLng); gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { @@ -430,6 +433,7 @@ function showDestinationPoint(latLng) { channel.objects.emulocationserver.sendFullRouteToEmu(0, 0.0, null, null); gGeocoder.geocode({ 'location': latLng }, function (results, status) { + incGeocodeCount(); var address = ""; var elevation = 0.0; if (status === 'OK' && results[0]) { diff --git a/android/emu/files/src/android/qt/qt_setup.cpp b/android/emu/files/src/android/qt/qt_setup.cpp index a3acce1cc9..57ff6fd6ea 100644 --- a/android/emu/files/src/android/qt/qt_setup.cpp +++ b/android/emu/files/src/android/qt/qt_setup.cpp @@ -64,6 +64,17 @@ auto androidQtSetupEnv(int bitness, const char* emulatorDir) -> bool { system->envSet("QT_SCALE_FACTOR", "none"); system->envSet("QT_SCREEN_SCALE_FACTORS", "none"); + if (!system->envGet("ANDROID_EMU_QTWEBENGINE_DEBUG").empty()) { + const std::string kDebuggingPort = "9876"; + system->envSet("QTWEBENGINE_CHROMIUM_FLAGS", + std::string("--webEngineArgs --remote-debugging-port=") + + kDebuggingPort); + // Forward javascript console logs to js Qt Logging Category handler. + system->envSet("QT_LOGGING_RULES", "js.debug=true;js.info=true"); + LOG(INFO) << "********* QtWebEngine debugging enabled. Point your browser to localhost:" + << kDebuggingPort; + } + #ifdef __linux__ // On some linux distributions, the kernel's anonymous namespaces feature is // turned off, which may cause issues with QtWebEngineProcess in sandbox mode |