[ROM] AOSP 7.x for Galaxy S 4G

Search This thread

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Code:
Code:
/*
 * Your probably long expired warranty is now void.
 *
 * I am not responsible for bricked devices, dead SD cards,
 * thermonuclear war, or you getting fired because the alarm app failed. Please
 * do some research if you have any concerns about features included in this ROM
 * before flashing it! YOU are choosing to make these modifications, and if
 * you point the finger at me for messing up your device, I will laugh at you 
* and point my finger right back at you.
 */

Installation Instructions
It will wipe your entire SD card! In order to make things work better, I've set it up to use the entire SD card as /data as opposed to having two partitions. The advantage is that you don't have to pick a size of /data.

If on a BML rom (stock-based GB)...
Untested, but is setup to hopefully work. If it doesn't flash my 6.0 Omni first
  • 1. Reboot to recovery
  • 2. Make sure your version of CWM is at least 5.x
  • 3. Install zip. First time will fail and let you know its repartionning. Second time it will reboot a couple of times, don't be worried.
  • 4. If you want gapps, reboot to recovery, wipe data+cache and install gapps.
  • 5. If you want root, flash according to instructions in Post #3
If on an MTD rom (CM7 and all ICS+)
  • 1. Reboot to recovery
  • 2. Wipe data, dalvik/art cache, system, and cache partitions
  • 3. Install zip. First time will fail and let you know its repartionning. Second time it will reboot a couple of times, don't be worried.
  • 4. If you want root or Gapps, install them now.
The first boot can take several minutes. Be patient. If it takes 20+ minutes, pull the battery and reboot to recovery.

Things to Take Note Of
  • I actually have a T959P, not a T959V... It was released by Telus in Canada. It is a very similar device (I can run ROMs for the T959V with limited problems - ie sometimes I get wakelocks and the gps never works), it has a different GPS chipset and also uses different cell bands (but I can still use your guys modems but I lose access to the 850Mhz band). I have created a build specifically for the T959V as best as I can guess.
  • If you're coming from either the last Lollipop build or the initial pre-release Marshmallow build, there is a bug in TWRP that will prevent flashing anything but the ROM. To get around this, please flash the Marshmallow zip, then reboot to recovery, and then follow the typical instructions.
  • If you decide to install gapps at a later date (ie after you've installed the ROM), you must do a factory reset first - otherwise you will get force-closes upon bootup
  • If you come across a bug, feel free to let me know by posting in this thread. I will not be working non-stop on this project, but will try to fix bugs that affect me as this is still my main phone (out of choice, not necessity).
  • This build is very close to the official AOSP source code. Recovery is TWRP but otherwise there aren't any added "features"
  • Gapps eat up about an extra 30MB of RAM so they slow down the device - tread carefully. Opengapps pico works on the latest 7.0 build, untested on 7.1 but should work just fine
  • Backup Backup Backup! I'm not responsible for you losing any data.

Working
  • Camera (built-in app needs workaround, see below)
  • RIL
  • SMS
  • Recovery
  • Bluetooth - first time it won't enable if enabling through settings, back out and then second time it will. Works just fine from status bar pulldown
  • Wifi
  • Vibration
  • Automatic Brightness
  • Compass
  • GPS on T959P, untested on T959V
  • Headset Buttons
  • SElinux in enforcing mode - this may have broken the T959V's gps...

Partially working
  • Camera and Browser apps need to have all their permissions manually enabled through settings for full functionality. This is because I've used the older Camera app (which hasn't been updated for dynamic permissions) and the older Browser app as the new one is simply a test shell with no features (thanks Google!)

What's been removed
  • TV-Out - It was removed upstream plus I think binary blobs would need a ton of shimming in Lollipop+

Everything else is not tested!!!

XDA:DevDB Information
AOSP 7.x for Galaxy S 4G, ROM for the Samsung Galaxy S 4G

Contributors
xc-racer99
Source Code: https://github.com/xc-racer99/

ROM OS Version: 7.x Nougat
ROM Kernel: Linux 3.0.x
Based On: AOSP

Version Information
Status: Beta

Created 2016-10-22
Last Updated 2016-10-21
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Thanks Time!

Thanks Time!
This would not have been possible without the following people:

Thanks to humberos for bringing Lollipop to the first-gen Galaxy S series. This would not have been possible without his work.
Thanks to FB and Dao for their work on the CM-11 device tree. I used several of their fixes.
Thanks to noiphonehere for his device trees and kernel, most of my work was based off of his.
Thanks to the OMAP4 AOSP team for their work on porting CMA to a 3.0 kernel.
Thanks to bhundven and the other members of teamacid for their work on the aries kernel.
Thanks to all others that have helped get this phone to where it is today!
Thanks to vcmerritt. A name you're probably not familiar with, but he was the only one to create something for the T959P and without him I'd still be on stock...


