• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_4 {
24 namespace clearkey {
25 
26 using ::android::hardware::drm::V1_2::clearkey::OfflineFile;
27 
28 class DeviceFiles {
29  public:
30     typedef enum {
31         kLicenseStateUnknown,
32         kLicenseStateActive,
33         kLicenseStateReleasing,
34     } LicenseState;
35 
DeviceFiles()36     DeviceFiles() {};
~DeviceFiles()37     virtual ~DeviceFiles() {};
38 
39     virtual bool StoreLicense(const std::string& keySetId, LicenseState state,
40             const std::string& keyResponse);
41 
42     virtual bool RetrieveLicense(
43             const std::string& key_set_id, LicenseState* state, std::string* offlineLicense);
44 
45     virtual bool LicenseExists(const std::string& keySetId);
46 
47     virtual std::vector<std::string> ListLicenses() const;
48 
49     virtual bool DeleteLicense(const std::string& keySetId);
50 
51     virtual bool DeleteAllLicenses();
52 
53  private:
54     bool FileExists(const std::string& path) const;
55     ssize_t GetFileSize(const std::string& fileName) const;
56     bool RemoveFile(const std::string& fileName);
57 
58     bool RetrieveHashedFile(const std::string& fileName, OfflineFile* deSerializedFile);
59     bool StoreFileRaw(const std::string& fileName, const std::string& serializedFile);
60     bool StoreFileWithHash(const std::string& fileName, const std::string& serializedFile);
61 
62     MemoryFileSystem mFileHandle;
63 
64     CLEARKEY_DISALLOW_COPY_AND_ASSIGN(DeviceFiles);
65 };
66 
67 } // namespace clearkey
68 } // namespace V1_4
69 } // namespace drm
70 } // namespace hardware
71 } // namespace android
72 
73 #endif  // CLEARKEY_DEVICE_FILES_H_
74