wv hidl: upgrade Drm/Crypto factories to v1.3

Bug: 139134043
Test: MediaDrmTest
Change-Id: I94d1cc8a323c144805d74d5568944dd48ae80e60
This commit is contained in:
Robert Shih
2019-12-02 16:20:13 -08:00
parent 2443fe807a
commit 8fce3e316b
25 changed files with 180 additions and 41 deletions

View File

@@ -66,6 +66,33 @@ LOCAL_VINTF_FRAGMENTS := manifest_android.hardware.drm@1.2-service.widevine.xml
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds android.hardware.drm@1.3-service.widevine
#
include $(CLEAR_VARS)
include $(LOCAL_PATH)/common_widevine_service.mk
LOCAL_SRC_FILES := src_hidl/service.cpp
LOCAL_MODULE := android.hardware.drm@1.3-service.widevine
LOCAL_INIT_RC := src_hidl/android.hardware.drm@1.3-service.widevine.rc
LOCAL_VINTF_FRAGMENTS := manifest_android.hardware.drm@1.3-service.widevine.xml
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds android.hardware.drm@1.3-service-lazy.widevine
#
include $(CLEAR_VARS)
include $(LOCAL_PATH)/common_widevine_service.mk
LOCAL_SRC_FILES := src_hidl/serviceLazy.cpp
LOCAL_MODULE := android.hardware.drm@1.3-service-lazy.widevine
LOCAL_OVERRIDES_MODULES := android.hardware.drm@1.3-service.widevine
LOCAL_INIT_RC := src_hidl/android.hardware.drm@1.3-service-lazy.widevine.rc
LOCAL_VINTF_FRAGMENTS := manifest_android.hardware.drm@1.3-service.widevine.xml
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds libcdm_utils.a
#
@@ -207,6 +234,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
android.hidl.memory@1.0 \
libbase \
libcrypto \

View File

@@ -12,6 +12,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
libbase \
libhidlbase \
liblog \

View File

@@ -7,12 +7,16 @@
#ifndef WV_UUID_H_
#define WV_UUID_H_
#include <stdint.h>
#include <array>
#include <cstdint>
#include <vector>
namespace wvdrm {
bool isWidevineUUID(const uint8_t uuid[16]);
std::vector<std::array<uint8_t, 16>> getSupportedCryptoSchemes();
} // namespace wvdrm
#endif // WV_UUID_H_

View File

@@ -8,12 +8,12 @@
#define HIDL_TYPES_H_
#include <android/hardware/drm/1.1/types.h>
#include <android/hardware/drm/1.2/ICryptoFactory.h>
#include <android/hardware/drm/1.2/ICryptoPlugin.h>
#include <android/hardware/drm/1.2/types.h>
#include <android/hardware/drm/1.2/IDrmFactory.h>
#include <android/hardware/drm/1.2/IDrmPlugin.h>
#include <android/hardware/drm/1.2/IDrmPluginListener.h>
#include <android/hardware/drm/1.3/ICryptoFactory.h>
#include <android/hardware/drm/1.3/IDrmFactory.h>
#include <hidl/HidlTransportSupport.h>
using ::android::hardware::configureRpcThreadpool;
@@ -48,12 +48,12 @@ using drm::V1_1::DrmMetricGroup;
using drm::V1_1::HdcpLevel;
using drm::V1_1::SecureStopRelease;
using drm::V1_1::SecurityLevel;
using drm::V1_2::ICryptoFactory;
using drm::V1_2::ICryptoPlugin;
using drm::V1_2::IDrmFactory;
using drm::V1_2::IDrmPlugin;
using drm::V1_2::KeySetId;
using drm::V1_2::OfflineLicenseState;
using drm::V1_3::ICryptoFactory;
using drm::V1_3::IDrmFactory;
typedef drm::V1_1::KeyRequestType KeyRequestType_V1_1;
typedef drm::V1_2::KeyStatus KeyStatus_V1_2;

View File

