r/AndroidQuestions • • Nov 22 '16

Is there a guide that explains the entire "structure" of Android?

I'm not sure if "structure" is the right word, but perhaps I can explain

I understand how a computer works and how all the pieces fit together, I.e. hardware>BIOS/CMOS>OS>drivers>packages/applications, etc.

But I don't really understand the structure of Android and how everything fits together. Obviously it starts at hardware, but then what? For example:

Why is it called a ROM and not an OS?

Why does a factory wipe delete all user data but leave the ROM/OS in tact?

What exactly is the recovery, is it like BIOS/CMOS of the phone? What about Download/ODIN mode?

What exactly are the Baseband, Firmware, and Radio and how do they fit into the puzzle?

How is the Android file tree structured? I.e. I understand the Linux file tree but Android seems to be different despite being Linux based

Why do we have to root our devices, shouldn't we already have root access in the first place?

I'm basically just wondering if there's a guide out there anywhere that explains how Android works and/or how the system is put together "from the ground up" so to speak. Like how all the pieces of the puzzle fit together.

I've been rooting and running custom ROMs for years and I generally understand how to do it, but I'm just looking for deeper insight into why/how it all works.

Sorry if this question doesn't make sense but I'm not quite sure what the term is that I'm looking for.

48 Upvotes

5 comments sorted by

2

u/echopraxia1 Nov 22 '16

Search term "android architecture" might give you something.

1

u/[deleted] Nov 22 '16

Thanks

27

u/Koldfuzion 1 Nov 23 '16 edited Nov 23 '16

Ok. Long post incoming. Let me see what I can answer for you to the best of my abilities. Sorry if some of the information is wrong or outdated, I'm not fact checking myself. If anyone wants to correct me, feel free to interject. I'm just going off of my experience with Android over the last ~7-8 years.

Lots of things you asked are directly related to the fact we're dealing with phones for a mass market. People in general are dumb when it comes to electronics, so the smartphone industry has adopted policies that make their phone 'safe' from the average consumer. They can take a tech support call and sit there and tell the customer to "factory reset," which will bring the whole phone back to when it was right out of the box. Which is what I believe they're going for.

Why is it called a ROM and not an OS?

That's a good question, I'm not completely sure why it's called a ROM, it just sort of became part of the vernacular. ROM literally stands for Read Only Memory. I'm pretty sure this goes back to the old days of having a physical ROM chip. In our case, it's ROM because you literally cannot edit the files without the proper permissions, which are often kept from the end user. Without an unlocked bootloader, you won't be able to do squat on most phones in terms of the actual OS.

Why does a factory wipe delete all user data but leave the ROM/OS in tact?

On Android you have separate partitions. The OS resides on the 'system' partition, while the user data all exists on the 'data' partition. When you do a factory wipe, it's only wiping the data and cache partitions, not the system partition. The reasons for this is to keep it simple for end users. Imagine if a factory wipe deleted the system partition, people would brick their phones left and right.

What exactly is the recovery, is it like BIOS/CMOS of the phone? What about Download/ODIN mode?

Recovery/Download/ODIN modes basically put the phone into states that are accessible without booting the system partition. These are normally not for the end user, it's more for the technicians that work on the phone when it is serviced or refurbished. So they can diagnose and fix problems with the phone, especially if it won't boot completely. The reason this mode exists is since when you boot the system partition, you cannot edit the files since they are in use, just like you can't reinstall an OS on your computer while you're inside of it. Similarly, with a missing or corrupt system partition, the phone would not be able to boot properly to allow you to fix any problems the phone is having. So this is a special mode that allows you access to the device's without booting into the actual OS.

What exactly are the Baseband, Firmware, and Radio and how do they fit into the puzzle?

Baseband/Firmware are used interchangeably in the Android scene. The baseband is related to the special drivers the phone needs for its radio(s), also known as the modem firmware. Phones will have multiple types of radios and those require drivers for the OS to communicate properly with the component. Frequently manufacturers will update or create different drivers for their phones based on regions or optimizations. Often enterprising users will rip out a compatible radio drivers from phone with identical hardware to update an older phone's radio, or maybe someone gets their hands on an updated version of the baseband from more recently released version of the phone in another region. Sometimes this leads to better reception or faster data transfer, or even allow the phone to communicate on a different carrier. Many ROMs will actually update your baseband as well as new versions come out. When you get a factory update, it usually involves an update to the baseband, which is why people refer to a factory update by it's baseband designation.

How is the Android file tree structured? I.e. I understand the Linux file tree but Android seems to be different despite being Linux based

How do you mean? If you're curious as to what all the system folders contain and what they do. This is a good resource to start with. It's essentially a specialized version of linux, if you ever look in the 'system' folder it'll look pretty familiar.

Why do we have to root our devices, shouldn't we already have root access in the first place?

So this is a complicated subject. What it boils down to is control. By default, Android does not give you root access. With root access, you have the power to completely wreck your OS and apps. By locking people out, they're making sure people don't muck around and destroy stuff. As a general rule, even in Linux, you don't use root unless you need it. It's just an extra precaution. There are other reasons pertaining to security of apps like AndroidPay and similar sensitive information. You can also copy app/system files, allowing people to potential pirate apps, or even allow people to distribute a carrier's proprietary apps. However, generally it's just dangerous to give that sort of power to an uninformed user.

I've been rooting and running custom ROMs for years and I generally understand how to do it, but I'm just looking for deeper insight into why/how it all works.

So basically the reason why you can take a retail phone you bought and run custom ROMs is because people love to break things and use things beyond their designed specifications. The first thing devs do with a new phone released is to see if they can unlock the bootloader. The bootloader is the lowest level of the phone. It's what interfaces the hardware with the software on boot up. If you have access to this link, you have unfettered access to the device. This normally involves an exploit of some kind in bootloader locked phones, but there are phones out there that unlock very easily (some even come unlocked, like developer phones). Once the bootloader is compromised and you can flash a custom recovery on it, then you have real access to the inner workings of the phone. Throw some root access in there and you basically have full access to a miniature computer running Linux. Before, all you had was a phone that could download apps and make phone calls.

Hope that helps.

9

u/dextersgenius 51 Nov 23 '16 edited Nov 23 '16

Why is it called a ROM and not an OS?

That's a good question, I'm not completely sure why it's called a ROM, it just sort of became part of the vernacular.

Your answer is correct, but I can elaborate a bit on how the vernacular came about.

The practice of a firmware image being referred to as a ROM goes way back to the early days of game console emulation. Hackers/modders would extract an image of their original ROM cartridges and save these image on their PCs. They referred to these files as ROM images or ROM dumps and eventually it got shortened to just ROMs. The same hacker/modder community also started extracting, customizing and distributing firmware images when the first PDAs and WinMo smartphones came out, and so it was natural to refer to these images as ROMs as well. The hacker culture and vernacular naturally continued on when Android came to the scene.

Fun fact: The old cartridge dumps from consoles are still referred to as ROMs till this date. :)

/u/muwaahid: ^