Skip to content

Commit a0c56c9

Browse files
committed
ubport: Import phh GSI SPL fixes
1 parent 7112f93 commit a0c56c9

5 files changed

Lines changed: 98 additions & 0 deletions

File tree

device.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ PRODUCT_PACKAGES += \
4343
PRODUCT_PACKAGES += \
4444
ld.config.vndk_lite.txt
4545

46+
# SPL fix
47+
PRODUCT_PACKAGES += \
48+
getSPL
49+
4650
# Test tools
4751
PRODUCT_PACKAGES += \
4852
bootctl \

fixSPL/Android.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
LOCAL_MODULE := getSPL
5+
LOCAL_MODULE_TAGS := optional eng
6+
LOCAL_MODULE_CLASS := EXECUTABLES
7+
LOCAL_SRC_FILES := getSPL.arm
8+
include $(BUILD_PREBUILT)

fixSPL/getSPL.arm

388 KB
Binary file not shown.

fixSPL/getSPL.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <stdio.h>
2+
#include <sys/types.h>
3+
#include <sys/stat.h>
4+
#include <fcntl.h>
5+
#include <stdint.h>
6+
#include <unistd.h>
7+
#include <stdlib.h>
8+
#include <string.h>
9+
10+
int main(int argc, char **argv) {
11+
if(argc!=3) {
12+
fprintf(stderr, "Usage: %s <bootimg> <android|spl>\n", argv[0]);
13+
exit(-1);
14+
}
15+
int fd = open(argv[1], O_RDONLY);
16+
lseek(fd, 11*4, SEEK_SET);
17+
uint32_t val = 0;
18+
read(fd, &val, sizeof(val));
19+
int android = val >> 11;
20+
int a = android >> 14;
21+
int b = (android >> 7) & 0x7f;
22+
int c = android & 0x7f;
23+
24+
int spl = val & 0x7ff;
25+
int y = 2000 + (spl >> 4);
26+
int m = spl & 0xf;
27+
28+
fprintf(stderr, "Android: %d.%d.%d\n", a, b, c);
29+
fprintf(stderr, "SPL: %d-%d-01\n", y, m);
30+
31+
if(strcmp(argv[2], "android") == 0) {
32+
printf("%d.%d.%d", a, b, c);
33+
} else if(strcmp(argv[2], "spl") == 0) {
34+
printf("%04d-%02d-%02d", y, m, 1);
35+
}
36+
37+
return 0;
38+
}

rootdir/bin/on-post-data.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
#!/system/bin/sh
22

3+
fixSPL() {
4+
if [ "$(getprop ro.product.cpu.abi)" = "armeabi-v7a" ]; then
5+
setprop ro.keymaster.mod 'AOSP on ARM32'
6+
else
7+
setprop ro.keymaster.mod 'AOSP on ARM64'
8+
fi
9+
img="$(find /dev/disk -type l -name kernel"$(getprop ro.boot.slot_suffix)" | grep by-partlabel | head -n 1)"
10+
[ -z "$img" ] && img="$(find /dev/disk -type l -name boot"$(getprop ro.boot.slot_suffix)" | grep by-partlabel | head -n 1)"
11+
[ -z "$img" ] && img="$(find /dev/block -type l -name kernel"$(getprop ro.boot.slot_suffix)" | grep by-name | head -n 1)"
12+
[ -z "$img" ] && img="$(find /dev/block -type l -name boot"$(getprop ro.boot.slot_suffix)" | grep by-name | head -n 1)"
13+
if [ -n "$img" ]; then
14+
#Rewrite SPL/Android version if needed
15+
Arelease="$(getSPL "$img" android)"
16+
setprop ro.keymaster.xxx.release "$Arelease"
17+
setprop ro.keymaster.xxx.security_patch "$(getSPL "$img" spl)"
18+
19+
getprop ro.vendor.build.fingerprint | grep -qiE '^samsung/' && return 0
20+
for f in \
21+
/vendor/lib64/hw/android.hardware.keymaster@3.0-impl-qti.so /vendor/lib/hw/android.hardware.keymaster@3.0-impl-qti.so \
22+
/system/lib64/vndk-26/libsoftkeymasterdevice.so /vendor/bin/teed \
23+
/system/lib64/vndk/libsoftkeymasterdevice.so /system/lib/vndk/libsoftkeymasterdevice.so \
24+
/system/lib/vndk-26/libsoftkeymasterdevice.so \
25+
/system/lib/vndk-27/libsoftkeymasterdevice.so /system/lib64/vndk-27/libsoftkeymasterdevice.so; do
26+
[ ! -f "$f" ] && continue
27+
b="$(echo "$f" | tr / _)"
28+
29+
cp -a "$f" "/data/phh/$b"
30+
sed -i \
31+
-e 's/ro.build.version.release/ro.keymaster.xxx.release/g' \
32+
-e 's/ro.build.version.security_patch/ro.keymaster.xxx.security_patch/g' \
33+
-e 's/ro.product.model/ro.keymaster.mod/g' \
34+
"/data/phh/$b"
35+
mount -o bind "/data/phh/$b" "$f"
36+
done
37+
if [ "$(getprop init.svc.keymaster-3-0)" = "running" ]; then
38+
setprop ctl.restart keymaster-3-0
39+
fi
40+
if [ "$(getprop init.svc.teed)" = "running" ]; then
41+
setprop ctl.restart teed
42+
fi
43+
fi
44+
}
45+
46+
mkdir -p /data/phh/
47+
mount -t tmpfs -o rw,nodev,relatime,mode=755,gid=0 none /data/phh || true
48+
mkdir /data/phh/empty_dir
49+
fixSPL
50+
351
if grep -qF android.hardware.boot /vendor/manifest.xml || grep -qF android.hardware.boot /vendor/etc/vintf/manifest.xml ;then
452
bootctl mark-boot-successful
553
fi

0 commit comments

Comments
 (0)