Commit Graph

727 Commits

Author SHA1 Message Date
Rahul Frias
e34f83cdce Consolidate update usage table calls
[ Merge of http://go/wvgerrit/24147 ]

In OEMCrypto version 13, usage information is updated by calls to
OEMCrypto_UpdateUsageEntry. In previous versions calls were made to
OEMCrypto_UpdateUsageTable instead. Both need to be supported as the
OEMCrypto version may vary by device.

This consolidates calls to OEMCrypto_UpdateUsageTable so that they
can be disabled if OEMCrypto version >= 13. No functional changes other
than disabling by OEMCrypto version were introduced in this section.

Helper routines have been added to device files as well.

Bug: 34327459

Test: WV unit/integration tests
Change-Id: I223b0a947c21b8b7ba3c8f345b0206747eb50984
2018-01-16 19:20:10 -08:00
Rahul Frias
17ccdcf351 Implement Cdm::listStoredLicenses() code review changes
[ Merge of http://go/wvgerrit/23822 ]

This merges back to master, code review related changes when
"Implement Cdm::listStoredLicenses()" was merged from master
(http://go/wvgerrit/23189) to oc-dev (http://go/wvgerrit/23600)

Bug: 34628115
Test: WV unit/integration tests
Change-Id: Idf3acb0ff668d1cc3fe2e6fd400daa183bdb340b
2018-01-16 19:19:26 -08:00
Rahul Frias
a483c18c59 Provisioning 3.0: Changes to Provisioning and Service Certs.
[ Merge of http://go/wvgerrit/23360 ]

Service Certificates are used in two places, provisioning and
licensing. The service certificate code depended on a session_id
to get and set the service certificate properties, but the session_id
was not available in the provisioning path.

This patch pulls out the property lookup by session_id dependency,
and passes the CdmImpl's property_set into the provisioning code, so
the service certificate can be read and written there.

Bug: 62972441

Test: WV unit/integration tests. This introduces three test failures
  * WvCdmRequestLicenseTest.PrivacyModeWithServiceCertificateTest
  * Cdm/WvCdmStreamingLicenseRenewalTest.WithClientId/4
  * Cdm/WvCdmOfflineLicenseReleaseTest.WithClientId/3

Change-Id: I6e9d4e23a9e7e81a63a994db8ec0b443893449a6
2018-01-16 19:18:52 -08:00
Rahul Frias
22fdf6ae06 Add new CDM API call: Cdm::removeUsageTable()
[ Merge of http://go/wvgerrit/23168 ]

Bug: 33380441

Test: WV unit/integration tests
Change-Id: Id63c31cdb367704b0bbb77ea9ea597cc86259eeb
2018-01-16 19:09:40 -08:00
Edwin Wong
59fcc20138 Move persistent data to /data/vendor.
Widevine persistent data is stored in /data/mediadrm, HALs
are not allowed to access files in /data. Move persistent
data to /data/vendor/mediadrm/widevine for older devices,
and persistent data will not be saved under /data/vendor.

Test: Play Movies & Tv, Netflix

bug: 36601695
Change-Id: I31fdd43b7db327bf6d8343dc95e9883ae6bce70d
2018-01-15 13:50:06 -08:00
Fred Gylys-Colwell
913c890c5f Change watchdog timer to 2 minutes
Merge from Widevine repo of http://go/wvgerrit/35480

This relaxes the watchdog timer around the level 3 oemcrypto
initialization to 120 seconds.  There are also a couple of new log
messages at the end of initialization and at termination.

Library for arm updated:
level3/arm/libwvlevel3.a       Level3 Library 4445 Oct  4 2017 17:06:25

bug: 65379279

Test: unit tests on n5.  View netflix on Nexus 5.  GTS tests on N5.
Change-Id: Id474d6728da557051801d2ca92987496672b896a
2017-10-06 00:15:44 +00:00
Rahul Frias
c103250eb6 Avoid re-initializing CDM properties
[ Merge of http://go/wvgerrit/35405 ]

Devices that launch with android O as their first release have
SPOIDs (Stable Per-Origin IDentifier) enabled. This results
in multiple CdmEngine instances, one for each CDM identifier
(that differ by app package name possibly origin).

Each time a CDMEngine object is created, the CDM properties are
reinitialized. This causes certain property information stored on
a session basis (privacy mode, service certificate, session sharing)
to be lost. Since Query calls are not app specific, they can often
result in CdmEngine object creation, causing existing sessions to
lose associated property information. This can be avoided by
initializing CDM proerpties only once.

Bug: 65732345

Test: WV unit/integration tests
Test: GTS tests
Test: Playback using Google Play, Netflix and YT Live

Change-Id: Ic121f322ed6e45e2033964e6439c026de2401b4c
2017-10-03 16:23:23 -07:00
Rahul Frias
be9aba6d3a Corrections to license duration reporting
[ Merge of http://go/wvgerrit/34900 ]

Querying information about licenses with uncommon duration values
did not, under all conditions, return expected values. This corrects
for licenses where
* playback and license durations were set to unlimited
* rental and license durations were set to unlimited

Bug: 65669869

Test: 9 new policy_engine_unittests
Test: WV unit/integration tests
Test: GTSMediaTestCases
Test: Playback using netflix and play movies
Change-Id: I6e48f82f1f194fb7e04491d33054dfe74d9465eb
2017-09-22 13:27:10 -07:00
Rahul Frias
20eeb1e546 Fixes for usage table upgrades
[ Merge of http://go/wvgerrit/34060 ]

License were not being upgraded successfully from usage
tables to usage table headers and entries (big usage tables).

Bug: 65730713

Test: WV unit/integration tests
Test: GTSMediaDrmTests
Test: Playback using netflix and play movies
Test: Manual upgrade from N (L3)
Change-Id: I7ef127204104fa36dd1ee385bc80ed6a81172b4b
2017-09-19 14:27:03 -07:00
TreeHugger Robot
ec9e1343ee Merge "Add watch dog timer to OEMCrypto L3" into oc-mr1-dev 2017-09-15 06:05:21 +00:00
Fred Gylys-Colwell
7ca2b21363 Add watch dog timer to OEMCrypto L3
Merge from Widevine repo of http://go/wvgerrit/33540

This code adds a watchdog timer to the level 3 initialization.  If
initialization does not finish within 5 seconds, the process will
abort, printing a small amount of debugging information.

arm/libwvlevel3.a Level3 Library 4445 Sep 11 2017 14:05:15

Test: unit tests on bullhead. Video on Play Movies.  
Kyle ran the GTS tests on loop overnight.

bug: 65379279

Change-Id: I0e0e4b158dbce193abbd8ee2cf6b366060c768b8
2017-09-14 18:16:21 +00:00
Rahul Frias
1f32bef75b Clock consistency checks
[ Merge from http://go/wvgerrit/33440 ]

Introduce checks to guard against clock tampering.

Bug: 62037413

Test: WV unit, integration tests on angler
Test: Manual clock rollback test
Test: Playback testing (Netflix, Play movies) on sailfish
Test: GTS test on angler
Change-Id: I47938109adb5c0f5e9aefc58eb5dac156b9f16ef
2017-09-11 11:56:32 -07:00
Rahul Frias
8309922a89 Merge "Correct when usage entry information is updated" into oc-mr1-dev 2017-09-10 04:55:59 +00:00
Rahul Frias
a40aeec7bf Correct when usage entry information is updated
[ Merge of http://go/wvgerrit/33340 ]

Update usage entry information only when usage entries are
supported.

Bug: 65483034

Test: wv unit/integration tests on angler
Test: GTS tests
Test: playback using play movies and netflix

Change-Id: If5a33900a30ce88f97ef46a800817cd4c71d195e
2017-09-08 11:24:15 -07:00
TreeHugger Robot
f2e7f23f00 Merge "Fix support for app package name." into oc-mr1-dev 2017-09-07 19:25:10 +00:00
Adam Stone
1b9c6ea789 Fix support for app package name.
The app package name was not being reported to the media stats. This
change adds the package name as part of the report to media stats.

This is one of two parts to this change. The other part is in
frameworks/av.

Bug: 64584568

Test: Unit tests, GTS tests, tried with Google Play Movies.
Change-Id: I1ca09db3a59d9a0950f424d977f8774dffd09c2b
2017-09-06 22:25:13 -07:00
Rahul Frias
d355e505c7 Merge "Corrections when releasing usage information" into oc-mr1-dev 2017-09-07 01:18:59 +00:00
Rahul Frias
4c69cf6245 Merge "Remove ExpiryOnReleaseOfflineKeyTest" into oc-mr1-dev 2017-09-07 00:42:51 +00:00
Rahul Frias
cb8bb251e4 Remove ExpiryOnReleaseOfflineKeyTest
The test verifies that a downloaded license receives an expiry event
in a session if it is released from another session. With
the introduction of the big usage table feature loading a
license/usage entry into multiple sessions is not permitted and
so this test is no longer needed.

Some OEMCrypto implementations might require OEMCrypto_UpdateUsageEntry
to be called between calls to OEMCrypto_LoadKeys and
OEMCrypto_ReportUsage. This CL adds the call to
OEMCrypto_UpdateUsageEntry.

Test: WV unit/integration test
Test: Playback using play movies and netflix
Test: GTS tests

Bug: 64988654
Change-Id: Ic737c3200ea1858736a168be835507378eaf7b3e
2017-09-06 12:06:05 -07:00
Rahul Frias
120c28cd9a Corrections when releasing usage information
[ Merge of http://go/wvgerrit/32940 ]

Releasing usage entries may cause other entries to be moved or
information updated. Instead of retrieving all entries once and trying
to release them, refetch them after each release.

Test: WV Unit/Integration tests
Test: GTS tests (failures seen, but no additional failures due to this CL)
Test: Playback testing using play movies and netflix.

Bug: 65372189
Change-Id: I700e60834c7f711c9146dfd720f9cac014981311
2017-09-06 10:22:43 -07:00
TreeHugger Robot
6e680854ed Merge "Call pthread_join to clean up watchdog thread" into oc-mr1-dev 2017-09-06 00:23:03 +00:00
Adam Stone
b3654fb2ab Merge "Fixes reporting of dynamic adapter metrics." into oc-mr1-dev 2017-09-05 23:46:58 +00:00
Fred Gylys-Colwell
e659655886 Call pthread_join to clean up watchdog thread
Merge from Widevine repo of http://go/wvgerrit/32880

This CL calls pthread_join on the watchdog thread to clean up its
stack and other memory usage.

Test: unit tests on bullhead, GTS tests run in loop, 
Play Movies on bullhead.

bug: 65302198

Change-Id: I90f993333dfd019c1ffb96647a6472e4828d50aa
2017-09-05 23:21:47 +00:00
Adam Stone
4d6cfd414c Fixes reporting of dynamic adapter metrics.
The metrics from the dynamic adapter were not previously being reported.
This change allows them to be reported when all other DRM metrics are
reported.

Bug: 64566432

Test: Unit tests, GTS tests, and Play movies.
Change-Id: I916fb028146fdd04b4cf5bbb5c10ecdaffae6c95
2017-09-05 11:11:49 -07:00
TreeHugger Robot
4a4f9ff815 Merge "Update PerOriginProvisioningSupportsOldPaths" into oc-mr1-dev 2017-09-01 00:48:27 +00:00
TreeHugger Robot
cd6178cf82 Merge "Unified State-Changing API for LicenseKeyStatus" into oc-mr1-dev 2017-08-31 23:45:41 +00:00
Fred Gylys-Colwell
fb1e0623ad Update PerOriginProvisioningSupportsOldPaths
Merge from Widevine repo of http://go/wvgerrit/32067

PerOriginProvisioningSupportsOldPaths is changed to allow for there to
be several other device files.

bug:64952779
Test: unit tests on bullhead.

Change-Id: I0593d95a877c236c9a87c5893bbec22abe25fde9
2017-08-31 14:42:49 -07:00
Rahul Frias
e492811200 Merge "Add SRM integration tests" into oc-mr1-dev 2017-08-30 20:57:06 +00:00
Adam Stone
5d2693536c Apply recommended type and name changes to metrics.
Bug: 36220619
BUG: 64071905

Test: Re-ran existing unit tests. Ran GTS tests. Tested with Google Play.
Change-Id: I79ddc8ed3290e6d74364cf96305054e55243c5ff
2017-08-29 17:12:44 -07:00
John W. Bruce
b8e31487a4 Unified State-Changing API for LicenseKeyStatus
(This is a merge of http://go/wvgerrit/31040)

Because the Policy Engine was only consulting the result of the Max-Res
Decode check when it was in kLicenseStateCanPlay and not in other states
that imply kKeyStatusUsable, like kLicenseStateWaitingLicenseUpdate, the
Max-Res Decode results would not be honored during the interval between
requesting a renewal and receiving the result. (Or until the key
expired.) This was particularly problematic for keys with renewal delays
less than ten seconds long, which would freeze the Max-Res state before
it had a chance to update for the first time, effectively disabling
Max-Res Decode until renewal was received.

Fixing this required changing how the Policy Engine and the
LicenseKeyStatus objects communicate about the changing usability state
of the LicenseKeyStatus objects. Before, a call to ApplyConstraints()
might calculate a Max-Res failure, but this failure would be pending
until the Policy Engine deigned to call ApplyStatusChange() again.
Without a call to ApplyStatusChange(), it could pend forever. This put a
burden on the PolicyEngine to poll the LicenseKeys with redundant
ApplyStatusChange() calls using the same CdmKeyStatus that the keys were
already in, just in case Max-Res had changed since the last necessary
call to ApplyStatusChange().

If the Policy Engine got the timing of these calls wrong, it would
result in Max-Res results being ignored. (as in the linked bug) If it
ever polled with the wrong CdmKeyStatus, it would update the
LicenseKeys' status when it did not mean to. It would be preferable if
this polling were not needed, so that the Policy Engine couldn't get it
wrong.

This patch changes the API between these classes so that when Max-Res
fails, the state change can be reported immediately instead of pending
until ApplyStatusChange() is called, eliminating the need for polling.
All state changes to the LicenseKeyStatus objects go through a unified
ApplyStatusChange() method that can update the CdmKeyStatus, resolution,
and/or HDCP level and report any resulting usability changes
immediately. This patch updates the unit tests to exercise this new API
instead of the old API.

Previously, the linked bug slipped past our unit tests because we only
test unrenewable, streaming licenses against Max-Res. This patch adds
several more variants to
policy_engine_constraints_unittest so that it tests six kinds of
license to provide better coverage.

Bug: 62393949
Test: build_and_run_all_unit_tests
Change-Id: I0dfdbf6b8ea39abb446089aef5f6ea0502e9b4c6
2017-08-29 16:37:49 -07:00
Rahul Frias
0c66866902 Add SRM integration tests
[ Merge of http://go/wvgerrit/30582 ]

Bug: 34285383

Test: WV unit, integration tests, cdm_feature_test.sh

Change-Id: I725150a12a589144e58ab04470d50ba9317a4c46
2017-08-29 12:14:57 -07:00
Adam Stone
c0133bf3a4 Merge "Create two new metric types to simplify metrics." into oc-mr1-dev 2017-08-26 20:26:08 +00:00
John W. Bruce
890f535b06 Silence Version Number Canary
(This is a merge of http://go/wvgerrit/32280)

At the same time as the last version number canary change went in, the
version number for O-MR1 was updated to its final value. Thus, the test
never stopped failing on the dashboard. This patch silences the canary
again. No Widevine version number update is needed, since we already
updated it for O-MR1 in the previous patch.

Bug: 64951985
Test: request_license_test
Change-Id: Idf3c4b96e3f200d08a089bd08afdee8b0fd9dd76
2017-08-24 16:04:38 -07:00
Adam Stone
466ec4e632 Create two new metric types to simplify metrics.
This is part one of a mult-part change to revise some metrics. Several
metrics are currently EventMetric type when they should be a simpler
type.

Test: Added unit tests for the new types. Also, re-ran existing tests.
Verified playback works with Google Play, and re-ran Widevine GTS tests.

Bug: 36220619
Change-Id: I2ec8fc355f66ad4834dd722aacd22541fb9c94ad
2017-08-24 12:19:17 -07:00
Fred Gylys-Colwell
481a1effcb Create new usage header if old one corrupted
Merge of http://go/wvgerrit/31561

If the usage table header is corrupted, or if it is stale, then the
CDM should create a new one.

bug: 64572642

Testing: pushed stale usage table to Fugu, and netflix recovered
gracefully.  New unit test UsageTableHeaderTest.StaleHeader.

Change-Id: Ic66854ff6b0b252a0f4ca20e09f27852a50d6fcc
2017-08-18 15:09:18 -07:00
John W. Bruce
ce9c5f35ac Update Widevine Android Version Number to 5.1.0
(This is a merge from http://go/wvgerrit/31360)

This also updates the version number change canary.

Bug: 64209738
Test: request_license_test
Change-Id: Ibdf27256822a32988a848ef5bf79bf2e2633fd59
2017-08-17 02:42:54 -07:00
TreeHugger Robot
07edf821c4 Merge "Move Watchdog Timer to L3 Init Only" into oc-mr1-dev 2017-08-11 01:27:51 +00:00
Fred Gylys-Colwell
5bb2e55318 Move Watchdog Timer to L3 Init Only
Merge from Widevine repo of http://go/wvgerrit/31340

This CL moves the oemcrypto watchdog timer so that it only watches the
L3 initialization.  This will allow L1 initialization to take more
than 5 seconds if it needs to.

TEST: oemcrypto unit tests, Media GTS tests, Play Movies
b/64069544

Change-Id: I7826e4d72eda52ae8b2c9f8b3ac360fb42cbb115
2017-08-11 01:24:32 +00:00
TreeHugger Robot
21715115bc Merge "Build widevine tests with BOARD_VNDK_VERSION set" into oc-mr1-dev 2017-08-09 02:32:48 +00:00
John Bruce
6dad75e395 Merge "Get System ID From OEM Cert" into oc-mr1-dev 2017-08-07 23:50:21 +00:00
Jiyong Park
853773dd93 Build widevine tests with BOARD_VNDK_VERSION set
The tests are using vendor only libs such as libcdm and libwvlevel3,
thus marked as LOCAL_PROPRIETARY_MODULE to use the libs. In addition,
the dependency to libmedia is changed to libmedia_omx since libmedia is
not available to vendor modules. UniquePtr is replaced with
std::unique_ptr since UniquePtr.h in /libnativehelper is not available
to vendors (and will not be completely removed in a near future).

Bug: 37342627
Test: BOARD_VNDK_VERSION=current m -j tests

Change-Id: I4e9d3267b20c1d52f57664b89f15330e2ebd953d
2017-08-07 16:28:28 +09:00
Yifan Hong
5e8f727b71 Move widevine unit tests to vendor.
Test: BOARD_VNDK_VERSION=current m checkbuild -j
Test: ./build_and_run_all_tests.sh

Bug: 33241851
Change-Id: I97c8fcc84bc19d88e8aa941eb283089c8ecf47d5
2017-08-04 15:26:26 -07:00
John W. Bruce
4d448d8165 Get System ID From OEM Cert
(This is a merge from http://go/wvgerrit/30220)

Previously, extracting the system ID was only supported on Keybox-based
systems. This patch adds support for extracting the system ID from the
OEM Certificate chain on Provisioning 3.0 devices. This is done by
getting the Widevine intermediate cert from the chain, finding the
Widevine System ID extension in that cert, and extracting the value.

The code that does the extraction is separate from any code that calls
OEMCrypto so that it can be unit-tested in isolation. This patch adds a
crypto_session_unittest test to do this unit-testing.

Bug: 34776194
Test: crypto_session_unittest
Change-Id: I3e273968208fb31ae6019ccc383b419625d1ae22
2017-07-26 20:31:39 -07:00
Rahul Frias
59daaa9dd4 Merge "Support provisioning 3.0" into oc-mr1-dev 2017-07-24 05:38:49 +00:00
Rahul Frias
e61259e075 Support provisioning 3.0
[ Merge of http://go/wvgerrit/29004 ]

Enable support for provisioning with OEM certificates as root of
trust.

b/62972441

Test: WV unit/intgration test, cdm_feature_test and GTSMediaTestCases

Change-Id: I30576fc0bb68a873eeaaca03f6b9c89fa6a14327
2017-07-23 18:00:23 +00:00
Jeff Tinker
0d526131b9 Correct watchdog timeout
am: bfef9c5748

Change-Id: I07c5d81ba1289381a12b54a944c206c1845a21d0
2017-07-21 22:11:18 +00:00
Jeff Tinker
bfef9c5748 Correct watchdog timeout
The L3 initialization watchdog was previously configured
for 2 seconds vs 5 seconds as originally intended.

Change-Id: Ie31251ac7a58c11262963ef9cb56d0dc08f5dc5b
related-to-bug:62106796
2017-07-21 12:09:43 -07:00
Fred Gylys-Colwell
08debe83c2 Add watch dog timer to OEMCrypto L3
Merge from Widevine repo of http://go/wvgerrit/29861

This code adds a watchdog timer to the oemcrypto initialization.  If
initialization does not finish within 5 seconds, the process will
abort.

For branch oc-dr1-dev, unlike nyc-mr2-dev, we save a metric indicating
there was a failure.

Testing: see code in patch 1.  Watch dog was forced while using Play
Movies.  The busy spinner spun for at least 5 seconds, but Play Movies
was able to restart itself.

b/62106796

Change-Id: Ib59f5bc4a484eff1dc386e07a4b198ecb713c69b
2017-07-21 10:17:54 -07:00
Fred Gylys-Colwell
a81caa5bf1 Add watch dog timer to OEMCrypto L3 am: e20e909cbd
am: 6de0bd8486

Change-Id: I60c2d5848e4e731b048118fea88b0367e9cf31a3
2017-07-20 01:46:41 +00:00
Fred Gylys-Colwell
e20e909cbd Add watch dog timer to OEMCrypto L3
Merge from Widevine repo of http://go/wvgerrit/29861

This code adds a watchdog timer to the oemcrypto initialization.  If
initialization does not finish within 5 seconds, the process will
abort.

Testing: see code in patch 1.  Watch dog was forced while using Play
Movies.  The busy spinner spun for at least 5 seconds, but Play Movies
was able to restart itself.

b/62106796

Change-Id: Ib59f5bc4a484eff1dc386e07a4b198ecb713c69b
2017-07-19 16:35:46 -07:00