<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_Apps_2023W_Lecture_13</id>
	<title>Mobile Apps 2023W Lecture 13 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_Apps_2023W_Lecture_13"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_13&amp;action=history"/>
	<updated>2026-04-08T03:33:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_13&amp;diff=24374&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Notes==  &lt;pre&gt; Android Architecture &amp; Security -------------------------------  * I&#039;ve graded all proposals * On Friday, progress report 3 is due * If you have something to demo, please demo in Friday!   What is running on an Android device?  How does it compare to a regular Linux system?  Android documentation uses lots of Android-specific jargon, not at all clear how it maps to more normal concepts.  So I&#039;m going to try explaining that here.  First, Android runs on L...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_13&amp;diff=24374&amp;oldid=prev"/>
		<updated>2023-03-02T04:52:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Notes==  &amp;lt;pre&amp;gt; Android Architecture &amp;amp; Security -------------------------------  * I&amp;#039;ve graded all proposals * On Friday, progress report 3 is due * If you have something to demo, please demo in Friday!   What is running on an Android device?  How does it compare to a regular Linux system?  Android documentation uses lots of Android-specific jargon, not at all clear how it maps to more normal concepts.  So I&amp;#039;m going to try explaining that here.  First, Android runs on L...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Android Architecture &amp;amp; Security&lt;br /&gt;
-------------------------------&lt;br /&gt;
&lt;br /&gt;
* I&amp;#039;ve graded all proposals&lt;br /&gt;
* On Friday, progress report 3 is due&lt;br /&gt;
* If you have something to demo, please demo in Friday!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is running on an Android device?  How does it compare to a regular Linux system?&lt;br /&gt;
&lt;br /&gt;
Android documentation uses lots of Android-specific jargon, not at all clear how it maps to more normal concepts.  So I&amp;#039;m going to try explaining that here.&lt;br /&gt;
&lt;br /&gt;
First, Android runs on Linux.  So what does that mean?&lt;br /&gt;
&lt;br /&gt;
Standard division for most Linux systems:&lt;br /&gt;
&lt;br /&gt;
Applications&lt;br /&gt;
------------&lt;br /&gt;
Linux Kernel&lt;br /&gt;
------------&lt;br /&gt;
Hardware&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kernel communicates with hardware using hardware APIs (accessing special memory locations, I/O ports, interrupts, etc)&lt;br /&gt;
&lt;br /&gt;
Applications talk to the Linux kernel using system calls.&lt;br /&gt;
&lt;br /&gt;
Applications run inside of processes.  A process is an address space + one or more execution context.  Each address space is separate, processes cannot access the memory of other processes (unless explicitly shared).&lt;br /&gt;
&lt;br /&gt;
When you run &amp;quot;ps&amp;quot; or &amp;quot;top&amp;quot; on a Linux system, you can see all of the processes that are running.&lt;br /&gt;
&lt;br /&gt;
You can do the same on Android as well, underneath it is just Linux.&lt;br /&gt;
But...Android has a bunch of extra stuff.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One key difference is in how processes talk to each other.  Standard Linux supports multiple communication mechanisms:&lt;br /&gt;
  - TCP/IP sockets&lt;br /&gt;
  - System V IPC&lt;br /&gt;
  - pipes&lt;br /&gt;
  - shared memory (using mmap)&lt;br /&gt;
&lt;br /&gt;
Android adds its own custom IPC mechanism, Binder.  Yes, they *patched* Linux to add support for a new IPC mechanism!&lt;br /&gt;
 - this is the mechanism that facilitates communication in Android&lt;br /&gt;
 - most Android APIs are built on this when they go between processes&lt;br /&gt;
 - key feature: it is very fast! (uses shared memory, but with kernel support)&lt;br /&gt;
&lt;br /&gt;
Originally Binder wasn&amp;#039;t in the main Linux kernel, it was kept &amp;quot;out of tree&amp;quot;, but it has been upstreamed and so modern Linux systems do have support for Binder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On a standard Linux system, permissions are all based on files and users.  Devices are special files, and access is granted or not based on the user and group of a process.&lt;br /&gt;
&lt;br /&gt;
User/group file permissions are not flexible enough for a system like Android, they wanted something else to determine what applications could access what.&lt;br /&gt;
&lt;br /&gt;
For example, how to control access to a camera?  The raw camera would show up as a device in /dev, how can we make sure only one app is using the camera at a time, that permission is only granted when the user says so and the user can withdraw it?&lt;br /&gt;
&lt;br /&gt;
Well, every app on Android has its own user ID, and that is used to limit the access the app has.&lt;br /&gt;
  - not per user, per APP!&lt;br /&gt;
&lt;br /&gt;
This user-ID-per-app thing is part of the Android *application sandbox* - applications have only limited access to files and other resources.  They are confined by default.&lt;br /&gt;
&lt;br /&gt;
Web browsers also implement a sandbox, that&amp;#039;s why each tab cannot access data in another tab (for JavaScript code), but it is implemented using very different technologies and with different levels of access&lt;br /&gt;
 - remember a sandbox is an aspiration, not a specific set of technologies!&lt;br /&gt;
&lt;br /&gt;
If a regular Android app asks the Linux kernel for access to the camera, the kernel will just say no because it won&amp;#039;t have the right permissions (it won&amp;#039;t have the right user and group ID for access).  But then how does it get access?&lt;br /&gt;
&lt;br /&gt;
Android has special background processes, &amp;quot;servers&amp;quot;, that wait for requests from Android applications and then do the work on behalf of the app.&lt;br /&gt;
 - these services perform a role somewhat like that of the Linux kernel,&lt;br /&gt;
   but in an Android-specific way&lt;br /&gt;
 - most central one is system_server, this implements the basic plumbing,&lt;br /&gt;
   but there are others like media_server&lt;br /&gt;
&lt;br /&gt;
Note that the camera device&amp;#039;s permissions are setup so that an android server process has exclusive access.  Applications then ask it (via intents which are Binder-relayed messages) for access to these resources and the server can say yes or no.  Because Binder is fast this interaction is also fast.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What&amp;#039;s cool about Binder is you don&amp;#039;t have to know which process you want to talk to.  You can broadcast a request with specific criteria and the appropriate processes (applications or servers) will get it and respond as they see fit.&lt;br /&gt;
  - this is all orchestrated by system_server with the help of the Linux kernel&amp;#039;s binder mechanism&lt;br /&gt;
&lt;br /&gt;
Why does all this matter?&lt;br /&gt;
 - to some degree it doesn&amp;#039;t, if you&amp;#039;re doing normal application development&lt;br /&gt;
 - but when things break, it is important to know who is telling you that there is a problem and where you can potentially observe things to try and fix them&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>