Maxing Out Sessions Can Cause SPOID Failures

(This is a merge of http://go/wvgerrit/25581)

To prevent dead DRM Plugins from being instantiated when there are no
sessions available, the time at which the device ID is queried has been
moved from instantiation-time to SPOID-calculation-time.

SPOIDs can now fail to be generated. Which means anything that depends
on a SPOID may fail because of this. However, this is a more actionable
problem for apps than having them receive a dead or unusable DRM Plugin
object.

Bug: 36660726
Test: libwvdrmdrmplugin_hidl_test
Change-Id: Ice6a8eabfee8d48bf2af02e2e7169aa95af9f2e4
This commit is contained in:
John W. Bruce
2017-04-11 11:57:20 -07:00
parent 19947dfe6f
commit c0a7655834
3 changed files with 106 additions and 163 deletions

View File

@@ -308,12 +308,21 @@ struct WVDrmPlugin : public IDrmPlugin, IDrmPluginListener,
class CdmIdentifierBuilder {
public:
CdmIdentifierBuilder(bool useSpoid, const std::string& appPackageName);
CdmIdentifierBuilder(bool useSpoid, const WVDrmPlugin& parent,
const std::string& appPackageName);
const CdmIdentifier& get_identifier();
const std::string& get_device_unique_id();
// Fills in the passed-in struct with the CDM Identifier for the current
// combination of Origin, Application, and Device. This is needed by some
// calls into the CDM in order to identify which CDM instance should receive
// the call. Calling this will seal the CDM Identifier Builder, thus making
// it an error to change the origin.
status_t getCdmIdentifier(CdmIdentifier* identifier);
bool set_device_id(const std::string& id);
// Gets the application-safe device-unique ID. On non-SPOID devices, this is
// the device-unique ID from OEMCrypto. On SPOID devices, this is the SPOID.
// On SPOID devices, calling this will seal the CDM Identifier Builder, thus
// making it an error to change the origin.
status_t getDeviceUniqueId(std::string* id);
const std::string& origin() const { return mCdmIdentifier.origin; }
bool set_origin(const std::string& id);
@@ -325,10 +334,16 @@ struct WVDrmPlugin : public IDrmPlugin, IDrmPluginListener,
bool mIsIdentifierSealed;
bool mUseSpoid;
std::string mDeviceId;
std::string mAppPackageName;
const WVDrmPlugin& mParent;
void calculateSpoid();
status_t calculateSpoid();
// Gets the device-unique ID from OEMCrypto. This must be private, since
// this value must not be exposed to applications on SPOID devices. Code
// outside this class should use getDeviceUniqueId() to get the
// application-safe device-unique ID.
status_t getOemcryptoDeviceId(std::string* id);
} mCdmIdentifierBuilder;
sp<wvcdm::WvContentDecryptionModule> const mCDM;