diff options
author | Josh Gao <jmgao@google.com> | 2020-06-24 16:11:21 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2020-06-24 16:14:34 -0700 |
commit | 9e933c54793f56a9c66cba353d997a38d5598d9c (patch) | |
tree | 26236cfdd75c8d6b513bc785dbbb2a987151f29d | |
parent | 975cee7270bd708514eac742ca6182b3caaf6962 (diff) | |
download | native-9e933c54793f56a9c66cba353d997a38d5598d9c.tar.gz |
adbd_auth: return auth id when requesting a prompt.
When multiple auth requests come in (e.g. if someone connects over TCP
and USB, or if we send a USB request, and then kill adb and try again),
we need to know the ID assigned to the request to disambiguate.
Bug: http://b/159061108
Test: manual
Change-Id: I68cf2335c5958decf29e58ed9132735577a7e074
-rw-r--r-- | libs/adbd_auth/adbd_auth.cpp | 7 | ||||
-rw-r--r-- | libs/adbd_auth/include/adbd_auth.h | 20 | ||||
-rw-r--r-- | libs/adbd_auth/libadbd_auth.map.txt | 1 |
3 files changed, 24 insertions, 4 deletions
diff --git a/libs/adbd_auth/adbd_auth.cpp b/libs/adbd_auth/adbd_auth.cpp index 458d3fc557..0e5d474612 100644 --- a/libs/adbd_auth/adbd_auth.cpp +++ b/libs/adbd_auth/adbd_auth.cpp @@ -549,7 +549,12 @@ void adbd_auth_notify_disconnect(AdbdAuthContext* ctx, uint64_t id) { void adbd_auth_prompt_user(AdbdAuthContext* ctx, const char* public_key, size_t len, void* opaque) { - ctx->PromptUser(std::string_view(public_key, len), opaque); + adbd_auth_prompt_user_with_id(ctx, public_key, len, opaque); +} + +uint64_t adbd_auth_prompt_user_with_id(AdbdAuthContext* ctx, const char* public_key, size_t len, + void* opaque) { + return ctx->PromptUser(std::string_view(public_key, len), opaque); } uint64_t adbd_auth_tls_device_connected(AdbdAuthContext* ctx, diff --git a/libs/adbd_auth/include/adbd_auth.h b/libs/adbd_auth/include/adbd_auth.h index 6ee3166e3a..8f834df62b 100644 --- a/libs/adbd_auth/include/adbd_auth.h +++ b/libs/adbd_auth/include/adbd_auth.h @@ -122,9 +122,23 @@ void adbd_auth_notify_disconnect(AdbdAuthContext* ctx, * @param len the length of the public_key argument * @param arg an opaque userdata argument */ -void adbd_auth_prompt_user(AdbdAuthContext* ctx, - const char* public_key, - size_t len, void* opaque) __INTRODUCED_IN(30); +void adbd_auth_prompt_user(AdbdAuthContext* ctx, const char* public_key, size_t len, void* opaque) + __INTRODUCED_IN(30); + +/** + * Prompt the user to authorize a public key. + * + * When this happens, a callback will be run on the auth thread with the result. + * + * @param ctx the AdbdAuthContext + * @param public_key the RSA public key to prompt user with + * @param len the length of the public_key argument + * @param arg an opaque userdata argument + * @return a unique id which will be returned via callback + */ +__attribute__((weak)) uint64_t adbd_auth_prompt_user_with_id(AdbdAuthContext* ctx, + const char* public_key, size_t len, + void* opaque) __INTRODUCED_IN(30); /** * Let system_server know that a TLS device has connected. diff --git a/libs/adbd_auth/libadbd_auth.map.txt b/libs/adbd_auth/libadbd_auth.map.txt index 5857ecb98e..7584ca3f53 100644 --- a/libs/adbd_auth/libadbd_auth.map.txt +++ b/libs/adbd_auth/libadbd_auth.map.txt @@ -7,6 +7,7 @@ LIBADBD_AUTH { adbd_auth_notify_auth; # apex introduced=30 adbd_auth_notify_disconnect; # apex introduced=30 adbd_auth_prompt_user; # apex introduced=30 + adbd_auth_prompt_user_with_id; # apex introduced=30 adbd_auth_tls_device_connected; # apex introduced=30 adbd_auth_tls_device_disconnected; # apex introduced=30 adbd_auth_get_max_version; # apex introduced=30 |