1 // Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary 2 // source code may only be used and distributed under the Widevine Master 3 // License Agreement. 4 // 5 #ifndef CLEARKEY_DEVICE_FILES_H_ 6 #define CLEARKEY_DEVICE_FILES_H_ 7 8 #include <errno.h> 9 #include <stdio.h> 10 #include <unistd.h> 11 12 #include <set> 13 #include <string> 14 #include <vector> 15 16 #include "protos/DeviceFiles.pb.h" 17 #include "ClearKeyTypes.h" 18 #include "MemoryFileSystem.h" 19 20 namespace android { 21 namespace hardware { 22 namespace drm { 23 namespace V1_2 { 24 namespace clearkey { 25 26 class DeviceFiles { 27 public: 28 typedef enum { 29 kLicenseStateUnknown, 30 kLicenseStateActive, 31 kLicenseStateReleasing, 32 } LicenseState; 33 DeviceFiles()34 DeviceFiles() {}; ~DeviceFiles()35 virtual ~DeviceFiles() {}; 36 37 virtual bool StoreLicense(const std::string& keySetId, LicenseState state, 38 const std::string& keyResponse); 39 40 virtual bool RetrieveLicense( 41 const std::string& key_set_id, LicenseState* state, std::string* offlineLicense); 42 43 virtual bool LicenseExists(const std::string& keySetId); 44 45 virtual std::vector<std::string> ListLicenses() const; 46 47 virtual bool DeleteLicense(const std::string& keySetId); 48 49 virtual bool DeleteAllLicenses(); 50 51 private: 52 bool FileExists(const std::string& path) const; 53 ssize_t GetFileSize(const std::string& fileName) const; 54 bool RemoveFile(const std::string& fileName); 55 56 bool RetrieveHashedFile(const std::string& fileName, OfflineFile* deSerializedFile); 57 bool StoreFileRaw(const std::string& fileName, const std::string& serializedFile); 58 bool StoreFileWithHash(const std::string& fileName, const std::string& serializedFile); 59 60 MemoryFileSystem mFileHandle; 61 62 CLEARKEY_DISALLOW_COPY_AND_ASSIGN(DeviceFiles); 63 }; 64 65 } // namespace clearkey 66 } // namespace V1_2 67 } // namespace drm 68 } // namespace hardware 69 } // namespace android 70 71 #endif // CLEARKEY_DEVICE_FILES_H_ 72