summaryrefslogtreecommitdiffstats
path: root/drm/mediadrm/plugins/clearkey/hidl/include/DeviceFiles.h
blob: a201e884acc868cb477c4ed8b7c2e415417e7c6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine Master
// License Agreement.
//
#ifndef CLEARKEY_DEVICE_FILES_H_
#define CLEARKEY_DEVICE_FILES_H_

#include <errno.h>
#include <stdio.h>
#include <unistd.h>

#include <set>
#include <string>
#include <vector>

#include "protos/DeviceFiles.pb.h"
#include "ClearKeyTypes.h"
#include "MemoryFileSystem.h"

namespace android {
namespace hardware {
namespace drm {
namespace V1_1 {
namespace clearkey {

class DeviceFiles {
 public:
    typedef enum {
        kLicenseStateActive,
        kLicenseStateReleasing,
        kLicenseStateUnknown,
    } LicenseState;

    DeviceFiles() {};
    virtual ~DeviceFiles() {};

    virtual bool StoreLicense(const std::string& keySetId, LicenseState state,
            const std::string& keyResponse);

    virtual bool RetrieveLicense(
            const std::string& key_set_id, LicenseState* state, std::string* offlineLicense);

    virtual bool LicenseExists(const std::string& keySetId);

    virtual bool DeleteAllLicenses();

 private:
    bool FileExists(const std::string& path) const;
    ssize_t GetFileSize(const std::string& fileName) const;
    bool RemoveFile(const std::string& fileName);

    bool RetrieveHashedFile(const std::string& fileName, OfflineFile* deSerializedFile);
    bool StoreFileRaw(const std::string& fileName, const std::string& serializedFile);
    bool StoreFileWithHash(const std::string& fileName, const std::string& serializedFile);

    MemoryFileSystem mFileHandle;

    CLEARKEY_DISALLOW_COPY_AND_ASSIGN(DeviceFiles);
};

} // namespace clearkey
} // namespace V1_1
} // namespace drm
} // namespace hardware
} // namespace android

#endif  // CLEARKEY_DEVICE_FILES_H_