Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse the Android process and its security

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to analyze the Android process and the security of the process, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

If the caller initiates another Android process, the method runs in another thread, which is in the same thread pool as the IBinder object, because a service may have multiple client requests, and more than one thread pool calls the IBinder method at the same time.

This property can be used to run the process of the component. This property can configure components to run in a separate process, or multiple components to run in the same process. You can even have multiple programs running in a single process-if they share a User ID and are given the same permissions. The node also contains the process attribute, which is used to set the default process for all components in the program.

All components are instantiated in the Android process of this process, and the system calls to these components are separated from the main thread. Not every object is detached from the main thread. In general, methods that respond to user actions such as View.onKeyDown () (discussed later in Component Lifecycles) also run in the main thread.

This means that components should not run for long periods of time or block operations (such as network operations or calculating large amounts of data) when called by the system, as this will block other components in the process. This type of operation can be separated from the main thread, which will be reduced to the following Threads. When more commonly used processes cannot get enough memory, Android may shut down less frequently used processes. The next time you start the program, there will be a startup process.

When deciding which process needs to be shut down, Android considers which is more useful to the user. For example, Android tends to close a process that is not displayed in the interface for a long time to support a process that is often displayed in the interface. Whether or not to shut down a process depends on the state of the component in the process, see the following section Component Lifecycles.

Even if different processes are assigned to the component, it is sometimes necessary to reassign the Android process. For example, the user interface needs to respond quickly to the user, so some time-consuming operations, such as network connections, downloads, or server-time-consuming operations, should be placed on other threads.

Threads are created through java's standard object Thread. Android provides many convenient ways to manage Android processes:-Looper runs a message loop in a thread; Handler passes a message; and HandlerThread creates a thread with a message loop.

Remote invocation Remote procedure callsAndroid has a lightweight mechanism for remote invocation (RPCs)-through which methods can be called locally, executed remotely (in other processes), and return a value. To achieve this requirement, the method call must decompose the method call, and all data to be passed must be at a level accessible to the operating system. Transfer from local process and memory addresses to remote process and memory addresses and remotely process and return.

The return value must be passed in the opposite direction. Android provides the code to do this, so developers can focus on implementing the interface to RPC.

There can be only one method per RPC interface. All methods are executed synchronously (the local method does not end blocking until the remote method returns), even when there is no return value.

To put it simply, the mechanism goes like this: use IDL (interface definition language). To define the interface you want to implement, the aidl tool can generate an interface definition for java, which is used locally and remotely. It contains two classes, as shown in the following figure:

The inner class contains all the code needed to manage remote programs (interfaces that conform to the IDL description). All inner classes implement the IBinder interface. One of them is used locally. You can ignore its code; another one called Stub inherits the Binder class. In order to call the Android process remotely, this class contains the RPC interface. Developers can inherit the Stub class to implement the required methods.

In general, a remote process is managed by a service (because service can inform the operating system of this process and communicate with other processes), it also contains the interface file generated by the aidl tool, and the Stub class implements the remote method. The client of the service only needs the interface file generated by the aidl tool.

Here is how to connect the service and the client call:

The client (local) of the ◆ service implements the onServiceConnected () and onServiceDisconnected () methods so that you can get notifications when the client connects or disconnects. Get the connection to the service through bindService ().

The onBind () method of the ◆ service can receive or reject the connection, depending on the intent it receives (the intent connects to the service through the bindService () method). If the service receives the connection, it returns an instance of the Stub class.

◆ if the service accepts the connection, Android invokes the client's onServiceConnected () method and passes an Ibinder object (a proxy for the system-managed Stub class), through which the client can connect to the remote service.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report