|
|
|
Modern Operating Systems by Herbert Bos and Andrew S. Tanenb...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf
Showing 865-866 out of 1137
Modern Operating Systems by Herbert Bos and Andrew...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Modern Operating Systems by Herbert...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Page 865
834
CASE STUDY 1: UNIX, LINUX, AND ANDROID
CHAP. 10
for a list of all receivers interested in the event, which is placed in a
Broadcast-
Record
representing that broadcast.
The activity manager will then proceed to step
through each entry in the list, having each associated application’s process create
and execute the appropriate receiver class.
Activity manager in system_server process
Calendar app process
Email app process
Browser app process
SyncControlReceiver
SyncControlReceiver
CleanupReceiver
BroadcastRecord
DEVICE_STORAGE_LOW
SyncControlReceiver
(Calendar app)
SyncControlReceiver
(Email app)
CleanupReceiver
(Browser app)
Figure 10-60.
Sending a broadcast to application receivers.
Receivers only run as one-shot operations. When an event happens, the system
finds any receivers interested in it, delivers that event to them, and once they have
consumed the event they are done.
There is no
ReceiverRecord
like those we have
seen for other application components, because a particular receiver is only a tran-
sient entity for the duration of a single broadcast.
Each time a new broadcast is
sent to a receiver component, a new instance of that receiver’s class is created.
Content Providers
Our last application component, the
content provider
, is the primary mechan-
ism that applications use to exchange data with each other.
All interactions with a
content provider are through URIs using a
content:
scheme; the authority of the
URI is used to find the correct content-provider implementation to interact with.
For example, in our email application from Fig. 10-51, the content provider
specifies that its authority is
com.example.email.provider.email
.
Thus URIs operat-
ing on this content provider would start with
content://com.example.email.provider.email/
The suffix to that URI is interpreted by the provider itself to determine which data
within it is being accessed.
In the example here, a common convention would be
that the URI
Page 866
SEC. 10.8
ANDROID
835
content://com.example.email.provider.email/messages
means the list of all email messages, while
content://com.example.email.provider.email/messages/1
provides access to a single message at key number 1.
To interact with a content provider, applications always go through a system
API called
ContentResolver
, where most methods have an initial URI argument
indicating the data to operate on.
One of the most often used
ContentResolver
methods is
query
, which performs a database query on a given URI and returns a
Cursor
for retrieving the structured results.
For example, retrieving a summary of
all of the available email messages would look something like:
query("content://com.example.email.provider.email/messages")
Though this does not look like it to applications, what is actually going on
when they use content providers has many similarities to binding to services.
Fig-
ure 10-61 illustrates how the system handles our query example:
1. The application calls
ContentResolver.query
to initiate the operation.
2. The URI’s authority is handed to the activity manager for it to find
(via the package manager) the appropriate content provider.
3.
If the content provider is not already running, it is created.
4.
Once created, the content provider returns to the activity manager its
IBinder
implementing the system’s
IContentProvider
interface.
5. The content provider’s
Binder
is returned to the
ContentResolver
.
6.
The content resolver can now complete the initial
query
operation by
calling the appropriate method on the AIDL interface, returning the
Cursor
result.
Content providers are one of the key mechanisms for performing interactions
across applications.
For example, if we return to the cross-application sharing sys-
tem previously described in Fig. 10-55, content providers are the way data is ac-
tually transferred. The full flow for this operation is:
1.
A share request that includes the URI of the data to be shared is creat-
ed and is submitted to the system.
2. The system asks the
ContentResolver
for the MIME type of the data
behind that URI; this works much like the
query
method we just dis-
cussed, but asks the content provider to return a MIME-type string for
the URI.
Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
Concordia_University
School:
Operating_Systems
Course:
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades
Students also viewed documents
lab 18.docx
lab_18.docx
Course
Course
3
Module5QuizSTA2023.d...
Module5QuizSTA2023.docx.docx
Course
Course
10
Week 7 Test Math302....
Week_7_Test_Math302.docx.docx
Course
Course
30
Chapter 1 Assigment ...
Chapter_1_Assigment_Questions.docx.docx
Course
Course
5
Week 4 tests.docx.do...
Week_4_tests.docx.docx
Course
Course
23
Week 6 tests.docx.do...
Week_6_tests.docx.docx
Course
Course
106