diff options
Diffstat (limited to 'drm')
51 files changed, 569 insertions, 1783 deletions
diff --git a/drm/common/Android.bp b/drm/common/Android.bp new file mode 100644 index 0000000000..0098c89630 --- /dev/null +++ b/drm/common/Android.bp @@ -0,0 +1,39 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_static { + name: "libdrmframeworkcommon", + + srcs: [ + "DrmConstraints.cpp", + "DrmMetadata.cpp", + "DrmConvertedStatus.cpp", + "DrmEngineBase.cpp", + "DrmInfo.cpp", + "DrmInfoRequest.cpp", + "DrmInfoStatus.cpp", + "DrmRights.cpp", + "DrmSupportInfo.cpp", + "IDrmManagerService.cpp", + "IDrmServiceListener.cpp", + "DrmInfoEvent.cpp", + "ReadWriteUtils.cpp", + ], + + static_libs: ["libbinder"], + + export_include_dirs: ["include"], +} diff --git a/drm/common/Android.mk b/drm/common/Android.mk deleted file mode 100644 index ca3d2cd7fb..0000000000 --- a/drm/common/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - DrmConstraints.cpp \ - DrmMetadata.cpp \ - DrmConvertedStatus.cpp \ - DrmEngineBase.cpp \ - DrmInfo.cpp \ - DrmInfoRequest.cpp \ - DrmInfoStatus.cpp \ - DrmRights.cpp \ - DrmSupportInfo.cpp \ - IDrmManagerService.cpp \ - IDrmServiceListener.cpp \ - DrmInfoEvent.cpp \ - ReadWriteUtils.cpp - -LOCAL_STATIC_LIBRARIES := libbinder - -LOCAL_C_INCLUDES := \ - $(TOP)/frameworks/av/include \ - $(TOP)/frameworks/av/drm/libdrmframework/include \ - $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include - -LOCAL_MODULE:= libdrmframeworkcommon - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/common/include/DrmEngineBase.h index 417107f1bd..417107f1bd 100644 --- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h +++ b/drm/common/include/DrmEngineBase.h diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/common/include/IDrmEngine.h index acc8ed9433..acc8ed9433 100644 --- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h +++ b/drm/common/include/IDrmEngine.h diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/common/include/IDrmManagerService.h index 0376b492d8..0376b492d8 100644 --- a/drm/libdrmframework/include/IDrmManagerService.h +++ b/drm/common/include/IDrmManagerService.h diff --git a/drm/libdrmframework/include/IDrmServiceListener.h b/drm/common/include/IDrmServiceListener.h index 78c5d1a34f..78c5d1a34f 100644 --- a/drm/libdrmframework/include/IDrmServiceListener.h +++ b/drm/common/include/IDrmServiceListener.h diff --git a/drm/libdrmframework/include/ReadWriteUtils.h b/drm/common/include/ReadWriteUtils.h index 529b342457..529b342457 100644 --- a/drm/libdrmframework/include/ReadWriteUtils.h +++ b/drm/common/include/ReadWriteUtils.h diff --git a/drm/drmserver/Android.bp b/drm/drmserver/Android.bp new file mode 100644 index 0000000000..c25a0a172f --- /dev/null +++ b/drm/drmserver/Android.bp @@ -0,0 +1,46 @@ +// +// Copyright (C) 2010 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. +// + +cc_binary { + name: "drmserver", + + srcs: [ + "main_drmserver.cpp", + "DrmManager.cpp", + "DrmManagerService.cpp", + ], + + shared_libs: [ + "libmedia", + "libutils", + "liblog", + "libbinder", + "libdl", + "libselinux", + ], + + static_libs: ["libdrmframeworkcommon"], + + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + + compile_multilib: "32", + + init_rc: ["drmserver.rc"], +} diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk deleted file mode 100644 index 3b8bb04e0d..0000000000 --- a/drm/drmserver/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - main_drmserver.cpp \ - DrmManager.cpp \ - DrmManagerService.cpp - -LOCAL_SHARED_LIBRARIES := \ - libmedia \ - libutils \ - liblog \ - libbinder \ - libdl \ - libselinux - -LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon - -LOCAL_C_INCLUDES := \ - $(TOP)/frameworks/av/include \ - $(TOP)/frameworks/av/drm/libdrmframework/include \ - $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include - -LOCAL_CFLAGS += -Wall -Wextra -Werror - -LOCAL_MODULE:= drmserver - -LOCAL_MODULE_TAGS := optional - -LOCAL_32_BIT_ONLY := true - -LOCAL_INIT_RC := drmserver.rc - -include $(BUILD_EXECUTABLE) diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/drmserver/DrmManager.h index e7cdd36b76..e7cdd36b76 100644 --- a/drm/libdrmframework/include/DrmManager.h +++ b/drm/drmserver/DrmManager.h diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/drmserver/DrmManagerService.h index 45cee2e203..45cee2e203 100644 --- a/drm/libdrmframework/include/DrmManagerService.h +++ b/drm/drmserver/DrmManagerService.h diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/drmserver/PlugInManager.h index 466844d8ee..466844d8ee 100644 --- a/drm/libdrmframework/include/PlugInManager.h +++ b/drm/drmserver/PlugInManager.h diff --git a/drm/libdrmframework/Android.bp b/drm/libdrmframework/Android.bp new file mode 100644 index 0000000000..43ba72bcb3 --- /dev/null +++ b/drm/libdrmframework/Android.bp @@ -0,0 +1,42 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_shared { + name: "libdrmframework", + + srcs: [ + "DrmManagerClientImpl.cpp", + "DrmManagerClient.cpp", + "NoOpDrmManagerClientImpl.cpp", + ], + + shared_libs: [ + "libutils", + "libcutils", + "liblog", + "libbinder", + "libdl", + ], + + static_libs: ["libdrmframeworkcommon"], + + export_include_dirs: ["include"], + export_static_lib_headers: ["libdrmframeworkcommon"], + + cflags: ["-Werror"], +} + +subdirs = ["plugins/*"] diff --git a/drm/libdrmframework/Android.mk b/drm/libdrmframework/Android.mk deleted file mode 100644 index cafcb9419f..0000000000 --- a/drm/libdrmframework/Android.mk +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - DrmManagerClientImpl.cpp \ - DrmManagerClient.cpp \ - NoOpDrmManagerClientImpl.cpp - -LOCAL_MODULE:= libdrmframework - -LOCAL_SHARED_LIBRARIES := \ - libutils \ - libcutils \ - liblog \ - libbinder \ - libdl - -LOCAL_STATIC_LIBRARIES := \ - libdrmframeworkcommon - -LOCAL_C_INCLUDES += \ - $(TOP)/frameworks/av/drm/libdrmframework/include \ - $(TOP)/frameworks/av/include - -LOCAL_CFLAGS += -Werror - - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/drm/libdrmframework/plugins/Android.mk b/drm/libdrmframework/plugins/Android.mk deleted file mode 100644 index 9ee79618c2..0000000000 --- a/drm/libdrmframework/plugins/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright (C) 2010 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. -# -include $(call all-subdir-makefiles) diff --git a/drm/libdrmframework/plugins/common/Android.bp b/drm/libdrmframework/plugins/common/Android.bp new file mode 100644 index 0000000000..213e57f859 --- /dev/null +++ b/drm/libdrmframework/plugins/common/Android.bp @@ -0,0 +1 @@ +subdirs = ["util"] diff --git a/drm/libdrmframework/plugins/common/Android.mk b/drm/libdrmframework/plugins/common/Android.mk deleted file mode 100644 index 9ee79618c2..0000000000 --- a/drm/libdrmframework/plugins/common/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright (C) 2010 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. -# -include $(call all-subdir-makefiles) diff --git a/drm/libdrmframework/plugins/common/util/Android.bp b/drm/libdrmframework/plugins/common/util/Android.bp new file mode 100644 index 0000000000..0c0b6f26fa --- /dev/null +++ b/drm/libdrmframework/plugins/common/util/Android.bp @@ -0,0 +1,23 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_static { + name: "libdrmutility", + + srcs: ["src/MimeTypeUtil.cpp"], + + export_include_dirs: ["include"], +} diff --git a/drm/libdrmframework/plugins/common/util/Android.mk b/drm/libdrmframework/plugins/common/util/Android.mk deleted file mode 100644 index 2a7b01fdd9..0000000000 --- a/drm/libdrmframework/plugins/common/util/Android.mk +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - src/MimeTypeUtil.cpp - -LOCAL_MODULE := libdrmutility - -base := frameworks/av - -LOCAL_C_INCLUDES += \ - $(base)/include \ - $(base)/include/drm \ - $(base)/include/drm/plugins \ - $(LOCAL_PATH)/include - - -ifneq ($(TARGET_BUILD_VARIANT),user) -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/tools - -endif - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) diff --git a/drm/libdrmframework/plugins/forward-lock/Android.bp b/drm/libdrmframework/plugins/forward-lock/Android.bp new file mode 100644 index 0000000000..f884c14986 --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/Android.bp @@ -0,0 +1,4 @@ +subdirs = [ + "FwdLockEngine", + "internal-format", +] diff --git a/drm/libdrmframework/plugins/forward-lock/Android.mk b/drm/libdrmframework/plugins/forward-lock/Android.mk deleted file mode 100644 index 9ee79618c2..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright (C) 2010 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. -# -include $(call all-subdir-makefiles) diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp new file mode 100644 index 0000000000..3f0f5f78e0 --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp @@ -0,0 +1,50 @@ +// +// Copyright (C) 2010 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 +//2 +// 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. +// + +cc_library_shared { + name: "libfwdlockengine", + + cflags: [ + "-DUSE_64BIT_DRM_API", + // The flag below turns on local debug printouts + //"-DDRM_OMA_FL_ENGINE_DEBUG", + ], + + srcs: ["src/FwdLockEngine.cpp"], + + shared_libs: [ + "libicui18n", + "libicuuc", + "libutils", + "liblog", + "libdl", + "libcrypto", + "libssl", + "libdrmframework", + ], + + static_libs: [ + "libdrmutility", + "libdrmframeworkcommon", + "libfwdlock-common", + "libfwdlock-converter", + "libfwdlock-decoder", + ], + + local_include_dirs: ["include"], + + relative_install_path: "drm", +} diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk deleted file mode 100644 index 933464ff56..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# The flag below turns on local debug printouts -#LOCAL_CFLAGS += -DDRM_OMA_FL_ENGINE_DEBUG - -base := frameworks/av - -# Determine whether the DRM framework uses 64-bit data types for file offsets and do the same. -ifneq ($(shell grep -c 'off64_t offset' $(base)/drm/libdrmframework/plugins/common/include/IDrmEngine.h), 0) -LOCAL_CFLAGS += -DUSE_64BIT_DRM_API -endif - -LOCAL_SRC_FILES:= \ - src/FwdLockEngine.cpp - -LOCAL_MODULE := libfwdlockengine - -LOCAL_SHARED_LIBRARIES := \ - libicui18n \ - libicuuc \ - libutils \ - liblog \ - libdl \ - libcrypto \ - libssl \ - libdrmframework - -LOCAL_STATIC_LIBRARIES := \ - libdrmutility \ - libdrmframeworkcommon \ - libfwdlock-common \ - libfwdlock-converter \ - libfwdlock-decoder - - - -LOCAL_C_INCLUDES += \ - $(base)/include/drm \ - $(base)/drm/libdrmframework/plugins/common/include \ - $(base)/drm/libdrmframework/plugins/common/util/include \ - $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/common \ - $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/converter \ - $(base)/drm/libdrmframework/plugins/forward-lock/internal-format/decoder \ - $(LOCAL_PATH)/include - -LOCAL_MODULE_RELATIVE_PATH := drm - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h index d222703497..a571b3aa1f 100644 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h @@ -18,14 +18,14 @@ #define __FWDLOCKENGINE_H__ #include <DrmEngineBase.h> -#include <DrmConstraints.h> -#include <DrmRights.h> -#include <DrmInfo.h> -#include <DrmInfoStatus.h> -#include <DrmConvertedStatus.h> -#include <DrmInfoRequest.h> -#include <DrmSupportInfo.h> -#include <DrmInfoEvent.h> +#include <drm/DrmConstraints.h> +#include <drm/DrmRights.h> +#include <drm/DrmInfo.h> +#include <drm/DrmInfoStatus.h> +#include <drm/DrmConvertedStatus.h> +#include <drm/DrmInfoRequest.h> +#include <drm/DrmSupportInfo.h> +#include <drm/DrmInfoEvent.h> #include "SessionMap.h" #include "FwdLockConv.h" diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp index a495616a38..830def931c 100644 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp @@ -20,17 +20,17 @@ #include <errno.h> #include <stdio.h> #include <unistd.h> -#include "drm_framework_common.h" +#include <drm/drm_framework_common.h> #include <fcntl.h> #include <limits.h> -#include <DrmRights.h> -#include <DrmConstraints.h> -#include <DrmMetadata.h> -#include <DrmInfo.h> -#include <DrmInfoStatus.h> -#include <DrmInfoRequest.h> -#include <DrmSupportInfo.h> -#include <DrmConvertedStatus.h> +#include <drm/DrmRights.h> +#include <drm/DrmConstraints.h> +#include <drm/DrmMetadata.h> +#include <drm/DrmInfo.h> +#include <drm/DrmInfoStatus.h> +#include <drm/DrmInfoRequest.h> +#include <drm/DrmSupportInfo.h> +#include <drm/DrmConvertedStatus.h> #include <utils/String8.h> #include "FwdLockConv.h" #include "FwdLockFile.h" diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp new file mode 100644 index 0000000000..9f58e264fd --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.bp @@ -0,0 +1,5 @@ +subdirs = [ + "common", + "converter", + "decoder", +] diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk deleted file mode 100644 index 9ee79618c2..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/internal-format/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright (C) 2010 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. -# -include $(call all-subdir-makefiles) diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp new file mode 100644 index 0000000000..698f278058 --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.bp @@ -0,0 +1,25 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_static { + name: "libfwdlock-common", + + srcs: ["FwdLockGlue.c"], + + shared_libs: ["libcrypto"], + + export_include_dirs: ["."], +} diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk deleted file mode 100644 index 3b4c8b4c36..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/internal-format/common/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - FwdLockGlue.c - -LOCAL_SHARED_LIBRARIES := libcrypto - -LOCAL_MODULE := libfwdlock-common - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp new file mode 100644 index 0000000000..33f2fe0702 --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_static { + name: "libfwdlock-converter", + + srcs: ["FwdLockConv.c"], + + shared_libs: ["libcrypto"], + static_libs: ["libfwdlock-common"], + + export_include_dirs: ["."], +} diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk deleted file mode 100644 index 2f51f0c90c..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - FwdLockConv.c - -LOCAL_C_INCLUDES := \ - frameworks/av/drm/libdrmframework/plugins/forward-lock/internal-format/common - -LOCAL_SHARED_LIBRARIES := libcrypto - -LOCAL_MODULE := libfwdlock-converter - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp new file mode 100644 index 0000000000..b6d7a06e84 --- /dev/null +++ b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_static { + name: "libfwdlock-decoder", + + srcs: ["FwdLockFile.c"], + + shared_libs: ["libcrypto"], + static_libs: ["libfwdlock-common"], + + export_include_dirs: ["."], +} diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk deleted file mode 100644 index 3399ae5641..0000000000 --- a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - FwdLockFile.c - -LOCAL_C_INCLUDES := \ - frameworks/av/drm/libdrmframework/plugins/forward-lock/internal-format/common - -LOCAL_SHARED_LIBRARIES := libcrypto - -LOCAL_MODULE := libfwdlock-decoder - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) diff --git a/drm/libdrmframework/plugins/passthru/Android.bp b/drm/libdrmframework/plugins/passthru/Android.bp new file mode 100644 index 0000000000..1dcf89cc07 --- /dev/null +++ b/drm/libdrmframework/plugins/passthru/Android.bp @@ -0,0 +1,36 @@ +// +// Copyright (C) 2010 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. +// + +cc_library_shared { + name: "libdrmpassthruplugin", + + srcs: ["src/DrmPassthruPlugIn.cpp"], + + static_libs: ["libdrmframeworkcommon"], + + shared_libs: [ + "libutils", + "liblog", + "libdl", + ], + + local_include_dirs: ["include"], + + cflags: [ + // Set the following flag to enable the decryption passthru flow + //"-DENABLE_PASSTHRU_DECRYPTION", + ], +} diff --git a/drm/libdrmframework/plugins/passthru/Android.mk b/drm/libdrmframework/plugins/passthru/Android.mk deleted file mode 100644 index cb3a2e2374..0000000000 --- a/drm/libdrmframework/plugins/passthru/Android.mk +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (C) 2010 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. -# -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - src/DrmPassthruPlugIn.cpp - -LOCAL_MODULE := libdrmpassthruplugin - -LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon - -LOCAL_SHARED_LIBRARIES := \ - libutils \ - liblog \ - libdl - - -LOCAL_C_INCLUDES += \ - $(TOP)/frameworks/av/drm/libdrmframework/include \ - $(TOP)/frameworks/av/drm/libdrmframework/plugins/passthru/include \ - $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include \ - $(TOP)/frameworks/av/include - -# Set the following flag to enable the decryption passthru flow -#LOCAL_CFLAGS += -DENABLE_PASSTHRU_DECRYPTION - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp index 7f5b0ec0dd..d7f2d287c0 100644 --- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp +++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp @@ -245,6 +245,8 @@ status_t DrmPassthruPlugIn::onOpenDecryptSession( decryptHandle->status = DRM_NO_ERROR; decryptHandle->decryptInfo = NULL; return DRM_NO_ERROR; +#else + (void)(decryptHandle); // unused #endif return DRM_ERROR_CANNOT_HANDLE; diff --git a/drm/libmediadrm/Android.bp b/drm/libmediadrm/Android.bp new file mode 100644 index 0000000000..66f5fc24ce --- /dev/null +++ b/drm/libmediadrm/Android.bp @@ -0,0 +1,51 @@ +// +// libmediadrm +// + +cc_library_shared { + name: "libmediadrm", + + aidl: { + local_include_dirs: ["aidl"], + export_aidl_headers: true, + }, + + srcs: [ + "aidl/android/media/ICas.aidl", + "aidl/android/media/ICasListener.aidl", + "aidl/android/media/IDescrambler.aidl", + "aidl/android/media/IMediaCasService.aidl", + + "CasImpl.cpp", + "DescramblerImpl.cpp", + "DrmPluginPath.cpp", + "DrmSessionManager.cpp", + "ICrypto.cpp", + "IDrm.cpp", + "IDrmClient.cpp", + "IMediaDrmService.cpp", + "MediaCasDefs.cpp", + "SharedLibrary.cpp", + "DrmHal.cpp", + "CryptoHal.cpp", + ], + + shared_libs: [ + "libbinder", + "libcutils", + "libdl", + "liblog", + "libmediautils", + "libstagefright_foundation", + "libutils", + "android.hardware.drm@1.0", + "libhidlbase", + "libhidlmemory", + "libhidltransport", + ], + + cflags: [ + "-Werror", + "-Wall", + ], +} diff --git a/drm/libmediadrm/Android.mk b/drm/libmediadrm/Android.mk deleted file mode 100644 index 5b56501a7b..0000000000 --- a/drm/libmediadrm/Android.mk +++ /dev/null @@ -1,62 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -# -# libmediadrm -# - -include $(CLEAR_VARS) - -LOCAL_AIDL_INCLUDES := \ - frameworks/av/drm/libmediadrm/aidl - -LOCAL_SRC_FILES := \ - aidl/android/media/ICas.aidl \ - aidl/android/media/ICasListener.aidl \ - aidl/android/media/IDescrambler.aidl \ - aidl/android/media/IMediaCasService.aidl \ - -LOCAL_SRC_FILES += \ - CasImpl.cpp \ - DescramblerImpl.cpp \ - DrmPluginPath.cpp \ - DrmSessionManager.cpp \ - ICrypto.cpp \ - IDrm.cpp \ - IDrmClient.cpp \ - IMediaDrmService.cpp \ - MediaCasDefs.cpp \ - SharedLibrary.cpp -ifneq ($(DISABLE_TREBLE_DRM), true) -LOCAL_SRC_FILES += \ - DrmHal.cpp \ - CryptoHal.cpp -else -LOCAL_SRC_FILES += \ - Drm.cpp \ - Crypto.cpp -endif - -LOCAL_SHARED_LIBRARIES := \ - libbinder \ - libcutils \ - libdl \ - liblog \ - libmediautils \ - libstagefright_foundation \ - libutils -ifneq ($(DISABLE_TREBLE_DRM), true) -LOCAL_SHARED_LIBRARIES += \ - android.hidl.base@1.0 \ - android.hardware.drm@1.0 \ - libhidlbase \ - libhidlmemory \ - libhidltransport -endif - -LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall - -LOCAL_MODULE:= libmediadrm - -include $(BUILD_SHARED_LIBRARY) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/drm/libmediadrm/Crypto.cpp b/drm/libmediadrm/Crypto.cpp deleted file mode 100644 index a5d7346619..0000000000 --- a/drm/libmediadrm/Crypto.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "Crypto" -#include <utils/Log.h> -#include <dirent.h> -#include <dlfcn.h> - -#include <binder/IMemory.h> -#include <media/Crypto.h> -#include <media/DrmPluginPath.h> -#include <media/hardware/CryptoAPI.h> -#include <media/stagefright/foundation/ADebug.h> -#include <media/stagefright/foundation/AString.h> -#include <media/stagefright/foundation/hexdump.h> -#include <media/stagefright/MediaErrors.h> - -namespace android { - -KeyedVector<Vector<uint8_t>, String8> Crypto::mUUIDToLibraryPathMap; -KeyedVector<String8, wp<SharedLibrary> > Crypto::mLibraryPathToOpenLibraryMap; -Mutex Crypto::mMapLock; - -static bool operator<(const Vector<uint8_t> &lhs, const Vector<uint8_t> &rhs) { - if (lhs.size() < rhs.size()) { - return true; - } else if (lhs.size() > rhs.size()) { - return false; - } - - return memcmp((void *)lhs.array(), (void *)rhs.array(), rhs.size()) < 0; -} - -Crypto::Crypto() - : mInitCheck(NO_INIT), - mFactory(NULL), - mPlugin(NULL) { -} - -Crypto::~Crypto() { - delete mPlugin; - mPlugin = NULL; - closeFactory(); -} - -void Crypto::closeFactory() { - delete mFactory; - mFactory = NULL; - mLibrary.clear(); -} - -status_t Crypto::initCheck() const { - return mInitCheck; -} - -/* - * Search the plugins directory for a plugin that supports the scheme - * specified by uuid - * - * If found: - * mLibrary holds a strong pointer to the dlopen'd library - * mFactory is set to the library's factory method - * mInitCheck is set to OK - * - * If not found: - * mLibrary is cleared and mFactory are set to NULL - * mInitCheck is set to an error (!OK) - */ -void Crypto::findFactoryForScheme(const uint8_t uuid[16]) { - - closeFactory(); - - // lock static maps - Mutex::Autolock autoLock(mMapLock); - - // first check cache - Vector<uint8_t> uuidVector; - uuidVector.appendArray(uuid, sizeof(uuid[0]) * 16); - ssize_t index = mUUIDToLibraryPathMap.indexOfKey(uuidVector); - if (index >= 0) { - if (loadLibraryForScheme(mUUIDToLibraryPathMap[index], uuid)) { - mInitCheck = OK; - return; - } else { - ALOGE("Failed to load from cached library path!"); - mInitCheck = ERROR_UNSUPPORTED; - return; - } - } - - // no luck, have to search - String8 dirPath(getDrmPluginPath()); - String8 pluginPath; - - DIR* pDir = opendir(dirPath.string()); - if (pDir) { - struct dirent* pEntry; - while ((pEntry = readdir(pDir))) { - - pluginPath = dirPath + "/" + pEntry->d_name; - - if (pluginPath.getPathExtension() == ".so") { - - if (loadLibraryForScheme(pluginPath, uuid)) { - mUUIDToLibraryPathMap.add(uuidVector, pluginPath); - mInitCheck = OK; - closedir(pDir); - return; - } - } - } - - closedir(pDir); - } - - // try the legacy libdrmdecrypt.so - pluginPath = "libdrmdecrypt.so"; - if (loadLibraryForScheme(pluginPath, uuid)) { - mUUIDToLibraryPathMap.add(uuidVector, pluginPath); - mInitCheck = OK; - return; - } - - mInitCheck = ERROR_UNSUPPORTED; -} - -bool Crypto::loadLibraryForScheme(const String8 &path, const uint8_t uuid[16]) { - - // get strong pointer to open shared library - ssize_t index = mLibraryPathToOpenLibraryMap.indexOfKey(path); - if (index >= 0) { - mLibrary = mLibraryPathToOpenLibraryMap[index].promote(); - } else { - index = mLibraryPathToOpenLibraryMap.add(path, NULL); - } - - if (!mLibrary.get()) { - mLibrary = new SharedLibrary(path); - if (!*mLibrary) { - ALOGE("loadLibraryForScheme failed:%s", mLibrary->lastError()); - return false; - } - - mLibraryPathToOpenLibraryMap.replaceValueAt(index, mLibrary); - } - - typedef CryptoFactory *(*CreateCryptoFactoryFunc)(); - - CreateCryptoFactoryFunc createCryptoFactory = - (CreateCryptoFactoryFunc)mLibrary->lookup("createCryptoFactory"); - - if (createCryptoFactory == NULL || - (mFactory = createCryptoFactory()) == NULL || - !mFactory->isCryptoSchemeSupported(uuid)) { - ALOGE("createCryptoFactory failed:%s", mLibrary->lastError()); - closeFactory(); - return false; - } - return true; -} - -bool Crypto::isCryptoSchemeSupported(const uint8_t uuid[16]) { - Mutex::Autolock autoLock(mLock); - - if (mFactory && mFactory->isCryptoSchemeSupported(uuid)) { - return true; - } - - findFactoryForScheme(uuid); - return (mInitCheck == OK); -} - -status_t Crypto::createPlugin( - const uint8_t uuid[16], const void *data, size_t size) { - Mutex::Autolock autoLock(mLock); - - if (mPlugin != NULL) { - return -EINVAL; - } - - if (!mFactory || !mFactory->isCryptoSchemeSupported(uuid)) { - findFactoryForScheme(uuid); - } - - if (mInitCheck != OK) { - return mInitCheck; - } - - return mFactory->createPlugin(uuid, data, size, &mPlugin); -} - -status_t Crypto::destroyPlugin() { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - delete mPlugin; - mPlugin = NULL; - - return OK; -} - -bool Crypto::requiresSecureDecoderComponent(const char *mime) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->requiresSecureDecoderComponent(mime); -} - -ssize_t Crypto::decrypt(const uint8_t key[16], const uint8_t iv[16], - CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, - const sp<IMemory> &source, size_t offset, - const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, - const ICrypto::DestinationBuffer &destination, AString *errorDetailMsg) { - - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - const void *srcPtr = static_cast<uint8_t *>(source->pointer()) + offset; - - void *destPtr; - bool secure = false; - if (destination.mType == kDestinationTypeNativeHandle) { - destPtr = static_cast<void *>(destination.mHandle); - secure = true; - } else { - destPtr = destination.mSharedMemory->pointer(); - } - - ssize_t result = mPlugin->decrypt(secure, key, iv, mode, pattern, srcPtr, subSamples, - numSubSamples, destPtr, errorDetailMsg); - - return result; -} - -void Crypto::notifyResolution(uint32_t width, uint32_t height) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck == OK && mPlugin != NULL) { - mPlugin->notifyResolution(width, height); - } -} - -status_t Crypto::setMediaDrmSession(const Vector<uint8_t> &sessionId) { - Mutex::Autolock autoLock(mLock); - - status_t result = NO_INIT; - if (mInitCheck == OK && mPlugin != NULL) { - result = mPlugin->setMediaDrmSession(sessionId); - } - return result; -} - -} // namespace android diff --git a/drm/libmediadrm/Drm.cpp b/drm/libmediadrm/Drm.cpp deleted file mode 100644 index 1004eb8b15..0000000000 --- a/drm/libmediadrm/Drm.cpp +++ /dev/null @@ -1,799 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "Drm" -#include <utils/Log.h> - -#include <dirent.h> -#include <dlfcn.h> - -#include <media/DrmPluginPath.h> -#include <media/DrmSessionClientInterface.h> -#include <media/DrmSessionManager.h> -#include <media/Drm.h> -#include <media/drm/DrmAPI.h> -#include <media/stagefright/foundation/ADebug.h> -#include <media/stagefright/foundation/AString.h> -#include <media/stagefright/foundation/hexdump.h> -#include <media/stagefright/MediaErrors.h> -#include <binder/IServiceManager.h> -#include <binder/IPCThreadState.h> - -namespace android { - -static inline int getCallingPid() { - return IPCThreadState::self()->getCallingPid(); -} - -static bool checkPermission(const char* permissionString) { - if (getpid() == IPCThreadState::self()->getCallingPid()) return true; - bool ok = checkCallingPermission(String16(permissionString)); - if (!ok) ALOGE("Request requires %s", permissionString); - return ok; -} - -KeyedVector<Vector<uint8_t>, String8> Drm::mUUIDToLibraryPathMap; -KeyedVector<String8, wp<SharedLibrary> > Drm::mLibraryPathToOpenLibraryMap; -Mutex Drm::mMapLock; -Mutex Drm::mLock; - -static bool operator<(const Vector<uint8_t> &lhs, const Vector<uint8_t> &rhs) { - if (lhs.size() < rhs.size()) { - return true; - } else if (lhs.size() > rhs.size()) { - return false; - } - - return memcmp((void *)lhs.array(), (void *)rhs.array(), rhs.size()) < 0; -} - -struct DrmSessionClient : public DrmSessionClientInterface { - explicit DrmSessionClient(Drm* drm) : mDrm(drm) {} - - virtual bool reclaimSession(const Vector<uint8_t>& sessionId) { - sp<Drm> drm = mDrm.promote(); - if (drm == NULL) { - return true; - } - status_t err = drm->closeSession(sessionId); - if (err != OK) { - return false; - } - drm->sendEvent(DrmPlugin::kDrmPluginEventSessionReclaimed, 0, &sessionId, NULL); - return true; - } - -protected: - virtual ~DrmSessionClient() {} - -private: - wp<Drm> mDrm; - - DISALLOW_EVIL_CONSTRUCTORS(DrmSessionClient); -}; - -Drm::Drm() - : mInitCheck(NO_INIT), - mDrmSessionClient(new DrmSessionClient(this)), - mListener(NULL), - mFactory(NULL), - mPlugin(NULL) { -} - -Drm::~Drm() { - DrmSessionManager::Instance()->removeDrm(mDrmSessionClient); - delete mPlugin; - mPlugin = NULL; - closeFactory(); -} - -void Drm::closeFactory() { - delete mFactory; - mFactory = NULL; - mLibrary.clear(); -} - -status_t Drm::initCheck() const { - return mInitCheck; -} - -status_t Drm::setListener(const sp<IDrmClient>& listener) -{ - Mutex::Autolock lock(mEventLock); - if (mListener != NULL){ - IInterface::asBinder(mListener)->unlinkToDeath(this); - } - if (listener != NULL) { - IInterface::asBinder(listener)->linkToDeath(this); - } - mListener = listener; - return NO_ERROR; -} - -void Drm::sendEvent(DrmPlugin::EventType eventType, int extra, - Vector<uint8_t> const *sessionId, - Vector<uint8_t> const *data) -{ - mEventLock.lock(); - sp<IDrmClient> listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - Parcel obj; - writeByteArray(obj, sessionId); - writeByteArray(obj, data); - - Mutex::Autolock lock(mNotifyLock); - listener->notify(eventType, extra, &obj); - } -} - -void Drm::sendExpirationUpdate(Vector<uint8_t> const *sessionId, - int64_t expiryTimeInMS) -{ - mEventLock.lock(); - sp<IDrmClient> listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - Parcel obj; - writeByteArray(obj, sessionId); - obj.writeInt64(expiryTimeInMS); - - Mutex::Autolock lock(mNotifyLock); - listener->notify(DrmPlugin::kDrmPluginEventExpirationUpdate, 0, &obj); - } -} - -void Drm::sendKeysChange(Vector<uint8_t> const *sessionId, - Vector<DrmPlugin::KeyStatus> const *keyStatusList, - bool hasNewUsableKey) -{ - mEventLock.lock(); - sp<IDrmClient> listener = mListener; - mEventLock.unlock(); - - if (listener != NULL) { - Parcel obj; - writeByteArray(obj, sessionId); - - size_t nkeys = keyStatusList->size(); - obj.writeInt32(keyStatusList->size()); - for (size_t i = 0; i < nkeys; ++i) { - const DrmPlugin::KeyStatus *keyStatus = &keyStatusList->itemAt(i); - writeByteArray(obj, &keyStatus->mKeyId); - obj.writeInt32(keyStatus->mType); - } - obj.writeInt32(hasNewUsableKey); - - Mutex::Autolock lock(mNotifyLock); - listener->notify(DrmPlugin::kDrmPluginEventKeysChange, 0, &obj); - } -} - -/* - * Search the plugins directory for a plugin that supports the scheme - * specified by uuid - * - * If found: - * mLibrary holds a strong pointer to the dlopen'd library - * mFactory is set to the library's factory method - * mInitCheck is set to OK - * - * If not found: - * mLibrary is cleared and mFactory are set to NULL - * mInitCheck is set to an error (!OK) - */ -void Drm::findFactoryForScheme(const uint8_t uuid[16]) { - - closeFactory(); - - // lock static maps - Mutex::Autolock autoLock(mMapLock); - - // first check cache - Vector<uint8_t> uuidVector; - uuidVector.appendArray(uuid, sizeof(uuid[0]) * 16); - ssize_t index = mUUIDToLibraryPathMap.indexOfKey(uuidVector); - if (index >= 0) { - if (loadLibraryForScheme(mUUIDToLibraryPathMap[index], uuid)) { - mInitCheck = OK; - return; - } else { - ALOGE("Failed to load from cached library path!"); - mInitCheck = ERROR_UNSUPPORTED; - return; - } - } - - // no luck, have to search - String8 dirPath(getDrmPluginPath()); - DIR* pDir = opendir(dirPath.string()); - - if (pDir == NULL) { - mInitCheck = ERROR_UNSUPPORTED; - ALOGE("Failed to open plugin directory %s", dirPath.string()); - return; - } - - - struct dirent* pEntry; - while ((pEntry = readdir(pDir))) { - - String8 pluginPath = dirPath + "/" + pEntry->d_name; - - if (pluginPath.getPathExtension() == ".so") { - - if (loadLibraryForScheme(pluginPath, uuid)) { - mUUIDToLibraryPathMap.add(uuidVector, pluginPath); - mInitCheck = OK; - closedir(pDir); - return; - } - } - } - - closedir(pDir); - - ALOGE("Failed to find drm plugin"); - mInitCheck = ERROR_UNSUPPORTED; -} - -bool Drm::loadLibraryForScheme(const String8 &path, const uint8_t uuid[16]) { - - // get strong pointer to open shared library - ssize_t index = mLibraryPathToOpenLibraryMap.indexOfKey(path); - if (index >= 0) { - mLibrary = mLibraryPathToOpenLibraryMap[index].promote(); - } else { - index = mLibraryPathToOpenLibraryMap.add(path, NULL); - } - - if (!mLibrary.get()) { - mLibrary = new SharedLibrary(path); - if (!*mLibrary) { - return false; - } - - mLibraryPathToOpenLibraryMap.replaceValueAt(index, mLibrary); - } - - typedef DrmFactory *(*CreateDrmFactoryFunc)(); - - CreateDrmFactoryFunc createDrmFactory = - (CreateDrmFactoryFunc)mLibrary->lookup("createDrmFactory"); - - if (createDrmFactory == NULL || - (mFactory = createDrmFactory()) == NULL || - !mFactory->isCryptoSchemeSupported(uuid)) { - closeFactory(); - return false; - } - return true; -} - -bool Drm::isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) { - - Mutex::Autolock autoLock(mLock); - - if (!mFactory || !mFactory->isCryptoSchemeSupported(uuid)) { - findFactoryForScheme(uuid); - if (mInitCheck != OK) { - return false; - } - } - - if (mimeType != "") { - return mFactory->isContentTypeSupported(mimeType); - } - - return true; -} - -status_t Drm::createPlugin(const uint8_t uuid[16], - const String8& /* appPackageName */) { - Mutex::Autolock autoLock(mLock); - - if (mPlugin != NULL) { - return -EINVAL; - } - - if (!mFactory || !mFactory->isCryptoSchemeSupported(uuid)) { - findFactoryForScheme(uuid); - } - - if (mInitCheck != OK) { - return mInitCheck; - } - - status_t result = mFactory->createDrmPlugin(uuid, &mPlugin); - if (mPlugin) { - mPlugin->setListener(this); - } else { - ALOGE("Failed to create plugin"); - return UNEXPECTED_NULL; - } - return result; -} - -status_t Drm::destroyPlugin() { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - setListener(NULL); - delete mPlugin; - mPlugin = NULL; - - return OK; -} - -status_t Drm::openSession(Vector<uint8_t> &sessionId) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - status_t err = mPlugin->openSession(sessionId); - if (err == ERROR_DRM_RESOURCE_BUSY) { - bool retry = false; - mLock.unlock(); - // reclaimSession may call back to closeSession, since mLock is shared between Drm - // instances, we should unlock here to avoid deadlock. - retry = DrmSessionManager::Instance()->reclaimSession(getCallingPid()); - mLock.lock(); - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - if (retry) { - err = mPlugin->openSession(sessionId); - } - } - if (err == OK) { - DrmSessionManager::Instance()->addSession(getCallingPid(), mDrmSessionClient, sessionId); - } - return err; -} - -status_t Drm::closeSession(Vector<uint8_t> const &sessionId) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - status_t err = mPlugin->closeSession(sessionId); - if (err == OK) { - DrmSessionManager::Instance()->removeSession(sessionId); - } - return err; -} - -status_t Drm::getKeyRequest(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &initData, - String8 const &mimeType, DrmPlugin::KeyType keyType, - KeyedVector<String8, String8> const &optionalParameters, - Vector<uint8_t> &request, String8 &defaultUrl, - DrmPlugin::KeyRequestType *keyRequestType) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->getKeyRequest(sessionId, initData, mimeType, keyType, - optionalParameters, request, defaultUrl, - keyRequestType); -} - -status_t Drm::provideKeyResponse(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &response, - Vector<uint8_t> &keySetId) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->provideKeyResponse(sessionId, response, keySetId); -} - -status_t Drm::removeKeys(Vector<uint8_t> const &keySetId) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->removeKeys(keySetId); -} - -status_t Drm::restoreKeys(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &keySetId) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->restoreKeys(sessionId, keySetId); -} - -status_t Drm::queryKeyStatus(Vector<uint8_t> const &sessionId, - KeyedVector<String8, String8> &infoMap) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->queryKeyStatus(sessionId, infoMap); -} - -status_t Drm::getProvisionRequest(String8 const &certType, String8 const &certAuthority, - Vector<uint8_t> &request, String8 &defaultUrl) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->getProvisionRequest(certType, certAuthority, - request, defaultUrl); -} - -status_t Drm::provideProvisionResponse(Vector<uint8_t> const &response, - Vector<uint8_t> &certificate, - Vector<uint8_t> &wrappedKey) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->provideProvisionResponse(response, certificate, wrappedKey); -} - -status_t Drm::getSecureStops(List<Vector<uint8_t> > &secureStops) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->getSecureStops(secureStops); -} - -status_t Drm::getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->getSecureStop(ssid, secureStop); -} - -status_t Drm::releaseSecureStops(Vector<uint8_t> const &ssRelease) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->releaseSecureStops(ssRelease); -} - -status_t Drm::releaseAllSecureStops() { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->releaseAllSecureStops(); -} - -status_t Drm::getPropertyString(String8 const &name, String8 &value ) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->getPropertyString(name, value); -} - -status_t Drm::getPropertyByteArray(String8 const &name, Vector<uint8_t> &value ) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->getPropertyByteArray(name, value); -} - -status_t Drm::setPropertyString(String8 const &name, String8 const &value ) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->setPropertyString(name, value); -} - -status_t Drm::setPropertyByteArray(String8 const &name, - Vector<uint8_t> const &value ) const { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - return mPlugin->setPropertyByteArray(name, value); -} - - -status_t Drm::setCipherAlgorithm(Vector<uint8_t> const &sessionId, - String8 const &algorithm) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->setCipherAlgorithm(sessionId, algorithm); -} - -status_t Drm::setMacAlgorithm(Vector<uint8_t> const &sessionId, - String8 const &algorithm) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->setMacAlgorithm(sessionId, algorithm); -} - -status_t Drm::encrypt(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &keyId, - Vector<uint8_t> const &input, - Vector<uint8_t> const &iv, - Vector<uint8_t> &output) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->encrypt(sessionId, keyId, input, iv, output); -} - -status_t Drm::decrypt(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &keyId, - Vector<uint8_t> const &input, - Vector<uint8_t> const &iv, - Vector<uint8_t> &output) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->decrypt(sessionId, keyId, input, iv, output); -} - -status_t Drm::sign(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &keyId, - Vector<uint8_t> const &message, - Vector<uint8_t> &signature) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->sign(sessionId, keyId, message, signature); -} - -status_t Drm::verify(Vector<uint8_t> const &sessionId, - Vector<uint8_t> const &keyId, - Vector<uint8_t> const &message, - Vector<uint8_t> const &signature, - bool &match) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->verify(sessionId, keyId, message, signature, match); -} - -status_t Drm::signRSA(Vector<uint8_t> const &sessionId, - String8 const &algorithm, - Vector<uint8_t> const &message, - Vector<uint8_t> const &wrappedKey, - Vector<uint8_t> &signature) { - Mutex::Autolock autoLock(mLock); - - if (mInitCheck != OK) { - return mInitCheck; - } - - if (mPlugin == NULL) { - return -EINVAL; - } - - if (!checkPermission("android.permission.ACCESS_DRM_CERTIFICATES")) { - return -EPERM; - } - - DrmSessionManager::Instance()->useSession(sessionId); - - return mPlugin->signRSA(sessionId, algorithm, message, wrappedKey, signature); -} - -void Drm::binderDied(const wp<IBinder> &the_late_who __unused) -{ - mEventLock.lock(); - mListener.clear(); - mEventLock.unlock(); - - Mutex::Autolock autoLock(mLock); - delete mPlugin; - mPlugin = NULL; - closeFactory(); -} - -void Drm::writeByteArray(Parcel &obj, Vector<uint8_t> const *array) -{ - if (array && array->size()) { - obj.writeInt32(array->size()); - obj.write(array->array(), array->size()); - } else { - obj.writeInt32(0); - } -} - -} // namespace android diff --git a/drm/libmediadrm/DrmHal.cpp b/drm/libmediadrm/DrmHal.cpp index 386546f2ab..074489a93f 100644 --- a/drm/libmediadrm/DrmHal.cpp +++ b/drm/libmediadrm/DrmHal.cpp @@ -245,6 +245,11 @@ sp<IDrmPlugin> DrmHal::makeDrmPlugin(const sp<IDrmFactory>& factory, plugin = hPlugin; } ); + + if (!hResult.isOk()) { + ALOGE("createPlugin remote call failed"); + } + return plugin; } @@ -396,8 +401,11 @@ status_t DrmHal::createPlugin(const uint8_t uuid[16], if (mPlugin == NULL) { mInitCheck = ERROR_UNSUPPORTED; } else { - mInitCheck = OK; - mPlugin->setListener(this); + if (!mPlugin->setListener(this).isOk()) { + mInitCheck = DEAD_OBJECT; + } else { + mInitCheck = OK; + } } return mInitCheck; @@ -411,12 +419,14 @@ status_t DrmHal::destroyPlugin() { } setListener(NULL); + mInitCheck = NO_INIT; + if (mPlugin != NULL) { - mPlugin->setListener(NULL); + if (!mPlugin->setListener(NULL).isOk()) { + mInitCheck = DEAD_OBJECT; + } } mPlugin.clear(); - mInitCheck = NO_INIT; - return OK; } @@ -472,11 +482,14 @@ status_t DrmHal::closeSession(Vector<uint8_t> const &sessionId) { return mInitCheck; } - Status status = mPlugin->closeSession(toHidlVec(sessionId)); - if (status == Status::OK) { - DrmSessionManager::Instance()->removeSession(sessionId); + Return<Status> status = mPlugin->closeSession(toHidlVec(sessionId)); + if (status.isOk()) { + if (status == Status::OK) { + DrmSessionManager::Instance()->removeSession(sessionId); + } + return toStatusT(status); } - return toStatusT(status); + return DEAD_OBJECT; } status_t DrmHal::getKeyRequest(Vector<uint8_t> const &sessionId, @@ -962,12 +975,16 @@ status_t DrmHal::signRSA(Vector<uint8_t> const &sessionId, void DrmHal::binderDied(const wp<IBinder> &the_late_who __unused) { Mutex::Autolock autoLock(mLock); + setListener(NULL); + mInitCheck = NO_INIT; + if (mPlugin != NULL) { - mPlugin->setListener(NULL); + if (!mPlugin->setListener(NULL).isOk()) { + mInitCheck = DEAD_OBJECT; + } } mPlugin.clear(); - mInitCheck = NO_INIT; } void DrmHal::writeByteArray(Parcel &obj, hidl_vec<uint8_t> const &vec) diff --git a/drm/mediadrm/Android.bp b/drm/mediadrm/Android.bp new file mode 100644 index 0000000000..b9f07f1ecd --- /dev/null +++ b/drm/mediadrm/Android.bp @@ -0,0 +1 @@ +subdirs = ["plugins/*"] diff --git a/drm/mediadrm/plugins/clearkey/Android.bp b/drm/mediadrm/plugins/clearkey/Android.bp new file mode 100644 index 0000000000..2973fcff54 --- /dev/null +++ b/drm/mediadrm/plugins/clearkey/Android.bp @@ -0,0 +1,59 @@ +// +// Copyright (C) 2014 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. +// + +cc_library_shared { + name: "libdrmclearkeyplugin", + + srcs: [ + "AesCtrDecryptor.cpp", + "ClearKeyUUID.cpp", + "CreatePluginFactories.cpp", + "CryptoFactory.cpp", + "CryptoPlugin.cpp", + "DrmFactory.cpp", + "DrmPlugin.cpp", + "InitDataParser.cpp", + "JsonWebKey.cpp", + "Session.cpp", + "SessionLibrary.cpp", + "Utils.cpp", + ], + + vendor: true, + relative_install_path: "mediadrm", + + shared_libs: [ + "libcrypto", + "liblog", + "libstagefright_foundation", + "libutils", + ], + + static_libs: ["libjsmn"], + + include_dirs: [ + "frameworks/native/include", + "frameworks/av/include", + ], + + export_include_dirs: ["."], + export_static_lib_headers: ["libjsmn"], +} + +//######################################################################## +// Build unit tests + +subdirs = ["tests"] diff --git a/drm/mediadrm/plugins/clearkey/Android.mk b/drm/mediadrm/plugins/clearkey/Android.mk deleted file mode 100644 index 2efdcf59f7..0000000000 --- a/drm/mediadrm/plugins/clearkey/Android.mk +++ /dev/null @@ -1,60 +0,0 @@ -# -# Copyright (C) 2014 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. -# -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - AesCtrDecryptor.cpp \ - ClearKeyUUID.cpp \ - CreatePluginFactories.cpp \ - CryptoFactory.cpp \ - CryptoPlugin.cpp \ - DrmFactory.cpp \ - DrmPlugin.cpp \ - InitDataParser.cpp \ - JsonWebKey.cpp \ - Session.cpp \ - SessionLibrary.cpp \ - Utils.cpp \ - -LOCAL_C_INCLUDES := \ - external/jsmn \ - frameworks/av/drm/mediadrm/plugins/clearkey \ - frameworks/av/include \ - frameworks/native/include \ - -LOCAL_MODULE := libdrmclearkeyplugin - -LOCAL_PROPRIETARY_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := mediadrm - -LOCAL_SHARED_LIBRARIES := \ - libcrypto \ - liblog \ - libstagefright_foundation \ - libutils \ - -LOCAL_STATIC_LIBRARIES := \ - libjsmn \ - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) - -######################################################################### -# Build unit tests - -include $(LOCAL_PATH)/tests/Android.mk diff --git a/drm/mediadrm/plugins/clearkey/tests/Android.bp b/drm/mediadrm/plugins/clearkey/tests/Android.bp new file mode 100644 index 0000000000..ac57d653c6 --- /dev/null +++ b/drm/mediadrm/plugins/clearkey/tests/Android.bp @@ -0,0 +1,37 @@ +// +// Copyright (C) 2014 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. +// +// ---------------------------------------------------------------- +// Builds ClearKey Drm Tests +// + +cc_test { + name: "ClearKeyDrmUnitTest", + vendor: true, + + srcs: [ + "AesCtrDecryptorUnittest.cpp", + "InitDataParserUnittest.cpp", + "JsonWebKeyUnittest.cpp", + ], + + shared_libs: [ + "libcrypto", + "libdrmclearkeyplugin", + "liblog", + "libstagefright_foundation", + "libutils", + ], +} diff --git a/drm/mediadrm/plugins/clearkey/tests/Android.mk b/drm/mediadrm/plugins/clearkey/tests/Android.mk deleted file mode 100644 index 392f218816..0000000000 --- a/drm/mediadrm/plugins/clearkey/tests/Android.mk +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (C) 2014 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. -# -# ---------------------------------------------------------------- -# Builds ClearKey Drm Tests -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := ClearKeyDrmUnitTest -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := \ - AesCtrDecryptorUnittest.cpp \ - InitDataParserUnittest.cpp \ - JsonWebKeyUnittest.cpp \ - -LOCAL_C_INCLUDES := \ - external/jsmn \ - frameworks/av/drm/mediadrm/plugins/clearkey \ - frameworks/av/include \ - frameworks/native/include \ - -LOCAL_SHARED_LIBRARIES := \ - libcrypto \ - libdrmclearkeyplugin \ - liblog \ - libstagefright_foundation \ - libutils \ - -include $(BUILD_NATIVE_TEST) diff --git a/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp b/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp index e2751084d1..84ed242246 100644 --- a/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp +++ b/drm/mediadrm/plugins/clearkey/tests/InitDataParserUnittest.cpp @@ -56,7 +56,7 @@ class InitDataParserTest : public ::testing::Test { request.size()); EXPECT_EQ(0, requestString.find(kRequestPrefix)); EXPECT_EQ(requestString.size() - kRequestSuffix.size(), - requestString.find(kRequestSuffix)); + (size_t)requestString.find(kRequestSuffix)); for (size_t i = 0; i < expectedKeys.size(); ++i) { AString encodedIdAString; android::encodeBase64(expectedKeys[i], kKeyIdSize, @@ -71,7 +71,7 @@ class InitDataParserTest : public ::testing::Test { const String8& mimeType) { Vector<uint8_t> request; ASSERT_NE(android::OK, attemptParse(initData, mimeType, &request)); - EXPECT_EQ(0, request.size()); + EXPECT_EQ(0u, request.size()); } }; diff --git a/drm/mediadrm/plugins/mock/Android.bp b/drm/mediadrm/plugins/mock/Android.bp new file mode 100644 index 0000000000..7f448195c5 --- /dev/null +++ b/drm/mediadrm/plugins/mock/Android.bp @@ -0,0 +1,34 @@ +// +// Copyright (C) 2013 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. +// + +cc_library_shared { + name: "libmockdrmcryptoplugin", + + srcs: ["MockDrmCryptoPlugin.cpp"], + + vendor: true, + relative_install_path: "mediadrm", + + shared_libs: [ + "libutils", + "liblog", + ], + + cflags: [ + // Set the following flag to enable the decryption passthru flow + //"-DENABLE_PASSTHRU_DECRYPTION", + ], +} diff --git a/drm/mediadrm/plugins/mock/Android.mk b/drm/mediadrm/plugins/mock/Android.mk deleted file mode 100644 index 26c245b817..0000000000 --- a/drm/mediadrm/plugins/mock/Android.mk +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2013 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. -# -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - MockDrmCryptoPlugin.cpp - -LOCAL_MODULE := libmockdrmcryptoplugin - -LOCAL_PROPRIETARY_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := mediadrm - -LOCAL_SHARED_LIBRARIES := \ - libutils liblog - -LOCAL_C_INCLUDES += \ - $(TOP)/frameworks/av/include \ - $(TOP)/frameworks/native/include/media - -# Set the following flag to enable the decryption passthru flow -#LOCAL_CFLAGS += -DENABLE_PASSTHRU_DECRYPTION - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp index c82b9d9147..3b4145f402 100644 --- a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp +++ b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.cpp @@ -19,7 +19,7 @@ #include <utils/Log.h> -#include "drm/DrmAPI.h" +#include "media/drm/DrmAPI.h" #include "MockDrmCryptoPlugin.h" #include "media/stagefright/MediaErrors.h" @@ -730,7 +730,7 @@ namespace android { ssize_t MockDrmPlugin::findSession(Vector<uint8_t> const &sessionId) const { - ALOGD("findSession: nsessions=%u, size=%u", mSessions.size(), sessionId.size()); + ALOGD("findSession: nsessions=%zu, size=%zu", mSessions.size(), sessionId.size()); for (size_t i = 0; i < mSessions.size(); ++i) { if (memcmp(mSessions[i].array(), sessionId.array(), sessionId.size()) == 0) { return i; @@ -741,7 +741,7 @@ namespace android { ssize_t MockDrmPlugin::findKeySet(Vector<uint8_t> const &keySetId) const { - ALOGD("findKeySet: nkeySets=%u, size=%u", mKeySets.size(), keySetId.size()); + ALOGD("findKeySet: nkeySets=%zu, size=%zu", mKeySets.size(), keySetId.size()); for (size_t i = 0; i < mKeySets.size(); ++i) { if (memcmp(mKeySets[i].array(), keySetId.array(), keySetId.size()) == 0) { return i; @@ -792,8 +792,9 @@ namespace android { } ssize_t - MockCryptoPlugin::decrypt(bool secure, const uint8_t key[16], const uint8_t iv[16], - Mode mode, const Pattern &pattern, const void *srcPtr, + MockCryptoPlugin::decrypt(bool secure, const uint8_t key[DECRYPT_KEY_SIZE], + const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode, + const Pattern &pattern, const void *srcPtr, const SubSample *subSamples, size_t numSubSamples, void *dstPtr, AString * /* errorDetailMsg */) { @@ -801,8 +802,8 @@ namespace android { "pattern:{encryptBlocks=%d, skipBlocks=%d} src=%p, " "subSamples=%s, dst=%p)", (int)secure, - arrayToString(key, sizeof(key)).string(), - arrayToString(iv, sizeof(iv)).string(), + arrayToString(key, DECRYPT_KEY_SIZE).string(), + arrayToString(iv, DECRYPT_KEY_SIZE).string(), (int)mode, pattern.mEncryptBlocks, pattern.mSkipBlocks, srcPtr, subSamplesToString(subSamples, numSubSamples).string(), dstPtr); diff --git a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h index 9f8db17932..4178c0350d 100644 --- a/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h +++ b/drm/mediadrm/plugins/mock/MockDrmCryptoPlugin.h @@ -16,8 +16,8 @@ #include <utils/Mutex.h> -#include "drm/DrmAPI.h" -#include "hardware/CryptoAPI.h" +#include "media/drm/DrmAPI.h" +#include "media/hardware/CryptoAPI.h" extern "C" { android::DrmFactory *createDrmFactory(); @@ -158,9 +158,12 @@ namespace android { bool requiresSecureDecoderComponent(const char *mime) const; + static constexpr size_t DECRYPT_KEY_SIZE = 16; + ssize_t decrypt(bool secure, - const uint8_t key[16], const uint8_t iv[16], - Mode mode, const Pattern &pattern, const void *srcPtr, + const uint8_t key[DECRYPT_KEY_SIZE], + const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode, + const Pattern &pattern, const void *srcPtr, const SubSample *subSamples, size_t numSubSamples, void *dstPtr, AString *errorDetailMsg); private: |
