Send DeleteUsers/DeleteAllUsers to Trusty

Actually route the DeleteUsers/DeleteAllUsers calls to Trusty,
instead of immediately returning ERROR_NOT_IMPLEMENTED.

Bug: 160731903
Test: "atest VtsHalGatekeeperV1_0TargetTest"
      manual testing with added instrumentation
Change-Id: I11fdaa0812fdfbc9b926611b15d84513ab13b18e
This commit is contained in:
Marco Nelissen 2021-01-25 14:57:23 -08:00
parent ea1f0fa006
commit 53dc3c99b7
3 changed files with 53 additions and 7 deletions

View File

@ -20,11 +20,13 @@
#define GATEKEEPER_MAX_BUFFER_LENGTH 1024
enum gatekeeper_command {
GK_REQ_SHIFT = 1,
GK_RESP_BIT = 1,
GK_REQ_SHIFT = 1,
GK_RESP_BIT = 1,
GK_ENROLL = (0 << GK_REQ_SHIFT),
GK_VERIFY = (1 << GK_REQ_SHIFT),
GK_ENROLL = (0 << GK_REQ_SHIFT),
GK_VERIFY = (1 << GK_REQ_SHIFT),
GK_DELETE_USER = (2 << GK_REQ_SHIFT),
GK_DELETE_ALL_USERS = (3 << GK_REQ_SHIFT),
};
/**

View File

@ -133,13 +133,48 @@ Return<void> TrustyGateKeeperDevice::verify(
return {};
}
Return<void> TrustyGateKeeperDevice::deleteUser(uint32_t /*uid*/, deleteUser_cb _hidl_cb) {
_hidl_cb({GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED, 0, {}});
Return<void> TrustyGateKeeperDevice::deleteUser(uint32_t uid, deleteUser_cb _hidl_cb) {
if (error_ != 0) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
return {};
}
DeleteUserRequest request(uid);
DeleteUserResponse response;
auto error = Send(request, &response);
if (error != ERROR_NONE) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
} else if (response.error == ERROR_NOT_IMPLEMENTED) {
_hidl_cb({GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED, 0, {}});
} else if (response.error != ERROR_NONE) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
} else {
_hidl_cb({GatekeeperStatusCode::STATUS_OK, response.retry_timeout, {}});
}
return {};
}
Return<void> TrustyGateKeeperDevice::deleteAllUsers(deleteAllUsers_cb _hidl_cb) {
_hidl_cb({GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED, 0, {}});
if (error_ != 0) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
return {};
}
DeleteAllUsersRequest request;
DeleteAllUsersResponse response;
auto error = Send(request, &response);
if (error != ERROR_NONE) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
} else if (response.error == ERROR_NOT_IMPLEMENTED) {
_hidl_cb({GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED, 0, {}});
} else if (response.error != ERROR_NONE) {
_hidl_cb({GatekeeperStatusCode::ERROR_GENERAL_FAILURE, 0, {}});
} else {
_hidl_cb({GatekeeperStatusCode::STATUS_OK, response.retry_timeout, {}});
}
return {};
}

View File

@ -81,6 +81,15 @@ class TrustyGateKeeperDevice : public ::android::hardware::gatekeeper::V1_0::IGa
return Send(GK_VERIFY, request, response);
}
gatekeeper_error_t Send(const DeleteUserRequest& request, DeleteUserResponse* response) {
return Send(GK_DELETE_USER, request, response);
}
gatekeeper_error_t Send(const DeleteAllUsersRequest& request,
DeleteAllUsersResponse* response) {
return Send(GK_DELETE_ALL_USERS, request, response);
}
int error_;
};