Interface jump processing method and device and electronic equipment
By writing jump data in shared memory and writing shared memory configuration information in Intent memory of Intent component, the problem of low stability of jump data transfer on the interface based on Intent memory is solved, and data transfer without size limits is achieved and stability and efficiency are improved.
Patent Information
- Application Number
- CN202411763082.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-02-28
AI Technical Summary
Interface jump based on Intent memory is not stable during data transfer, especially when the data size exceeds 1MB, it will cause data transfer to fail.
By writing jump data in shared memory and writing shared memory configuration information in the Intent memory corresponding to the Intent component, large data is avoided writing to Intent memory, thereby improving the stability of data transmission.
It realizes the transfer of data without size limits during interface jumping, which improves the stability of data transfer and the accuracy and efficiency of interface jumping.
Smart Images

Figure CN119536893A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to an interface jump processing method, device, electronic device, storage medium and computer program product. Background Art
[0002] In Android system development, data transfer can be divided into intra-process data transfer and inter-process data transfer. Among them, the data transfer process such as interface jump, service startup or external application startup can be realized based on Intent memory.
[0003] However, data transmission failure may occur based on Intent memory, and the data transmission stability is not high. Summary of the invention
[0004] Based on this, it is necessary to provide an interface jump processing method, device, electronic device, computer-readable storage medium and computer program product that can improve the stability of data transmission during the interface jump process in order to address the above technical problems.
[0005] In the first aspect, the present application provides an interface jump processing method. The method includes: in response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request; applying for and creating a shared memory and an intent component matching the jump data; writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; calling a system service component to send the configuration information read from the intent memory to a second process; calling the second process to read the jump data from the shared memory matching the configuration information, and loading the second interface corresponding to the interface jump request based on the jump data.
[0006] In one embodiment, the method further includes: calling the first process to write the starting write offset value information of the jump data in the shared memory into the intent memory; calling the second process to read the starting write offset value information from the intent memory; the configuration information includes the handle value of the shared memory, and calling the second process to read the jump data from the shared memory matching the configuration information includes: calling the second process to read the jump data from the shared memory matching the handle value based on the starting write offset value information.
[0007] In one embodiment, the method also includes: calling the first process to write the class name information corresponding to the jump data into the intent memory; calling the second process to read the class name information from the intent memory; calling the second process to load the second interface corresponding to the interface jump request based on the jump data, including: calling the second process to obtain the first target instance from the buffer pool, and based on the deserialization method matching the first target instance, parsing the jump data into the first target instance to obtain a parsed instance; based on the class name information, processing the parsed instance to obtain a data instance corresponding to the first interface; based on the data instance, calling the second process to load the second interface corresponding to the interface jump request.
[0008] In one embodiment, calling the first process to obtain jump data matching the interface jump request includes: calling the first process to obtain the data to be transferred matching the interface jump request, obtaining a second target instance from a buffer pool, and writing the data to be transferred into the second target instance to obtain a write instance; calling a serialization method matching the second target instance, serializing the write instance, and obtaining jump data matching the interface jump request.
[0009] In one embodiment, the method further includes: based on the data size of the jump data, calling the first process to apply for creating a shared memory in the memory space of the first process; the memory size of the shared memory matches the data size of the jump data.
[0010] In one embodiment, it also includes any one of the following items: the first item: when the jump data is written to the shared memory and / or the intent component is started, the timing component is called to start the timing; when the timing duration reaches a duration threshold, if it is detected that the shared memory is not released, the first process is called to release the shared memory; the second item: after calling the second process to read the jump data from the shared memory matching the configuration information, the first process is called to release the shared memory.
[0011] In the second aspect, the present application provides an interface jump processing device, which includes: an acquisition module, which is used to call a first process to obtain jump data matching the interface jump request in response to an interface jump request for a first interface; a creation module, which is used to apply for and create a shared memory and intent component matching the jump data; a writing module, which is used to write the jump data into the shared memory, and write the configuration information for the shared memory into the intent memory corresponding to the intent component; a communication module, which is used to call a system service component to send the configuration information read from the intent memory to a second process; a processing module, which is used to call the second process to read the jump data from the shared memory matching the configuration information, and load the second interface corresponding to the interface jump request based on the jump data.
[0012] In a third aspect, the present application also provides an electronic device. The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program: in response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request; applying for and creating a shared memory and an intent component matching the jump data; writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; calling a system service component to send the configuration information read from the intent memory to a second process; calling the second process to read the jump data from the shared memory matching the configuration information, and loading the second interface corresponding to the interface jump request based on the jump data.
[0013] In a fourth aspect, the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented: in response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request; applying for and creating a shared memory and an intent component matching the jump data; writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; calling a system service component to send the configuration information read from the intent memory to a second process; calling the second process to read the jump data from the shared memory matching the configuration information, and loading the second interface corresponding to the interface jump request based on the jump data.
[0014] In a fifth aspect, the present application also provides a computer program product. The computer program product includes a computer program, which implements the following steps when executed by a processor: in response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request; applying for and creating a shared memory and intent component matching the jump data; writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; calling a system service component to send the configuration information read from the intent memory to a second process; calling the second process to read the jump data from the shared memory matching the configuration information, and loading the second interface corresponding to the interface jump request based on the jump data.
[0015] The above-mentioned interface jump processing method, device, electronic device, storage medium and computer program product, in response to an interface jump request for a first interface, call the first process to obtain jump data matching the interface jump request, and call the first process to apply for and create a shared memory and intent component matching the jump data, and call the first process to write the jump data into the shared memory, and write the configuration information for the shared memory into the intent memory corresponding to the intent component, and then call the system service component to send the configuration information read from the intent memory to the second process, and call the second process to read the jump data from the shared memory matching the configuration information, and load the second interface corresponding to the interface jump request based on the jump data. Therefore, by writing the jump data in the shared memory and writing the configuration information of the shared memory in the intent memory corresponding to the intent component, it is possible to avoid the situation where the jump data is larger than the fixed storage size of the intent memory when writing the jump data into the intent memory. This allows jump data with no size limit to be transmitted during the interface jump process, thereby improving the stability of data transmission during the interface jump process. Moreover, the second process directly jumps data from the shared memory based on the configuration information, and loads the second interface based on the jump data, thereby achieving accuracy and efficiency in interface jumps. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] FIG1 is a schematic diagram of the parameter transmission principle of jumping between interfaces in one embodiment;
[0017] FIG2 is an application environment diagram of an interface jump processing method in one embodiment;
[0018] FIG3 is a schematic diagram of a flow chart of an interface jump processing method in one embodiment;
[0019] FIG4 is a schematic diagram of a flow chart of calling a second process to read jump data from a shared memory matching configuration information in one embodiment;
[0020] 5 is a schematic diagram of a process of calling a second process to jump to a second interface corresponding to a request based on a jump data loading interface in one embodiment;
[0021] FIG6 is a schematic diagram of a process of calling a first process to obtain jump data matching an interface jump request in one embodiment;
[0022] FIG7 is a flow chart of an interface jump processing method in another embodiment;
[0023] FIG8 is a schematic diagram of the parameter transmission principle of jumping between interfaces in another embodiment;
[0024] FIG9 is a structural block diagram of an interface jump processing device in another embodiment;
[0025] FIG. 10 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] Although the Intent memory can support data transfer within and between processes at the same time, the data transfer process requires the intervention of the Android system service component (Activity Manager Service, AMS); and AMS runs in the system process, or the sender and receiver of the data transfer are not in the same process, that is, data transfer in the Android system must involve inter-process communication (Inter-Process Communication, IPC), and IPC in the Android system can be implemented through Binder. When implementing IPC, Binder will allocate a piece of memory (i.e., Intent memory) in the kernel through mmap() to store relevant data during the interface jump process and data that needs to be transferred when the interface jumps. Due to the limited kernel memory space, Binder will limit the memory size for storing data. Usually, the memory size is less than or equal to 1MB. Therefore, for the data that needs to be transferred when the interface jumps, when the data size of the data to be transferred exceeds 1MB, the application process will throw an exception and crash, interrupting data transfer.
[0028] From the above, it can be seen that data transfer failure may occur based on the Intent memory, making the data transfer stability not high. For example, as shown in Figure 1, a schematic diagram of the parameter transfer principle for jumping between interfaces is provided. Among them, the applications and processes to which interfaces A and B belong can be the same or different; AMS runs in the kernel space. When interface A carries data to jump to interface B, the process corresponding to interface A can write the data to be transferred directly into the Intent memory, and then pass it to AMS, and finally pass it from AMS to the process corresponding to interface B, and then the process corresponding to interface B loads the corresponding interface. However, if the size of the data exceeds 1MB, the Android system will throw an exception, resulting in a jump failure.
[0029] In view of this, you can consider writing a small amount of data in the Intent memory, and applying for another memory to store the data that needs to be transmitted when the interface jumps. By configuring the data stored in the Intent memory and the data stored in the applied memory to have a correlation, you can avoid the situation where the data stored in the Intent memory is too large and causes data transmission failure, and improve the stability of data transmission during the interface jump process.
[0030] In one embodiment, the present application implements an interface jump processing method, which can be applied in the application environment shown in FIG2. The terminal 200 includes a first process 202 for loading a first interface, a system service component (Activity Manager Service, AMS) 204, a second process 206 for loading a second interface, and a processor 208. The terminal 200 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, etc. The second interface is the interface after the first interface jumps.
[0031] Specifically, in response to an interface jump request for the first interface, the processor 208 calls the first process to obtain jump data that matches the interface jump request, and calls the first process to apply for and create shared memory and intent components that match the jump data, and calls the first process to write the jump data into the shared memory, and writes the configuration information for the shared memory into the intent memory corresponding to the intent component, and then calls the system service component to send the configuration information read from the intent memory to the second process, and calls the second process to read the jump data from the shared memory that matches the configuration information, and loads the second interface corresponding to the interface jump request based on the jump data, thereby achieving a jump from the first interface to the second interface.
[0032] In one embodiment, as shown in FIG. 3 , a method for processing interface jump is provided, and the method is applied to the processor 208 in FIG. 1 as an example for description, including the following steps:
[0033] S302: In response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request.
[0034] In this embodiment, the interface jump request refers to a request to jump from a first interface to an interface different from the first interface. There is no limit to the way to trigger the interface jump request. For example, it can be triggered based on the user's active operation (such as clicking a button, link, etc.), or it can be triggered based on a specific condition. The specific condition can refer to a specific gesture, a specific voice, etc.
[0035] The first process refers to the process of loading the first interface, and the jump data refers to data related to the data that needs to be transmitted during the jump of the first interface. The form of the jump data is not limited, for example, the jump data can refer to the data that needs to be transmitted during the jump of the first interface, or it can refer to the data processed after the data that needs to be transmitted during the jump of the first interface.
[0036] The jump data includes but is not limited to: picture data, text data, etc. For example, when the picture in the first interface A is jumped and displayed in the second interface B, the jump data may refer to the picture data.
[0037] S304, apply for and create a shared memory and intent component that matches the jump data.
[0038] Among them, in the Android system, the Intent component is the component corresponding to the Intent mechanism, which is used to assist the interaction and communication between applications and processes. It can also be used for communication and interaction between different components (such as Activity, Service, BroadcastReceiver, etc.).
[0039] The shared memory is a memory space temporarily applied for in the memory space of the first process. After the shared memory is used up, the shared memory can be released to save memory space.
[0040] In some embodiments, based on the data size of the jump data, the first process is called to apply for creating a shared memory in the memory space of the first process; the memory size of the shared memory matches the data size of the jump data. There is no limit to the way to create the shared memory, for example, the shared memory can be created based on the MemoryFile mechanism.
[0041] S306, writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component.
[0042] The configuration information of the shared memory is information related to the shared memory, including but not limited to: the handle value of the shared memory, the memory size of the shared memory, the access rights of the shared memory, the memory address of the shared memory, etc. The handle value of the shared memory refers to a unique identifier or pointer used to identify the shared memory, and the access rights of the shared memory are used to define the processes or users that are allowed to access the shared memory.
[0043] Among them, the intent memory is the memory used to store the data that needs to be transferred during the interface jump when implementing cross-process communication based on the intent component. Before writing the configuration information for the shared memory into the intent memory corresponding to the intent component, you need to start the intent component. There is no limit to the way to start the intent component. For example, you can start the intent memory through Context#startActivity.
[0044] S308: Call the system service component to send the configuration information read from the intent memory to the second process.
[0045] The second process is used to load the second interface corresponding to the interface jump request, that is, to load the interface after the jump from the first interface. The second process can be any process in the process pool that is different from the first process.
[0046] Before calling the system service component to send the configuration information read from the intent memory to the second process, the second process needs to be started. There is no limit to the way to start the second process, and several of the ways are described below as examples.
[0047] In one embodiment, the system service component may be called to start the second process, so that after the system service component reads the configuration information from the intent memory, the read configuration information may be sent to the second process.
[0048] In one embodiment, the first process may be called to start the second process, so that after detecting that the second process is started, the system service component may send the configuration information read from the intent memory to the second process.
[0049] S310, calling the second process to read jump data from the shared memory matching the configuration information, and loading the second interface corresponding to the interface jump request based on the jump data.
[0050] There is no limitation on the implementation method of calling the second process to read jump data from the shared memory matching the configuration information. For example, if the configuration information of the shared memory includes the memory address of the shared memory, the second process is called to read jump data from the shared memory matching the memory address.
[0051] After the shared memory is used, the shared memory can be released. For example, after calling the second process to read the jump data from the shared memory that matches the configuration information, the first process is called to release the shared memory to save memory space. For example, when the jump data is written to the shared memory, and / or the intent component is started, the timing component is called to start the timing; when the timing reaches the duration threshold, if it is detected that the shared memory has not been released, the first process is called to release the shared memory. The duration threshold can be 5 seconds or other values.
[0052] Based on the content shown in Figure 3, in response to the interface jump request for the first interface, the first process is called to obtain jump data matching the interface jump request, and the first process is called to apply for and create shared memory and intent components matching the jump data, and the first process is called to write the jump data into the shared memory, and the configuration information for the shared memory is written into the intent memory corresponding to the intent component, and then the system service component is called to send the configuration information read from the intent memory to the second process, and the second process is called to read the jump data from the shared memory matching the configuration information, and the second interface corresponding to the interface jump request is loaded based on the jump data. Therefore, by writing the jump data in the shared memory and writing the configuration information of the shared memory in the intent memory corresponding to the intent component, it is possible to avoid the situation where the jump data is larger than the fixed storage size of the intent memory when writing the jump data into the intent memory. This allows jump data with no size limit to be transmitted during the interface jump process, thereby improving the stability of data transmission during the interface jump process. Moreover, the second process directly jumps data from the shared memory based on the configuration information, and loads the second interface based on the jump data, thereby achieving accuracy and efficiency in interface jumps.
[0053] In one embodiment, the configuration information of the shared memory includes a handle value of the shared memory. Specifically, as shown in FIG. 4 , a flow chart of calling a second process to read jump data from a shared memory matching the configuration information is provided, including the following steps:
[0054] S402, calling the first process to write the starting write offset value information of the jump data in the shared memory into the intent memory.
[0055] The start write offset value information refers to information related to the offset of the start position of writing jump data in the shared memory relative to the start address of the shared memory, including but not limited to: the offset value of the shared memory, the unit of the offset, etc. The offset value represents the number of bytes from the start address of the shared memory to the start position of writing jump data. The unit of the offset is byte.
[0056] S404, calling the second process to read the starting write offset value information from the intent memory.
[0057] S406, calling the second process to read jump data from the shared memory matching the handle value based on the start write offset value information.
[0058] Specifically, a shared memory handle may be created based on the shared memory handle value, and then an input stream may be created based on the shared memory handle to read data matching the start write offset value information from the input stream to obtain the jump data. For example, a FileDescriptor may be created based on the handle value, a FileInputStream input stream may be created based on the FileDescriptor, and the jump data may be read from the input stream.
[0059] Based on the content shown in Figure 4, by using shared memory to store jump data, the handle value and starting write offset value information of the shared memory are written into the intent memory, thereby reducing the amount of data written in the intent memory, so that data with no size limit can be transmitted when transmitting data for interface jumps, which greatly facilitates the function development of R&D personnel and enables R&D personnel to focus more on the development of functional business logic without being affected by data transmission restrictions, thereby improving the efficiency of application R&D personnel.
[0060] In one embodiment, as shown in FIG. 5 , a flow chart of calling a second process to jump to a second interface corresponding to a request based on a jump data loading interface is provided, including the following steps:
[0061] S502, calling the first process to write the class name information corresponding to the jump data into the intent memory.
[0062] The class name information of the jump data refers to information related to the data representation form of the jump data. For example, when the data representation form of the jump data is a picture, the class name information corresponding to the corresponding jump data may refer to android.graphics.Bitmap.
[0063] S504, calling the second process to read the class name information from the intent memory.
[0064] S506, calling the second process to obtain the first target instance from the buffer pool, and parsing the jump data into the first target instance based on the deserialization method matching the first target instance to obtain a parsed instance.
[0065] The type of the buffer pool is not limited. For example, the buffer pool may refer to a Parcel buffer pool, and the first target instance refers to a Parcel instance. Specifically, the Parcel instance may be obtained from the Parcel buffer pool through Parcel.obtain() to obtain the first target instance.
[0066] Furthermore, when the first target instance refers to a Parcel instance, the redirected data may be parsed into the Parcel instance based on the unmarshall method of the Parcel instance to obtain a parsed instance.
[0067] S508: Process the parsed instance based on the class name information to obtain a data instance corresponding to the first interface.
[0068] Specifically, when the parsed instance is a Parcel instance, the Parcelable.Creator static interface object can be found based on the class name information reflection, and the parsed instance can be passed in through createFromParcel to create a data instance corresponding to the first interface. For example, when the image data in the first interface A is displayed in the second interface B in the form of Bitmap, the data instance refers to the Bitmap instance.
[0069] S510: Based on the data instance, call the second process to load the second interface corresponding to the interface jump request.
[0070] In this embodiment, based on the data instance, the second process can be called to load the interface jump request corresponding to the second interface based on the ImageView component. For example, based on the ImageView component, the Bitmap instance is displayed on the second interface, so that the image corresponding to the image data transmitted from the first interface can be seen on the second interface.
[0071] Based on the method shown in FIG. 5 , by also writing the class name information corresponding to the jump data into the intent memory, the loading process of the second interface corresponding to the interface jump request is implemented based on the class name information, which can improve the accuracy of interface loading.
[0072] In one embodiment, as shown in FIG. 6 , a flow chart of calling a first process to obtain jump data matching an interface jump request is provided, including the following steps:
[0073] S602, calling the first process to obtain the data to be transferred that matches the interface jump request, and obtaining the second target instance from the buffer pool, and writing the data to be transferred into the second target instance to obtain a write instance.
[0074] The data to be transferred refers to the data that needs to be transferred during the jump of the first interface. The type of the buffer pool is not limited. For example, the buffer pool can refer to the Parcel buffer pool, and the second target instance refers to the Parcel instance. Specifically, the Parcel instance can be obtained from the Parcel buffer pool through Parcel.obtain() as the second target instance.
[0075] There is no limitation on the method of writing the data to be transferred that matches the interface jump request to the second target instance. For example, the data to be transferred can be written to the second target instance based on a preset method corresponding to the data representation form of the data to be transferred to obtain a written instance.
[0076] For example, taking the data representation form of the data to be transferred as Bitmap form, the data to be transferred can be written into the Parcel instance based on the writeToParcel method corresponding to the Bitmap form to obtain the written instance.
[0077] S604, calling the serialization method that matches the second target instance, serializing the written instance, and obtaining jump data that matches the interface jump request.
[0078] For example, when the second target instance refers to a Parcel instance, the write instance can be serialized based on the marshall method of the Parcel instance to obtain jump data matching the interface jump request. In other words, the jump data stored in the shared memory is the data processed after the data to be transmitted during the first interface jump process.
[0079] Based on the content shown in FIG. 6 , the jump data matching the interface jump request is obtained by adopting a serialization processing method, so that when the jump data is written into the shared memory, the stability and security of the data writing process can be improved.
[0080] In combination with the above content, in one embodiment, as shown in FIG. 7 , a method for processing interface jump is provided. Taking the method applied to the processor 208 in FIG. 1 as an example, the method includes the following steps:
[0081] S702, in response to an interface jump request for the first interface, calling the first process to obtain data to be transferred that matches the interface jump request, obtaining a second target instance from a buffer pool, and writing the data to be transferred into the second target instance to obtain a write instance.
[0082] S704, calling the serialization method that matches the second target instance, serializing the written instance, and obtaining jump data that matches the interface jump request.
[0083] S706, based on the data size of the jump data, calling the first process to apply for creating a shared memory in the memory space of the first process; the memory size of the shared memory matches the data size of the jump data.
[0084] S708, calling the first process to apply for and create an intent component, and start the intent component.
[0085] S710, calling the first process to write the jump data into the shared memory, and writing the handle value of the shared memory, the starting write offset value information of the jump data in the shared memory, and the class name information corresponding to the jump data into the intent memory corresponding to the intent component.
[0086] S712, calling the system service component to start the second process, and sending the handle value of the shared memory read from the intent memory, the starting write offset value information of the jump data in the shared memory, and the class name information corresponding to the jump data to the second process.
[0087] S714, calling the second process to read jump data from the shared memory matching the handle value based on the start write offset value information.
[0088] S716, calling the second process to obtain the first target instance from the buffer pool, and parsing the jump data into the first target instance based on the deserialization method matching the first target instance to obtain a parsed instance.
[0089] S718, calling the second process to process the parsed instance based on the class name information to obtain a data instance corresponding to the first interface.
[0090] S720: Based on the data instance, call the second process to load the second interface corresponding to the interface jump request.
[0091] Among them, the specific content of S702-S720 can be adapted to the description of the aforementioned content and will not be repeated here.
[0092] In combination with the above content, taking the example of transferring 6MB of image data from the first interface to the second interface for display, as shown in Figure 8, a schematic diagram of the parameter transfer principle of jumping between interfaces is provided. Based on Figure 8, the data transfer processing process during the interface jump includes the following steps:
[0093] S1, in the first interface, use BitmapFactory to load the image data in the form of Bitmap into the memory space of the first process where the first interface is located.
[0094] S2 uses MemoryFile to apply for creating a 6MB shared memory.
[0095] S3, obtain a Parcel instance from the Parcel cache pool through Parcel.obtain(), use the writeToParcel method corresponding to the Bitmap format to write the image data loaded in the Bitmap format into the Parcel instance, and call the marshall method of the Parcel instance to obtain the Byte array, which is the jump data.
[0096] S4, write the obtained Byte array into the shared memory.
[0097] S5, start the newly created Intent component through Context#startActivity, and write the class name information android.graphics.Bitmap corresponding to the Byte array and the handle value of the shared memory (that is, the descriptor value of FileDescriptor) into the Intent memory corresponding to the newly created Intent component.
[0098] S6, calling the second process to obtain the class name information corresponding to the Byte array transmitted from the AMS, the starting write offset value information corresponding to the class name information corresponding to the Byte array in the shared memory, and the handle value of the shared memory.
[0099] S7, create a FileDescriptor according to the handle value of the shared memory, create a FileInputStream input stream according to the FileDescriptor, and read the Byte array from the input stream based on the start write offset value information, and release the shared memory after the reading is completed.
[0100] S8, obtain a Parcel instance from the Parcel cache pool through Parcel.obtain(), and use the unmarshall method of the Parcel instance to parse the Byte array into the Parcel instance.
[0101] S9, find the Parcelable.Creator static interface object according to the reflection of the class name information corresponding to the Byte array, and pass the parsed Parcel instance through createFromParcel to create a Bitmap instance, which is the data instance corresponding to the first interface.
[0102] S10, displaying the obtained Bitmap instance through ImageView, that is, viewing the image corresponding to the image data transferred from the first interface A in the second interface B.
[0103] Based on the above content, it can be known that the data transmission method of the present application can save all the data to be transmitted into the shared memory first, and then only transmit the handle value of the shared memory and the corresponding metadata, such as the class name information and the starting write offset value information, through the memory corresponding to the Intent component. The handle value and metadata of the shared memory only occupy a very small part of the space. On the one hand, it can avoid the situation where the jump data is written into the intent memory because the jump data is larger than the fixed storage size of the intent memory, so that jump data with no size limit can be transmitted during the interface jump process, which can improve the stability of data transmission during the interface jump process; on the other hand, data with no size limit can be transmitted during the data transmission for interface jump, which greatly facilitates the function development of R&D personnel, enables R&D personnel to focus more on the development of functional business logic without being affected by data transmission restrictions, and can improve the efficiency of application R&D personnel.
[0104] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0105] Based on the same inventive concept, the embodiment of the present application also provides an interface jump processing device for implementing the interface jump processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more interface jump processing device embodiments provided below can refer to the limitations of the interface jump processing method above, and will not be repeated here.
[0106] In one embodiment, as shown in Figure 9, an interface jump processing device is provided, including: an acquisition module 902, a creation module 904, a writing module 906, a communication module 908 and a processing module 910, wherein: the acquisition module is used to respond to an interface jump request for a first interface, call a first process to obtain jump data matching the interface jump request; the creation module is used to apply for and create a shared memory and intent component matching the jump data; the writing module is used to write the jump data into the shared memory, and write the configuration information for the shared memory into the intent memory corresponding to the intent component; the communication module is used to call a system service component to send the configuration information read from the intent memory to a second process; the processing module is used to call the second process to read the jump data from the shared memory matching the configuration information, and load the second interface corresponding to the interface jump request based on the jump data.
[0107] In one embodiment, the writing module is further used to: call the first process to write the starting write offset value information of the jump data in the shared memory into the intent memory; the device also includes a reading module, the reading module is used to call the second process to read the starting write offset value information from the intent memory; the configuration information includes the handle value of the shared memory, and the processing module is further used to: call the second process to read the jump data from the shared memory matching the handle value based on the starting write offset value information.
[0108] In one embodiment, the writing module is also used to call the first process to write the class name information corresponding to the jump data into the intent memory; the reading module is also used to call the second process to read the class name information from the intent memory; the processing module is also used to: call the second process to obtain the first target instance from the buffer pool, and based on the deserialization method matching the first target instance, parse the jump data into the first target instance to obtain a parsed instance; based on the class name information, process the parsed instance to obtain a data instance corresponding to the first interface; based on the data instance, call the second process to load the second interface corresponding to the interface jump request.
[0109] In one embodiment, the acquisition module is also used to: call the first process to obtain the data to be transferred that matches the interface jump request, obtain the second target instance from the buffer pool, and write the data to be transferred into the second target instance to obtain a write instance; call the serialization method that matches the second target instance, serialize the write instance, and obtain the jump data that matches the interface jump request.
[0110] In one embodiment, the creation module is further used to: based on the data size of the jump data, call the first process to apply for creating a shared memory in the memory space of the first process; the memory size of the shared memory matches the data size of the jump data.
[0111] In one embodiment, the processing module is also used to execute any one of the following: the first item: when the jump data is written to the shared memory and / or the intent component is started, the timing component is called to start the timing; when the timing duration reaches a duration threshold, if it is detected that the shared memory is not released, the first process is called to release the shared memory; the second item: after calling the second process to read the jump data from the shared memory matching the configuration information, the first process is called to release the shared memory.
[0112] Each module in the above-mentioned interface jump processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory in the electronic device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0113] In one embodiment, an electronic device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG10. The electronic device includes a processor, a memory, a communication interface, a display screen, and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an interface jump processing method is implemented. The display screen of the electronic device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device may be a touch layer covered on the display screen, or a key, a trackball or a touch pad provided on the housing of the electronic device, or an external keyboard, touch pad or mouse, etc.
[0114] Those skilled in the art will understand that the structure shown in FIG. 10 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0115] In one embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0117] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0118] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0119] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0120] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0121] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An interface jump processing method, characterized in that: The method comprises: In response to an interface jump request for a first interface, calling a first process to obtain jump data matching the interface jump request; Apply for and create a shared memory and intent component that matches the jump data; Writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; Calling a system service component to send the configuration information read from the intent memory to the second process; The second process is called to read the jump data from the shared memory matching the configuration information, and load the second interface corresponding to the interface jump request based on the jump data.
2. The method according to claim 1, characterized in that The method further comprises: Calling the first process to write the starting write offset value information of the jump data in the shared memory into the intent memory; Calling the second process to read the starting write offset value information from the intent memory; The configuration information includes a handle value of the shared memory, and the calling of the second process to read the jump data from the shared memory matching the configuration information includes: The second process is called to read the jump data from the shared memory matching the handle value based on the start write offset value information.
3. The method according to claim 2, characterized in that The method further comprises: Calling the first process to write the class name information corresponding to the jump data into the intent memory; Calling the second process to read the class name information from the intent memory; Calling the second process to load the second interface corresponding to the interface jump request based on the jump data includes: Calling the second process to obtain the first target instance from the buffer pool, and parsing the jump data into the first target instance based on the deserialization method matching the first target instance to obtain a parsed instance; Based on the class name information, the parsed instance is processed to obtain a data instance corresponding to the first interface; Based on the data instance, the second process is called to load the second interface corresponding to the interface jump request.
4. The method according to claim 1, characterized in that: The calling of the first process to obtain jump data matching the interface jump request includes: Calling the first process to obtain the data to be transferred that matches the interface jump request, obtaining a second target instance from a buffer pool, and writing the data to be transferred into the second target instance to obtain a write instance; A serialization method matching the second target instance is called to perform serialization processing on the write instance to obtain jump data matching the interface jump request.
5. The method according to claim 4, characterized in that The method further comprises: Based on the data size of the jump data, the first process is called to apply for creating a shared memory in the memory space of the first process; the memory size of the shared memory matches the data size of the jump data.
6. The method according to claim 1, characterized in that Also includes any of the following: Item 1: When the jump data is written into the shared memory and / or the intent component is started, calling the timing component to start timing; When the timing duration reaches a duration threshold, if it is detected that the shared memory is not released, calling the first process to release the shared memory; Item 2: After calling the second process to read the jump data from the shared memory matching the configuration information, calling the first process to release the shared memory.
7. An interface jump processing device, characterized in that: The device comprises: An acquisition module, configured to, in response to an interface jump request for a first interface, call a first process to acquire jump data matching the interface jump request; A creation module is used to apply for and create a shared memory and intent component matching the jump data; A writing module, used for writing the jump data into the shared memory, and writing the configuration information for the shared memory into the intent memory corresponding to the intent component; A communication module, used for calling a system service component to send the configuration information read from the intent memory to the second process; A processing module is used to call the second process to read the jump data from the shared memory matching the configuration information, and load the second interface corresponding to the interface jump request based on the jump data.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.