Thursday, November 14, 2013

Post# 2 - Understanding the Advanced Android For Dummies

Don't you hate how people talk about CyanogenMod in front of you and say they flashed a new ROM or a new kernel or patched a new .zip with their custom recovery and you feel totally lost? Does this happen to you? If not, you probably need to get more technologically advanced friends. Its always good to have one around. As much as annoying it may get when he becomes addicted to flashing...
O.O
<<rewind.

No I don't mean 'flashing'
Lesson #1-

flashing (adj.) flashing is the word used for when you 'put', or "flash" custom .zips to your phone via a custom recovery...
Custom Recovery you say?

Lesson #2-

Custom Recovery (n.) Now, the easiest way to describe this is like... You know how when you start up your computer and it tells you to press random buttons to enter into the unknown "BIOS SETUP"? Its one of those F-ing keys. . ie, F12, F11, F10, .. or DEL or.. whatever; you get the idea. So think of custom recovery as closest to that. It's quite similar like you can access it before the phone starts up, you gotta do some button gymnastics and press multiple hardware buttons on the phone as the phone boots up. If you've never done this before you probably will be taken to the Stock Recovery. The recovery that ships with phones out of the box. They're not that great.
Enter ClockworkMod (CWM)
ClockworkMod is an example of a custom recovery. I use this one. I prefer CWM to the other recoveries out there like TWRP (Team Win Recovery Project) or other stuff.
What can you do with a custom recovery?
Well, you can flash new Custom ROMs to your phone, change its kernel, flash a patch to make or break the phone, format the phone, take a NANDROID Backup {A nandroid backup is a complete backup of everything in your phone at the current time of backup. These are usually taken by custom recovery(s?)} stuff like that. If you're not confident of yourself, you shouldn't meddle with this much. So for example, today, I flashed on a new ROM by WayLandACE for my phone. .. its based on android 4.2.2 and even though the ROM is quite aged, I must say its quite decent performance wise.
Now wait whaaat? What's flashing a ROM you ask?

Oy vey.

Lesson #3-
ROM (n. abbr.)  Read Only Memory; or ROM is basically everything on your phone (the software side of it) From the time your phone starts at your bootlogo till the time you power it off and everything you did in between all is because of the ROM in your phone. ROM isn't a physical component in phones. It's the OS (Operating System) on your phone. So in my case right now, I have a Custom ROM, developed by WayLand_ACE (a developer on XDA with a bunch of others) which is based off Cyanogenmod10.1, running obviously, 4.2.

CyanogenWHAT?

Lesson #4-
CyanogenMod (n.) "sigh-an-oh-gen-mod" 

      CyanogenMod, as defined by Cyanogenmod.org,
is an aftermarket firmware for a number of cell phones based on the open-source Android operating system. It offers features not found in the official Android based firmwares of vendors.
...yeah.

Lets talk about a few things first.
What's Open Source?

It's a word that doesn't exist in Apple Inc.'s dictionary.

Open Source basically means everyone is free to use this, modify , do whatever the hell they want with it as long as they know what they're doing.
Android, is an Open Source Project. The name, AOSP (Android Open Source Project) comes from, Andro.. you get the idea. Now, Google being so developer friendly as always releases the codes of every Android version online. Developers can download these codes to make more beautiful apps and tweak with the settings, understand how the OS works, and make ROMs and stuff.
Cyanogenmod takes these codes provided and tweaks them to alter system performance and offer features and tweaks ,..."not found in the official Android firmwares of vendors" Now, Cyanogen is waaaaaay awesome than any Stock OS out there., Why? Because it has experimental builds, new features, and constant tweaking which companies can't normally try out because of issues that may follow like instability or an untested, unwanted experience in phones. Cyanogen doesn't have to worry about all this because not everyone knows about it. We, the people who know Cyanogenmod exists, we know who we are ;) We're that crowd who is slightly more into tech than the rest.. We're more knowledgeable about the working and functioning of our beloved Android OSs, and we understand the risks involved when we go through processes such as these and if something does get screwed up, we know how to get back to the way things were without any trouble. Now if you're reading this and you've never heard of Cyanogenmod, I suggest you brush up some knowledge with the help of XDA and other stuff.. and please, in the words of EVERY XDA Developer, STAY OUT OF THE ****ING DEVELOPER THREAD

What is this XDA you speak of?Oh my..