@@ -12,7 +12,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
extern "C" {
@@ -21,7 +21,7 @@ extern "C" {
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -13,7 +13,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
struct WVCryptoFactory : public ICryptoFactory {
@@ -34,7 +34,7 @@ struct WVCryptoFactory : public ICryptoFactory {
};
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -14,7 +14,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
struct WVDrmFactory : public IDrmFactory {
@@ -37,6 +37,9 @@ struct WVDrmFactory : public IDrmFactory {
const hidl_string& appPackageName,
createPlugin_cb _hidl_cb) override;
Return<void> getSupportedCryptoSchemes(
getSupportedCryptoSchemes_cb _hidl_cb) override;
private:
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVDrmFactory);
@@ -52,7 +55,7 @@ struct WVDrmFactory : public IDrmFactory {
extern "C" IDrmFactory* HIDL_FETCH_IDrmFactory(const char* name);
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.drm</name>
<transport>hwbinder</transport>
<fqname>@1.3::ICryptoFactory/widevine</fqname>
<fqname>@1.3::IDrmFactory/widevine</fqname>
</hal>
</manifest>

View File

@@ -67,6 +67,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
android.hidl.memory@1.0 \
libcrypto \
libhidlmemory \

View File

@@ -93,6 +93,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
android.hidl.memory@1.0 \
libbase \
libbinder \

View File

@@ -69,6 +69,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
android.hidl.memory@1.0 \
libcrypto \
liblog

View File

@@ -93,6 +93,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
android.hidl.memory@1.0 \
libbinder \
libbase \

View File

@@ -6,23 +6,32 @@
#include "WVUUID.h"
#include <string.h>
#include <array>
#include <cstring>
namespace wvdrm {
bool isWidevineUUID(const uint8_t uuid[16]) {
static const uint8_t kWidevineUUID[16] = {
namespace {
const std::array<uint8_t, 16> kWidevineUUID = {
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
0xA3,0xC8,0x27,0xDC,0xD5,0x1D,0x21,0xED
};
};
static const uint8_t kOldNetflixWidevineUUID[16] = {
const std::array<uint8_t, 16> kOldNetflixWidevineUUID = {
0x29,0x70,0x1F,0xE4,0x3C,0xC7,0x4A,0x34,
0x8C,0x5B,0xAE,0x90,0xC7,0x43,0x9A,0x47
};
};
return !memcmp(uuid, kWidevineUUID, 16) ||
!memcmp(uuid, kOldNetflixWidevineUUID, 16);
}
bool isWidevineUUID(const uint8_t uuid[16]) {
return !memcmp(uuid, kWidevineUUID.data(), 16) ||
!memcmp(uuid, kOldNetflixWidevineUUID.data(), 16);
}
std::vector<std::array<uint8_t, 16>> getSupportedCryptoSchemes() {
return {kWidevineUUID, kOldNetflixWidevineUUID};
}
} // namespace wvdrm

View File

@@ -12,7 +12,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
extern "C" {
@@ -27,7 +27,7 @@ ICryptoFactory* createCryptoFactory() {
} // extern "C"
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -19,9 +19,11 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
using wvdrm::hardware::drm::V1_2::widevine::WVCryptoPlugin;
Return<bool> WVCryptoFactory::isCryptoSchemeSupported(
const hidl_array<uint8_t, 16>& uuid) {
return isWidevineUUID(uuid.data());
@@ -52,7 +54,7 @@ Return<void> WVCryptoFactory::createPlugin(
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -22,9 +22,11 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
using wvdrm::hardware::drm::V1_2::widevine::WVDrmPlugin;
WVGenericCryptoInterface WVDrmFactory::sOemCryptoInterface;
Return<bool> WVDrmFactory::isCryptoSchemeSupported(
@@ -67,7 +69,7 @@ Return<void> WVDrmFactory::createPlugin(
const auto& self = android::hardware::IPCThreadState::self();
const char* sid = self->getCallingSid();
sid = sid ? (strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
ALOGI("[%s] calling %s", sid, __PRETTY_FUNCTION__);
ALOGI("[%s][%s] calling %s", sid, appPackageName.c_str(), __PRETTY_FUNCTION__);
sp<IDrmPlugin> plugin;
if (!isCryptoSchemeSupported(uuid.data())) {
@@ -112,9 +114,17 @@ int32_t WVDrmFactory::firstApiLevel() {
return firstApiLevel;
}
Return<void> WVDrmFactory::getSupportedCryptoSchemes(getSupportedCryptoSchemes_cb _hidl_cb) {
std::vector<hidl_array<uint8_t, 16>> schemes;
for (const auto &scheme : wvdrm::getSupportedCryptoSchemes()) {
schemes.push_back(scheme);
}
_hidl_cb(schemes);
return Void();
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -17,6 +17,7 @@ service vendor.drm-widevine-hal-1-2 /vendor/bin/hw/android.hardware.drm@1.2-serv
interface android.hardware.drm@1.2::ICryptoFactory widevine
interface android.hardware.drm@1.2::IDrmFactory widevine
interface android.hidl.base@1.0::IBase widevine
disabled
class hal
user media
group media mediadrm drmrpc system

View File

@@ -0,0 +1,28 @@
on property:init.svc.mediadrm=running
mkdir /data/vendor/mediadrm 0770 media mediadrm
start vendor.move_data_sh
service vendor.move_data_sh /system/bin/move_widevine_data.sh
class late_start
user media
group media mediadrm system
disabled
oneshot
service vendor.drm-widevine-hal-1-3 /vendor/bin/hw/android.hardware.drm@1.3-service-lazy.widevine
interface android.hardware.drm@1.0::ICryptoFactory widevine
interface android.hardware.drm@1.0::IDrmFactory widevine
interface android.hardware.drm@1.1::ICryptoFactory widevine
interface android.hardware.drm@1.1::IDrmFactory widevine
interface android.hardware.drm@1.2::ICryptoFactory widevine
interface android.hardware.drm@1.2::IDrmFactory widevine
interface android.hardware.drm@1.3::ICryptoFactory widevine
interface android.hardware.drm@1.3::IDrmFactory widevine
interface android.hidl.base@1.0::IBase widevine
oneshot
disabled
class hal
user media
group media mediadrm drmrpc system
ioprio rt 4
writepid /dev/cpuset/foreground/tasks

View File

@@ -0,0 +1,26 @@
on property:init.svc.mediadrm=running
mkdir /data/vendor/mediadrm 0770 media mediadrm
start vendor.move_data_sh
service vendor.move_data_sh /system/bin/move_widevine_data.sh
class late_start
user media
group media mediadrm system
disabled
oneshot
service vendor.drm-widevine-hal-1-3 /vendor/bin/hw/android.hardware.drm@1.3-service.widevine
interface android.hardware.drm@1.0::ICryptoFactory widevine
interface android.hardware.drm@1.0::IDrmFactory widevine
interface android.hardware.drm@1.1::ICryptoFactory widevine
interface android.hardware.drm@1.1::IDrmFactory widevine
interface android.hardware.drm@1.2::ICryptoFactory widevine
interface android.hardware.drm@1.2::IDrmFactory widevine
interface android.hardware.drm@1.3::ICryptoFactory widevine
interface android.hardware.drm@1.3::IDrmFactory widevine
interface android.hidl.base@1.0::IBase widevine
class hal
user media
group media mediadrm drmrpc system
ioprio rt 4
writepid /dev/cpuset/foreground/tasks

View File

@@ -22,8 +22,8 @@
#include "WVCryptoFactory.h"
#include "WVDrmFactory.h"
using wvdrm::hardware::drm::V1_2::widevine::WVCryptoFactory;
using wvdrm::hardware::drm::V1_2::widevine::WVDrmFactory;
using wvdrm::hardware::drm::V1_3::widevine::WVCryptoFactory;
using wvdrm::hardware::drm::V1_3::widevine::WVDrmFactory;
int main(int /* argc */, char** /* argv */) {
sp<IDrmFactory> drmFactory = new WVDrmFactory;

View File

@@ -23,8 +23,8 @@
#include "WVCryptoFactory.h"
#include "WVDrmFactory.h"
using wvdrm::hardware::drm::V1_2::widevine::WVCryptoFactory;
using wvdrm::hardware::drm::V1_2::widevine::WVDrmFactory;
using wvdrm::hardware::drm::V1_3::widevine::WVCryptoFactory;
using wvdrm::hardware::drm::V1_3::widevine::WVDrmFactory;
using android::hardware::LazyServiceRegistrar;
int main(int /* argc */, char** /* argv */) {

View File

@@ -72,6 +72,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hardware.drm@1.2 \
android.hardware.drm@1.3 \
libbase \
libdl \
libhidlbase \

View File

@@ -10,7 +10,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
using ::android::sp;
@@ -32,7 +32,7 @@ TEST(CreatePluginFactoriesTest, CreatesCryptoFactory) {
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -10,10 +10,9 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
using wvdrm::hardware::drm::V1_2::widevine::WVCryptoFactory;
using ::android::sp;
const uint8_t kWidevineUUID[16] = {
@@ -49,7 +48,7 @@ TEST(WVCryptoFactoryTest, DoesNotSupportUnsupportedCryptoSchemes) {
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm

View File

@@ -13,7 +13,7 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_2 {
namespace V1_3 {
namespace widevine {
using namespace android;
@@ -144,7 +144,7 @@ TEST(WVDrmFactoryTest, CalculatesBlankAppPackageNamePermissibilityCorrectly) {
}
} // namespace widevine
} // namespace V1_2
} // namespace V1_3
} // namespace drm
} // namespace hardware
} // namespace wvdrm