[Android Software Development] egingell:
I will be using this thread to post my scripts and link them to other threads as needed. For this thread, I am assuming you know what you're doing. You don't need mad hacking skills and you don't need to be an expert (I'm sure as hell not), but knowing your way around the file system and basic shell scripting are helpful.

Some background: I am using the stock ROM and kernel (SGS2 - GB27, SGS4 - MDC), so all of my tips revolve around using stock and all of my scripts (even the flashable ones) will work without flashing from recovery (just extract the script from the ZIP and execute it while the phone is in phone-mode - you know... powered on :p ).

You are welcome to use my scripts in your apps. I only ask that you give me some credit. :)

I am not responsible for bricking your phone. I have only tested my scripts on my personal Samsung Galaxy S2 and S4 from Sprint. You are welcome to try on your phone, but I offer no warranties or guarantees as to whether they will work or not. Back up your ****!

All of this requires root!

Below is a list of the scripts I have written for y'alls. Enjoy.

Custom df: Shows where irregular mounts ("mount -o bind") are mounted. [ Forum post | Download ]

Currently doesn't work on my SGS4.

Easily move Phonesky.apk and GoogleServicesFramework.apk to /system or /preload for Multi DPI Play Store. [ Forum post | Download ]

Untested on my SGS4, but there's no reason to think that it won't work.

Use your SGS2's internal SD card for Link2SD instead of making a second partition on your external SD card (although, depending on the setup, you may still need to make a tiny partition on your external SD card) and your external SD card as your internal SD card [ Forum post ]

Untested on my SGS4. I have no need for it.

Clean up Link2SD: Delete files associated with Link2SD when uninstalling it. It does not revert the links Link2SD makes. It only deletes the mount scripts. [ Forum post | Download ]

If you use the debuggerd script to enable init.d, running this script will cause you to lose init.d.

Untested on my SGS4, but there's no reason to think that it won't work.

Delete Samsung's bloatware from the Sprint SGS2. [ Forum post | Download ]

Untested on my SGS4, but there's no reason to think that it won't work; however, it was written specifically for the SGS2's bloatware. See thread S4 System Apps Safe To Remove for a list of SGS4 bloatware apps.

Google Home Launcher (from Kit Kat).

Works on Jelly Bean.

Below are some other tweaks.

You can use custom boot animations with the stock ROM. All you need to do is swipe a "/system/bin/bootanimation" binary file from another ROM (such as [MENTION=599465]rujelus22[/MENTION]'s Blu Kuban FL24 (ICS) or Blu Kuban GB27 (JB 4.1.2)), paste it into "/system/bin", and make it executable.

For JB 4.2.2, make sure the user and group are root and shell respectively. This doesn't seem to be a problem with JB 4.1.2 and below. It's also possible that my initial testing involved a boot animation that didn't work on my SGS4, so if it works with root as both user and group, then roll with it. :good:

Also for JB 4.2.2, use the file from a JB 4.2.2 ROM, such as The Blu Kuban S4.

You can enable init.d scripts very easily by renaming "/system/bin/debuggerd" to "/system/bin/debuggerd.bin", replace it with the following, and make both files executable. If "/system/bin/debugger.bin" already exists, then edit "/system/xbin/busybox run-parts /system/etc/init.d" into "/system/bin/debuggerd".

As with the above, make sure the user and group are root and shell.

[color=green]#!/system/bin/sh[/color]
LOG=/data/debuggerd.log

echo "$(date)" > $LOG
echo "init.d" >> $LOG

/system/xbin/busybox run-parts /system/etc/init.d 1>>$LOG 2>>$LOG

echo "$(date) finished" >> $LOG
echo debuggerd.bin launched >> $LOG
exec /system/bin/debuggerd.bin

Below are some tips.

Most of the things you can do with a custom kernel, you can do with the stock kernel, it just requires more work and more risk.

If you replace an odexed system app with a deodexed system app, make sure you delete the app's ODEX file (it's the same file name except with the extension .odex).

