From 7a31ab675e30de858c690dcff8f1daf447358dae Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 3 Jun 2019 12:10:54 -0700 Subject: minadbd: More allowed properties. Most of these properties are already part of the fingerprint. This CL allows querying them directly, instead of encouraging users to decode from fingerprints. Bug: 134027350 Test: Boot into rescue mode on taimen. Run `adb rescue getprop` with new props. Change-Id: Id4667fcaf0e908c391085b22e22c957acd01d9c4 Merged-In: Id4667fcaf0e908c391085b22e22c957acd01d9c4 (cherry picked from commit 3b9ef341be618885407bc302ffc235585bc01c5d) --- minadbd/minadbd_services.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 1c4c0f494..e271c36fe 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -158,8 +158,15 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) { static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { static const std::unordered_set kGetpropAllowedProps = { - "ro.build.fingerprint", "ro.build.date.utc", + "ro.build.fingerprint", + "ro.build.flavor", + "ro.build.id", + "ro.build.product", + "ro.build.tags", + "ro.build.version.incremental", + "ro.product.device", + "ro.product.vendor.device", }; auto allowed = kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end(); if (!allowed) { -- cgit v1.2.3 From 5359d777e624ddc6b50ae7221d61e83ff52bab80 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 4 Jun 2019 11:20:00 -0700 Subject: minadbd: Support `adb rescue getprop`. It dumps all the allowed properties, similar to `adb shell getprop`. Bug: 134027350 Test: Run the command under rescue mode. Change-Id: Ic0864ca0fb51505ec1e4f38af2464591aa576201 Merged-In: Ic0864ca0fb51505ec1e4f38af2464591aa576201 (cherry picked from commit d8db81a01464c53c9bd6dbff32194faed85b6ccc) --- minadbd/minadbd_services.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index e271c36fe..7181fcf45 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -25,10 +25,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -156,8 +156,11 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) { } } +// Answers the query on a given property. The result will be written to the given sfd. If given an +// empty string, dumps all the supported properties (similar to `adb shell getprop`) in lines, e.g. +// "[prop]: [value]". static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { - static const std::unordered_set kGetpropAllowedProps = { + static const std::set kGetpropAllowedProps = { "ro.build.date.utc", "ro.build.fingerprint", "ro.build.flavor", @@ -168,12 +171,22 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { "ro.product.device", "ro.product.vendor.device", }; - auto allowed = kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end(); - if (!allowed) { + if (!prop.empty() && kGetpropAllowedProps.find(prop) == kGetpropAllowedProps.end()) { return; } - auto result = android::base::GetProperty(prop, ""); + std::string result; + if (prop.empty()) { + for (const auto& key : kGetpropAllowedProps) { + auto value = android::base::GetProperty(key, ""); + if (value.empty()) { + continue; + } + result += "[" + key + "]: [" + value + "]\n"; + } + } else { + result = android::base::GetProperty(prop, ""); + } if (result.empty()) { return; } -- cgit v1.2.3 From e3cc180d3121c98a5b5c14e0dbaa080169b46ae6 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 10 Jun 2019 12:41:44 -0700 Subject: minadbd: `adb rescue getprop` returns newline-terminated result. This change addresses the comment in [1], which makes the results of `adb shell getprop foo` and `adb rescue getprop foo` more consistent. That is, both will return newline-terminated results now. [1] https://r.android.com/c/platform/bootable/recovery/+/976340/3/minadbd/minadbd_services.cpp#188 Fixes: 134027350 Test: Run the following commands on taimen (under rescue mode): `adb rescue getprop ro.build.fingerprint` `adb rescue getprop ro.nonexistent` `adb rescue getprop` Change-Id: I5af47f8ea4d569b8507e259daef87749c0945f47 Merged-In: I5af47f8ea4d569b8507e259daef87749c0945f47 (cherry picked from commit 57a27890cec050d36a0d2d6e7db008cd22eb0560) --- minadbd/minadbd_services.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 7181fcf45..68f940cd8 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -156,9 +156,10 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) { } } -// Answers the query on a given property. The result will be written to the given sfd. If given an -// empty string, dumps all the supported properties (similar to `adb shell getprop`) in lines, e.g. -// "[prop]: [value]". +// Answers the query on a given property |prop|, by writing the result to the given |sfd|. The +// result will be newline-terminated, so nonexistent or nonallowed query will be answered with "\n". +// If given an empty string, dumps all the supported properties (analogous to `adb shell getprop`) +// in lines, e.g. "[prop]: [value]". static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { static const std::set kGetpropAllowedProps = { "ro.build.date.utc", @@ -171,10 +172,6 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { "ro.product.device", "ro.product.vendor.device", }; - if (!prop.empty() && kGetpropAllowedProps.find(prop) == kGetpropAllowedProps.end()) { - return; - } - std::string result; if (prop.empty()) { for (const auto& key : kGetpropAllowedProps) { @@ -184,11 +181,11 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { } result += "[" + key + "]: [" + value + "]\n"; } - } else { - result = android::base::GetProperty(prop, ""); + } else if (kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end()) { + result = android::base::GetProperty(prop, "") + "\n"; } if (result.empty()) { - return; + result = "\n"; } if (!android::base::WriteFully(sfd, result.data(), result.size())) { exit(kMinadbdHostSocketIOError); -- cgit v1.2.3 From 0bbb2ed53eb4dc4ae8d447062482f9eda5ef9a91 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 8 Jul 2019 18:07:22 -0700 Subject: minadbd sends heartbeat to rescue service for getprop command. We start minadbd and rescue services in two processes. In particular, minadbd handles the requests from host, then communicates with rescue service to do install/wipe works. When resuce service doesn't see any request in a pre-defined timeout (currently 300s), rescue service will exit to avoid endless waiting. This CL changes minadbd to additionally send a no-op command to rescue service as a heartbeat signal, so that host side can finish time-consuming operations (e.g. downloading over network) while keeping rescue service alive. Bug: 136457446 Test: Enter resuce mode on blueline. Send `adb rescue getprop ro.build.fingerprint` and check that rescue service doesn't exit. Test: Stop sending the getprop command. Check that rescue service exits after 300s. Change-Id: Ib9d5ed710cfa94ecfe6cf393a71a0b67b2539531 Merged-In: Ib9d5ed710cfa94ecfe6cf393a71a0b67b2539531 (cherry picked from commit 2223e6a9f8bf24b023e8ae3103b50c37def3147e) --- install/adb_install.cpp | 4 +++- minadbd/minadbd_services.cpp | 8 ++++++++ minadbd/minadbd_types.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install/adb_install.cpp b/install/adb_install.cpp index 4dd1f1b09..9497df501 100644 --- a/install/adb_install.cpp +++ b/install/adb_install.cpp @@ -363,11 +363,13 @@ int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot "\n\nNow send the package you want to apply\n" "to the device with \"adb sideload \"...\n"); } else { - ui->Print("\n\nWaiting for rescue commands...\n"); command_map.emplace(MinadbdCommand::kWipeData, [&device]() { bool result = WipeData(device, false); return std::make_pair(result, true); }); + command_map.emplace(MinadbdCommand::kNoOp, []() { return std::make_pair(true, true); }); + + ui->Print("\n\nWaiting for rescue commands...\n"); } CreateMinadbdServiceAndExecuteCommands(ui, command_map, rescue_mode); diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 68f940cd8..03341e4b8 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -190,6 +190,14 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { if (!android::base::WriteFully(sfd, result.data(), result.size())) { exit(kMinadbdHostSocketIOError); } + + // Send heartbeat signal to keep the rescue service alive. + if (!WriteCommandToFd(MinadbdCommand::kNoOp, minadbd_socket)) { + exit(kMinadbdSocketIOError); + } + if (MinadbdCommandStatus status; !WaitForCommandStatus(minadbd_socket, &status)) { + exit(kMinadbdMessageFormatError); + } } // Reboots into the given target. We don't reboot directly from minadbd, but going through recovery diff --git a/minadbd/minadbd_types.h b/minadbd/minadbd_types.h index 99fd45e83..002523f1f 100644 --- a/minadbd/minadbd_types.h +++ b/minadbd/minadbd_types.h @@ -53,6 +53,7 @@ enum class MinadbdCommand : uint32_t { kRebootRescue = 6, kWipeCache = 7, kWipeData = 8, + kNoOp = 9, // Last but invalid command. kError, -- cgit v1.2.3 From dd0158ac6016f2853d1af336e345980e06144abd Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 8 Jul 2019 18:07:22 -0700 Subject: minadbd sends heartbeat to rescue service for getprop command. We start minadbd and rescue services in two processes. In particular, minadbd handles the requests from host, then communicates with rescue service to do install/wipe works. When resuce service doesn't see any request in a pre-defined timeout (currently 300s), rescue service will exit to avoid endless waiting. This CL changes minadbd to additionally send a no-op command to rescue service as a heartbeat signal, so that host side can finish time-consuming operations (e.g. downloading over network) while keeping rescue service alive. Bug: 136457446 Test: Enter resuce mode on blueline. Send `adb rescue getprop ro.build.fingerprint` and check that rescue service doesn't exit. Test: Stop sending the getprop command. Check that rescue service exits after 300s. Change-Id: Ib9d5ed710cfa94ecfe6cf393a71a0b67b2539531 Merged-In: Ib9d5ed710cfa94ecfe6cf393a71a0b67b2539531 (cherry picked from commit 2223e6a9f8bf24b023e8ae3103b50c37def3147e) (cherry picked from commit 0bbb2ed53eb4dc4ae8d447062482f9eda5ef9a91) --- install/adb_install.cpp | 4 +++- minadbd/minadbd_services.cpp | 8 ++++++++ minadbd/minadbd_types.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install/adb_install.cpp b/install/adb_install.cpp index 4dd1f1b09..9497df501 100644 --- a/install/adb_install.cpp +++ b/install/adb_install.cpp @@ -363,11 +363,13 @@ int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot "\n\nNow send the package you want to apply\n" "to the device with \"adb sideload \"...\n"); } else { - ui->Print("\n\nWaiting for rescue commands...\n"); command_map.emplace(MinadbdCommand::kWipeData, [&device]() { bool result = WipeData(device, false); return std::make_pair(result, true); }); + command_map.emplace(MinadbdCommand::kNoOp, []() { return std::make_pair(true, true); }); + + ui->Print("\n\nWaiting for rescue commands...\n"); } CreateMinadbdServiceAndExecuteCommands(ui, command_map, rescue_mode); diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 1c4c0f494..6c10274dc 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -173,6 +173,14 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { if (!android::base::WriteFully(sfd, result.data(), result.size())) { exit(kMinadbdHostSocketIOError); } + + // Send heartbeat signal to keep the rescue service alive. + if (!WriteCommandToFd(MinadbdCommand::kNoOp, minadbd_socket)) { + exit(kMinadbdSocketIOError); + } + if (MinadbdCommandStatus status; !WaitForCommandStatus(minadbd_socket, &status)) { + exit(kMinadbdMessageFormatError); + } } // Reboots into the given target. We don't reboot directly from minadbd, but going through recovery diff --git a/minadbd/minadbd_types.h b/minadbd/minadbd_types.h index 99fd45e83..002523f1f 100644 --- a/minadbd/minadbd_types.h +++ b/minadbd/minadbd_types.h @@ -53,6 +53,7 @@ enum class MinadbdCommand : uint32_t { kRebootRescue = 6, kWipeCache = 7, kWipeData = 8, + kNoOp = 9, // Last but invalid command. kError, -- cgit v1.2.3 From 92214baec296e1de024d7482141078fad47de866 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Tue, 24 Sep 2019 14:36:40 -0700 Subject: Import translations. DO NOT MERGE Change-Id: I18c2199dc9439d6013329d1f0eb40dd106618bfb Auto-generated-cl: translation import --- tools/recovery_l10n/res/values-gl/strings.xml | 4 ++-- tools/recovery_l10n/res/values-in/strings.xml | 2 +- tools/recovery_l10n/res/values-ja/strings.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/recovery_l10n/res/values-gl/strings.xml b/tools/recovery_l10n/res/values-gl/strings.xml index e51b36dfb..e6f2ffd84 100644 --- a/tools/recovery_l10n/res/values-gl/strings.xml +++ b/tools/recovery_l10n/res/values-gl/strings.xml @@ -6,9 +6,9 @@ "Non hai ningún comando" "Erro" "Instalando actualización de seguranza" - "Non se puido cargar o sistema Android. Os teus datos poden estar danados. Se segue aparecendo esta mensaxe, pode ser necesario restablecer os datos de fábrica e borrar todos os datos de usuario almacenados neste dispositivo." + "Non se puido cargar o sistema Android. Os teus datos poden estar danados. Se segue aparecendo esta mensaxe, pode ser necesario restablecer os datos de fábrica e borrar todos os datos do usuario almacenados neste dispositivo." "Tentar de novo" "Restablecemento dos datos de fábrica" - "Queres borrar todos os datos de usuario?\n\n ESTA ACCIÓN NON SE PODE DESFACER." + "Queres borrar todos os datos do usuario?\n\n ESTA ACCIÓN NON SE PODE DESFACER." "Cancelar" diff --git a/tools/recovery_l10n/res/values-in/strings.xml b/tools/recovery_l10n/res/values-in/strings.xml index 15a78ec48..43c9deb94 100644 --- a/tools/recovery_l10n/res/values-in/strings.xml +++ b/tools/recovery_l10n/res/values-in/strings.xml @@ -9,6 +9,6 @@ "Tidak dapat memuat sistem Android. Data Anda mungkin rusak. Jika terus mendapatkan pesan ini, Anda mungkin perlu melakukan reset ke setelan pabrik dan menghapus semua data pengguna yang disimpan di perangkat ini." "Coba lagi" "Reset ke setelan pabrik" - "Wipe semua data pengguna?\n\n TINDAKAN INI TIDAK DAPAT DIURUNGKAN!" + "Hapus total semua data pengguna?\n\n TINDAKAN INI TIDAK DAPAT DIURUNGKAN!" "Batal" diff --git a/tools/recovery_l10n/res/values-ja/strings.xml b/tools/recovery_l10n/res/values-ja/strings.xml index 3d6637278..2d6c0abc4 100644 --- a/tools/recovery_l10n/res/values-ja/strings.xml +++ b/tools/recovery_l10n/res/values-ja/strings.xml @@ -6,7 +6,7 @@ "コマンドが指定されていません" "エラーが発生しました。" "セキュリティ アップデートをインストールしています" - "Android システムを読み込めません。データが破損している可能性があります。このメッセージが引き続き表示される場合は、データの初期化を行い、この端末に保存されているすべてのユーザー データを消去することが必要な場合があります。" + "Android システムを読み込めません。データが破損している可能性があります。このメッセージが引き続き表示される場合は、データの初期化を行い、このデバイスに保存されているすべてのユーザー データを消去することが必要な場合があります。" "再試行" "データの初期化" "すべてのユーザー データをワイプしますか?\n\nこの操作は元に戻せません。" -- cgit v1.2.3