Part of fix for bug 4371230.

Differentiate native and Java listeners based on the 0x100 bit of unique ID.

Change-Id: I68531947e5fd3ccc702aa6a7590311fdfd89b0f3
This commit is contained in:
Gloria Wang
2011-07-21 14:33:20 -07:00
parent ba2fd8b297
commit 025ab6a4dc

View File

@@ -112,7 +112,13 @@ status_t WVMDrmPlugin::onTerminate(int uniqueId) {
* Register a callback to be invoked when the caller required to
* receive necessary information
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] uniqueId Unique identifier for a session. uniqueId is a random
* number generated in the DRM service. If the DrmManagerClient
* is created in native code, uniqueId will be a number ranged
* from 0x1000 to 0x1fff. If it comes from Java code, the uniqueId
* will be a number ranged from 0x00 to 0xfff. So bit 0x1000 in
* uniqueId could be used in DRM plugins to differentiate native
* OnInfoListener and Java OnInfoListener.
* @param[in] infoListener Listener
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
@@ -124,8 +130,8 @@ status_t WVMDrmPlugin::onSetOnInfoListener(
Listener newListener = Listener(const_cast<IDrmEngine::OnInfoListener *>(infoListener), uniqueId);
bool found = false;
const int maxNativeUniqueId = 100;
if (uniqueId <= maxNativeUniqueId) {
const int nativeUniqueIdFlag = 0x1000;
if (uniqueId & nativeUniqueIdFlag) {
// Replace old listener for this id if it exists
for (size_t i = 0; i < sNativeListeners->size(); i++) {
if ((*sNativeListeners)[i].GetUniqueId() == uniqueId) {