Fixed auth_token_table tests
auth_token_table tests did not make the transition to hidle types and
were broken.
Noww they use the hidle types as well.
Also this patch fixes an awkward ownership transfer of an object
referred to by a const pointer and reduses the use of the type hw_auth_token.
Test: Ran all keystore CTS test as well as the fixed auth_token_table
tests
Bug: 68149839
Change-Id: Ia69a80fad12edc134646a7b340f8e27ea4da2210
diff --git a/keystore/auth_token_table.h b/keystore/auth_token_table.h
index 0056b26..3e3ff6e 100644
--- a/keystore/auth_token_table.h
+++ b/keystore/auth_token_table.h
@@ -17,7 +17,6 @@
#include <memory>
#include <vector>
-#include <hardware/hw_auth_token.h>
#include <keystore/authorization_set.h>
#ifndef KEYSTORE_AUTH_TOKEN_TABLE_H_
@@ -61,7 +60,7 @@
/**
* Add an authorization token to the table. The table takes ownership of the argument.
*/
- void AddAuthenticationToken(const HardwareAuthToken* token);
+ void AddAuthenticationToken(std::unique_ptr<const HardwareAuthToken>&& auth_token);
/**
* Find an authorization token that authorizes the operation specified by \p operation_handle on
@@ -97,7 +96,7 @@
class Entry {
public:
- Entry(const HardwareAuthToken* token, time_t current_time);
+ Entry(std::unique_ptr<const HardwareAuthToken>&& token, time_t current_time);
Entry(Entry&& entry) { *this = std::move(entry); }
void operator=(Entry&& rhs) {
@@ -127,7 +126,7 @@
void mark_completed() { operation_completed_ = true; }
- const HardwareAuthToken* token() { return token_.get(); }
+ const HardwareAuthToken& token() { return *token_.get(); }
time_t time_received() const { return time_received_; }
bool completed() const { return operation_completed_; }
uint64_t timestamp_host_order() const;