Fundamenty aplikacji Flashcards

1
Q

What include .apk file?

A

One APK file contains all the contents of an Android app and is the file that Android-powered devices use to install app.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Security features of Android

A
  • The Android operating system is a multi-user Linux system in which each app is a different user.
  • By default, the system assigns each app a unique Linusx user ID (the ID is used only by the system and is unknown to the app). The system sets permissions for all the files in an app so that only the user ID assigned to that app can access them.
  • Each process has its own virtual machine(VM) , so an app’s code runs in isolation from other apps.
  • By default, every app runs in its own Lunux process. The Android system starts the process when any of the app’s components need to be executed, and then shuts down the process when it’s no longer needed or when the system must recover memory for the other apps.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The principle of least privilege. Describe it.

A

That is, each app, by default, has access only to the components that is requires to di its work and no more. This creates a very secure environment in which an app cannot access parts of the system for which it is not given permission. However, there are ways for an app to share data with other apps and for an app to access system services.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How app can share data with other apps

A
  • It’s possible to arrange for two apps to share the same Linux user ID, in which case they are able to access each other’s files. To conserve system resources, apps with the same user ID can also arrange to run in the same Linux process and share the same VM. The apps must also be signed with the same certificate.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How app can access system services:

A

An app can request permission to access device data such as the device’s location, camera, and Bluetooth connection. The user has to explicitly grant these permissions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is app component and what are the types of it?

A

App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others.

There are four different types of app components:

  • Activities
  • Services
  • Broadcast receivers
  • Content providers

Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an activity component?

A

An activity is the entry point for interacting with the user. It represents a single screen with a user interface.

  • Activities work together to form a cohesive user experience
  • Each one is independent from others
  • Different app can start any of these activities if the ‘mother’ app allows it.

For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work tohether to form a cohesive user experience in the email app, each one is intependent of the others. As such, a different app can start any one of these activities if the email app allows it. For example, a camera app can start the activity in the email app that composes new mail to allow user to share a picture.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What key interactions between system and app does the activity facilitates?

A
  • Keeping track of what the user currently cares about (what is on the screen) to ensure that the system keeps running the process that is hosting the activity.
  • Knowing that previously used processes contain things the user may return to (stopped activities), and thus more highly prioritize keeping those processes around.
  • Helping the app handle having its process killed so the user can return to activities with their previous state restored.
  • Providing a way for apps to implement user flows between each other, and for the system to coordinate these flows. (The most classic example here being share).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is service?

A

A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.

For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with and activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it.
There are actually two very distinct semantics services tell the system about how to manage an app:
Started services tell the system to keep them running until their work is completed. This could be to sync some data in the background or play music even after the user leaves the app. Syncing data in the background or playing music also represent two different types of started services that modify how the system handles them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Two ways how the system handle services.

A
  • User is aware of running the service, then system knows that it should try really hard to keep that service’s process running, because the user will be unhappy if it goes away.
  • Regular background service - user is not directly aware as running. System has more freedom in managing its process. It may allow it to be killed (and then restarting the service sometime later) if it needs RAM for things that are of more immediate concern to the user.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Bounding services to another process.

A

Bound services run because some other app (or the system) has said that it wants to make use of the service. This is basically the service providing an API to another process. The system thus knows there is a dependency between these processes, so if process A is bound to a service in process B, it knows that it needs to keep process B (and its service) running for A. Further, if process A is something the user cares about, then it also knows to treat process B as something the user also cares about. Because of their flexibility (for better or worse), services have turned out to be a really useful building block for all kinds of higher-level system concepts. Live wallpapers, notification listeners, screen savers, input methods, accessibility services, and many other core system features are all built as services that applications implement and the system binds to when they should be running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Broadcast Receivers

A

A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements.

Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren’t currently running. So, for example, an app can schedule an alarm to post a notification to tell the user about an upcoming event… and by delivering that alarm to a BroadcastReceiver of the app, there is no need for the app to remain running until the alarm goes off. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Apps can also initiate broadcasts—for example, to let other apps know that some data has been downloaded to the device and is available for them to use. Although broadcast receivers don’t display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a gateway to other components and is intended to do a very minimal amount of work. For instance, it might schedule a JobService to perform some work based on the event with JobScheduler

A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Content provider

A

A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access. Through the content provider, other apps can query or modify the data if the content provider allows it.

For example, the Android system provides a content provider that manages the user’s contact information. As such, any app with the proper permissions can query the content provider, such as ContactsContract.Data, to read and write information about a particular person. It is tempting to think of a content provider as an abstraction on a database, because there is a lot of API and support built in to them for that common case. However, they have a different core purpose from a system-design perspective.

A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other apps to perform transactions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is content provider for the system?

A

To the system, a content provider is an entry point into an app for publishing named data items, identified by a URI scheme. Thus an app can decide how it wants to map the data it contains to a URI namespace, handing out those URIs to other entities which can in turn use them to access the data. There are a few particular things this allows the system to do in managing an app:

  • Assigning a URI doesn’t require that the app remain running, so URIs can persist after their owning apps have exited. The system only needs to make sure that an owning app is still running when it has to retrieve the app’s data from the corresponding URI.
  • These URIs also provide an important fine-grained security model. For example, an app can place the URI for an image it has on the clipboard, but leave its content provider locked up so that other apps cannot freely access it. When a second app attempts to access that URI on the clipboard, the system can allow that app to access the data via a temporary URI permission grant so that it is allowed to access the data only behind that URI, but nothing else in the second app.

Content providers are also useful for reading and writing data that is private to your app and not shared.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Unique aspect of the Android system desing.

A

App can start another app’s component.

For example, if you want the user to capture a photo with the device camera, there’s probably another app that does that and your app can use it instead of developing an activity to capture a photo yourself. You don’t need to incorporate or even link to the code from the camera app. Instead, you can simply start the activity in the camera app that captures a photo. When complete, the photo is even returned to your app so you can use it. To the user, it seems as if the camera is actually a part of your app.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is going on when the system starts a component. Does the Android have a single entry point?

A

When the system starts a component, it starts the process for that app if it’s not already running and instantiates the classes needed for the component.

For example, if your app starts the activity in the camera app that captures a photo, that activity runs in the process that belongs to the camera app, not in your app’s process.

Therefore, unlike apps on most other systems, Android apps don’t have a single entry point (there’s no main() function).

17
Q

Does app can directly start component from other app?

A

No, because the system runs each app in a separate process with file permissions that restrict access to other apps, your app cannot directly activate a component from another app. However, the Android system can. To activate a component in another app, deliver a message to the system that specifies your intent to start a particular component. The system then activates the component for you.

18
Q

Which components are activated by intent?

A

Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent.

19
Q

What is intent?

A

An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.