Build your own!
Follow https://source.android.com/source/initializing.html. The branch you want when you run repo init is the latest tag from https://source.android.com/source/build-numbers.html#source-code-tags-and-builds for your desired android version (7.0 or 7.1). Before you run repo sync, from the WORKING_DIRECTORY/.repo folder, run "git clone https://github.com/xc-racer99/local_manifests -b BRANCH" where BRANCH is either aosp-7.0 or aosp-7.1. Continue on with the build guide, the device codename you want is "galaxys4gmtd".

If you want to build the kernel, follow the instructions in WORKING_DIRECTORY/kernel/samsung/aries/AOSP_README. Put the resulting arch/arm/boot/zImage in device/samsung/galaxys4gmtd-kernel

Other aries devices (captivate, i9000, i9000B, vibrant) should be fairly easy to do (ie the galaxysmtd on my github as well as the captivate trees work). The fascinate and p1 would need a fair bit of work.
Changelogs

Changelog for 2016-12-19
  • December security patches
  • goes back to the older graphics drivers so hardware recording works but has a kernel patch to prevent crashes
  • Tweaked the graphics drivers options so it seems a little bit faster
  • Tweaked the RIL a little bit for better stability
  • Other things I've forgotten about, see github for details
Changelog for 2016-12-19-V2
  • Kernel without slowdowns....
Changelog for 2017-1-19
  • selinux to enforcing - this may break the T959V's GPS - if it does, let me know and send me a dmesg and I'll fix it
  • Update to the interactive governor - should have less slowdowns if using the default governor
  • Slightly better RIL reliability (I think)
  • Better low memory killing - we now don't run out of memory as often
  • Hardware decoding re-enabled
  • Slightly less intensive background services
  • Based on 7.1.1_r13
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Source Code, Downloads, Root Options

Main Source
https://android.googlesource.com/
Device Specific Source Code
http://github.com/xc-racer99/android_device_samsung_telusgalaxys4gmtd for the device tree (see aosp-7.x branch)
http://github.com/xc-racer99/android_device_samsung_aries-common for the common device tree (see aosp-7.x branch).
http://github.com/xc-racer99/android_kernel_samsung_aries for the kernel (see aosp-7.x branch)
http://github.com/xc-racer99/proprietary_vendor_samsung for the prop blobs (see aosp-7.x branch)
http://github.com/xc-racer99/android_patches for all the patches necessary for the device to work properly (see aosp-7.x branch)

Downloads!
All builds can be downloaded from AndroidFileHost at https://www.androidfilehost.com/?w=files&flid=58191