Conversely: if you replace a deodexed system app with an odexed system app, you better have the ODEX file to go with it.

You can clear the dalvik-cache without a custom kernel by deleting the contents of "/data/dalvik-cache". You can even delete an individual app's dalvik-cache by finding the file "/data/dalvik-cache/data@app@.apk@classes.dex" or "/data/dalvik-cache/system@app@.apk@classes.dex" and delete it.

You can manually uninstall a system app's update by finding the file "/data/app/.apk" and delete it.

You can manually delete all user data by deleting the contents of "/data/data". You can even delete an individual app's data by finding the folder "/data/data/" and delete it.

Making scripts and binaries executable:

They must be on an EXT formatted filesystem (e.g. /data, /system, /preload).

They must be at least readable and executable by the user 'shell' (755 (read/execute for all, write only for user - "u=rwx,a=rx" if your busybox supports that method) is what I usually use).

chown root:shell ""
chmod 755 ""
chmod u=rwx,a=rx "" # busybox must support symbolic modes

Changing file permissions requires read/write access to the filesystem on which the file resides:

mount -o remount,rw /system # make the /system partition read/write
mount -o remount,ro /system # make the /system partition read only

The stock kernel is considered "production" whether or not it's rooted; therefore, you cannot use ADB to push or pull files directly to or from protected partitions, nor run ADB as root, nor use ADB's remount command, so you have to use unprotected partitions as a sort of buffer. You can, however, access the ADB shell and issue the "su" command wherein you can use "cp" to copy files to or from protected partitions prior to using ADB to push or pull the desired file. However, there is an app aptly named [root] adbd Insecure by [MENTION=631273]Chainfire[/MENTION] that patches the ADB daemon to get around this limitation.

Example:

c:/android-sdk> adb shell
shell@android:/ $ su
root@android:/ # cp /system/bin/debuggerd /sdcard/debuggerd
[COLOR="green"]-- open a new command prompt window --[/COLOR]
c:\android-sdk> adb pull /sdcard/debuggerd debuggerd
c:\android-sdk> adb push debuggerd /sdcard/debuggerd
[COLOR="green"]-- switch to the first command prompt window --[/color]
root@android:/ # mount -o remount,rw /system
root@android:/ # cp /sdcard/debuggerd /system/bin/debuggerd
root@android:/ # chown root:shell /system/bin/debuggerd
root@android:/ # chmod 755 /system/bin/debuggerd
root@android:/ # mount -o remount,ro /system

Some noteworthy files and folders:

/proc/self/mountinfo: If you can read it, it tells you where your partitions and folder binds are mounted.

/proc/partitions: Shows all of your SD card's partitions, how many blocks each has, and their vold numbers (eg "179 1 30578964 mmcnlk0p1").

/dev/block/platform/dw_mmc/by-name: This folder contains symlinks to your internal eMMC's partitions indexed by what they are for (eg UMS for your internal SD card - "realpath /dev/block/platform/dw_mmc/by-name/UMS" will print out the device path (ie "/dev/block/mmcblk0p11")).

/dev/block/platform/dw_mmc/by-num: This folder is like the previous except that they are indexed by partition number (eg "p11").

/proc/version: Shows what version of Linux is currently being used.

/data/system/batterystats.bin: Delete this when your battery is fully charged and still plugged in to recalibrate it.

Footnotes:

For "/data/app", "/data/data", and "/data/dalvik-cache" files you need to know the package name. There are various apps that will tell you, including Link2SD (mentioned above), Titanium Backup, and the web URL of the app in the Play Store (ex: https://play.google.com/store/apps/details?id=com.devname.appname).

More:

Random boot sound using your notification sounds

Make ADB work for all users - Jelly Bean 4.2.2 (Updated 07/15/13 00:35 MST)

Stock ROM - SGS4 - init.d

No-data restore tips

SGS4 Bloatware Remover

Make apps run faster and increase battery life