Monday, January 30, 2012

CM9: ICS Android 4.0.3 for Samsung Epic 4G

qbking77's Video Review of CM9 alpha0 for Epic 4G

The Epic CM team is proud to announce the release of CM9 alpha 1 for Sprint's Samsung Epic 4G.  This is VERY NEW so please read these pages carefully before you proceed with testing.
How to Install CM9 Alpha0 on Epic 4G

Please discuss CM9 in the Epic Cyanogenmod forum.

If you appreciate our work, please consider supporting the Epic CM team. Thanks to Cyanogenmod and Teamhacksung for making this possible!

Camera on CM9 -- Feature Showcase

Some quick shots of a few android figurines I have lying around my desk.


As you can see, all the functions seemed to be handled properly by the camera sensor.



..............................................................................




These panorama shots are directly from the ICS camera app.







Pardon my inability to keep my hands steady.



............................................................................


Below is an exampled of HD recording in CM9. Notice Auto White Balance is fully functional.

Friday, January 27, 2012

Issue with Low memory killer and kswapd0

UPDATE: This was fixed in CM9 alpha2.  We think...

CM9 longterm testing is showing Android and kswapd0 (part of the linux kernel) are fighting over the small amout of space available.  Android appears to be caching some apps to use most of the available space however when an App opens the sudden lack of free ram causes kswapd0 to become very active and and eat a lot of cpu for seemingly no purpose till android releases a small amount of ram to pacify kswapd0.

I backed out https://github.com/CyanogenMod/android_kernel_samsung_victory/commit/9f470cb2eda8f9c5316c2772bf0c2d5c53d8b138 which was a lowmemkiller change and it appears to have been the cause of the issue.  I am continuing to monitor the memory and will update with any further changes.  Is there threshold changes that need to be made?

Thursday, January 26, 2012

CWM modem upgrades: EC05 to EI22 or EL30

You can use Odin or Heimdall to flash the full EC05 modem binary, download links and instructions are available in the XDA modem thread.  CM users must use this special BML-capable CWM that boots from sdcard in order to flash the below modem updates!  Save it on your sdcard along with your desired modem upgrade .zip.

Upgrading to EI22 modem - currently CWM flashing from EC05 is the only way to install the EI22 modem.

epic4g-cwm-modem-delta-EC05-to-EL30.zip
md5sum 7832dc8545dd3dc2d267fc2b31f8ca23
epic4g-cwm-modem-delta-EC05-to-EI22.zip
md5sum af7360bca8beea9829cb87dddaef8acc
epic4g-cwm-modem-delta-EI22-to-EL30.zip
md5sum 002807b930c1f91b0c8792f41bd0f9d5

NEW! EL30 modem is now available for Odin flash.  See here for downloads and a video demonstrating how to flash it.
NEW! FC09 modem is available for CWM delta flash.  See here for release notes.


Some users have reported that they need to boot into Samsung's stock EL30 in order to update Profile and PRL after updating the modem.  If you are having data issues after upgrading the modem, a convenient method is via the temporary EL30 from sdcard.  Data will not work while booted in EL30 sdcard, but you will be able to update Profile and PRL and reboot back into CM7 where data should work.

Warning: Delta modem upgrades often result in a corrupted modem.  If you have weird issues after an upgrade, reflash EC05 or EL30 with Odin and try again.

If this tip was helpful, please consider supporting the Epic CM Team with even a tiny contribution.

Tuesday, January 24, 2012

Boot CWM5 BML from sdcard, NO FLASH

Samsung Epic 4G owners who have converted their phones to MTD partition layout can "flash" this in MTD recovery.  It temporarily boots CWM5 BML, allowing you to flash modem upgrades without wiping your phones back to BML layout.  You may safely ignore the error messages when this CWM starts.  This CWM is not written to your phone, so the next time you run recovery it will be MTD CWM.

Requirement: Your CWM MTD recovery kernel must support kexec.  CM7 kernels nightly 12+ support kexec.

[CWM-bml-sdcard-5.0.2.7-epic4g.zip]
md5sum bb5a10ae66eb4d39fea0f18bf361329e

[XDA discussion]

Thanks to mkasick for making kexec possible on the Epic 4G, and to DRockstar for CWM5.

If this tip was helpful, please consider supporting the Epic CM Team with even a tiny contribution. 