Gapps
The smallest http://opengapps.org/ package for 7.0 is known to work, but any small 7.0 gapps package should work. However, they will cause the device to slowdown significantly as they use a fair bit of RAM. Gapps are untested on 7.1
This ROM is compatible with MicroG (https://microg.org/ and http://forum.xda-developers.com/android/apps-games/app-microg-gmscore-floss-play-services-t3217616) gapps. This is an open-source reimplementation of Google Play Services that doesn't track you and uses way less battery than the original.

Root
Root is achieved via Magisk or SuperSU.
MagiskDue to our odd partition layout, you need to use my custom Magisk install zip (source code here) attached to this post and not the official install or the Magisk Manager install. Then follow the instructions on how to root/install other modules from http://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 Also, don't try to use the official Magisk uninstall tool as it won't work.
SuperSU
Please note: I've been told this doesn't work any more, YMMV
Again, we need a custom SuperSU install zip for it to work due to our partition scheme. It should be an all-in-one zip so it's simplier than Magisk (but not open source). This is based off of the latest (at time of writing) 2.79SR1 release, the diff is below

Code:
diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary
index d437f6f..3a312bf 100644
--- a/META-INF/com/google/android/update-binary
+++ b/META-INF/com/google/android/update-binary
@@ -642,16 +642,23 @@ detect_systemless_required() {
   find_boot_image
 
   CONTINUE=true
+if false ; then
   if [ -z "$BOOTIMAGE" ]; then
     # no boot image partition detected, abort
     return
   fi
+fi
 
   # extract ramdisk from boot image
   rm -rf /sutmp
   mkdir /sutmp
 
+if false ; then
   check_zero "" "" "" "LD_LIBRARY_PATH=$RAMDISKLIB $BIN/sukernel --bootimg-extract-ramdisk $BOOTIMAGE /sutmp/ramdisk.packed"
+else
+  mount /ramdisk
+  cp /ramdisk/ramdisk.img /sutmp/ramdisk.packed
+fi
   check_zero "" "" "" "LD_LIBRARY_PATH=$RAMDISKLIB $BIN/sukernel --ungzip /sutmp/ramdisk.packed /sutmp/ramdisk"
   if (! $CONTINUE); then return; fi
 
@@ -1331,6 +1338,8 @@ else
     ui_print_always "Boot image patcher"
     ui_print        "******************"
 
+if false ; then
+    # SGS Modification - we don't have a "real" boot image
     ui_print "- Finding boot image"
     find_boot_image
 
@@ -1357,6 +1366,10 @@ else
     fi
 
     check_zero_def "- Extracting ramdisk" "LD_LIBRARY_PATH=$SYSTEMLIB /su/bin/sukernel --bootimg-extract-ramdisk $BOOTIMAGE /sutmp/ramdisk.packed"
+else
+    mount /ramdisk
+    cp /ramdisk/ramdisk.img /sutmp/ramdisk.packed
+fi
     check_zero_def "- Decompressing ramdisk" "LD_LIBRARY_PATH=$SYSTEMLIB /su/bin/sukernel --ungzip /sutmp/ramdisk.packed /sutmp/ramdisk"
 
     if ($CONTINUE); then
@@ -1545,6 +1558,7 @@ else
         check_zero_def "- Calling user boot image patch script" "sh /data/custom_boot_image_patch.sh /sutmp/boot.img"
     fi
 
+if false ; then
     if ($CONTINUE); then
       DEV=$(echo `resolve_link $BOOTIMAGE` | grep /dev/block/)
       if [ $? -eq 0 ]; then
@@ -1564,6 +1578,10 @@ else
 
       dd if=/sutmp/boot.img of=$BOOTIMAGE bs=4096
     fi
+else
+    cp /sutmp/ramdisk.packed /ramdisk/ramdisk.img
+    umount /ramdisk
+fi
 
     rm -rf /sutmp
   fi
 

Attachments

  • Magisk-v7-SGS.zip
    2.2 MB · Views: 211
  • Magisk-v9-SGS.zip
    5.4 MB · Views: 291
  • SuperSU-2.79-SR1-SGS.zip
    5.8 MB · Views: 410
Last edited:

graycow9

Senior Member
Mar 10, 2012
191
70
28
West Warwick, RI
It's been a while, no home internet and very busy life lately :p but the time I did get The 7.0 zip to flash (0930) it was running very well, no random reboots and limited freezes (just 1 really)

BUT. I always reinstall a new ROM to get the process down and- I haven't been able to get it running again. Let alone with root which I haven't managed to do. When I install the ROM now it gives me a quick first boot however it says encryption unsuccessful and asks me to reset. Resetting and factory resetting as well as formatting won't help it.

Excellent work ^_^ you're becoming the new SGS4G guru around here :D

As for a new setting in the dev options, labeled Consistent Logging-- if I turn this on is it A: Safe in terms of information vulnerability and B: Will it fill up my SD card quickly with a mass amount of logging data?
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
It's been a while, no home internet and very busy life lately :p but the time I did get The 7.0 zip to flash (0930) it was running very well, no random reboots and limited freezes (just 1 really)

BUT. I always reinstall a new ROM to get the process down and- I haven't been able to get it running again. Let alone with root which I haven't managed to do. When I install the ROM now it gives me a quick first boot however it says encryption unsuccessful and asks me to reset. Resetting and factory resetting as well as formatting won't help it.

Excellent work ^_^ you're becoming the new SGS4G guru around here :D

As for a new setting in the dev options, labeled Consistent Logging-- if I turn this on is it A: Safe in terms of information vulnerability and B: Will it fill up my SD card quickly with a mass amount of logging data?
Hmm, flash the ROM, go into recovery, change the filesystem of /data to ext4 or f2fs. The error sounds as if the sdcard is formatted as fat while it shouldn't be. If that doesn't work, please send me the contents of /sdcard/aries_mtd.log after you've installed it.

Hadn't noticed the new "persistent logging" section. I suspect that what it does it keep the logcat contents over a reboot. Since the logcat does have a max size, it is probably safe to enable it. I highly doubt it contains any more info than a regular logcat.
 

Domunus

Senior Member
May 13, 2011
59
13
Thanks for keeping this device alive in this community! My kids wanted to use it for simple games so I dusted it off and came here to see if anything was still in development and sure enough there was!

I tested going from BML stock and it worked! I had to restart the install 5 times, but it ultimately took. The first two times installed TWRP, then it rebooted into TWRP. Then it took 3 additional times before it went through the whole install. It booted up fine, but I had messed up and forgot to do a full reset before install gapps. So it would boot the encryption screen telling me it was interrupted and I had to reset the phone. Unfortunately at that point no matter what I did it would always boot to that encryption error screen. So I wiped completed and started over but mistakenly flashed the 7.1 build. It went through but was stuck on a boot loop. So now i can't install 7.0 because it keeps telling me it can't install over newer builds. Is there anything I can do to fix this or do i have to start from stock all over again?

Edited* Update
I went ahead and started from scratch but still ran in to the same problem with the encryption. Didn't install gapps this time.
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Thanks for keeping this device alive in this community! My kids wanted to use it for simple games so I dusted it off and came here to see if anything was still in development and sure enough there was!

I tested going from BML stock and it worked! I had to restart the install 5 times, but it ultimately took. The first two times installed TWRP, then it rebooted into TWRP. Then it took 3 additional times before it went through the whole install. It booted up fine, but I had messed up and forgot to do a full reset before install gapps. So it would boot the encryption screen telling me it was interrupted and I had to reset the phone. Unfortunately at that point no matter what I did it would always boot to that encryption error screen. So I wiped completed and started over but mistakenly flashed the 7.1 build. It went through but was stuck on a boot loop. So now i can't install 7.0 because it keeps telling me it can't install over newer builds. Is there anything I can do to fix this or do i have to start from stock all over again?

Edited* Update
I went ahead and started from scratch but still ran in to the same problem with the encryption. Didn't install gapps this time.
Ok, sounds like a messed up somewhere. I'll do some testing and try to release an updated build. Could you please post the output of /sdcard/aries_bml.log and /sdcard/aries_mtd.log? The "Encryption Unsuccessful" message sounds as if the SD wasn't properly formatted to ext4/f2fs.
 

Domunus

Senior Member
May 13, 2011
59
13
Hi xc-racerr99, I found what the issue was. Apparently I had an extra partition on the sdcard. After removing it and running the install script again everything booted up and i'm now using the ROM! It's awesome I have Nougat on this old Galaxy S. Without Gapps it's been running really stable and very responsive..

However, at this point, I've tried opengapps pico and TKgapps pico and neither work. The script runs and says update completed, but it's too fast. When I boot to the ROM no gapps were installed. Is there another gapps you would recommend trying?
 

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Hi xc-racerr99, I found what the issue was. Apparently I had an extra partition on the sdcard. After removing it and running the install script again everything booted up and i'm now using the ROM! It's awesome I have Nougat on this old Galaxy S. Without Gapps it's been running really stable and very responsive..

However, at this point, I've tried opengapps pico and TKgapps pico and neither work. The script runs and says update completed, but it's too fast. When I boot to the ROM no gapps were installed. Is there another gapps you would recommend trying?
Odd, I thought my install script removed the extra partition.


Anyways, it sounds as if there's some issue with recovery. You could try replacing the ramdisk-recovery.img in the ROM zip you downloaded with the one from https://www.androidfilehost.com/?fid=457095661767105384. Then reboot to recovery and flash your gapps package again.
Doesn't work....

I'll try to do some more testing with gapps and from stock with 1 or 2 partitions when I get a chance.
 
Last edited:

graycow9

Senior Member
Mar 10, 2012
191
70
28
West Warwick, RI
I figured out a sure fire way to boot 7.0, I'm running it as I respond with XDA app right now. But to keep it short if possible, I just fix permissions then factory wipe before I run the zip- do this while on CWM right after you heimdall to BML.

So to recap:
1- Flash to stock via heimdall
2- Fix permissions + factory wipe
3- Flash 7.0 zip
4- TWRP should boot- so flash ROM once more - wipe caches
5- Reboot and chew some nougat :)

Will follow up with a log next time I try to get the 7.1 rolling. ?

Oh! And when I add my email (hotmail) I get a bad handshake everytime. Do I need gapps to sync my contacts? o_O

Sent from my SGH-T959V using XDA-Developers mobile app
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
I figured out a sure fire way to boot 7.0, I'm running it as I respond with XDA app right now. But to keep it short if possible, I just fix permissions then factory wipe before I run the zip- do this while on CWM right after you heimdall to BML.

So to recap:
1- Flash to stock via heimdall
2- Fix permissions + factory wipe
3- Flash 7.0 zip
4- TWRP should boot- so flash ROM once more - wipe caches
5- Reboot and chew some nougat :)

