[Moto Z Questions & Answers] erfanoabdi:
Hello again guys

today i just wanted to play with treble and CLT so i decided to boot MIUI from leaked oreo 8.1 firmware : https://www.xda-developers.com/xiaomi-redmi-note-5-pro-android-oreo-stable/

and after all it's booted on griffin

i'll upload my twrp backup from system partition

bugs : very very unstable :

* for boot need to enter "wificond" in adb shell and to get adb access you need run this command on adb shell from twrp : "cd ~/.android && adb push adbkey.pub /data/misc/adb/adb_keys"

* wifi broken

* ril broken

* camera broken

whats working :

* few things like BT and sensors ...

twrp backup : https://www.androidfilehost.com/?fid=890129502657599583

flash lineage

restore backup

flash premssiver.zip

---------------------------------------------------

how is it booted?

i'm going to explain from beginning, porting it is not very hard

got leaked miui and latest lineage and started CLT on it

then i got miui with griffin vendor inside

flashed on device with clean (not magisked) boot.img from lineage

and enabled premissive selinux

edited prop.default and build.prop to remove device specific props and enabled adb + pm.dexopt (see props.zip)

build.prop for /system/

and prop.default for /system/etc/

>>> First try to boot failed by rebooting to bootloader

by generating multiple times the spammy console-remoops, finally i found out reboots because of selinux problems

i didn't want to mess with it so i directly adb pushed lineage /system/etc/selinux dir to my device

>>> booted to bootanimation

here i got huge errors as usual

/bin/keystore was looking for vendor.qti.hardware.wifi.keystore...._vendor.so and we don't have it because that miui rom is built from full CAF source and we are using aosp keystore in lineage so i replaced it with lineage /bin/keystore

wificond had missing symbol which is coming from qsap_sdk so i just replaced miui wificond with lineage one

and cameraserver is spamming here

>>> nothing much same on bootanimation

now zygote dies because can't find power_profile.xml in res/xml

actually this miui is not enabled RRO in that build so theres no framework-res__auto_generated_rro.apk in vendor, everything is on system framework-res.apk

so i removed my framework-res__auto_generated_rro.apk

need to wipe data

>>> failed again

libstagefright had some issues

i replaced it with lineage one with some other media libs (sorry i don't remember names)

>>> i guess booted this time :fingers-crossed: but soft reboots on setupwizard on trying to search for wifis with this error:

04-23 11:04:56.499 893 1505 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: WifiScanningService
04-23 11:04:56.499 893 1505 E AndroidRuntime: java.lang.IllegalArgumentException
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.os.BinderProxy.transactNative(Native Method)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.os.BinderProxy.transact(Binder.java:767)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.net.wifi.IWifiScannerImpl$Stub$Proxy.scan(IWifiScannerImpl.java:310)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.WificondControl.scan(WificondControl.java:600)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.WifiNative.scan(WifiNative.java:351)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.scanner.WificondScannerImpl.processPendingScans(WificondScannerImpl.java:452)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.scanner.WificondScannerImpl.startSingleScan(WificondScannerImpl.java:203)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.scanner.HalWifiScannerImpl.startSingleScan(HalWifiScannerImpl.java:78)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.scanner.WifiScanningServiceImpl$WifiSingleScanStateMachine.tryToStartNewScan(WifiScanningServiceImpl.java:851)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.server.wifi.scanner.WifiScanningServiceImpl$WifiSingleScanStateMachine$DriverStartedState.processMessage(WifiScanningServiceImpl.java:650)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.internal.util.StateMachine$SmHandler.processMsg(StateMachine.java:992)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at com.android.internal.util.StateMachine$SmHandler.handleMessage(StateMachine.java:809)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.os.Handler.dispatchMessage(Handler.java:106)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.os.Looper.loop(Looper.java:164)
04-23 11:04:56.499 893 1505 E AndroidRuntime:	at android.os.HandlerThread.run(HandlerThread.java:65)

you can stop rebooting by entering "wificond" in adb shell

now setupwizard after sim detect stops with black screen

---

in logs we can see it's looking for 2 services miui.shell and miui.fdpp :silly:

they have some ramdisk scripts related to miui in boot.img but all we need is init.miui.rc

import it in your init.qcom.rc and add to /vendor/etc/init/hw/

almost done but you need to clear file_contexts of this 2 bin because we're using lineage sepolicies : /system/xbin/shelld and /system/bin/fdpp

>>> setupwizard goes further

but i couldn't finish it so simply removed it from /priv-app

booted but system is not very usable

so i took this TWRP backup and tried flashing gapps

finished setupwizard

and restored backup

>>> now miui is fully booted

i don't know any better way to bypass setupwizard :p