From 8d7cafed36ef2a7555131a69c6aee4eb696e1a3f Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Thu, 28 Jan 2021 09:20:03 -0800 Subject: Implement DeleteUser/DeleteAllUsers Bug: 160731903 Test: "atest VtsHalGatekeeperV1_0TargetTest" manual testing with added instrumentation Change-Id: I79fab5910a344fdec0e7acf62839146e146ac922 --- gatekeeper.cpp | 11 ++++++++--- include/gatekeeper/gatekeeper.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gatekeeper.cpp b/gatekeeper.cpp index 436ae81..57be100 100644 --- a/gatekeeper.cpp +++ b/gatekeeper.cpp @@ -163,13 +163,18 @@ void GateKeeper::Verify(const VerifyRequest &request, VerifyResponse *response) } } -void GateKeeper::DeleteUser(const DeleteUserRequest &/*request*/, DeleteUserResponse *response) { - response->error = ERROR_NOT_IMPLEMENTED; +void GateKeeper::DeleteUser(const DeleteUserRequest &request, DeleteUserResponse *response) { + if (response == nullptr) return; + + uint32_t uid = request.user_id; + response->error = RemoveUser(uid); } void GateKeeper::DeleteAllUsers(const DeleteAllUsersRequest &/*request*/, DeleteAllUsersResponse *response) { - response->error = ERROR_NOT_IMPLEMENTED; + if (response == nullptr) return; + + response->error = RemoveAllUsers(); } bool GateKeeper::CreatePasswordHandle(SizedBuffer *password_handle_buffer, salt_t salt, diff --git a/include/gatekeeper/gatekeeper.h b/include/gatekeeper/gatekeeper.h index 9f70d6f..62f0b34 100644 --- a/include/gatekeeper/gatekeeper.h +++ b/include/gatekeeper/gatekeeper.h @@ -116,6 +116,20 @@ protected: */ virtual uint64_t GetMillisecondsSinceBoot() const = 0; + /** + * Removes all records for the given user. + * + * Returns true if the user's records were successfully deleted. + */ + virtual gatekeeper_error_t RemoveUser(uint32_t /* uid */) { return ERROR_NOT_IMPLEMENTED; } + + /** + * Removes all records. + * + * Returns true if the records were successfully deleted. + */ + virtual gatekeeper_error_t RemoveAllUsers() { return ERROR_NOT_IMPLEMENTED; } + /** * Returns the value of the current failure record for the user. * -- cgit v1.2.3