[REFERENCE]Port any P Preview images into semi-GSI

fxsheep

Senior Member
May 26, 2017
399
543
113
This thread described the main steps to port a P Preview image into semi-GSI .This is only a reference that points out the key files you may need to deal with, but not a step to step guide.Also I can only lead you to make it boot,and I'm not promising anything.

Things you need to prepare:
1.An Android device with official / unofficial 8.1 Treble support and a PC.
2.P DP3 semi-GSI image(most OEM P are working with DP3)
3.A *Qualcomm OEM P Preview image you want to port.
4.Better have a recent Android kitchen.

*Seems that there's only Qualcomm based devices received official P Preview builds. I'm not sure if someone has early access to P images for Kirin processors (e.g. for Huawei Mate 10) or Exynos.
In theory ,P images can be ported between chipsets from the same vendor.(If anyone have these images feel free to share it)

Also you need to prepare for (in case)bricks,if something goes wrong.

So let's start.
Unpack P semiGSI and the ROM you want to port.

*the lib&lib64 below means there are to files you need to replace,one in lib and one in lib64 folder.

Replace /system/lib&lib64/libselinux.so from semiGSI to your port.

Look for a txt file start with ld.config in your /system/etc of port image, then replace it with /system/etc/ld.configs.txt from semiGSI.

Remove /system/etc/permissions/qti-permissions.jar

Modify /system/etc/prop.default to disable adb secure and enable all debug props for debugging.

Unpack /vendor from port, try to find out services added by OEM in manifest.xml.
The manifest can be in /vendor or /vendor/etc/vintf
Pick out all /vendor HALs related to services you found in manifest.
Basically they are located in:
/vendor/bin/hw
/vendor/etc/init
/vendor/lib&lib64/
/vendor/lib&lib64/hw

Also look for some additional files related to OEM rom.(framework, overlays etc.)


Then pack your /system into img.

Flash 8.1 vendor & P semi-GSI boot & vendor patches.

Flash your port.

Add all additional thing you found in vendor.
You need to modify your device's manifest.xml and add OEM related.

Flash FBE Disabler and permissiver to disable FBE and SELinux.

Format /data ,push adb keys into system for debug
& reboot.

If you're lucky then you can get into bootanimation.If not, try to check everything.

Use adb logcat >logcat.txt and get logs.

Open the log, search 'died' and you will get to lines near system crash. Here you need some ROM porting skills,try to find out what's going wrong.
 

fxsheep

Senior Member
May 26, 2017
399
543
113
Some frequently bug's solutions:

'dumplicate permission : XXX'
Find the XXX permission in files in /system/etc/permissions . Delete lines for that permission.

'fail to make lockscreen ready'

Add libpuresoftkeymasterdevice.so from P semi GSI to your /system.

Reboot or black screen after enter system
(Most SDM845 ports)
Replace
/system/bin/surfaceflinger
/system/lib&lib64/libsurfaceflinger.so and libtimestats_pronto.so
 
Last edited:
  • Like
Reactions: VanoSM

fxsheep

Senior Member
May 26, 2017
399
543
113
Great job, OP. My question is, does this mean that in the future we may be able to trebelize most, if not all, OEM roms?
The answer is ,'yes it should be'.In theory ,ported sGSI should work on the same platform ,e.g. Qcom sGSI,Exynos sGSI.But these OEM roms usually intend to specific hardware, so there may always bugs exist.As we know developers of O GSIs did a lot of hacks ,try to enable the maximum compatibility.But porting makes this not possible cuz no source code.

Also, the port I do is only on OEM without too much modification to original P, what about Samsung with their own hals and Huawei EMUI with the *** OEMINFO partition ? These roms are not possible to port in the near past,I think nor in the near future.
 

fxsheep

Senior Member
May 26, 2017
399
543
113
Surprising Update : I got leaked EMUI 9 rom of Huawei Mate 20 (powered by Kirin 980) and followed this method on a Qualcomm Trebled device. What surprised me is that I already got bootanimation ,end up with the same SELinux error when I port MIX2S MIUI P.
This may means that in the future we can even port roms between platforms ,and make real GSI.
 

fxsheep

Senior Member
May 26, 2017
399
543
113
Surprising Update : I got leaked EMUI 9 rom of Huawei Mate 20 (powered by Kirin 980) and followed this method on a Qualcomm Trebled device. What surprised me is that I already got bootanimation ,end up with the same SELinux error when I port MIX2S MIUI P.
This may means that in the future we can even port roms between platforms ,and make real GSI.
If anyone can give me the way to get this firmware https://www.xda-developers.com/huawei-mate-10-pro-android-p/amp/
Then I can prove it
 
  • Like
Reactions: prin2ce

麦麦观

Member
Dec 10, 2017
27
9
0

Attachments

unknown

Senior Member
Oct 2, 2016
1,580
505
0
17
Hanoi
dohoangkhanhnam.blogspot.com
Surprising Update : I got leaked EMUI 9 rom of Huawei Mate 20 (powered by Kirin 980) and followed this method on a Qualcomm Trebled device. What surprised me is that I already got bootanimation ,end up with the same SELinux error when I port MIX2S MIUI P.
This may means that in the future we can even port roms between platforms ,and make real GSI.
Do you think is it possible to port oppo color os into gsi ? :confused::confused:
 

fxsheep

Senior Member
May 26, 2017
399
543
113
Update:This guide does not support P Release versions.i.e.If you port any P roms which is marked as "release" not "beta" by OEM then probably this won't work.It can only boot on 9.0 vendor.
 

MAREK10747

Senior Member
Feb 4, 2016
403
184
73
Better is make script same as my :) cd C:\Users\MAREK\Desktop\BASE\system
echo FAZA 1 ld.config.txt
pause
COPY C:\Users\MAREK\Desktop\BASE\system\etc\ld.config.txt C:\Users\MAREK\Desktop\skrypt\BASE\system\etc\
pause
echo FAZA 2 libselinux.so
pause
COPY C:\Users\MAREK\Desktop\BASE\system\lib\libselinux.so C:\Users\MAREK\Desktop\skrypt\BASE\system\lib\
pause
COPY C:\Users\MAREK\Desktop\BASE\system\lib64\libselinux.so C:\Users\MAREK\Desktop\skrypt\BASE\system\lib64\
pause