blob: 19c2963c056915f6c5244a9b29f14fa098a38f75 [file] [log] [blame]
nkk7171c6c502017-01-05 23:55:05 +02001# Copyright (C) 2017 TeamWin Recovery Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
16
17ifeq ($(TW_INCLUDE_CRYPTO), true)
18 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),)
nkk7171c6c502017-01-05 23:55:05 +020019
20
21 # Parse TW_CRYPTO_USE_SYSTEM_VOLD
22 ifeq ($(TW_CRYPTO_USE_SYSTEM_VOLD),true)
23 # Just enabled, so only vold + vdc
24 services :=
25 else
26 # Additional services needed by vold
27 services := $(TW_CRYPTO_USE_SYSTEM_VOLD)
28 endif
29
30 # List of .rc files for each additional service
31 rc_files := $(foreach item,$(services),init.recovery.vold_decrypt.$(item).rc)
32
33
34 include $(CLEAR_VARS)
35 LOCAL_MODULE := init.recovery.vold_decrypt.rc
36 LOCAL_MODULE_TAGS := eng
37 LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
38
39 # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc
40 # during ramdisk creation and only allows init.recovery.*.rc files to be copied
41 # from TARGET_ROOT_OUT thereafter
42 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
43
44 LOCAL_SRC_FILES := $(LOCAL_MODULE)
45
46 # Add additional .rc files and imports into init.recovery.vold_decrypt.rc
47 # Note: any init.recovery.vold_decrypt.{service}.rc that are not default
48 # in crypto/vold_decrypt should be in the device tree
49 LOCAL_POST_INSTALL_CMD := $(hide) \
50 $(foreach item, $(rc_files), \
51 sed -i '1iimport \/$(item)' "$(TARGET_ROOT_OUT)/$(LOCAL_MODULE)"; \
52 if [ -f "$(LOCAL_PATH)/$(item)" ]; then \
53 cp -f "$(LOCAL_PATH)/$(item)" "$(TARGET_ROOT_OUT)"/; \
54 fi; \
55 )
nkk717d1222a2017-11-06 17:27:21 +020056
57 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0)
58 # Truncate service_name to max 16 characters
59 LOCAL_POST_INSTALL_CMD += \
60 $(foreach item, $(rc_files), \
61 if [ -f "$(TARGET_ROOT_OUT)/$(item)" ]; then \
62 sed -i 's/\([ \t]*service[ \t]*\)\(.\{16\}\).*\([ \t].*\)/\1\2\3/' "$(TARGET_ROOT_OUT)/$(item)"; \
63 fi; \
64 )
65 endif
66
nkk7171c6c502017-01-05 23:55:05 +020067 include $(BUILD_PREBUILT)
68
69
70 include $(CLEAR_VARS)
71 LOCAL_MODULE := libvolddecrypt
72 LOCAL_MODULE_TAGS := eng optional
73 LOCAL_CFLAGS := -Wall
74 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
75 LOCAL_C_INCLUDES += external/stlport/stlport bionic bionic/libstdc++/include
76 endif
77
78 ifneq ($(services),)
nkk717d1222a2017-11-06 17:27:21 +020079 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0)
80 # Truncate service_name to max 12 characters due to the 4 character prefix
81 truncated_services := $(foreach item,$(services),$(shell echo -n "$(item)" | sed 's/\(.\{12\}\).*/\1/'))
82 LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_SERVICES='"$(truncated_services)"'
83 LOCAL_CFLAGS += -D_USING_SHORT_SERVICE_NAMES
84 else
85 LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_SERVICES='"$(services)"'
86 endif
nkk7171c6c502017-01-05 23:55:05 +020087 endif
88
89 ifeq ($(TW_CRYPTO_SYSTEM_VOLD_DEBUG),true)
90 # Enabling strace will expose the password in the strace logs!!
91 LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_DEBUG
nailyk-frca3fd0c2018-03-28 14:55:45 +020092 else
93 ifneq ($(TW_CRYPTO_SYSTEM_VOLD_DEBUG),)
94 # Specify strace path
95 LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_DEBUG
96 LOCAL_CFLAGS += -DVD_STRACE_BIN=\"$(TW_CRYPTO_SYSTEM_VOLD_DEBUG)\"
97 endif
nkk7171c6c502017-01-05 23:55:05 +020098 endif
99
nkk7171c6c502017-01-05 23:55:05 +0200100 LOCAL_SRC_FILES = vold_decrypt.cpp
101 LOCAL_SHARED_LIBRARIES := libcutils
102 include $(BUILD_STATIC_LIBRARY)
103
104 endif
nkk7171c6c502017-01-05 23:55:05 +0200105endif