forum.xda-developers.com (n.) XDA Developers, was started off long ago for development on HTC's .. XDA phone. It was quite the thing back then, it had a stylus responsive screen, you could send emails and browse the web from the palm of your hand and stuff. Well, as it always happens, technology advances, .. rather too quickly. .. And now hundreds of phones with OSs ranging from Windows to Android, Ubuntu OS, and FireFox OS, and I'm sure theres some other small ones around there on XDA. XDA Developers in short, is basically God for your android phone. .. if you're lucky.
You have the developer thread where the magic happens. Custom ROMs and tweaks and patches and kernels and everything is just waiting to visit your phone and try it on. XDA is your portal to experimental android. You can get your phone optimized with various .zips flashed.. Try out some Custom ROMs by single developers, or if you really want a helluva experience, try out ROMs, *in order of my preference*

CyanogenMod > AOKP  > Paranoid Android > PAC > and then all the other ROMs..

And ofcourse, if you dont want anything flashy, there's always the cleanest and the best - AOSP ROMs.. Just plain, clear, sleek, vanilla Android, the way Google intended.

I'm mostly an AOSP and CM ROM lover.

Now after flashing a ROM on my phone, I add 2 patches.
Patches, unlike what granny created on your torn sweaters, are basically small, .zip files that help the OS run better in any way.  Patches are usually included when a ROM now already out there seems to have a bug and the solution is a tweak to a specific part of the OS. Lets say, for example you get a new ROM and the camera doesn't work. The developer of that ROM realizes the mistake and now uploads a Cam_Patch.zip. You will after installing the OS via CWM or other recovery, flash the .zip in the same manner. Done :D
Other things to patch are tweaks like... INT2EXT which helps increasing the internal storage to how much ever of an ext4 partition you've given to your SD Card..

Ext.. whaa?
EXT4. A System Partition.

System Parkinson?

Sigh.

Ever heard of FAT32? NTFS? Ring any bells? Great.

uhh..

Siiiiigh. I'm surrounded by dummies.

Ah well, gather around. Grandpa has a fun story to tell..

'twas the night before storage devices were invented,
 and all was dark..  
it was an idea behold
that struck a cowardly schmuck!

He realized computers too, with all their power and might, 
wouldn't be able to find their folders and files 
he had a light bulb and all was bright,
"I shall invent the File Allocation Table" he vowed that night!
He worked for a fortnight and then some more,
"Lo! Behold! This needs work no more!"

For now he had created a system that allowed computers to easily search for stuff,

He huffed and he puffed and he had some more snuff.

And thus ends the tale of an invention in a lone stable, 

For he called this file system, the "File Allocation Table"

And then grandpa realized it didn't make much sense so he just slowly spoke - "File systems are basically for storing, searching and retrieving data on a storage device"

FAT, FAT12, FAT32, FAT16, NTFS, etc are most commonly used by devices running Windows.

Ext, Ext2, Ext4 and some others are used by Linux based operating systems.
Android, if you haven't already guessed is based off Linux.
Another example of a Linux based operating system is Ubuntu.
MAC OS X by Apple runs on Linux based codes too.


oh. so.. uh.. where were we?

 I was explaining the SD Card partitioning.

Note that partitioning the SD card decreases the life of the card and voids warranty.

Anyway Now, my phone barely has around 200MB of storage right? I have a 32GB, Class 10 SDHC (Secure Digital High Capacity -32GB SD cards are termed as SDHC) Card.. Most people don't know this but the average MicroSD card is a class 4. With a slower read/write speed as compared to a Class 10 .. On an average, a class 4 sd card will copy files at a speed of around 4 MB/s, a Class 2, will copy at 2MB/s, Class 6, 6 MB/s.. (seeing the pattern here?) and a Class 10,..... surprise surprise, 10MB/s. So! Now that we have that out of the way, I'll proceed in explaining...

I partitioned my 32GB SD Card giving it 2GBs of an ext4 partition, around 256MBs of a SWAP Partition, and the rest is FAT32 for all my actual data I'll store. A Swap partition isn't really necessary to have but its what Linux uses as a virtual RAM. Incase you run out of physical memory, it'll go to your swap partition on the SD Card (if you tell it to) and start using up the space there.

There are 3 tweaks to increase internal storage on an android that's been rooted.

No way am I gonna plant my phone and wait till its rooted..
No dummy not that root.
In Windows, since we're familiar with it, we all know that guy "Administrator" who secretly makes his account on your computer and never seems to use it. Yeah, well that guy, has all the rights to your computer and can completely modify the computer if he knows what he's doing.
Root is the exact same thing, except for Linux. Its the administrator in Linux. All administrator privileges are given to a root user. Root, by the way, in Linux, is also the starting directory. The way we have usually by default "C:/Program Files" in Windows; in Linux, it begins with " /system/otherstuff" so if you also hear someone saying "Copy that file into the root directory" it means you just copy it straight to " / " and not in any folder.