Tuesday, January 17, 2012

Porting TouchWiz Apps for CM7



So hey, I'm Tortel. Recently, I've taken some time to port some of my favorite stock apps to CM7. In that time, I came up with a pretty decent process to remove all the TouchWiz dependencies from stock apps, and I would like to share what I have done. Check the thread on XDA for some downloads.

Here's the basic steps I took for removing the TouchWiz dependencies from the Memo, Calendar, and Task Manager apps

1. De-compile the app
I used apktool for this, use whatever you want

2. Remove the library dependence from the AndroidManifest.xml
The line looks like this:
<uses-library android:name="touchwiz" />
With that removed, it will install correctly. Might not work yet, but it will install.
Something else to look out for is alsong the lines of ‘com.device.samsung’

3. De-compile both the twframework.jar and twframework-res.apk files.

I used apktool again for this. We need the code for the stupidly re-written widgets, resources, and other shit.

4. Copy the twframework code into the app source.
With apktool, the directories to copy are in ‘twframework.jar.out/smali/’
Copy that entire directory tree into the app your de-TWing. Some directories will overlap, that’s normal.
The app your working on now contains both its own code, and all the needed TouchWiz code. There’s a small chance it might work if you recompile it now, but it probably also needs resources.

5. Update the resources

a. Add the needed files/parts
I found its easiest to search for any ‘@touchwiz:’ parts in any xml file under res/.
Next, you will need to merge everything under /res/ from the twframework-res.apk.
Copy over anything that doesn’t already exist. Files under /res/values/ (Except public.xml) will need to be merged, meaning insert all the values from the framework into the app, before the closing tag (Keep the XML valid). If your missing any resources, re-compiling the APK will fail and let you know vaguely what you need.

b. Remove the touchwiz references
Replace every occurrence of ‘@touchwiz:’ with just an ‘@’
In the Memo.apk, there were lots of references to ‘@touchwiz:color__’. find and sed are helpful
Don’t forget to remove the colon!

There are some calls to IDs in the 0x20 range, this is an issue because as far as I know, the 0x20 range can only be provided by the system somehow. For the Calendar app, I had to remove setIcon calls in a few activities to prevent ResourceNotFound exceptions.
If you remove them, then some things like images might not work. I also found that just removing them can cause random NullPointer errors.

Note: While working on the Task Manager, it became more complex. I had to update the old 0x20 references to the references within the new package.
After the resources are added, decompile it again, so the added resources show up in the /res/values/public.xml
Search for the old 0x20 value, and update it to the new value. If you include the /smali/touchwiz/ directory, then you can just search for the hex value and you will get the name of it from the TW R.smali files, and you can find the updated hex value in the /res/value/public.xml file

6. Re-compile

I used apktool again.

7. Sign the apk

Its a system app, so it will need one of two possible keys: The CM testkey, or the CM platform key, depending on its permissions.
These keys are found in ~/android/system/build/target/product/security/ as testkey.pk8 and testkey.x509.pem (Or platform)

