[ Merge of http://go/wvgerrit/89383 ] Bug: 134787536 Test: check calling sid in logs Change-Id: If47ccaf9296a157b72181fb2bd00318bb957c15c
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
//
|
|
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
//
|
|
|
|
//#define LOG_NDEBUG 0
|
|
#define LOG_TAG "WVCryptoFactory"
|
|
#include <utils/Log.h>
|
|
#include <hwbinder/IPCThreadState.h>
|
|
|
|
#include "WVCryptoFactory.h"
|
|
|
|
#include "HidlTypes.h"
|
|
#include "WVCDMSingleton.h"
|
|
#include "WVCryptoPlugin.h"
|
|
#include "WVUUID.h"
|
|
|
|
namespace wvdrm {
|
|
namespace hardware {
|
|
namespace drm {
|
|
namespace V1_2 {
|
|
namespace widevine {
|
|
|
|
Return<bool> WVCryptoFactory::isCryptoSchemeSupported(
|
|
const hidl_array<uint8_t, 16>& uuid) {
|
|
return isWidevineUUID(uuid.data());
|
|
}
|
|
|
|
Return<void> WVCryptoFactory::createPlugin(
|
|
const hidl_array<uint8_t, 16>& uuid,
|
|
const hidl_vec<uint8_t>& initData,
|
|
createPlugin_cb _hidl_cb) {
|
|
|
|
const auto& self = android::hardware::IPCThreadState::self();
|
|
const char* sid = self->getCallingSid();
|
|
sid = strstr(sid, "mediadrmserver") ? sid : (sid ? "app" : "nullptr");
|
|
ALOGI("%s: calling sid [%s]", __func__, sid);
|
|
|
|
sp<ICryptoPlugin> plugin;
|
|
if (!isCryptoSchemeSupported(uuid.data())) {
|
|
ALOGE("Widevine Drm HAL: failed to create crypto plugin, " \
|
|
"invalid crypto scheme");
|
|
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, plugin);
|
|
return Void();
|
|
}
|
|
|
|
plugin = new WVCryptoPlugin(initData.data(), initData.size(), getCDM());
|
|
android::hardware::setRequestingSid(plugin, true);
|
|
_hidl_cb(Status::OK, plugin);
|
|
return Void();
|
|
}
|
|
|
|
} // namespace widevine
|
|
} // namespace V1_2
|
|
} // namespace drm
|
|
} // namespace hardware
|
|
} // namespace wvdrm
|