Note that rooting voids warranty of the phone, and is often discouraged by vendors.

Back to the three tweaks....

Now, if you are rooted and running low on internal storage, you can try

1-
Download Android Terminal Emulator from the PlayStore.

Type in this ->

su
*wait for response*

pm set-install-location 2
*wait for it*

and thats it. Close Terminal and you should now be able to move most of the phone apps to the SD card. Quite a neat trick if you wanna avoid partitioning the SD card and not have to connect your phone to the PC or do a lot of other stuff. This is simple, quick and effective.
Mind you though, in some Android versions, you may need to instead type pm setInstallLocation 2 or instead just read the help file that gets displayed if you typed in the wrong code. Somewhere there it should tell you what exactly is the code and what number is the right number. Some devices have the number 3 instead so be sure of what you're doing. 

Tweak # 2-

Using Link2SD or Mounts2SD or S2E or similar.
These require partitioning of the SD Card. Each one with their own requirements. An ext4 partition is actually the best partition to make. After partitioning, Links2SD will just ask what kind of partition you made and it'll do the magic, then allow the phone to reboot and go to the settings in the app to fiddle around with it.. With Mounts2SD and S2E though, they require certain files moved to certain locations and set certain permissions.

Permissions? 
Any file on any operating system has certain permissions that are allotted to it. 3 basic permissions exist - Read , Write and Execute for three kinds of users.. Owner, Group and Others . .. This is kinda self explanatory really.... A read permission allows the file to only be viewed, nothing more. A write permission allows it to be written, modified, deleted. And an execute permission allows the file to be run if its a line of codes or something that make a difference and actually produce outcomes, be it visible or not.

Okay, and the third and last way, is the method I always use along with the pm set-install-location 2 command.

For this I use INT2EXT4+ And my 2GB Ext4 Partition on my SD Card. Its quite simple really.
Using CWM, immediately after flashing a new ROM, go to mounts and storage in CWM, and mount everything you see mountable, as wrong as this sounds. Then, select the int2xxxx.zip from Install zip from SD card that you have from the INT2EXT page over at XDA and flash the .zip . Then go back to mounts and storage and format sd-ext . Thats it! This links the internal storage to the ext4 partition you created.
Now obviously, this could slow down the performance of your phone. But, with a Class 10 SD card it shouldn't be unbearable.  I know when I had a Class 4 SDHC card I had a considerable amount of lag between apps but with a Class 10, there indeed is still a lil time delay but I can live with that.

Now if the overall performance starts getting laggy, which in my case happens a lot since I'm running an 800MHz processor, thanks to being rooted you can tweak everything of the phone and even change the CPU Speed and CPU Governor. The process of increasing the CPU speed is called overclocking and decreasing the speed is underclocking.


What's clocking?

It's a fun concept. When one thread of data goes through the processor in a given amount of time, its called a "Tick" when the data is processed in the time and sent out, its a "Tock" What ticks and tocks? Clocks. :P Clock! :D CLOCKING :D Underclocking is decreasing CPU speed, overclocking is increasing.
I'm totally screwing with you. I have no idea how they came up with that word.

Gotcha!
Anyway so custom ROMs give you the options to overclock and underclock.

My CPU at its stock 800MHz is okay for 2.3 gingerbread, but when you come up to Jellybean, that 800MHz will get you no where.. So I overclock my CPU. I now have my CPU clocked at 921MHz. Which isn't really a big deal compared to today's processor speeds (The Nexus 5 has a 2.3GHz processor) The newer phones run in Gigahertz. By newer I mean all the phones that realized just after I bought mine. I'm almost near 1GHz and although I still experience lag because my processor isn't a speed demon, I don't mind .. But take caution. If I overclock around 941MHz, my CPU will start to overheat, the back of my phone becoming really hot and eventually restarting the phone. Sometimes, this could even fry the processor on the board and your phone may not ever recover. So stay in limit!

Now what happens when your battery is a 1250mAh and you have a cpu of 921 MHz?

BAAATTTERRYY DRAAAIIIN

So, they put in a CPU Governor. What CPU Governors do is they monitor usage and accordingly provide CPU speeds when needed. Thus only going to the stretch of the 921MHz you set when required. And dialing it back down gradually as the demands decrease. This is where underclocking comes in. If you set the phone at a minimum of 122MHz, when your phone is idle, and you're not doing any CPU intensive work, its gonna go to that 122MHz and rest the CPU there. (Deep Sleep is another android implementation that clocks the cpu slightly lower so the battery is considerably saved when the phone is left idle for long periods) This saves the battery a lot.

