Bug fixes of DRM framework.
- Add death listener to clean-up drmserver appropriately when drmserver died. - Remove "static" declaration of mUniqueIdVector because it was not needed to be static variable. - Remove "class DrmContentIds;" because the class does not exist. - contentPath in saveRights() could be empty because it is not required by some DRM schemes. - Fix naming convention to use sXXX for static variables. - Fix typo Change-Id: I7d440488fc074c200f1009d1bafafeffebd690b2
This commit is contained in:
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
Vector<int> DrmManager::mUniqueIdVector;
|
|
||||||
const String8 DrmManager::EMPTY_STRING("");
|
const String8 DrmManager::EMPTY_STRING("");
|
||||||
|
|
||||||
DrmManager::DrmManager() :
|
DrmManager::DrmManager() :
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ using namespace android;
|
|||||||
|
|
||||||
#define INVALID_VALUE -1
|
#define INVALID_VALUE -1
|
||||||
|
|
||||||
Mutex DrmManagerClientImpl::mMutex;
|
Mutex DrmManagerClientImpl::sMutex;
|
||||||
sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService;
|
sp<IDrmManagerService> DrmManagerClientImpl::sDrmManagerService;
|
||||||
|
sp<DrmManagerClientImpl::DeathNotifier> DrmManagerClientImpl::sDeathNotifier;
|
||||||
const String8 DrmManagerClientImpl::EMPTY_STRING("");
|
const String8 DrmManagerClientImpl::EMPTY_STRING("");
|
||||||
|
|
||||||
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
|
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
|
||||||
@@ -47,8 +48,8 @@ void DrmManagerClientImpl::remove(int uniqueId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
|
const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
|
||||||
mMutex.lock();
|
Mutex::Autolock lock(sMutex);
|
||||||
if (NULL == mDrmManagerService.get()) {
|
if (NULL == sDrmManagerService.get()) {
|
||||||
sp<IServiceManager> sm = defaultServiceManager();
|
sp<IServiceManager> sm = defaultServiceManager();
|
||||||
sp<IBinder> binder;
|
sp<IBinder> binder;
|
||||||
do {
|
do {
|
||||||
@@ -62,11 +63,13 @@ const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
|
|||||||
reqt.tv_nsec = 500000000; //0.5 sec
|
reqt.tv_nsec = 500000000; //0.5 sec
|
||||||
nanosleep(&reqt, NULL);
|
nanosleep(&reqt, NULL);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
if (NULL == sDeathNotifier.get()) {
|
||||||
mDrmManagerService = interface_cast<IDrmManagerService>(binder);
|
sDeathNotifier = new DeathNotifier();
|
||||||
}
|
}
|
||||||
mMutex.unlock();
|
binder->linkToDeath(sDeathNotifier);
|
||||||
return mDrmManagerService;
|
sDrmManagerService = interface_cast<IDrmManagerService>(binder);
|
||||||
|
}
|
||||||
|
return sDrmManagerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmManagerClientImpl::addClient(int uniqueId) {
|
void DrmManagerClientImpl::addClient(int uniqueId) {
|
||||||
@@ -143,12 +146,9 @@ DrmInfo* DrmManagerClientImpl::acquireDrmInfo(
|
|||||||
status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
|
status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
|
||||||
const String8& rightsPath, const String8& contentPath) {
|
const String8& rightsPath, const String8& contentPath) {
|
||||||
status_t status = DRM_ERROR_UNKNOWN;
|
status_t status = DRM_ERROR_UNKNOWN;
|
||||||
if (EMPTY_STRING != contentPath) {
|
return getDrmManagerService()->saveRights(
|
||||||
status = getDrmManagerService()->saveRights(
|
|
||||||
uniqueId, drmRights, rightsPath, contentPath);
|
uniqueId, drmRights, rightsPath, contentPath);
|
||||||
}
|
}
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
String8 DrmManagerClientImpl::getOriginalMimeType(
|
String8 DrmManagerClientImpl::getOriginalMimeType(
|
||||||
int uniqueId, const String8& path) {
|
int uniqueId, const String8& path) {
|
||||||
@@ -336,3 +336,16 @@ status_t DrmManagerClientImpl::notify(const DrmInfoEvent& event) {
|
|||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrmManagerClientImpl::DeathNotifier::~DeathNotifier() {
|
||||||
|
Mutex::Autolock lock(sMutex);
|
||||||
|
if (NULL != sDrmManagerService.get()) {
|
||||||
|
sDrmManagerService->asBinder()->unlinkToDeath(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmManagerClientImpl::DeathNotifier::binderDied(const wp<IBinder>& who) {
|
||||||
|
Mutex::Autolock lock(sMutex);
|
||||||
|
DrmManagerClientImpl::sDrmManagerService.clear();
|
||||||
|
LOGW("DrmManager server died!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class IDrmManager;
|
|||||||
class DrmRegistrationInfo;
|
class DrmRegistrationInfo;
|
||||||
class DrmUnregistrationInfo;
|
class DrmUnregistrationInfo;
|
||||||
class DrmRightsAcquisitionInfo;
|
class DrmRightsAcquisitionInfo;
|
||||||
class DrmContentIds;
|
|
||||||
class DrmConstraints;
|
class DrmConstraints;
|
||||||
class DrmMetadata;
|
class DrmMetadata;
|
||||||
class DrmRights;
|
class DrmRights;
|
||||||
@@ -141,7 +140,7 @@ private:
|
|||||||
bool canHandle(int uniqueId, const String8& path);
|
bool canHandle(int uniqueId, const String8& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Vector<int> mUniqueIdVector;
|
Vector<int> mUniqueIdVector;
|
||||||
static const String8 EMPTY_STRING;
|
static const String8 EMPTY_STRING;
|
||||||
|
|
||||||
int mDecryptSessionId;
|
int mDecryptSessionId;
|
||||||
|
|||||||
@@ -407,9 +407,17 @@ private:
|
|||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
sp<DrmManagerClient::OnInfoListener> mOnInfoListener;
|
sp<DrmManagerClient::OnInfoListener> mOnInfoListener;
|
||||||
|
|
||||||
|
class DeathNotifier: public IBinder::DeathRecipient {
|
||||||
|
public:
|
||||||
|
DeathNotifier() {}
|
||||||
|
virtual ~DeathNotifier();
|
||||||
|
virtual void binderDied(const wp<IBinder>& who);
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Mutex mMutex;
|
static Mutex sMutex;
|
||||||
static sp<IDrmManagerService> mDrmManagerService;
|
static sp<DeathNotifier> sDeathNotifier;
|
||||||
|
static sp<IDrmManagerService> sDrmManagerService;
|
||||||
static const sp<IDrmManagerService>& getDrmManagerService();
|
static const sp<IDrmManagerService>& getDrmManagerService();
|
||||||
static const String8 EMPTY_STRING;
|
static const String8 EMPTY_STRING;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
class DrmContentIds;
|
|
||||||
class DrmConstraints;
|
class DrmConstraints;
|
||||||
class DrmMetadata;
|
class DrmMetadata;
|
||||||
class DrmRights;
|
class DrmRights;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
class DrmContentIds;
|
|
||||||
class DrmConstraints;
|
class DrmConstraints;
|
||||||
class DrmMetadata;
|
class DrmMetadata;
|
||||||
class DrmRights;
|
class DrmRights;
|
||||||
|
|||||||
Reference in New Issue
Block a user