[Android Software/Hacking General [Developers Only]] steadfasterX:
Bring FIsH on the menu card (porting FIsH)

So you may now have a little bit understanding of what FIsH can do for you and what not.

When you feel FIsH could work for your device then why not just trying to port it?

This guide should help you for this task.

FIsH was made from scratch with portability in mind.

That means I tried to make it as simple as possible for you to port.

I really hope that task has been accomplished.. :P

1. Met the pre-requirements

You have to understood that FIsH will work ONLY when the pre-requirements are met.

There is no way around or "if i met 1 of the 2 - will it work?" NO. You need BOTH!

If you will be asked by a user to port FIsH -> Ensure that the requirements can be met first before investing your time.

There is an easy test u can go for this: just execute the installer like this:

./install.sh --check

The installer will test and check if it get what it needs and then EXIT without(!) any installation.

2. Build your FIsHFOOD (your custom ramdisk)

I recommend to start with TWRP but choose whatever you like. For this guide i stay with TWRP.

Keep in mind that your FIsHFOOD has to be build with the same sources as

your running STOCK ROM.

If you want to support multiple STOCK ROM versions you may have to build multiple FIsHFOOD versions.

Testing your FIsHFOOD is not that easy on locked devices so your only option is to go on once you feel your build is ready.

3. Cook the FIsHFOOD

When you build images or ramdisks you may end up with an image file needed some preparation first:

4. Prepare the FIsH installer

Download FIsH and extract it.

open the file install.sh

Check the variables u may need to adjust: Check Post #2 above for some explanations and read the comments within

Note about the Android goFIsHing installer (fishing/gofishing.sh)

You normally do not need to touch this file. It may be required if you cannot install FIsH but that should hopefully not happen..

5. Cook the FIsH

open fishing/FIsH.porting

You will find 2 sections: GLOBAL and PORTING

Each section has hopefully meaningful comments to give you an idea what they do and how you should modify them.

Most vars also have example instructions to find the correct values for your device.

When you're trying to port FIsH you may have to try & error FIsH several times before and you may do not want to use your defined key combo to do so.

For this and also as a convenient option when you want to boot directly into FIsH from Android you can set a special flag to always boot FIsH.

Use it with care because it may let it bootloop while in your testing phase.

The file which activates FIsH without a key press is: /cache/recovery/boot

It can make sense to use this for an easier testing process (don't need any key presses to activate FIsH).

In sum the following command comes very handy while developing:

./install.sh && adb shell "su -c touch /cache/recovery/boot" && adb reboot

So the other way is using a key combo without the need to boot into Android.

For this you will find everything you need in the file fishing/FIsH.porting which you usually have to adjust to your specific device.

Providing user feedback for activating the FIsH:

FIsH gets NOT activated by default. That means if you would reboot your device it will

just reboot

.

To

activate

FIsH you need either to use a key combination (provided by you) or using the FIsH file flag.

The idea of the FIsH booting process is (see fishing/FIsH.porting)

a) WAIT_LED: show a LED color indicating FIsH has been STARTED (not ACTIVATED)

---> the user has to press the magic key combo NOW

b) VIBRATE: will vibrate to indicate that the time for pressing the magic key combo is over

c) FISH_LED: show a LED color indicating that FIsH has been ACTIVATED .... or NOT!

d) boot into either Android or your FIsHFOOD depending on what the user wants

If your device does not support different LEDs you can instead use the path to vibrate in the LEDs.

e.g. WAIT_LED="$VIBRATE". This will let the device vibrate instead of showing a LED color.

Whatever you end up with you have to check and adapt the enduser installation guide ofc as well..

6. Let the FIsH swim

Now it's time to test your FIsH port. But BEFORE:

You will take a high risk here at this early stage because it CAN bootloop/soft-brick your device if something goes totally wrong!

I hope I had done all to keep the risk for this low but no guarantees!!

So make a FULL backup of ALL your apps and do not forget to backup your internal storage with all your pictures etc.!!! (just a reminder: TWRP does NOT backup your internal storage!! Read the explanation here)

If the worse case happens you may need to totally bring your device back to pure STOCK so you have been warned!

7. Finally give the FIsH a name

If your FIsH swims... omg.. CONGRATS well done !!! The most hardest stuff is done now! Woot u r a REALLY good dev did u know that?! :) Your community will praise u! :)

Of course u r free to choose a name but I recommend to name your FIsH package like this:

[yourFIsHFOOD]-in-FIsH-v[VERSIONNUMBER]_[DEVICE-MODEL]_[Android-Version]

e.g.

TWRP-in-FIsH-v1_LG-G4_LL.tgz

Note: Did u see the different use of dashes and underscores? Keeping it that way is important.

This way we all get a clear understanding what it is, which TWRP-in-FIsH version, for which device and for which STOCK ROM version.

8. Release your FIsH to the wild ocean

Ok I will not tell you how you should release but it would be nice if you tell the users where this all comes from ;)

Do not forget to report back to this thread if you have implemented a port so I can add it here for reference.

An example installation guide for your endusers can be found at Post #7: Go FIsHing

If you struggle somewhere

you can find me in the IRC (see OP)

When you have to choose a channel it is: #Carbon-Fusion

When you will be asked for a server network choose: freenode

Trouble / Bootloop fix

if you encounter a bootloop (should never happen but who knows) you have 3 choices at least:

Option 1a: (TWRP-Bootloop) Within TWRP open Advanced -> File Manager -> Goto: /system/su.d and click "select" button -> Delete

Option 1b: (TWRP-Bootloop) From your PC: adb shell rm -rf /system/su.d/

Important

: Catch the fish log (see next topic)

Option 2 (this works also for a bootloop without twrp): boot into download mode and use LGLaf to get a shell

then:

setenforce 0 <-- if that doesn't work you may have to do a FULL restore to stock

mount -oremount,rw /system

rm -rf /system/su.d/

reboot. You are out of the bootloop.

Important

: Catch the fish log (see next topic)

Option 3: Last resort: Reflash STOCK. sorry.. there is always a risk..

Catch the FIsH logs

when in TWRP (or other ramdisk providing adb shell):

adb shell "cat /cache/fish/fish.log"

adb shell "cat /tmp/recovery.log"

OR - when in Android:

adb shell "su -c cat /cache/fish/fish.log"

adb shell "su -c cat /cache/fish/fish.log.old"

adb shell "su -c tar cvzf recoverylogs.tgz /cache/recovery"

adb pull recoverylogs.tgz

Upload the output to https://paste.omnirom.org and paste the link in the IRC channel