There are different CPU governors to choose from. By default, you have the Governor "ONDEMAND" set. On Demand is what companies like Samsung, Sony and all use. They never show you this option but it's almost the perfect CPU governor. (Note I said ALMOST) With this governor, when the user unlocks the phone, the cpu immediately kicks into full throttle even if you're just checking an SMS. So much power isn't needed. If you just checked an SMS you didn't need 1.3GHz to get you to there. Barely 320MHz was enough to get the job done. But since it sucked out 1.3GHz in under 1 second, the battery begins to drain. Why use so much when not needed? So, with the many governors available (I have my CPU governor as InteractiveX set) There are different types of cpu governors like Smartass, LionHeart, Performance, Lagfree, MinMax, etc. Lots and lots are out there, each working in specific ways for the cpu speeds. They each boost up or slow down the cpu speed when needed in their own times and rules. For example, Performance governor is, well, living upto its name. It clocks the cpu to the highest setting and keeps it there no matter what you're doing..
BATTERRY DRAIIIN
For more information on many CPU Governors, check this XDA page or this one..

There's another concept to understand with the CPU,
They're called I/O Schedulers. (Input/Output Schedulers)

I am not entirely clear on this so don't take my word for this. .. As far as I understand I/O Scheduling they're just.. basically the time taken from when you opened the app, it starts one thread, and if you do something while this thread is on , it makes another thread after this first thread gets completed. I/O Schedulers are used for users who wanna push cpu limits and take advantage of threading so allowing multiple inputs in one thread rather than a single input per thread this overall increases speed and decreases latency and in turn, increases performance. I use a very aggressive IO scheduler called Deadline. It creates multiple threads in one process request and does not give an eff. If a process takes too long to complete in one thread, it will kill it and carry on. I haven't quite understood I/O schedulers well, so head to this XDA page to know more.. I/O schedulers like CPU governors are many to choose from, the default being "NOOP".. if you're interested in knowing more, go over to that XDA page.

But then again, availability of all these depends on your kernel running in your phone.

SIR YES SIR!

Now the kernel here isn't one of those men in an army uniform running about inside your processor and draining all the recruits of their energy - no. This is totally different.

A kernel is what helps software connect with hardware. It's that magic inside every single computerized device which lets software and hardware work together. It's what tells the software what it is running on, what devices are connected to it (if any). When you first start a computer, the first ever thing that happens is a POST.

Ah so that's where my emails come from?
POST .. Power On Self Test. After this process, the kernel is loaded. You should avoid flashing kernels as they're risky. If you know what you're doing and are sure you have the right stuff, go ahead by all means. I currently run a kernel by Mardon on XDA. This gives me access to more Governors and more I/O schedulers and has some slight under the hood tweaks which subtly increases performance.

Wow that's a lot to take in now .... I think its enough for the    day     week    month. (year?)

After reading so much you should now have a somewhat idea of what's going on..
You can always ask questions in the correct threads in XDA Developers and love the community and knowledge you'll gain .. All that I have written has been learnt solely from XDA and Google searches. There's a lot of information out there you'll find. This was just to give you a lil touch of all that's happening..












Post #1 - Pilot

To be straight out with it, this isn't meant actually intended for many people to come read, this is kinda like my tech journal where I'm gonna write down stuff that happens quite often with my phone, and I may talk about other stuff in the tech world to just express myself...

THE PHONE-
An outdated Galaxy Ace.

The beauty of it?
It runs Android 4.2 thanks to the brilliant guys over at XDA .

My next (hopefully) to-be phone?
The Nexus 5.

The specs of a Galaxy Ace?

<sarcasm>
A lightning fast 800MHz processor,
Humongous 277MB RAM, (which renders just 50mb free)
"Never-gonna-need-more" 200MB Storage (which after everything renders around 95MB free)
State-of-the-art Adreno 200 GPU.
And the ever so amazing Gingerbread as the Stock OS.
</sarcasm>

What I've made this into?

Overclocked to around 921MHz (still meh, considered to today's standards - laughable even; but hey! better than 800 right?)
Gave it a swap partition for virtual RAM so about 256MB more..
Thanks to INT2EXT4+ by Cronsomething over at XDA, increased internal storage to around 1.8GB
Thanks to another mod over at XDA, disabled CPU rendering and enabled full GPU rendering for a better UI experience and smoother graphics.
And the beautiful 4.2 Jellybean OS.

In reality, I'm not the actual genius here, the guys over at XDA are. But it takes a lil knowledge to know what to do to your phone..

Anyway, brace yourself. The blogs are coming. ..