-
Notifications
You must be signed in to change notification settings - Fork 2
/
extract-files.sh
executable file
·175 lines (159 loc) · 6.98 KB
/
extract-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#
# SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
# SPDX-License-Identifier: Apache-2.0
#
set -e
DEVICE=cancunf
VENDOR=motorola
# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.."
export TARGET_ENABLE_CHECKELF=true
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}"
exit 1
fi
source "${HELPER}"
# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true
KANG=
SECTION=
while [ "${#}" -gt 0 ]; do
case "${1}" in
-n | --no-cleanup )
CLEAN_VENDOR=false
;;
-k | --kang )
KANG="--kang"
;;
-s | --section )
SECTION="${2}"; shift
CLEAN_VENDOR=false
;;
* )
SRC="${1}"
;;
esac
shift
done
if [ -z "${SRC}" ]; then
SRC="adb"
fi
function blob_fixup {
case "$1" in
vendor/etc/init/android.hardware.neuralnetworks-shim-service-mtk.rc)
[ "$2" = "" ] && return 0
sed -i 's/start/enable/' "$2"
;;
vendor/etc/vintf/manifest/manifest_media_c2_V1_2_default.xml)
[ "$2" = "" ] && return 0
sed -i 's/1.1/1.2/' "$2"
;;
vendor/bin/hw/[email protected] | vendor/bin/hw/[email protected])
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libavservices_minijail_vendor.so" "libavservices_minijail.so" "${2}"
grep -q "libstagefright_foundation-v33.so" "${2}" || "${PATCHELF}" --add-needed "libstagefright_foundation-v33.so" "${2}"
;;
vendor/bin/hw/android.hardware.security.keymint-service.trustonic)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "android.hardware.security.keymint-V1-ndk_platform.so" "android.hardware.security.keymint-V1-ndk.so" "${2}"
"${PATCHELF}" --replace-needed "android.hardware.security.secureclock-V1-ndk_platform.so" "android.hardware.security.secureclock-V1-ndk.so" "${2}"
"${PATCHELF}" --replace-needed "android.hardware.security.sharedsecret-V1-ndk_platform.so" "android.hardware.security.sharedsecret-V1-ndk.so" "${2}"
grep -q "android.hardware.security.rkp-V1-ndk.so" "${2}" || "${PATCHELF}" --add-needed "android.hardware.security.rkp-V1-ndk.so" "${2}"
;;
vendor/lib*/hw/mt6855/[email protected] \
|vendor/lib64/mt6855/libmtkcam_stdutils.so \
|vendor/lib64/hw/mt6855/[email protected])
"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}"
;;
vendor/lib*/hw/audio.primary.mediatek.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}"
"${PATCHELF}" --replace-needed "libalsautils.so" "libalsautils-v31.so" "${2}"
grep -q "libstagefright_foundation-v33.so" "${2}" || "${PATCHELF}" --add-needed "libstagefright_foundation-v33.so" "${2}"
;;
vendor/bin/mnld \
|vendor/lib64/hw/[email protected]\
|vendor/lib64/mt6855/libcam.utils.sensorprovider.so)
[ "$2" = "" ] && return 0
grep -q "libshim_sensors.so" "$2" || "$PATCHELF" --add-needed "libshim_sensors.so" "$2"
;;
vendor/lib64/libdlbdsservice.so \
|vendor/lib64/libcodec2_soft_ddpdec.so \
|vendor/lib*/soundfx/libswdap.so \
|vendor/lib*/soundfx/libdlbvol.so \
|vendor/lib64/libcodec2_soft_ac4dec.so \
|vendor/bin/hw/[email protected])
[ "$2" = "" ] && return 0
grep -q "libstagefright_foundation-v33.so" "${2}" || "${PATCHELF}" --add-needed "libstagefright_foundation-v33.so" "${2}"
;;
vendor/etc/dolby/dax-default.xml)
[ "$2" = "" ] && return 0
sed -i 's|volume-leveler-enable value="true"|volume-leveler-enable value="false"|g' "${2}"
;;
vendor/lib64/libmtkcam_featurepolicy.so)
[ "$2" = "" ] && return 0
# evaluateCaptureConfiguration()
printf '\x28\x02\x80\x52' | dd of="$2" bs=1 seek=$((0x3e828)) count=4 conv=notrunc
printf '\x28\x02\x80\x52' | dd of="$2" bs=1 seek=$((0x3e8f4)) count=4 conv=notrunc
;;
vendor/etc/init/[email protected])
[ "$2" = "" ] && return 0
sed -i '/vts/Q' "$2"
;;
vendor/lib64/sensors.moto.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "libutils.so" "libutils-v32.so" "${2}"
;;
system_ext/lib64/libsource.so)
[ "$2" = "" ] && return 0
grep -q libui_shim.so "$2" || "$PATCHELF" --add-needed libui_shim.so "$2"
;;
vendor/lib64/hw/android.hardware.gnss-impl-mediatek.so \
|vendor/bin/hw/android.hardware.gnss-service.mediatek)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "android.hardware.gnss-V1-ndk_platform.so" "android.hardware.gnss-V1-ndk.so" "${2}"
;;
vendor/bin/hw/android.hardware.memtrack-service.mediatek)
[ "$2" = "" ] && return 0
"${PATCHELF}" --replace-needed "android.hardware.memtrack-V1-ndk_platform.so" "android.hardware.memtrack-V1-ndk.so" "${2}"
;;
vendor/lib64/mt6855/lib3a.flash.so \
|vendor/lib64/mt6855/lib3a.ae.stat.so \
|vendor/lib64/mt6855/lib3a.sensors.flicker.so \
|vendor/lib64/mt6855/lib3a.sensors.color.so \
|vendor/lib64/mt6855/libaaa_ltm.so \
|vendor/lib64/lib3a.ae.pipe.so \
|vendor/lib64/libSQLiteModule_VER_ALL.so)
[ "$2" = "" ] && return 0
grep -q "liblog.so" "${2}" || "${PATCHELF_0_17_2}" --add-needed "liblog.so" "${2}"
;;
vendor/lib64/mt6855/libmnl.so)
[ "$2" = "" ] && return 0
grep -q "libcutils.so" "${2}" || "${PATCHELF}" --add-needed "libcutils.so" "${2}"
;;
system_ext/priv-app/ImsService/ImsService.apk)
[ "$2" = "" ] && return 0
apktool_patch "${2}" "$MY_DIR/ims-patches"
;;
vendor/etc/init/init.thermal_core.rc)
[ "$2" = "" ] && return 0
sed -i 's|ro.vendor.mtk_thermal_2_0|vendor.thermal.link_ready|g' "${2}"
;;
*)
return 1
;;
esac
return 0
}
function blob_fixup_dry() {
blob_fixup "$1" ""
}
# Initialize the helper
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
"${MY_DIR}/setup-makefiles.sh"