Merge "Add error details when offline license is not found" into udc-dev

This commit is contained in:
Rahul Frias
2023-05-02 23:41:30 +00:00
committed by Android (Google) Code Review
10 changed files with 183 additions and 38 deletions

View File

@@ -236,9 +236,21 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
DeviceFiles::ResponseTypeToString(sub_error_code),
IdToString(key_set_id));
SetErrorDetail(error_detail, sub_error_code);
return sub_error_code == DeviceFiles::kFileNotFound
? CdmResponseType(KEYSET_ID_NOT_FOUND_4)
: CdmResponseType(GET_LICENSE_ERROR);
switch (sub_error_code) {
case DeviceFiles::kFileNotFound:
case DeviceFiles::kFileNotFoundEAcces:
case DeviceFiles::kFileNotFoundEFault:
case DeviceFiles::kFileNotFoundELoop:
case DeviceFiles::kFileNotFoundENameTooLong:
case DeviceFiles::kFileNotFoundENoEnt:
case DeviceFiles::kFileNotFoundENoMem:
case DeviceFiles::kFileNotFoundENotDir:
case DeviceFiles::kFileNotFoundEOverflow:
case DeviceFiles::kFileNotFoundOther:
return (CdmResponseType(KEYSET_ID_NOT_FOUND_4));
default:
return (CdmResponseType(GET_LICENSE_ERROR));
}
}
offline_init_data_ = std::move(license_data.pssh_data);
key_request_ = std::move(license_data.license_request);

View File

@@ -358,12 +358,56 @@ const char* DeviceFiles::ResponseTypeToString(ResponseType type) {
return "IncorrectFileVersion";
case kLicenseNotPresent:
return "LicenseNotFound";
case kFileNotFoundEAcces:
return "FileNotFound_EAcces";
case kFileNotFoundEFault:
return "FileNotFound_EFault";
case kFileNotFoundELoop:
return "FileNotFound_ELoop";
case kFileNotFoundENameTooLong:
return "FileNotFound_ENameTooLong";
case kFileNotFoundENoEnt:
return "FileNotFound_ENoEnt";
case kFileNotFoundENoMem:
return "FileNotFound_ENoMem";
case kFileNotFoundENotDir:
return "FileNotFound_ENotDir";
case kFileNotFoundEOverflow:
return "FileNotFound_EOverflow";
case kFileNotFoundOther:
return "FileNotFound_Other";
case kResponseTypeBase: // Not a valid value.
break;
}
return UnknownEnumValueToString(static_cast<int>(type));
}
// static
DeviceFiles::ResponseType DeviceFiles::ErrnoToResponseType(int errno_value) {
switch (errno_value) {
case 0:
return kNoError;
case EACCES:
return kFileNotFoundEAcces;
case EFAULT:
return kFileNotFoundEFault;
case ELOOP:
return kFileNotFoundELoop;
case ENAMETOOLONG:
return kFileNotFoundENameTooLong;
case ENOENT:
return kFileNotFoundENoEnt;
case ENOMEM:
return kFileNotFoundENoMem;
case ENOTDIR:
return kFileNotFoundENotDir;
case EOVERFLOW:
return kFileNotFoundEOverflow;
default:
return kFileNotFoundOther;
}
}
// static
std::set<std::string> DeviceFiles::reserved_license_ids_;
std::mutex DeviceFiles::reserved_license_ids_mutex_;
@@ -1999,9 +2043,12 @@ DeviceFiles::ResponseType DeviceFiles::RetrieveHashedFile(
path += name;
if (!file_system_->Exists(path)) {
LOGW("File does not exist: path = %s", path.c_str());
return kFileNotFound;
int errno_value = 0;
if (!file_system_->Exists(path, &errno_value)) {
const ResponseType result = ErrnoToResponseType(errno_value);
LOGW("File does not exist: path = %s, error = %s", path.c_str(),
ResponseTypeToString(result));
return result;
}
const ssize_t file_size = file_system_->FileSize(path);