Will follow up with a log next time I try to get the 7.1 rolling.

Oh! And when I add my email (hotmail) I get a bad handshake everytime. Do I need gapps to sync my contacts? o_O

Sent from my SGH-T959V using XDA-Developers mobile app
Yeah, I get a bad handshake as well. Only happens with hotmail/oulook accounts, my gmail and my other email work just fine.

I figured out what was causing the issues with install from BML - on TWRP boot, it wasn't setting up the sdcard properly. I've now fixed it so that it should work regardless (in the next build, obviously).
 
  • Like
Reactions: graycow9

Domunus

Senior Member
May 13, 2011
59
13
Anyways, it sounds as if there's some issue with recovery. You could try replacing the ramdisk-recovery.img in the ROM zip you downloaded with the one from https://www.androidfilehost.com/?fid=457095661767105384. Then reboot to recovery and flash your gapps package again.

Gave this a try and still no luck.

Update **
It actually killed the recovery. Recovery just keeps crashing and rebooting when trying to get in to it. Tried it from the a clean install and same results. Will wait for your next build. Thanks for putting time in to this!
 
Last edited:

graycow9

Senior Member
Mar 10, 2012
191
70
28
West Warwick, RI
Odd, it lets me add my gmail but only syncs my emails- no option for contacts still. I ought to keep a vcf from my other device jic.

