[Miscellaneous Android Development] Typhus_:
Hello!

Just wanted to share with you my progress. ;)

Bugs I had:

- Baseband unknown (Lost IMEI's, Wi-Fi and BT MAC's)

- HOME and MENU soft buttons didn't work

- I had no access to internal storage (only external while using CM's File Manager)

Bugs I have now:

- Baseband unknown (Lost IMEI's)

- MENU soft button doesn't work

Solving steps:

- WiFi and BT are able to work after changing SELinux to permissive (using SELinuxModeChanger apk)

- HOME key works after deleting the file "mtk-tpd.kl" and editing the file "mk-kpd.kl" (removed the # in line 29)

- I now have internal and external storage available. Many thanks to [MENTION=5186178]carliv[/MENTION] (I've checked THIS post and there I've found THIS official documentation about storage configuration)

Storage solving steps explained in detail:

init.mt6592.rc (kingzone's CM12 original kernel's ramdisk)

on init
export LD_PRELOAD /system/lib/libxlog.so
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1

mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root

symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard

mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw[/COLOR]

.....

on fs

.....

[COLOR="Red"]#setprop ro.crypto.fuse_sdcard true[/COLOR]

.....

# virtual sdcard daemon running as media_rw (1023)
[COLOR="red"]service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
service fuse_usbotg /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbotg /storage/usbotg
class late_start
disabled

After analyzing the official documentation, and also, after noticing that my stock kernel ramdisk had a file "init.ssd.rc", I've modified init.mt6592.rc to:

on init

[COLOR="Blue"]mkdir /mnt/shell/emulated 0700 shell shell
mkdir /storage/emulated 0555 root root

mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard1 0700 root root

export EXTERNAL_STORAGE /storage/emulated/legacy
export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
export EMULATED_STORAGE_TARGET /storage/emulated
export SECONDARY_STORAGE /storage/sdcard1[/COLOR]

export LD_PRELOAD /system/lib/libxlog.so

[COLOR="blue"]mount tmpfs tmpfs /storage/emulated mode=0755,uid=1023,gid=1023

# Support legacy paths
symlink /storage/emulated/legacy /sdcard
symlink /storage/emulated/legacy /mnt/sdcard
symlink /storage/emulated/legacy /storage/sdcard0
symlink /storage/sdcard1 /mnt/sdcard2[/COLOR]

.....

on fs

.....

[COLOR="blue"]setprop ro.crypto.fuse_sdcard true[/COLOR]

.....

# virtual sdcard daemon running as media_rw (1023)
[COLOR="Blue"]service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
class late_start
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
service fuse_usbotg /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbotg /storage/usbotg
class late_start
disabled

fstab.mt6592 (kingzone's CM12 original kernel's ramdisk)

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/emmc@android /system ext4 ro,commit=1,noauto_da_alloc	wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/devices/platform/mtk-msdc.0/mmc_host/mmc0/mmc0	auto	[COLOR="Red"]auto	[/COLOR]defaults	voldmanaged=sdcard0:[COLOR="red"]8,nonremovable,noemulatedsd[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1/mmc1	auto	[COLOR="red"]auto	[/COLOR]defaults voldmanaged=sdcard1:auto
/devices/platform/mt_usb	auto	auto	defaults	voldmanaged=usbotg:auto

Changed to:

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/emmc@android /system ext4 ro,commit=1,noauto_da_alloc	wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/devices/platform/mtk-msdc.0/mmc_host/mmc0/mmc0	auto	[COLOR="Blue"]vfat[/COLOR]	defaults	voldmanaged=sdcard0:[COLOR="Blue"]auto[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1/mmc1	auto	[COLOR="blue"]vfat[/COLOR]	defaults voldmanaged=sdcard1:auto
/devices/platform/mt_usb	auto	auto	defaults	voldmanaged=usbotg:auto

This was a mere guess. Don't know if this is the most accurate configuration but...well, it works.

framework-res.apk (framework-res.apk\res\xml\storage_list.xml kingzone's CM12 original)

<?xml version="1.0" encoding="utf-8"?>
<StorageList
xmlns:android="http://schemas.android.com/apk/res/android">
<storage android:mountPoint="/storage/sdcard0" android:storageDescription="@string/storage_internal" android:primary="true" [COLOR="Red"]android:removable="false"[/COLOR] android:allowMassStorage="true" />
<storage android:mountPoint="/storage/sdcard1" android:storageDescription="@string/storage_sd_card" android:primary="false" android:removable="true" android:allowMassStorage="true" />
<storage android:mountPoint="/storage/usbotg" android:storageDescription="@string/storage_usb" android:removable="true" />
</StorageList>

Changed to:

<?xml version="1.0" encoding="utf-8"?>
<StorageList
xmlns:android="http://schemas.android.com/apk/res/android">
<storage android:mountPoint="/storage/sdcard0" android:storageDescription="@string/storage_internal" android:primary="true" [COLOR="blue"]android:emulated="true"[/COLOR] android:allowMassStorage="true" />
<storage android:mountPoint="/storage/sdcard1" android:storageDescription="@string/storage_sd_card" android:primary="false" android:removable="true" android:allowMassStorage="true" />
<storage android:mountPoint="/storage/usbotg" android:storageDescription="@string/storage_usb" android:removable="true" />
</StorageList>

DONE! :victory:

Currently I can't still understand why the HOME

MENU

key doesn't work...weird (I've tried the same solution used for HOME key and it didn't work).

Now I'll try to find if I know how to fix Baseband unknown bug (the most awful one...).

I hope that, with this, I may help anyone else trying to port this to their device.

Cheers!