Generate renewal and expiry events
The android timer class was not generating timer events correctly. This caused renewal and expiration events not to be sent. A strong pointer to the timer thread was not held and this caused the android util timer thread to exit after firing once. This is now addressed. Bug: 8736545 Merge of https://widevine-internal-review.googlesource.com/#/c/5353/ from the Widevine CDM repository. Change-Id: I2d904e55d4d10eacc1a51f1c6b5c1a267c92c8d8
This commit is contained in:
@@ -34,7 +34,7 @@ class Timer {
|
||||
Timer();
|
||||
~Timer();
|
||||
|
||||
void Start(TimerHandler *handler, uint32_t time_in_secs);
|
||||
bool Start(TimerHandler *handler, uint32_t time_in_secs);
|
||||
void Stop();
|
||||
bool IsRunning();
|
||||
|
||||
|
||||
@@ -101,6 +101,8 @@ CdmResponseType CdmEngine::CloseSession(const CdmSessionId& session_id) {
|
||||
}
|
||||
|
||||
sessions_.erase(session_id);
|
||||
if (sessions_.size() == 0)
|
||||
DisablePolicyTimer();
|
||||
iter->second->DestroySession();
|
||||
delete iter->second;
|
||||
return NO_ERROR;
|
||||
|
||||
54
libwvdrmengine/cdm/core/test/timer_unittest.cpp
Normal file
54
libwvdrmengine/cdm/core/test/timer_unittest.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "timer.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class TestTimerHandler : public TimerHandler {
|
||||
public:
|
||||
TestTimerHandler() : timer_events_(0) {};
|
||||
virtual ~TestTimerHandler() {};
|
||||
|
||||
virtual void OnTimerEvent() {
|
||||
timer_events_++;
|
||||
}
|
||||
|
||||
uint32_t GetTimerEvents() { return timer_events_; }
|
||||
void ResetTimerEvents() { timer_events_ = 0; }
|
||||
|
||||
private:
|
||||
uint32_t timer_events_;
|
||||
};
|
||||
|
||||
TEST(TimerTest, ParametersCheck) {
|
||||
Timer timer;
|
||||
EXPECT_FALSE(timer.Start(NULL, 10));
|
||||
|
||||
TestTimerHandler handler;
|
||||
EXPECT_FALSE(timer.Start(&handler, 0));
|
||||
}
|
||||
|
||||
TEST(TimerTest, TimerCheck) {
|
||||
TestTimerHandler handler;
|
||||
Timer timer;
|
||||
uint32_t duration = 10;
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(0), handler.GetTimerEvents());
|
||||
EXPECT_FALSE(timer.IsRunning());
|
||||
|
||||
EXPECT_TRUE(timer.Start(&handler, 1));
|
||||
EXPECT_TRUE(timer.IsRunning());
|
||||
sleep(duration);
|
||||
|
||||
EXPECT_TRUE(duration-1 <= handler.GetTimerEvents());
|
||||
EXPECT_TRUE(handler.GetTimerEvents() <= duration+1);
|
||||
timer.Stop();
|
||||
EXPECT_FALSE(timer.IsRunning());
|
||||
sleep(duration);
|
||||
|
||||
EXPECT_TRUE(duration-1 <= handler.GetTimerEvents());
|
||||
EXPECT_TRUE(handler.GetTimerEvents() <= duration+1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user