In-class notes for 01/17/2018
CS 284 (MCA), Interim 2018
Lab 9 complete, with step 12 on SQL injection and
PreparedStatement
Collect project ideas - due at 1pm this form
Next quiz tomorrow afternoon (Thursday) -- topics
Submitted questions on assignments and technology
Backend server
Backend server: Only Lab 10 (multithreaded file server) will be required
Lab 11 (client interactions, database for backend) and Lab 12 (mobile client) in production, for project use.
EXPO SDK
Android architecture and execution model
Some general terms
process -- an execution of a program.
runtime system -- code for implementing the core behavior of a software system, such as a computer language or operating system
operating system -- body of reusable code for computing with hardware resources of a computing device. Typical components: process management; memory management; hardware device drivers; file system.
kernel -- the code of an operating system.
background computation -- a computation that executes without direct access by the user.
thread -- a sequence of execution within a process. Java, C++, and many other languages enable processes to have multiple threads; with CPUs having more than one core, those executions may take place in paralle (at the same time).
core -- a circuit capable of executing code. Modern computers and recent Android devices have multiple cores, which make it possible to carry out multiple computations in parallel
Note: Computer CPU manufacturers now produce CPUs with more and more cores in part because creating faster and larger single-core computers would require a prohibitive amount of power (i.e., wattage). Conversely, mobile device CPU manufacturers now produce CPUs with more and more cores in order to reduce the amount of power those devices will require.
Some Android terms
activity -- a user-interface screen.
Note: activated via an Intentintent -- a request for a specific action, e.g., send an email
resource -- a datum (such as a string or bitmap) used by an application
content provider -- a data set with an custom API for reading/writing it. e.g., contacts
Note: activated via a ContentResolver, which provides a layer for security.service -- background process that provides specific computation. e.g., music player.
Note: activated via an Intent.broadcast receiver -- responds to system-wide broadcast messages. Broadcast messages may originate from the Android system (e.g., notification that screen has turned off), or from an application (e.g., letting other applications know that a download has been received). Broadcast messages are delivered as Intents.
application -- an Android Java package (archived into a single
.apk
file) that contains one or more application components: activities; services; content providers; and/or broadcast receivers.
Note: Each application receives its own unique Linux user id, for protecting that application's files. The components in an application are listed in that application's manifest file (XML).open application -- We will use this unofficial term for an application that has been launched and not removed from the system, whether or not it currently has a process.
Android process -- a Linux process created for running (i.e., executing) components of an application.
Notes: Each process has its own virtual machine, in order to provide "sandbox" security for applications. An application can remain open even if its process is deleted by Android in order to free up memory.UI thread or main thread -- a thread of execution created for an application when that application launches that responds to UI (user interface) events (e.g., a button click in an Activity) and dispatches other events (e.g., to draw on the screen).
Note: Exactly one UI thread exists per (open) application. It must never be blocked (e.g., waiting for file input to complete), and Android UI calls for that application must only originate from the UI thread. (This is because the Android UI toolkit is not "thread safe.") Thus, blocking calls (such as file input) must be carried out in background "worker" threads.(Reference onAndroid applications and Android processes and threads)
Terms and concepts activity - Layers of Android architecture
Consider the Android system architecture Figure 9 in Hello, Android. This figure describes a four-layer architecture: Linux kernel; Libraries and the Android runtime; Android Application Framework; and Android applications and widgets (such as you will write). We have also identified the ``physical'' layer for hardware, below the Linux kernel.
For seven or more of the following items related to Android applications,
indicate which layer(s) that item occurs at (physical, kernel, libraries or runtime, framework, and/or app), and
give a rationale for your answer.
If an item occurs at multiple layers, list all of those layers and give rationale for each. {\em Note:} There may be more than one ``correct'' answer for an item -- use the combination of layer and rationale to indicate that you understand the architecture. One example answer is provided.
An Activity
A mobile device's camera
Launching a new app
Managing parameters that govern an application
Dialing the phone -- An answer: Framework, Libraries/runtime, Kernel, Physical layers. In particular, at the Framework level I'd expect the Telephony Manager to supervise carrying out the process of sending the number to the phone service. The VM within the Runtime system would execute the instructions of the Telephony Manager, and other libraries would presumably be used. At the Kernel level, the Keypad Driver would be used to obtain the digits of the phone number from the user.
Retrieving values from database
Drawing a line on the screen
Executing an application's instructions
Reading a character from an onscreen keyboard
To study for quiz
SQL and databases
Notions of relational databases:
data definition (e.g.,
CREATE TABLE
)data manipulation (e.g.,
INSERT, DELETE, DROP, UPDATE
)queries (e.g.,
SELECT
)
Formulating queries
JDBC -- concepts, reading code
Security and protection
Password security;
.pgpass
rationaleSQL injection attack; prepared queries
< >