The performance is even better than M and it doesn't have the weird battery glitch anymore ?? (I think the new partition layout helped a lot.)

Another thing I noticed, sometimes my SIM won't register or gives me a no signal indicator. I can't get root still either[emoji14]still poking around. Looking forward to the next build ?

Edit: Another bug I noticed is the inability to save files through the browser or Tumblr app for example.
(By the way, just wanted to add, I hope I'm still being more help than a nag or something. I aim to be helpful. So I look for things that seem astray. Heh)



Sent from my SGH-T959V using XDA-Developers mobile app
 
Last edited:

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
Odd, it lets me add my gmail but only syncs my emails- no option for contacts still. I ought to keep a vcf from my other device jic.

The performance is even better than M and it doesn't have the weird battery glitch anymore (I think the new partition layout helped a lot.)

Another thing I noticed, sometimes my SIM won't register or gives me a no signal indicator. I can't get root still either[emoji14]still poking around. Looking forward to the next build

Edit: Another bug I noticed is the inability to save files through the browser or Tumblr app for example.
(By the way, just wanted to add, I hope I'm still being more help than a nag or something. I aim to be helpful. So I look for things that seem astray. Heh)



Sent from my SGH-T959V using XDA-Developers mobile app
I've never used the contact sync.

With SIM not registering, it's because Google introduced a bug and the workaround the bug causes the SIM to occasionally not work. One of the problems with legacy devices I guess.

With the files not saving, manually grant the storage permission in Settings->Apps - it doesn't seem to automatically update for most apps.

With root, sounds like I should modify the SuperSU install zip as it's easier to use (but not open-source). For the PHH Superuser, you need
1) The Magisk-7-SGS.zip from my thread.
2) The phh-superuser-r259.zip from the Magisk root thread (link in OP)
3) The PHH Superuser app from the Play Store or FDroid
Even then, it only works for certain apps as it doesn't mount anything to /system/xbin/su which is what some apps look for

Edit: And I have no issues if you keep posting here with the problems you find, it's good to know.
 
Last edited:
  • Like
Reactions: graycow9

asmalldharma