To sign using these files, you need SignAPK (http://code.google.com/p/signapk/)
Usage: signapk testkey.x509.pem testkey.pk8 original.apk signed.apk

The Calendar and provider needed the testkey signature, but the Task Manager needed the platform signature. It depends on the permissions of the app. Check the log for any permission errors, and google them. Most apps will probably only need the testkey signature.

8. Install
adb push /system/app/ ftw!

9. Run it, and have logcat open
Check for any exceptions, fix whats needed, and re-test.
Most likely, you’ll run into ResourceNotFound exceptions, and maybe NullPointer exceptions. This is the most fun part.
For ResourceNotFound, I grepped the source for the hex value. Then checked for the new value, and replaced all occurrences. (See 5b)
NullPointer exceptions seem to be from findResource calls. Check the smali for the class where the error occurs, and replace any 0x20x hex values with the updated value.
Keep testing until it actually works. Make sure you check all parts of the app, and the context menus. Samsung’s code isn’t the cleanest, so there are fun surprises hiding everywhere.



Once its running
Don’t forget to zipalign the final working apk, after its signed. Then it should be all set.

Wednesday, January 11, 2012

Tools: repoclone, reporeset, repohardlink

Updated: January 22nd, 2012

I wrote three simple scripts that may be useful for Android AOSP or CyanogenMod developers.  Download the scripts from github.
  • repoclone
    • Clone entire local repo to another local repo.  VERY QUICK because it uses hardlinks between git pack objects.  This is safe because git clone itself hardlinks these large files if you clone two local git repos.  Note: repoclone can be even more storage efficient if it runs git gc in every git repo prior to cloning.  Future versions will do this.
  • reporeset
    • git reset --hard in every git repo.  You can also use this to fully clean your existing repo back to pristine sources.  First use repo status to check for topic branches and repo abandon if you want to drop your local branches and revert fully to upstream.
  • repohardlink
    • Use this script to safely hardlink git pack objects between two existing repos in order to reclaim some storage space.  For best results, repo sync in both repos prior to using repohardlink.  By default, repohardlink will only attempt to unify git repos that have changed since you used repoclone.  Use --all to unify storage between two existing repos.  Unfortunately, --all is not as storage efficient as repoclone.  Currently repoclone saves you ~2GB additional storage between two parallel CM trees.
Why repoclone?
  • If you have cm7 locally and want a parallel cm9 repo so you can easily build from both, you can use this script to have both repos side-by-side while maximizing storage efficiency.
    • repoclone cm7 cm9
    • cd cm9
    • (Edit your .repo/local_manifest.xml) 
    • repo init -b ics
    • repo sync
Please reply here or write me at wtogami@gmail.com if you have any comments or questions.

If this tip was helpful, please consider supporting the Epic CM Team with even a tiny contribution. 

Tuesday, January 3, 2012

First Glimpse of Working 4G on Epic CM7

Great job UberPinguin and the CM7 team!  Toggle and tether doesn't work yet, but this is a major step forward!  See this thread for details.

Fix wifi on Epic 4G

These instructions are to help fix Wifi issues that some people have with EI22 or CM7 firmwares.  For example, EI22 for some people will disconnect and reconnect wifi repeatedly.  CM7 for some people has connection problems with wifi.  This procedure seems to fix wifi for many people, although we don't know why.
  1. Follow these instructions for the Odin recovery tool and flash the stock tar image to restore your Epic to EC05.
    • Use a better USB cable.  The one that came with the Epic most often will fail.  If Odin fails, your USB cable is probably bad.  I had to try three different USB cables until I found one that worked reliably.
  2. Boot your phone with stock EC05 and test wifi.  It should be stable.  DO NOT ROOT
  3. Download this file, put it in /sdcard, and rename to update.zip.
  4. 3-finger boot into stock recovery.
  5. Update will flash to EI22 stock.
  6. Boot your phone with stock EI22 and test wifi.  It should be stable.  DO NOT ROOT
  7. Put your desired custom ROM in /sdcard.
  8. Go here and download cwm-5.0.2.7-epic4g.tar.md5.
    •  Run Odin.
    • Uncheck auto-reboot!!!  If you don't, it will reboot into stock EI22 which will overwrite with stock recovery, undoing your CWM5 BML install.
    • Flash it using the PDA slot.
    • Remove the battery to power off.
  9. 3-finger boot into CWM5 BML.  Flash your custom ROM.  Wifi should now be working.

Monday, January 2, 2012

How to make Flashable .zip and .apk's

<mkasick> a flashable zip has to have "META-INF/com/google/android/update-binary" which is invoked by recovery
<mkasick> the usual update-binary is compiled from AOSP or CM sources, if you follow the source.android.com directions for obtaining AOSP sources, you can make it with "make out/target/product/generic/system/bin/updater; cp -a out/target/product/generic/system/bin/updater update-binary"
<mkasick> that update-binary also requires "META-INF/com/google/android/updater-script" in the zip, which in recent Android is "edify" format, there's a bunch of tutorials on writing edify updater-scripts
<mkasick> some update.zips are signed, as stock/AOSP recovery checks the signature and verifies the zip contents before installing, although CWM is modified to disable the signature check by default
<mkasick> Samsung stock recovery uses a signing key we don't know, but AOSP defaults to a well-known key "testkey"
<mkasick> the public keys is actually contained in /res/keys of a recovery initramfs, so some custom kernels use the testkey public key instead so they can flash testkey-signed zips
<mkasick> zips are signed using signapk.jar, which can also be made from AOSP sources ("make out/host/linux-x86/framework/signapk.jar")
<mkasick> http://www.club.cc.cmu.edu/~mkasick/android/tools/signapk.tar.gz is a compiled version I built
<mkasick> that archive also includes the testkey keypair and a README that demonstrates how to use it to sign an update.zip
<mkasick> particularly notable (or rather, it took me a good while to figure out) is that you have to invoke signapk.jar with "-w" to sign the "whole zip", which is required for update.zips and nothing else in Android to my knowledge
<mkasick> on packaging .apks
<mkasick> source-built apks are packaged when buiding from AOSP/CM sources, or from the Android SDK
<mkasick> it's a blackbox mechanism as far as I'm concerned
<mkasick> if you want to repackage an existing apk, apktool (https://code.google.com/p/android-apktool/) is probably the best

Multiboot Android for Debugging/Testing

This post will contain notes on setting up a multiboot environment on your Epic 4G, allowing you to boot different kernels and Android userspace "ROM's" stored on the sdcard.  This makes it faster and safer to test new builds.

<mkasick> EI22 on sdcard is just putting /system, /data, and /cache as mmcblk0p2-4 ext4-formatted partitions respectively
<mkasick> first, you'll need to flash back to EI22
<mkasick> and make a tar of /system to preserve uid and permission bits
<mkasick> "cd /system; busybox tar cf /sdcard/system.tar ." is what I use, you can run it from a root shell either in recovery (when /system is mounted) or while in Android since /system is always mounted read-only
<mkasick> and keep that guy around since it's very handy to have a properly-permissioned /system dump (which ironically, I don't have, at least not unmodified)
<mkasick> the instructions for formatting the sdcard are here: http://forum.xda-developers.com/showpost.php?p=19460677&postcount=25
<mkasick> the one difference is you'll have to use "mkfs.ext4 -O ^has_journal /dev/sdb2" (or device equivalent) to format the system partition for EI22 since it's large enough that the 8 MB journal takes too much space
<mkasick> or you can make the partition larger, but the journal doesn't matter sine it's never mounted rw after the first write
<mkasick> warren, http://www.club.cc.cmu.edu/~mkasick/android/sdrom/kernel-GB-sdrom.tar.gz and http://www.club.cc.cmu.edu/~mkasick/android/sdrom/kernel-GB-sdrom-patches.tar.gz
<mkasick> the first is an EI22 custom kernel that runs EI22 installed on SD, the second are the patches against the kernel and a README with build instructions and how to prep the SD card
<mkasick> the patches are fairly minimal, it's a few to "better support" being kexec'd, and the userdebug patch which enables "adb root" to run adbd as root (if you don't already have a rooted /system), and the testkey public key if you use _its_ recovery to flash update.zips
<mkasick> which is unlikely, and you'd need to kexec into its recovery, but it's there
<mkasick> the kernel has partial BML support, it uses Samsung's param.ko and mounts /mnt/.lfs, but doesn't include rfs or attempts to mount /system,/data,/cache from OneNAND, so it will work fine on MTD devices.  


  • EI22 as root, tar the contents of /system in at tarball in order to preserve permissions.
mount -t vfat /dev/block/mmcblk0p1 /sdcard
cat /sdcard/busybox-armv6l > /tmp/busybox
chmod 755 /tmp/busybox
cd /system
rm etc/install-recovery.sh recovery-from-boot.p
mount -ro remount /dev/block/stl9 /system
/tmp/busybox tar cvf /sdcard/system.tar .
umount /sdcard
sync
  • Install CWM5 BML (for 3 finger boot recovery)
  • Install CM7 MTD.
  • Install CWM5 BML again.  This kernel supports kexec, so you can most easily boot into alternate ROM's from here.
  • Use this in CWM5 BML to reboot into CWM5 MTD if you want to modify your CM7 installation.
  • Something like this from CWM5 BML will allow you to boot into alternate ROM's.

Kernel Console on Epic 4G

  • Serial Debugger
    We have not found a way to print kernel console messages to the screen.  In order to capture kernel messages, a serial debugger rig can be connected to the USB port.  Advantage of the debugger vs the screen is that you can capture the logs for offline analysis. [thread1] [thread2]
  • ram_console <mkasick> the way I do ram_console is I kexec the kernel I want to test, it fails, reboots automatically to the working recovery kernel, and I run "adb shell cat /proc/last_kmsg" to pull the boot-time log of the failed kernel and see what went wrong