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
This commit is contained in:
Rahul Frias
2017-09-22 13:27:10 -07:00
parent 20eeb1e546
commit be9aba6d3a
2 changed files with 421 additions and 0 deletions

View File

@@ -403,6 +403,8 @@ int64_t PolicyEngine::GetLicenseOrRentalDurationRemaining(
if (license_expiry_time == NEVER_EXPIRES) return LLONG_MAX;
if (license_expiry_time < current_time) return 0;
const int64_t policy_license_duration = policy_.license_duration_seconds();
if (policy_license_duration == NEVER_EXPIRES)
return license_expiry_time - current_time;
return std::min(license_expiry_time - current_time, policy_license_duration);
}