Member
Jul 22, 2015
33
5
GT-i9250
Nexus 7
bootloop :(

just tried to flash this 7.1 rom from your omnirom 6.0. Seemed to flash ok as described. couldn't get pico opengapps to flash but ignored it. Now it's stuck in a bootloop and I can't get into recovery using hardware buttons. Any guidance as to how I should proceed? As a relative novice, can I push a new recovery through ADB and try again?
 

xc-racer99

Senior Member
Aug 28, 2013
668
1,063
just tried to flash this 7.1 rom from your omnirom 6.0. Seemed to flash ok as described. couldn't get pico opengapps to flash but ignored it. Now it's stuck in a bootloop and I can't get into recovery using hardware buttons. Any guidance as to how I should proceed? As a relative novice, can I push a new recovery through ADB and try again?
Well, it depends on where you are bootlooping. If you're stuck at either of the first two splash screens, then you're out of luck with ADB as it isn't available yet. If you're bootlooping but getting to the bootanimation, then you can. To do so, run
Code:
$ adb root
$ adb shell mkdir /data/ramdisk
$ adb shell mount /dev/block/mtdblock5 /data/ramdisk
$ adb push ramdisk-recovery.img /data/ramdisk
$ adb reboot recovery
where ramdisk-recovery.img is from the AOSP 7.0 zip.

If you're stuck at the first or second splash screens, then you need Odin or Heimdall. With heimdall, you can do
Code:
$ heimdall flash --KERNEL boot.img
where the boot.img is the one from Omni 6.0, the one from 7.x won't work on its own as the recovery is not stored in it. You can use Odin to go back to stock.

I haven't tried gapps so I guess I should sometime and see what the issue with them is.
 

asmalldharma

Member
Jul 22, 2015
33
5
GT-i9250
Nexus 7
Gets to the second splash screen. I'll give that a shot when i have some free time. I'm really looking forward to getting this working as I'm amused by the idea of my oldest android phone running the newest OS before my other two. :D

Update: couldn't get it to work with my cheap laptop. Kept throwing up the libusb 12 error. Then when i finally gave up and pulled the battery, I noticed it was starting to bulge a little. I think I'm out for a while. I'm hoping i can come back to this soon.

Sent from my A0001 using XDA-Developers mobile app
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Code:
    Code:
    /*
     * Your probably long expired warranty is now void.
     *
     * I am not responsible for bricked devices, dead SD cards,
     * thermonuclear war, or you getting fired because the alarm app failed. Please
     * do some research if you have any concerns about features included in this ROM
     * before flashing it! YOU are choosing to make these modifications, and if
     * you point the finger at me for messing up your device, I will laugh at you 
    * and point my finger right back at you.
     */

    Installation Instructions
    It will wipe your entire SD card! In order to make things work better, I've set it up to use the entire SD card as /data as opposed to having two partitions. The advantage is that you don't have to pick a size of /data.

    If on a BML rom (stock-based GB)...
    Untested, but is setup to hopefully work. If it doesn't flash my 6.0 Omni first
    • 1. Reboot to recovery
    • 2. Make sure your version of CWM is at least 5.x
    • 3. Install zip. First time will fail and let you know its repartionning. Second time it will reboot a couple of times, don't be worried.
    • 4. If you want gapps, reboot to recovery, wipe data+cache and install gapps.
    • 5. If you want root, flash according to instructions in Post #3
    If on an MTD rom (CM7 and all ICS+)
    • 1. Reboot to recovery
    • 2. Wipe data, dalvik/art cache, system, and cache partitions
    • 3. Install zip. First time will fail and let you know its repartionning. Second time it will reboot a couple of times, don't be worried.
    • 4. If you want root or Gapps, install them now.
    The first boot can take several minutes. Be patient. If it takes 20+ minutes, pull the battery and reboot to recovery.

    Things to Take Note Of
    • I actually have a T959P, not a T959V... It was released by Telus in Canada. It is a very similar device (I can run ROMs for the T959V with limited problems - ie sometimes I get wakelocks and the gps never works), it has a different GPS chipset and also uses different cell bands (but I can still use your guys modems but I lose access to the 850Mhz band). I have created a build specifically for the T959V as best as I can guess.
    • If you're coming from either the last Lollipop build or the initial pre-release Marshmallow build, there is a bug in TWRP that will prevent flashing anything but the ROM. To get around this, please flash the Marshmallow zip, then reboot to recovery, and then follow the typical instructions.
    • If you decide to install gapps at a later date (ie after you've installed the ROM), you must do a factory reset first - otherwise you will get force-closes upon bootup
    • If you come across a bug, feel free to let me know by posting in this thread. I will not be working non-stop on this project, but will try to fix bugs that affect me as this is still my main phone (out of choice, not necessity).
    • This build is very close to the official AOSP source code. Recovery is TWRP but otherwise there aren't any added "features"
    • Gapps eat up about an extra 30MB of RAM so they slow down the device - tread carefully. Opengapps pico works on the latest 7.0 build, untested on 7.1 but should work just fine
    • Backup Backup Backup! I'm not responsible for you losing any data.

    Working
    • Camera (built-in app needs workaround, see below)
    • RIL
    • SMS
    • Recovery
    • Bluetooth - first time it won't enable if enabling through settings, back out and then second time it will. Works just fine from status bar pulldown
    • Wifi
    • Vibration
    • Automatic Brightness
    • Compass
    • GPS on T959P, untested on T959V
    • Headset Buttons
    • SElinux in enforcing mode - this may have broken the T959V's gps...

    Partially working
    • Camera and Browser apps need to have all their permissions manually enabled through settings for full functionality. This is because I've used the older Camera app (which hasn't been updated for dynamic permissions) and the older Browser app as the new one is simply a test shell with no features (thanks Google!)

    What's been removed
    • TV-Out - It was removed upstream plus I think binary blobs would need a ton of shimming in Lollipop+

    Everything else is not tested!!!

    XDA:DevDB Information
    AOSP 7.x for Galaxy S 4G, ROM for the Samsung Galaxy S 4G

    Contributors
    xc-racer99
    Source Code: https://github.com/xc-racer99/

    ROM OS Version: 7.x Nougat
    ROM Kernel: Linux 3.0.x
    Based On: AOSP

    Version Information
    Status: Beta

    Created 2016-10-22
    Last Updated 2016-10-21
    3
    Thanks Time!

    Thanks Time!
    This would not have been possible without the following people:

    Thanks to humberos for bringing Lollipop to the first-gen Galaxy S series. This would not have been possible without his work.
    Thanks to FB and Dao for their work on the CM-11 device tree. I used several of their fixes.
    Thanks to noiphonehere for his device trees and kernel, most of my work was based off of his.
    Thanks to the OMAP4 AOSP team for their work on porting CMA to a 3.0 kernel.
    Thanks to bhundven and the other members of teamacid for their work on the aries kernel.
    Thanks to all others that have helped get this phone to where it is today!
    Thanks to vcmerritt. A name you're probably not familiar with, but he was the only one to create something for the T959P and without him I'd still be on stock...


    Build your own!
    Follow https://source.android.com/source/initializing.html. The branch you want when you run repo init is the latest tag from https://source.android.com/source/build-numbers.html#source-code-tags-and-builds for your desired android version (7.0 or 7.1). Before you run repo sync, from the WORKING_DIRECTORY/.repo folder, run "git clone https://github.com/xc-racer99/local_manifests -b BRANCH" where BRANCH is either aosp-7.0 or aosp-7.1. Continue on with the build guide, the device codename you want is "galaxys4gmtd".

    If you want to build the kernel, follow the instructions in WORKING_DIRECTORY/kernel/samsung/aries/AOSP_README. Put the resulting arch/arm/boot/zImage in device/samsung/galaxys4gmtd-kernel

    Other aries devices (captivate, i9000, i9000B, vibrant) should be fairly easy to do (ie the galaxysmtd on my github as well as the captivate trees work). The fascinate and p1 would need a fair bit of work.
    Changelogs

    Changelog for 2016-12-19
    • December security patches
    • goes back to the older graphics drivers so hardware recording works but has a kernel patch to prevent crashes
    • Tweaked the graphics drivers options so it seems a little bit faster
    • Tweaked the RIL a little bit for better stability
    • Other things I've forgotten about, see github for details
    Changelog for 2016-12-19-V2
    • Kernel without slowdowns....
    Changelog for 2017-1-19
    • selinux to enforcing - this may break the T959V's GPS - if it does, let me know and send me a dmesg and I'll fix it
    • Update to the interactive governor - should have less slowdowns if using the default governor
    • Slightly better RIL reliability (I think)
    • Better low memory killing - we now don't run out of memory as often
    • Hardware decoding re-enabled
    • Slightly less intensive background services
    • Based on 7.1.1_r13
    2
    Source Code, Downloads, Root Options

    Main Source
    https://android.googlesource.com/
    Device Specific Source Code
    http://github.com/xc-racer99/android_device_samsung_telusgalaxys4gmtd for the device tree (see aosp-7.x branch)
    http://github.com/xc-racer99/android_device_samsung_aries-common for the common device tree (see aosp-7.x branch).
    http://github.com/xc-racer99/android_kernel_samsung_aries for the kernel (see aosp-7.x branch)
    http://github.com/xc-racer99/proprietary_vendor_samsung for the prop blobs (see aosp-7.x branch)
    http://github.com/xc-racer99/android_patches for all the patches necessary for the device to work properly (see aosp-7.x branch)

    Downloads!
    All builds can be downloaded from AndroidFileHost at https://www.androidfilehost.com/?w=files&flid=58191

    Gapps
    The smallest http://opengapps.org/ package for 7.0 is known to work, but any small 7.0 gapps package should work. However, they will cause the device to slowdown significantly as they use a fair bit of RAM. Gapps are untested on 7.1
    This ROM is compatible with MicroG (https://microg.org/ and http://forum.xda-developers.com/android/apps-games/app-microg-gmscore-floss-play-services-t3217616) gapps. This is an open-source reimplementation of Google Play Services that doesn't track you and uses way less battery than the original.

    Root
    Root is achieved via Magisk or SuperSU.
    MagiskDue to our odd partition layout, you need to use my custom Magisk install zip (source code here) attached to this post and not the official install or the Magisk Manager install. Then follow the instructions on how to root/install other modules from http://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 Also, don't try to use the official Magisk uninstall tool as it won't work.
    SuperSU
    Please note: I've been told this doesn't work any more, YMMV
    Again, we need a custom SuperSU install zip for it to work due to our partition scheme. It should be an all-in-one zip so it's simplier than Magisk (but not open source). This is based off of the latest (at time of writing) 2.79SR1 release, the diff is below

    Code:
    diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary
    index d437f6f..3a312bf 100644
    --- a/META-INF/com/google/android/update-binary
    +++ b/META-INF/com/google/android/update-binary
    @@ -642,16 +642,23 @@ detect_systemless_required() {
       find_boot_image
     
       CONTINUE=true
    +if false ; then
       if [ -z "$BOOTIMAGE" ]; then
         # no boot image partition detected, abort
         return
       fi
    +fi
     
       # extract ramdisk from boot image
       rm -rf /sutmp
       mkdir /sutmp
     
    +if false ; then
       check_zero "" "" "" "LD_LIBRARY_PATH=$RAMDISKLIB $BIN/sukernel --bootimg-extract-ramdisk $BOOTIMAGE /sutmp/ramdisk.packed"
    +else
    +  mount /ramdisk
    +  cp /ramdisk/ramdisk.img /sutmp/ramdisk.packed
    +fi
       check_zero "" "" "" "LD_LIBRARY_PATH=$RAMDISKLIB $BIN/sukernel --ungzip /sutmp/ramdisk.packed /sutmp/ramdisk"
       if (! $CONTINUE); then return; fi
     
    @@ -1331,6 +1338,8 @@ else
         ui_print_always "Boot image patcher"
         ui_print        "******************"
     
    +if false ; then
    +    # SGS Modification - we don't have a "real" boot image
         ui_print "- Finding boot image"
         find_boot_image
     
    @@ -1357,6 +1366,10 @@ else
         fi
     
         check_zero_def "- Extracting ramdisk" "LD_LIBRARY_PATH=$SYSTEMLIB /su/bin/sukernel --bootimg-extract-ramdisk $BOOTIMAGE /sutmp/ramdisk.packed"
    +else
    +    mount /ramdisk
    +    cp /ramdisk/ramdisk.img /sutmp/ramdisk.packed
    +fi
         check_zero_def "- Decompressing ramdisk" "LD_LIBRARY_PATH=$SYSTEMLIB /su/bin/sukernel --ungzip /sutmp/ramdisk.packed /sutmp/ramdisk"
     
         if ($CONTINUE); then
    @@ -1545,6 +1558,7 @@ else
             check_zero_def "- Calling user boot image patch script" "sh /data/custom_boot_image_patch.sh /sutmp/boot.img"
         fi
     
    +if false ; then
         if ($CONTINUE); then
           DEV=$(echo `resolve_link $BOOTIMAGE` | grep /dev/block/)
           if [ $? -eq 0 ]; then
    @@ -1564,6 +1578,10 @@ else
     
           dd if=/sutmp/boot.img of=$BOOTIMAGE bs=4096
         fi
    +else
    +    cp /sutmp/ramdisk.packed /ramdisk/ramdisk.img
    +    umount /ramdisk
    +fi
     
         rm -rf /sutmp
       fi
    2
    why does it give me a data partition error every time I try to flash, but still finish booting, then have no recovery?

    Never mind, I'm sure I answered my own question there. How do I fix it?
    It's odd that you have no recovery. You'll get an error the first time you flash it if the first partition on the SD card is not already ext4 - I added this warning in so that people wouldn't wipe all the data on their sdcards if they didn't read everything.

    To get recovery working again, here is probably what you need to do (assuming you can boot up).
    1) Get ADB setup (plenty of guides around, look one up).
    2) Extract the ramdisk-recovery.img from the ROM zip
    3) Run "adb root" so that we get root permissions in an adb shell
    4) From an adb shell (run "adb shell"), run the following commands
    a) "mkdir /data/ramdisk-recovery"
    b) "mount -t yaffs2 /dev/block/mtdblock5 /data/ramdisk-recovery"
    5) From the directory that you extracted the ramdisk-recovery.img to, run
    a) "adb push ramdisk-recovery.img /data/ramdisk-recovery"
    6) Run "adb reboot recovery" and you should now have a working recovery.

    If this doesn't work, please output the exact wording of any error messages you may get (flashing or otherwise), as well as the contents of any aries_*.log files from your SD card - these will tell me where things went wrong.

    Hope this helps.

    I've also uploaded a new LineageOS build, it should fix BT. Download from https://www.androidfilehost.com/?fid=817550096634743399
    2
    When I try to flash it stops early on saying "this package is for galazys4gmtd devices: this is a SGH-T959V" I am on your MM rom which I flashed after flashing to stock GB CWM kernel. My SDCard is 1gb fat32 and 7gb ext4(approx) Do I need a new bootloader that has a different device name or do I just change the update script to force it to install. Thanks.
    Yeah, just modify the updater-script. Was this the 7.1 build? I think there were some conflicts with the patch that allows different device names to work. If you install from the 7.0 build it does work...

    I should upload a new build sometime for both 7.1 and 7.0. 7.1 seems (at least to me) to crash more frequently. The main thing stopping me is slow internet...