[adb] Correctly read host/user name on Windows.
Bug: 162111908
Test: On linux/mac:
HOSTNAME="" adb keygen mykey; cat mykey.pub # Also LOGNAME
HOSTNAME="测试" adb keygen mykey; cat mykey.pub
HOSTNAME="test" adb keygen mykey; cat mykey.pub
Test: On Windows:
set COMPUTERNAME=&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub" # Also USERNAME
set COMPUTERNAME=测试&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub"
set COMPUTERNAME=test&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub"
Change-Id: I62c952c511a620286aa4e05b1763361406e9f89a
diff --git a/adb/Android.bp b/adb/Android.bp
index 87ac54d..8addf95 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -117,6 +117,7 @@
static_libs: [
"libadb_crypto",
"libadb_pairing_connection",
+ "libadb_sysdeps",
"libadb_tls_connection",
"libadbd",
"libadbd_core",
@@ -167,6 +168,7 @@
"services.cpp",
"sockets.cpp",
"socket_spec.cpp",
+ "sysdeps/env.cpp",
"sysdeps/errno.cpp",
"transport.cpp",
"transport_fd.cpp",
@@ -261,6 +263,43 @@
],
}
+cc_library {
+ name: "libadb_sysdeps",
+ defaults: ["adb_defaults"],
+ recovery_available: true,
+ host_supported: true,
+ compile_multilib: "both",
+ min_sdk_version: "apex_inherit",
+
+ srcs: [
+ "sysdeps/env.cpp",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+
+ target: {
+ windows: {
+ enabled: true,
+ ldflags: ["-municode"],
+ },
+ },
+
+ export_include_dirs: ["."],
+
+ visibility: [
+ "//system/core/adb:__subpackages__",
+ "//bootable/recovery/minadbd:__subpackages__",
+ ],
+
+ apex_available: [
+ "com.android.adbd",
+ "test_com.android.adbd",
+ ],
+}
+
cc_test_host {
name: "adb_test",
defaults: ["adb_defaults"],
@@ -274,6 +313,7 @@
"libadb_pairing_auth_static",
"libadb_pairing_connection_static",
"libadb_protos_static",
+ "libadb_sysdeps",
"libadb_tls_connection_static",
"libbase",
"libcutils",
@@ -330,6 +370,7 @@
"libadb_pairing_auth",
"libadb_pairing_connection",
"libadb_protos",
+ "libadb_sysdeps",
"libadb_tls_connection",
"libandroidfw",
"libapp_processes_protos_full",
@@ -831,6 +872,7 @@
"libadb_pairing_auth_static",
"libadb_pairing_connection_static",
"libadb_protos_static",
+ "libadb_sysdeps",
"libadb_tls_connection_static",
"libandroidfw",
"libbase",