Add error details when offline license is not found
[ Merge of http://go/wvgerrit/171310 ] Offline license not found errors are identified by CdmResponseEnum 347 (KEYSET_ID_NOT_FOUND_4). No addition file system information is shared. Checks for file existance use the stat command. The stat call can return error codes from errno.h when the command fails. These are now converted into sub error codes and returned along with the offline license file not found error. This also includes a change to log stat errors other than ENOENT (no such file or directory) as a warning rather than verbose. Bug: 276225520 Test: file_store_unittest, file_utils_unittest, GtsMediaTestCases Change-Id: Ic09d036549582cd65783b49fa96ffefc4bf562c7
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user