Application interface display method, electronic device and computer readable storage medium
By loading the resources of the application interface from the first cache in the electronic device, the problem of slow startup of the application interface is solved, the interface startup performance is optimized and the user experience is improved.
Patent Information
- Application Number
- CN202310824697.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-05
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2043-07-05
AI Technical Summary
In the prior art, there are problems such as lag, unsmooth, and poor follow-up performance when starting the application interface, resulting in a degradation of user experience.
By implementing a method of displaying an application interface in an electronic device, the method loads a first resource from the first cache instead of accessing the application package APK across packets, thereby constructing and displaying the first interface.
This method optimizes the startup performance of the application interface, shortens the startup delay of the interface, improves the user experience, and reduces the memory usage.
Smart Images

Figure CN117707657B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic devices, and in particular, relates to a method for displaying an application interface, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of electronic technology and communication technology, mobile phones and other electronic devices support the installation of application programs (APPs, also known as applications) to provide users with a richer user experience. For example, users can install various applications such as social, news, finance, and entertainment on their mobile phones.
[0003] However, when an application interface needs to be displayed and started, there is a problem of slow startup of the application interface. From the user's perspective, this problem can be described as "stuttering, unsmoothness, poor hand tracking performance", etc., which greatly reduces the user experience. Summary of the invention
[0004] The present application provides a method for displaying an application interface, an electronic device, and a computer-readable storage medium, which can solve the problem of slow startup of the application interface and improve the user experience.
[0005] In a first aspect, an embodiment of the present application provides a method for displaying an application interface, which is applied to an electronic device. The method for displaying an application interface includes: displaying a target interface. A first operation instruction for the target interface is detected, and the first operation instruction is used to trigger the electronic device to display a first application; in response to the first operation instruction, a first resource is loaded from a first cache, and the first resource is used to construct a first interface; the first resource is determined by a resource included in an application package of the first application, and the storage space occupied by the first resource is less than the storage space occupied by the application package of the application; according to the first resource, the first interface is displayed on the electronic device.
[0006] In the display method of the application interface, when a first operation instruction for the target interface is detected, the electronic device starts the first interface of the first application, and the construction of the first interface is involved in the process of starting the first interface. When constructing the first interface, the electronic device can directly load the first resource from the first cache to realize the construction of the first interface, without accessing the application package APK of the first application across packages to obtain the first resource. It should be noted that APK is a file, and accessing the application package APK of the first application across packages to obtain the first resource involves loading, parsing resources, extracting, etc. of APK, which leads to a long time for the electronic device to access the APK of the first application across packages to obtain the first resource. In addition, the APK of the first application is usually stored in the external memory of the electronic device, and it takes a long time for the electronic device to access the APK of the first application in the external memory to obtain the first resource, which leads to a long time to start the application interface, that is, there is a problem of slow startup of the application interface. Compared with loading the first resource across packages, loading the first resource from the first cache is equivalent to loading the first resource from the memory, which takes less time. In addition, the first cache caches the resource itself instead of an APK file, and the resource can be directly extracted from the first cache, which takes less time, which shortens the delay of the first interface of the first application. It can be seen that this embodiment can optimize the startup performance of the first interface of the first application.
[0007] At the same time, since the storage space occupied by the first resource cached by the first cache is smaller than the storage space occupied by all resources contained in the APK of the first application, when the capacity size of the first cache is adjusted to the maximum number of application processes simultaneously running on the electronic device to improve the hit rate of the first cache, even if the size of the first cache is occupied by multiple applications, the memory occupied by the first cache is still smaller. It can be seen that this embodiment reduces the memory occupation while ensuring the hit rate of the first cache to optimize the first interface startup performance of the first application.
[0008] In some possible implementations, the electronic device further includes a second cache, the second cache is used to cache at least a second resource of the first application, and the second resource of the first application includes all resources included in the application package of the first application. Loading the first resource from the first cache includes: if the first resource is in the first cache, loading the first resource from the first cache. If the first resource is not in the first cache, the above-mentioned method for displaying the application interface also includes: loading the first resource from the second cache.
[0009] In this embodiment, the second cache is used as the first-level cache to cache all resources of the APK of the first application, and the first cache is added as the second-level cache to cache only the first resources. The size of the first cache can be increased, for example, to the maximum number of application processes running simultaneously, so as to improve the hit rate to optimize the startup performance of the application interface. At the same time, the size of the second cache can be maintained at a smaller number. Since the storage space occupied by the first resource is small, even if the size of the first cache is increased to the maximum number of application processes running simultaneously and is occupied by multiple applications, compared to only setting the second cache to store all resources of the APK of the first application and increasing the size of the second cache (for example, to the maximum number of application processes running simultaneously), the memory occupied by the first cache and the second cache is still smaller.
[0010] Since the sizes of the two caches are different, when a new application is started, the resources of the applications deleted from the two caches are also different, which may lead to the following situation: the first cache does not have the first resource, while the second cache has the second resource of the first application. Based on this, when the first cache is queried and the first resource is not hit, since the second cache may cache all the resources included in the APK of the first application, that is, the second resource, this embodiment can load the first resource from the second cache to enable the first interface to start in time.
[0011] Optionally, loading the first resource from the second cache includes: storing the first resource in the first cache.
[0012] In this embodiment, by storing the first resource in the first cache, it can be ensured that when the first interface of the first application is subsequently started, the first resource can be directly obtained from the first cache to start the first interface, thereby optimizing the startup performance of the first interface of the first application.
[0013] Optionally, loading the first resource from the second cache includes: acquiring a second resource of the first application from the second cache; and determining the first resource according to the second resource.
[0014] In this embodiment, if the first cache does not cache the first resource, the second resource of the first application can be obtained from the second cache and the first resource can be determined according to the second resource of the first application, so that the first interface is started in time.
[0015] In some possible implementations, obtaining the second resource of the first application from the second cache includes: obtaining the second resource from the second cache when the second resource is in the second cache; and obtaining the second resource of the first application from the application package of the first application when the second resource of the first application does not exist in the second cache.
[0016] In the case where the second cache has not cached the second resource of the first application, the second resource of the first application can be obtained from the APK of the first application and the first resource can be determined based on the second resource of the first application, so that the first interface is started in time.
[0017] Optionally, acquiring the second resource of the first application from the application package of the first application further includes: determining the first resource according to the second resource; and storing the first resource in a first cache.
[0018] In this embodiment, the first resource is determined based on the second resource and the first resource is stored in the first cache. This can ensure that when the first interface of the first application is subsequently started, the first resource can be directly obtained from the first cache to start the first interface, thereby optimizing the startup performance of the first interface of the first application.
[0019] In some embodiments, the first resource includes a window attribute resource; wherein the window attribute resource is an attribute resource used to draw a window of the first interface when the electronic device constructs the first interface. It should be noted that, in addition to the window attribute resources, the resources used to draw the window when the electronic device constructs the first interface (referred to as window resources for short) may also include other window resources. However, the electronic device can draw the window based on the window attribute resources. Therefore, in this embodiment, the first resource only includes the window attribute resources in the window resources. It should be understood that when the first resource only includes the window attribute resources, the memory occupied by the first resource can be further reduced, thereby reducing the memory occupied by the first cache as a whole. It should be understood that in other optional implementations, the first resource may include other window resources in addition to the basic window resources.
[0020] In some other embodiments, the first resource also includes an animation resource, wherein the animation resource is a resource required for drawing the animation of the first interface when the electronic device constructs the first interface, or the animation resource is an animation drawn when the electronic device constructs the first interface.
[0021] In the case where the first interface is an interface containing dynamic effects, it is necessary to draw the window and draw the dynamic effects. Therefore, the first resource must also include dynamic effect resources so that the constructed first interface meets expectations. Optionally, the dynamic effect resources can be dynamic effects used by the electronic device to construct the first interface. The dynamic effect resources can also be resources used to draw dynamic effects when the electronic device constructs the first interface. For the latter, when the electronic device constructs the first interface using the first resource containing resources for drawing dynamic effects, the electronic device must first synthesize the dynamic effects based on the resources for drawing dynamic effects, and then use the dynamic effects to construct the first interface. Obviously, if the dynamic effects themselves are cached directly, there is no need to synthesize the dynamic effects, thereby improving the speed of building the first interface, and then improving the speed of starting the first interface, and optimizing the startup performance of the first interface of the first application. In addition, the resources used to draw dynamic effects include contexts and resources related to dynamic effect content. The storage space occupied by the context is large, which makes the storage space occupied by the resources used to draw dynamic effects larger than the storage space occupied by the dynamic effects themselves. Based on this, when the motion effect resource included in the first resource is a motion effect for constructing the first interface, the memory occupied by the first resource can be further reduced, thereby reducing the memory occupied by the first cache as a whole.
[0022] In some possible implementations, the motion effect resource is a motion effect used by the electronic device to construct the first interface, and the motion effect resource is cloned based on the motion effect used to construct the first interface stored in the first cache. The motion effect used to construct the first interface cached in the first cache is copied by a cloning method to obtain an identical new motion effect, so that the acquisition of the repeatedly used and set motion effect can be avoided, so that the expected motion effect can be obtained.
[0023] In a second aspect, an embodiment of the present application provides an electronic device. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method described in the first aspect or various possible implementations of the first aspect is implemented.
[0024] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method described in the first aspect or various possible implementations of the first aspect.
[0025] In a fourth aspect, an embodiment of the present application provides a chip system. The chip system includes a processor and a memory; wherein the processor is coupled to the memory, and the memory is used to store programs or instructions, and when the program or instructions are executed by the processor, the chip system implements the method described in the first aspect or various possible implementations of the first aspect.
[0026] It can be understood that the beneficial effects that can be achieved by the technical solutions of the second to fourth aspects provided above can refer to the beneficial effects of the display method of the application interface in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A software structure block diagram of an electronic device provided in an embodiment of the present application;
[0028] Figure 2 A schematic diagram of monitoring the duration of a cross-package access APK process provided in an embodiment of the present application;
[0029] Figure 3 A schematic diagram of an interface for an application startup process of an electronic device provided in an embodiment of the present application;
[0030] Figure 4 The process of the display method of the application interface provided in the embodiment of the present application Figure 1 ;
[0031] Figure 5 A schematic diagram of an interface for a user to start a portrait interface from a photo taking interface provided in an embodiment of the present application;
[0032] Figure 6 A schematic diagram of an interface for a user to start a photo taking interface from a desktop provided in an embodiment of the present application;
[0033] Figure 7 A schematic diagram of an interface for a user to start a photo taking interface from a multi-tasking interface provided in an embodiment of the present application;
[0034] Figure 8 The user starts WPS from the WeChat interface provided in the embodiment of the present application TM Schematic diagram of the startup interface;
[0035] Fig. 9 The process of the display method of the application interface provided in the embodiment of the present application Figure 2 ;
[0036] Fig.10 The process of the display method of the application interface provided in the embodiment of the present application Figure 3 ;
[0037] Fig.11 An interactive diagram of the startup process of the application interface provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0039] The terms "first" and "second" in the specification and claims herein are used to distinguish different objects rather than to describe a specific order of objects. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two, for example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0040] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0041] To facilitate understanding, the technical terms involved in this application are first described.
[0042] 1. Application (APP, referred to as application)
[0043] An application is a program that runs on an operating system (hereinafter referred to as the system) and provides specific services to users.
[0044] In the embodiment of the present application, the application can be an embedded application (i.e., a system application of an electronic device) or a downloadable application. A downloadable application is an application that can provide its own Internet protocol multimedia subsystem (IMS) connection. The downloadable application can be an application pre-installed in the electronic device or can be a third-party application downloaded and installed in the electronic device by the user.
[0045] 2. Home screen of electronic devices
[0046] The home screen of an electronic device, which may also be referred to as the desktop of the electronic device, is used to display application icons of one or more applications installed on the electronic device.
[0047] Of course, the main screen of the electronic device can also display other controls (control elements) in addition to the application icon. A control is a graphical user interface (GUI) element, which is a software component included in an application and controls all data processed by the application and the interactive operations on these data. Users can interact with the control through direct manipulation to read or edit the relevant information of the application. For example, a control can include icons (such as icons of applications installed in the electronic device, icons of folders where applications are located), buttons and other visual interface elements.
[0048] 3. Activity
[0049] Activity is a display component. Activity can display an interface to the user to achieve interaction with the user. One interface corresponds to one Activity. From the user's perspective, Activity can be simply understood as the interface itself. To start an interface, you first need to construct the corresponding Activity for the interface, and then start the Activity to start the interface.
[0050] 4. Window
[0051] A window refers to a display window that displays content. For example, an application window of a game application is used to display content within the game application. For another example, an application window of a reading application is used to display content within the reading application.
[0052] For an application interface, the window is equivalent to the carrier of the display content. The system provides the window for the application to draw the display content in it, thereby realizing the construction of the Activity of the interface.
[0053] 5. Animation
[0054] Motion effects, or dynamic effects, are all motion effects on the user interface (UI), which can be seen as a combination of interface design and dynamic design. In the Material design specification, motion effects are named animation. Good motion effects can help guide and please users, reduce waiting anxiety, and are an effective means to bring users closer to products.
[0055] For example, the progress bar that pops up when starting a game application, the words and icons of "loading" displayed during the interface loading process, the percentage used to indicate the download progress when downloading files, etc. Animation effects can appear during the application startup process, during the running process after the application is started, and during the application shutdown process. In the embodiment of the present application, the animation effect during the application startup process is called the application startup animation effect.
[0056] 6. Cold start and hot start
[0057] Cold start: When starting an application, the system (such as Android TM If there is no application process of the application in the background of the system, the system will recreate a new application process and assign it to the application, which is called cold start;
[0058] Hot start: When you start an application, the system (such as Android TM If there is already an application process of the application in the background of the system (for example, after clicking to start an application, and then exiting the home screen of the electronic device, the application process of the application still exists in the background), the application will be started in the existing application process, which is a hot start.
[0059] Electronic devices such as mobile phones support the installation of applications in order to provide users with a richer user experience. When users use electronic devices, they usually involve the process of launching a certain interface of the application. For example, after the user clicks a control on the main interface of the application, the application will launch another interface corresponding to the control and jump to that interface; for another example, after the user clicks the application icon of the application on the desktop of the electronic device, the application will launch some interfaces (such as advertisements, the main interface of the application, etc.) and jump to these interfaces in turn until it finally jumps to the main interface of the application.
[0060] It should be noted that in order to start a certain interface of an application, the electronic device will construct an Activity for the interface. In the process of constructing the Activity, the system needs to access the application package (Android application package, Android, APK) of the application across packages to obtain resources for constructing the Activity.
[0061] Combine the following Figure 1 This section describes the process of the system accessing the APK of an application across packages.
[0062] Please refer to Figure 1 , Figure 1 A software structure block diagram of an electronic device provided in an embodiment of the present application.
[0063] First, the software structure of the electronic device is explained. TMTake the system as an example, Android TM The system may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device.
[0064] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, Android TM The system is divided into four layers, from top to bottom: application layer (applications), system framework layer (framework), system Native library (C++ / C) and Android runtime (AndroidRuntime), and kernel layer (kernel).
[0065] The application layer may include a series of application packages. For example, the application layer may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, reading, travel, sports and health, smart life, etc. (applications may be referred to as desktop applications for short), and the present application embodiment does not impose any restrictions on this. In addition, the application layer also includes a desktop application launcher (Launcher) for launching desktop applications.
[0066] The system framework layer provides an application programming interface (API) and a programming framework for the application programs in the application layer. The system framework layer includes some predefined functions. The system framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, an activity manager, etc., and the embodiments of the present application do not impose any restrictions on this.
[0067] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. In the embodiment of the present application, the window manager is used to draw windows and draw display content, such as dynamic effects.
[0068] Content providers are used to store and retrieve file data and make it accessible to applications. The file data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0069] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including SMS notification options can include a view for displaying text and a view for displaying images.
[0070] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0071] The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and disappear automatically after a short stay without user interaction.
[0072] The activity manager is used to manage the life cycle of each application and the navigation fallback function. It is responsible for creating the Android main thread and maintaining the life cycle of each application.
[0073] Android Runtime includes core libraries and virtual machines. Android Runtime is responsible for scheduling and management of the Android system.
[0074] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0075] The application layer and the system framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the system framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0076] The system native library can include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as openGL ES), 2D graphics engine (such as SGL), etc. The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0077] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0078] Understandably, Figure 1 The layers in the software structure shown and the components contained in each layer do not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer layers than shown in the figure, and each layer may include more or fewer components, which is not limited in the embodiments of the present application.
[0079] Next, the process of the system accessing the APK of the application across packages is explained.
[0080] The system is equivalent to a program package, which is started when the electronic device is turned on. When a certain interface of an application needs to be started, the system framework layer in the system needs to access the APK of the application in the application layer from the program package where the system is located, that is, access the APK of the application across packages.
[0081] APK is a file. Cross-package access to the APK of an application and obtaining resources from it involves loading, parsing, and extracting the APK, which results in a long time for the system to access the APK of an application across packages to obtain resources. In addition, the system's program packages are usually stored in the memory of the electronic device, while the application's APK is stored in the external memory of the electronic device. Obviously, the system framework layer accesses the APK of the application in the external memory, which makes the system take a long time to access the APK of the application across packages, resulting in a long time to start the application interface, that is, there is a problem of slow startup of the application interface.
[0082] Please refer to Figure 2 , Figure 2 A schematic diagram of duration monitoring of the cross-package access APK process provided in an embodiment of the present application.
[0083] Depend on Figure 2 It can be seen that the time it takes for an electronic device to obtain resources of a third-party application through the getResources method in the resource manager (ResourceManager) is 20+ms. For different applications, the time it takes to obtain resources varies due to the size of the resources; for different electronic devices, the time it takes to obtain resources of the same application varies due to the performance of the electronic device chip.
[0084] It can be seen that during the startup of the application interface, the application resources need to be obtained across packages, so there is a problem of slow startup of the application interface. From the user's perspective, this problem can be described as "stuttering, not smooth, and poor hand tracking performance." If the interface startup process occurs during the startup of the application, there is a problem of long application startup response time. From the user's perspective, this problem manifests as "poor application startup hand tracking performance."
[0085] In order to further understand the above problems, Figure 3 The above problem is explained by taking the application startup process as an example.
[0086] Please refer to Figure 3 , Figure 3 A schematic diagram of an interface showing an application startup process of an electronic device.
[0087] like Figure 3 As shown, the user clicks the desktop application icon to trigger the application launch process. Figure 3Taking the case where a user clicks on a game application icon as an example, the following nodes in the application startup process are illustrated from the perspective of interface changes: the user clicks on the desktop application icon --> displays the application startup interface 1 with motion effects --> displays the application startup interface 2 --> displays the application main interface. In other embodiments, the application startup process may also have more or fewer nodes, for example, not displaying the application startup interface. In addition, Figure 3 Taking the user clicking on the desktop application icon as an example, a method of starting the application is illustrated. In other embodiments, the method of starting the application can also be other methods.
[0088] The time from when the user clicks the desktop application icon to when the application startup interface with animation begins to be displayed is called the application startup response delay. The existence of the application startup response delay is due to the system's need to obtain the resources required to create the Activity corresponding to the application startup interface with animation from the application's APK. The shorter the application startup response delay, the better the application startup tracking performance; the longer the application startup response delay, the worse the application startup tracking performance.
[0089] In response to the above-mentioned problem of slow application interface startup, in some embodiments of the present application, a second cache can be created, at least for caching all resources contained in the APK of the first application (hereinafter all resources contained in the APK of the first application will be referred to as second resources). It should be understood that the second cache can also be used to store all resources contained in the APKs of other applications. In specific implementation, the second cache can be obtained by creating a cache class AttributeCache. In subsequent embodiments, AttributeCache represents the second cache. Optionally, AttributeCache can be a cache table with a least recently used (LRU) mechanism, which can store the resources of each application in units of packages, that is, the resources of an application are packaged into a package and cached in the cache table, and the resources of different applications are packaged into different packages for cache. The required resources can be obtained from AttributeCache through the resource index (resld).
[0090] In this embodiment, taking the first interface of the first application as an example, if the first interface of the first application is started for the first time, that is, the first time the first application is cold started, the system obtains the second resource of the first application from the APK of the first application across packages, and then stores it in AttributeCache; if the first interface of the first application is started does not involve the first time the first application is cold started, such as the first application is cold started again, the system will first query AttributeCache, if the cache is hit (when the application requests data, the system indexes the requested data in the cache, if the requested data is found in the cache, it is regarded as a cache hit), then the resources required for starting the first interface are directly obtained from the second resource of the first application cached in AttributeCache. Compared with accessing the APK of the first application across packages, it takes less time to directly obtain the resources required for the first interface from the second resource of the first application cached in AttributeCache. After testing the application startup response delay of multiple applications, it was found that the benefit of application startup response delay can reach 10+ms.
[0091] In addition, it should be understood that if AttributeCache is not set, each time an interface of the first application is started, the APK of the first application needs to be accessed across packages, resulting in a slow startup problem each time an interface of the first application is started. In this embodiment, by setting AttributeCache, there is no need to repeatedly access the APK.
[0092] It should be noted that starting the first application for the first time refers to cold starting the first application when the second cache does not cache the second resource of the first application. Starting the first application again refers to cold starting the first application when the second cache caches the second resource of the first application.
[0093] However, there are scenarios where the second resources of the first application cached in the AttributeCache are cleared. Exemplarily, when the cache table of the LRU mechanism has reached its upper capacity limit, if the second resources of other applications are to be cached in the cache table, it is necessary to replace the second resources of a cached application according to the LRU algorithm, thereby possibly clearing the second resources of the first application. Exemplarily, when the first application is uninstalled or updated, the second resources of the first application will be cleared from the cache table. Exemplarily, when the parameters of the first application change, the previously cached second resources are no longer applicable, the second resources of the first application will be cleared from the AttributeCache, and even the second resources of all applications cached in the entire AttributeCache will be cleared. For example, scenarios such as rotating the screen or switching between the inner and outer screens of a folding screen trigger parameter changes, resulting in the second resources of all previously cached applications no longer being used. In this case, the entire AttributeCache is cleared.
[0094] It should be understood that after the second resource of the first application is cleared, it is necessary to access the APK of the first application across packages again to obtain the second resource of the first application for caching. For the case where the AttributeCache capacity (size) is small (for example, the size of AttributeCache is 4, that is, only 4 packages can be stored), the second resource of the first application cached in AttributeCache is often cleared, resulting in the need to frequently access the APK of the first application across packages, which makes it impossible to ensure the interface startup response performance of the first application.
[0095] In order to ensure the application interface startup response performance, in some embodiments of the present application, the capacity of the above-mentioned AttributeCache is set as a configurable item, that is, the capacity of the AttributeCache can be adjusted as needed. For example, the size of the AttributeCache can be adjusted according to the maximum number of application processes running simultaneously on the electronic device. For example, the size of the AttributeCache is changed from 4 to 25. In this way, when other applications are cold started and the second resources of the other applications need to be cached, the second resources of the cached applications are not easily cleared due to the need to cache the second resources of other applications, thereby improving the cache hit rate and optimizing the application interface startup response performance. Taking the first interface of the first application as an example, it is necessary to query the AttributeCache to obtain the resources required to start the first interface from the second resources of the first application stored therein. Since the second resources of the first application are less likely to be cleared, the probability of hitting the resources required to start the first interface is higher, thereby completing the creation of the Activity of the first interface faster, and then realizing the startup of the first interface faster.
[0096] However, since the second resource of the application cached in AttributeCache is all the resources included in the APK of the application, which is relatively large in size, as the size of AttributeCache increases, the number of cacheable resource packages increases, which leads to an increase in the memory of the electronic device.
[0097] By launching multiple identical applications on the same model of mobile phone, the following data in Table 1 is obtained:
[0098] Table 1
[0099]
[0100] By comparison, we can find that by increasing the size of AttributeCache from 4 to 25, the performance benefit of the average application startup response delay (the average of the response delays of multiple application startups) is 10+ms, but this results in a 33M increase in memory usage.
[0101] It should be noted that as the size of AttributeCache increases, the resident memory of the electronic device becomes larger, which greatly affects the operating speed of the electronic device and reduces the operating performance of the electronic device.
[0102] In order to optimize the startup performance of the interface while avoiding occupying too much memory and affecting the operating performance of the electronic device, an embodiment of the present application provides a method for displaying an application interface, which can be applied to an electronic device.
[0103] Exemplarily, the electronic device may be a mobile phone, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, or the like. The embodiments of the present application do not impose any special restrictions on the specific form of the device.
[0104] In the display method of the application interface, taking the first interface of the first application as an example, when the first interface of the first application is started and the first interface needs to be constructed, the first resource is directly loaded from the first cache to realize the construction of the first interface, without the need to access the application package APK of the first application across packages to obtain the first resource. It should be noted that APK is a file, and accessing the application package APK of the first application across packages to obtain the first resource involves loading, parsing resources, extracting, etc. of APK, which results in a long time for the electronic device to access the APK of the first application across packages to obtain the first resource. In addition, the APK of the first application is usually stored in the external memory of the electronic device, and it takes a long time for the electronic device to access the APK of the first application in the external memory to obtain the first resource, which results in a long time for starting the application interface, that is, there is a problem of slow startup of the application interface. Compared with loading the first resource across packages, loading the first resource from the first cache is equivalent to loading the first resource from the memory, which takes less time. In addition, the first cache caches the resource itself instead of an APK file, and the resource can be directly extracted from the first cache, which takes less time, which shortens the delay of the first interface of the first application. It can be seen that this embodiment can optimize the startup performance of the first interface of the first application.
[0105] At the same time, since the storage space occupied by the first resource cached by the first cache is smaller than the storage space occupied by all resources contained in the APK of the first application, when the capacity size of the first cache is adjusted to the maximum number of application processes simultaneously running on the electronic device to improve the hit rate of the first cache, even if the size of the first cache is occupied by multiple applications, the memory occupied by the first cache is still smaller. It can be seen that this embodiment reduces the memory occupation while ensuring the hit rate of the first cache to optimize the first interface startup performance of the first application.
[0106] The implementation of the method for displaying an application interface provided by an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0107] Please refer to Figure 4 , Figure 4 The process of the display method of the application interface provided in the embodiment of the present application Figure 1 The display method of the application interface is applied to an electronic device, and can be used in a Figure 1 The software structure shown in the figure is run in the electronic device. The display method of the application interface includes the following steps S401 to S404.
[0108] S401, displaying a target interface.
[0109] S402: Detecting a first operation instruction for a target interface.
[0110] The first operation instruction is used to trigger the electronic device to display the first interface of the first application.
[0111] The first application may be any foreground application of one or more applications running in the electronic device, that is, an application that can display an interface and interact with the user. For example, a desktop application of the electronic device, that is, an application with an application icon on the desktop of the electronic device. The first application may be a third-party application or a system application in the electronic device, which is not limited in the embodiments of the present application.
[0112] For example, the first interface can be any interface among all interfaces of the first application, such as the startup interface during the startup of the first application, the main interface of the first application, the interface switched during the operation of the first application (excluding the interfaces of other applications), the exit interface during the exit of the first application, etc.
[0113] For example, in the above S401, the scenario in which the first interface of the first application is triggered to be displayed may be:
[0114] A1: The user clicks on a control for calling the first interface on the second interface of the first application. By clicking on the control, the user can switch the interface of the electronic device from the second interface of the first application to the first interface of the first application. Here, the second interface and the first interface are two interfaces of the first application.
[0115] For example, please refer to Figure 5 , taking the first application as a "camera" application as an example, the second interface of the first application can be Figure 5 In the photographing interface shown in (a), the control for calling the first interface in the second interface can be Figure 5 The "portrait" control in the interface shown in (a) in FIG. 1 may be a first interface. Figure 5 In response to the user's Figure 5 When the "portrait" control in the photo taking interface shown in (a) is clicked, the electronic device displays the following Figure 5 The portrait interface shown in (b) in FIG.
[0116] A2: The user clicks on the control for calling the first interface of the first application on the third interface of the second application. By clicking on the control, the user can make the interface of the electronic device jump from the third interface of the second application to the first interface of the first application. Here, the second application and the first application are two applications. The definition of the second application can refer to the definition of the first application.
[0117] For example, please refer to Figure 6 , taking the first application as the "Camera" application and the second application as the desktop launcher Launcher as an example, the third interface of the second application can be Figure 6In the desktop shown in (a), the control for calling the first interface in the third interface can be Figure 6 The "camera" control in the interface shown in (a) in FIG. 1 , the first interface of the first application can be Figure 6 In response to the user's Figure 6 By clicking the "camera" control on the desktop shown in (a), the electronic device jumps to Figure 6 The photo taking interface shown in (b) in FIG.
[0118] For example, please refer to Figure 7 , taking the first application as a "camera" application and the second application as a task manager as an example, the third interface of the second application can be Figure 7 In the multi-task card interface shown in (a), the control for calling the first interface in the third interface can be Figure 7 The first interface of the first application can be a control of the "camera" card in the multitasking card interface shown in (a) Figure 7 In response to the user's Figure 7 By clicking the control of the "Camera" card in the multitasking card interface shown in (a), the electronic device jumps to Figure 7 The photo taking interface shown in (b) in FIG.
[0119] For example, please refer to Figure 8 , with the second application being "WeChat TM "Applications, the first application is "WPS TM " application as an example, the third interface of the second application can be Figure 8 WeChat shown in (a) TM Interface, the WeChat TM The interface is "WeChat TM "The application pops up an interface for selecting the opening method of the file one, and the control for calling the first interface in the third interface can be Figure 8 In the "Open with WPS" control in the interface shown in (a), the first interface of the first application can be Figure 8 WPS shown in (b) TM In response to the user's Figure 8 By clicking the "Open with WPS" control on the desktop shown in (a), the electronic device jumps to Figure 8 WPS shown in (b) TM Startup interface.
[0120] A1 and A2 above only provide an exemplary introduction to the scenario in which the first interface of the first application is triggered to display from the perspective of a user click. It should be understood that in the specific implementation process, the first interface of the first application may be triggered to display in other scenarios, such as a user sliding the desktop to switch desktops, or the electronic device automatically starting according to operating needs, and this application does not make specific limitations on this.
[0121] It can be seen that the target interface can be the second interface of the first application, the third interface of the second application, or the desktop of the electronic device. Figure 5 For , the target interface is the photo taking interface. Figure 6 For , the target interface is the desktop of the electronic device. Figure 7 For , the target interface is the multi-task card interface. Figure 8 For example, the target interface is WeChat TM interface.
[0122] The first operation instruction may be any operation event detected by the electronic device that triggers the electronic device to display the first interface of the first application. For example, the first operation instruction may be a click event detected by the electronic device on a first control on the target interface; for example, the first operation instruction may be a sliding operation on the target interface detected by the electronic device. Figure 5 For example, the target interface is a photo taking interface, the first control is a "portrait" control, and the first operation instruction is a click event of the user on the "portrait" control detected by the electronic device. Figure 6 For example, the target interface is the desktop, the first control is the "camera" control, and the first operation instruction is a click event of the user on the "camera" control detected by the electronic device. Figure 7 For example, the target interface is a multi-task card interface, the first control is a "camera" card, and the first operation instruction is a click event of the user on the "camera" card detected by the electronic device. Figure 8 For example, the target interface is WeChat TM interface, the first control is an "Open with WPS" control, and the first operation instruction is a click event of the user on the "Open with WPS" control detected by the electronic device.
[0123] Of course, the first operation instruction may also be an instruction for self-starting the first interface of the first application that is detected by the electronic device itself according to the operation needs. Alternatively, the first operation instruction may also be an instruction for starting the first interface of the first application that is detected by the electronic device and initiated by the electronic device based on the first two situations, such as a startActivity request. The third situation is described below by taking scenario A2 and the second application in scenario A2 being Launcher as an example.
[0124] Combination Figure 1 When the user clicks on the application icon of the first application on the desktop, the Launcher senses the click event on the application icon of the first application and recognizes that the click event triggers the application icon of the first application. Then the Launcher initiates a startActivity request (i.e., the first operation instruction) to the Framework for starting the first interface of the first application. When the system framework layer receives the startActivity request, it detects the first operation instruction for the first interface of the first application.
[0125] S403: In response to the first operation instruction, load a first resource from a first cache.
[0126] The first resource is used to construct the first interface.
[0127] S404: Display a first interface on the electronic device according to the first resource.
[0128] It should be noted that after the electronic device detects the first operation instruction for the target interface, in order to finally display the first interface, the electronic device will first construct the Activity of the first interface; after constructing the Activity of the first interface, the Activity of the first interface is started, that is, the first interface is started; it should be understood that after the first interface is started, the electronic device displays the first interface. In the process of constructing the Activity of the first interface, it involves obtaining the resources required to construct the Activity of the first interface, that is, the first resources. If the startup of the first interface involves the startup of the first application, whether it is a hot start of the first application or a cold start of the first application, the startup process of the first interface involves the process of obtaining the first resource from the first cache. In other words, the display method of the application interface provided in the embodiment of the present application is applicable to both hot start of the application (such as Figure 7 ), and also for cold starts of applications (such as Figure 6 The scene shown is, of course, Figure 6 The scenario shown could also be a warm start).
[0129] Figure 4 In the method for displaying the application interface shown, the electronic device loads the first resource from the first cache instead of loading from the second cache, that is, the content of S403 above. The following focuses on S403 of the present application embodiment, and S404 is a fairly mature technology, which will not be described in detail in the present application embodiment.
[0130] First, the first cache in S403 is introduced.
[0131] In S403, the first cache is used to cache at least the first resource.
[0132] The specific implementation of the first cache can be obtained by creating a cache class HnAttributeCache that is independent of AttributeCache. In subsequent embodiments, HnAttributeCache represents the first cache. Optionally, HnAttributeCache can also be a cache table of an LRU mechanism, which can also store the first resources of each application in units of package, that is, the first resource of an application is packaged into a package and cached in the cache table, and the first resources of different applications are packaged into different packages for cache. The required resources can be obtained from HnAttributeCache through resld.
[0133] The first resource is determined by the resources included in the application package of the first application, and the storage space occupied by the first resource is smaller than the storage space occupied by all resources included in the APK of the first application.
[0134] The first resource may be a part of all resources included in the application package of the first application, and the part of the resources is used to construct the first interface. Alternatively, the first resource may be a resource further determined based on a part of all resources included in the application package of the first application. Alternatively, a part of the first resource is a part of all resources included in the application package of the first application, and the other part is a resource further determined based on a part of all resources included in the application package of the first application.
[0135] Optionally, in addition to the first resource, the first cache may also include resources of other interfaces of the first application that are used to construct the first interface (hereinafter referred to as construction resources).
[0136] In the first case, the first cache only contains the first resource of the first application. In this case, since the first cache only contains the first resource, when the first interface needs to be started, the electronic device can directly obtain the first resource from the first cache to construct and start the first interface; but when starting other interfaces, since the construction resources of other interfaces are not cached in the first cache, when starting the other interface, the construction resources of the other interface cannot be obtained from the first cache to construct and start the other interface. It can be seen that this embodiment can only optimize the startup performance of the first interface.
[0137] In the second case, in addition to the first resource of the first application, the first cache may also include construction resources of other interfaces of the first application.
[0138] For example, the first cache contains the construction resources of the restart interface of the first application, and the restart interface refers to the interface of the first application that is not started for the first time. For this example, since the construction resources of the restart interface of the first application are cached in the first cache, when these restart interfaces are started, the construction resources of these restart interfaces can be directly obtained from the first cache to construct and start these restart interfaces, thereby optimizing the startup performance of all restart interfaces of the first application.
[0139] For another example, the first cache contains the construction resources of all interfaces of the first application. For this example, since the first cache caches the construction resources of all interfaces of the first application, when any interface of all interfaces is started, the construction resources of any interface can be directly obtained from the first cache to construct and start any interface, thereby optimizing the startup performance of all interfaces of the first application.
[0140] visible, Figure 4 In the embodiment shown, the startup performance of the interface whose construction resources are included in the first cache can be optimized. The timing of storing the first resource in the first cache can refer to Fig.10 and Fig.11 The embodiments shown are understood.
[0141] In addition, the first cache may also cache construction resources of one or more other applications, such as construction resources of one or more interfaces of the application.
[0142] Next, the first resource in S403 is introduced.
[0143] According to the foregoing content, it can be known that the first interface may include a window and display content drawn in the window. Of course, the first interface may also only include a window. In this case, the first interface is a blank interface, that is, an interface without display content. For example, a scenario involving a blank interface may be: after clicking the application icon of an application on the desktop, a blank interface is displayed first, and then the main interface of the first application is jumped to. For the case where the first interface is an interface with display content, constructing the Activity of the first interface involves drawing a window and drawing display content; for the case where the first interface is a blank interface, constructing the Activity of the first interface only involves drawing a window. The following discusses each case.
[0144] In some embodiments, when the first interface is a blank interface and only a window needs to be drawn, it is only necessary to obtain resources for drawing the window (referred to as window resources for short), that is, the first resources in S403 include window resources.
[0145] Optionally, the first resource includes a window attribute resource. The window attribute resource is an attribute resource used to draw a window when the electronic device constructs the first interface.
[0146] Specifically, the window attribute resources may include: window transparency parameter, window suspension parameter, window wallpaper parameter, window preview parameter, window display parameter, and transition window style parameter. Among them, the window transparency parameter is used to indicate the transparency of the window; the window suspension parameter is used to indicate whether the window is suspended; the window wallpaper parameter is used to indicate whether the window displays wallpaper; the window preview parameter is used to indicate whether the window is prohibited from preview; the window display parameter is used to indicate whether the window is not displayed; the window style parameter is used to indicate the style of the transition window display, and the transition window refers to the window drawn when the electronic device constructs the first interface.
[0147] It should be noted that the difference between window resources and window attribute resources is that window resources can include other resources in addition to window attribute resources. However, the electronic device can realize the drawing of the window based on the window attribute resources. Therefore, in this embodiment, the first resource only includes the window attribute resources in the window resources. It should be understood that when the first resource only includes the window attribute resources, the memory occupied by the first resource can be further reduced, thereby reducing the memory occupied by the first cache as a whole. It should be understood that in other optional implementations, the first resource can include other window resources in addition to the window basic resources.
[0148] In other embodiments, when the first interface is an interface with display content and a window and display content need to be drawn, it is necessary to obtain both window resources and resources for drawing display content, that is, the first resource in S403 may include window resources and resources for drawing display content.
[0149] The window resource included in the first resource may be only a window attribute resource, and the reason is referred to the previous embodiment. Here, the focus is on the resources used to draw the display content. The following takes the display content as an example to explain the resources used to draw the display content.
[0150] Optionally, the first resource also includes motion effect resources. Among them, the motion effect resources are resources required for drawing motion effects when the electronic device constructs the first interface, or the electronic device uses motion effects to construct the first interface. For the latter, when the electronic device constructs the first interface using the first resource containing resources for drawing motion effects, the electronic device needs to first synthesize the motion effects based on the resources for drawing motion effects, and then use the motion effects to construct the first interface. Obviously, if the motion effects themselves are cached directly, there is no need to synthesize the motion effects, thereby increasing the speed of building the first interface, thereby increasing the speed of starting the first interface, and optimizing the startup performance of the first interface of the first application. In addition, the resources used to draw motion effects include context and resources related to motion effect content. The storage space occupied by context is large, which makes the storage space occupied by the resources used to draw motion effects larger than the storage space occupied by the motion effects themselves. Based on this, when the motion effect resources contained in the first resource are motion effects, the memory occupied by the first resource can be further reduced, thereby reducing the memory occupied by the first cache as a whole.
[0151] It should be noted that the second cache caches all the resources of the APK of the first application. All the resources of the APK of the first application include resources for drawing animations, that is, resources containing contexts and related animation content. Therefore, the second cache occupies a larger space. It should be noted that APK is a file and does not contain contexts itself. After loading the APK, the electronic device parses the APK and creates a context based on the resources of the APK.
[0152] Next, a cache manner of the first resource in the first cache is exemplarily described.
[0153] In order to facilitate querying and acquiring various resources of the interface from the first cache, the resources cached in the first cache may have associated index information. That is, a resource and an index information are associated and cached in the first cache, and different resources are associated with different index information in the first cache. In this way, the electronic device can locate the resource associated with the index information through the index information and acquire it. Exemplarily, the index information may include the application to which the resource belongs, the interface to which the resource belongs, the resource ID, and the resource type.
[0154] In conjunction with Table 2, the following takes the first interface of the first application as an example to illustrate its various resources and associated index information.
[0155] Table 2
[0156]
[0157] It should be understood that the first operation instruction is used to instruct the electronic device to start the first interface of the first application. Therefore, the first operation instruction at least includes the activity to be started, that is, the first interface of the first application. It can be seen that the electronic device can know that the started activity is the first interface of the first application based on the first operation instruction.
[0158] It should be noted that, in some embodiments, the electronic device can also store the association relationship between the Activity to be started and the resource type and resource ID of the corresponding resource. In this way, when the electronic device starts the Activity, it can obtain the index information of the resource corresponding to the Activity to be started based on the association relationship between the Activity to be started and the resource type and resource ID of the corresponding resource, so that the resource associated with the index information can be found and obtained from the first cache based on the index information. Of course, in other embodiments, the index information can also be directly carried in the first operation instruction, and the embodiments of the present application do not limit this.
[0159] It should be noted that, in a specific implementation process, each resource and the associated index information may not be stored in the form of a table. For example, the application to which the resource in the index information belongs may be associated in the form of a package name of a resource package.
[0160] Next, the relevant content of loading the first resource from the first cache in S403 is described.
[0161] Please refer to Fig. 9 , Fig. 9 The process of the display method of the application interface provided in the embodiment of the present application Figure 2 Only S403a to S403h are described here, and other steps refer to Figure 4 The embodiment shown.
[0162] S403a: In response to the first operation instruction, query whether the first cache has the first resource.
[0163] If the first resource is not hit, it means that the first cache has the first resource, and S403b is executed.
[0164] If the first resource is hit, it means that the first cache does not have the first resource, and S403h is executed.
[0165] S403b: Query whether the second cache has the second resource of the first application.
[0166] The relevant contents of the second cache have been described in the above embodiments and will not be repeated here. In addition, in order to facilitate indexing, in the second cache, a resource and an index information are associated and cached in the second cache, and different resources are associated with different index information in the second cache. The specific implementation can be adaptively referred to the storage method of each resource in the first cache, which will not be repeated here.
[0167] If the second resource of the first application is not hit, it means that the second cache does not have the second resource of the first application, and S403c is executed.
[0168] If the second resource of the first application is hit, it means that the second resource of the first application is in the second cache, and S403e is executed.
[0169] S403c, obtaining a second resource of the first application from the APK of the first application.
[0170] S403d, storing the second resource of the first application into the second cache.
[0171] S403e: Acquire a second resource of the first application from the second cache.
[0172] S403f, determine the first resource according to the second resource of the first application.
[0173] According to the foregoing content, the second resource is all the resources of the APK of the first application. Obviously, the electronic device can determine the first resource according to the second resource of the first application. According to the foregoing content, the first resource includes window resources and animation resources. The animation resource can be a resource for drawing animation, or a resource for constructing the animation of the first interface. When the animation resource is a resource for drawing the animation of the first interface, S403f involves extracting the window resource of the first interface from the second resource of the first application, and also involves extracting the resource for drawing the animation of the first interface from the second resource of the first application, thereby obtaining the first resource. When the animation resource is a animation for constructing the first interface, S403f involves extracting the window resource from the second resource of the first application, and also involves extracting the resource for drawing the animation from the second resource of the first application, and then based on the resource for drawing the animation, synthesize the animation used to construct the first interface, thereby obtaining the first resource.
[0174] Taking the example that the first resource includes window attribute resources and animations for constructing the first interface, in S403f, it is necessary to extract the window attribute resources from the window resources contained in the second resource; it is also necessary to synthesize the animations for constructing the first interface based on the resources for drawing animations contained in the second resource.
[0175] S403g: Store the first resource into a first cache.
[0176] S403h: Load the first resource from the first cache.
[0177] visible, Fig. 9 In the illustrated embodiment, the second cache is used as the first-level cache to cache all resources of the APK of the first application, and the first cache is added as the second-level cache to cache only the first resources. The size of the first cache can be increased, for example, to the maximum number of application processes running simultaneously, so as to improve the hit rate to optimize the startup performance of the application interface. At the same time, the size of the second cache can be kept at a smaller number. Since the storage space occupied by the first resource is small, even if the size of the first cache is increased to the maximum number of application processes running simultaneously and is occupied by multiple applications, compared to the solution of only setting the second cache to store all resources of the APK of the first application and increasing the size of the second cache (for example, to the maximum number of application processes running simultaneously), the memory occupied by the first cache and the second cache is still smaller.
[0178] In addition, since the sizes of the two caches are different, when a new application is started, the resources of the applications deleted from the two caches are also different, which may lead to the following situation: the first cache does not have the first resource, while the second cache has the second resource of the first application. Since the second cache may cache all the resources contained in the APK of the first application, that is, the second resource, when the query of the first cache does not hit the first resource, this embodiment obtains the second resource of the first application from the second cache and caches it, and then determines the first resource according to the second resource of the first application in real time and caches it, and finally obtains the first resource from the first cache, so that the first interface can be started in time.
[0179] It should be understood that in other embodiments, if the first cache does not cache the first resource, the second resource of the first application can be directly obtained from the APK of the first application across packages, and the first resource can be obtained and cached based on the second resource of the first application.
[0180] Please refer to Fig.10 , Fig.10 The process of the display method of the application interface provided in the embodiment of the present application Figure 3 Here only S403a' to S403h' are described, and other steps refer to Figure 4 The embodiment shown.
[0181] S403a': In response to the first operation instruction, query whether the first cache has the first resource.
[0182] If the first resource is hit, it means that the first cache has the first resource, and S403b' is executed.
[0183] If the first resource is not hit, the first resource does not exist in the first cache, and S403c' is executed.
[0184] S403b', obtain the first resource from the first cache.
[0185] S403c', query whether the second resource of the first application exists in the second cache.
[0186] If the second resource of the first application is hit, it means that the second resource of the first application exists in the second cache, and S403d' is executed.
[0187] If the second resource of the first application is not hit, it means that the second resource of the first application does not exist in the second cache, and S403e' is executed.
[0188] S403d', obtaining the second resource of the first application from the second cache. After S403d', execute S403f.
[0189] Compared to Fig. 9 The embodiment shown, Fig.10 In the display method of the application interface shown, when the first cache is queried and the first resource is not hit, since the second cache may cache all the resources contained in the APK of the first application, namely the second resources, the first interface can be started in time by obtaining the second resources of the first application from the second cache and instantly determining the first resource based on the second resources of the first application.
[0190] S403e', obtaining the second resource of the first application from the APK of the first application. After S403e', execute S403f.
[0191] Compared to Fig. 9 The embodiment shown, Fig.10 In the method for displaying the application interface shown, if the launch of the first interface of the first application involves the first cold launch of the first application, the second cache has not yet cached the second resource of the first application. In this case, the second resource of the first application can be obtained from the APK of the first application and the first resource can be determined based on the second resource of the first application, so that the first interface is launched in time.
[0192] S403f', determine the first resource according to the second resource of the first application.
[0193] Optionally, after S403d', Fig.10 The method for displaying the application interface shown also includes:
[0194] S403h', determine the first resource according to the second resource of the first application, and store the first resource into the first cache.
[0195] In this embodiment, by storing the first resource in the first cache, it can be ensured that when the first interface of the first application is subsequently started, the first resource can be directly obtained from the first cache to start the first interface, thereby optimizing the startup performance of the first interface of the first application.
[0196] Optionally, after S403e', Fig.10 The method for displaying the application interface shown also includes:
[0197] S403g', store the second resource of the first application into the second cache.
[0198] In this embodiment, by storing the second resource of the first application in the second cache, when the first interface of the first application is subsequently started, if the first resource in the first cache is deleted, the electronic device can obtain the second resource of the first application from the second cache, thereby obtaining the first resource to realize the startup of the first interface, thereby enabling the first interface to be started in a timely manner.
[0199] Optionally, after S403e', Fig.10 The method for displaying the application interface shown also includes:
[0200] S403h', determine the first resource according to the second resource of the first application, and store the first resource into the first cache.
[0201] In this embodiment, by storing the first resource in the first cache, it can be ensured that when the first interface of the first application is subsequently started, the first resource can be directly obtained from the first cache to start the first interface, thereby optimizing the startup performance of the first interface of the first application.
[0202] Fig.10 In the illustrated embodiment, the electronic device has a priority for acquiring and launching the first resource, wherein the priority of the first cache is higher than the priority of the second cache which is higher than the priority of acquiring resources from the APK. This means that when the first resource needs to be acquired, it is first acquired from the first cache; when the first resource is not acquired from the first cache, it is acquired from the second cache; when the first resource is not acquired from the second cache, it is then acquired from the APK.
[0203] Combine the following Fig.11 , taking the display content in the first interface of the first application as the animation, and the scenario that triggers the launch of the first interface as the user clicking the application icon of the first application on the desktop as an example, the internal specific implementation of launching the first interface of the first application by the electronic device is described.
[0204] Please refer to Fig.11 , Fig.11 An interactive diagram of the startup process of an application interface provided in an embodiment of the present application. The startup process of the application interface specifically includes:
[0205] S1101: The application layer detects a user clicking event on an application icon of a first application on the desktop.
[0206] S1102, the application layer sends a startActivity request to the system framework layer.
[0207] The startActivity request is used to instruct to start the first interface of the first application. Based on this, the startActivity request includes the Activity to be started, for example, the Activity to be started is the first interface of the first application.
[0208] S1103: The system framework layer creates an Activity of the first interface of the first application in response to the startActivity request.
[0209] Optionally, S1103 specifically includes:
[0210] S1103a, obtaining window attribute resources for constructing a first interface of a first application from HnAttributeCache, and creating an Activityrecord of the first interface of the first application.
[0211] Among them, Activityrecord can be understood as the data format of the window of the first interface of the first application.
[0212] It should be noted that after receiving the startActivity request, the system framework layer can obtain the index information of the window attribute resources of the first interface of the first application based on the activity to be started included in the startActivity request. Based on the index information of the window attribute resources of the first interface of the first application, the window attribute resources for constructing the first interface of the first application can be obtained from HnAttributeCache.
[0213] S1103b, drawing a window of the first interface according to the Activityrecord of the first interface of the first application.
[0214] S1103c, obtaining the dynamic effect resources for constructing the first interface of the first application from HnAttributeCache, and drawing the dynamic effect in the window of the first interface.
[0215] S1103d, obtain the Activity of the first interface of the first application.
[0216] S1104, the system framework layer starts the first interface.
[0217] According to the above content, the animation resource can be the animation used by the electronic device to construct the first interface. After the animation used to construct the first interface is cached in HnAttributeCache, each time the animation resource is obtained from HnAttributeCache, the same animation object is obtained, which causes the animation object to be reused and set, resulting in the animation not meeting expectations, that is, not the desired animation.
[0218] In response to this situation, in some embodiments of the present application, after the animation used to construct the first interface is cached in HnAttributeCache, when the system framework layer needs to obtain the animation used to construct the first interface from HnAttributeCache, a request is initiated to HnAttributeCache. After receiving the request, HnAttributeCache first indexes the animation used to construct the first interface stored in HnAttributeCache, and then copies the queried animation used to construct the first interface stored in HnAttributeCache into a new animation object through the cloning method to the system framework layer. In this way, the system framework layer can avoid obtaining the animation objects that are reused and set, so that the expected animation can be obtained.
[0219] In specific implementation, the clone interface of animation can be encapsulated. When the system framework layer needs to obtain the animation used to construct the first interface from HnAttributeCache, a request is initiated by calling the clone interface, so that a new animation object returned by HnAttributeCache can be received, thereby obtaining the animation used to construct the first interface.
[0220] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0221] The embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the power-on control method of any of the above embodiments when executing the computer program.
[0222] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the power-on control method as described in any of the above embodiments is implemented.
[0223] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media do not include electric carrier signals and telecommunication signals.
[0224] The embodiment of the present application also provides a chip system. The chip system includes a processor and a memory, wherein the processor is coupled to the memory, and the memory is used to store programs or instructions, and when the program or instruction is executed by the processor, the chip system implements any method as described in the first aspect.
[0225] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0226] Optionally, the memory in the chip system may be one or more. The memory may be integrated with the processor or may be separately provided with the processor, which is not limited in the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be provided on different chips. The present application does not specifically limit the type of memory and the method for providing the memory and the processor.
[0227] Exemplarily, the chip system can be a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), a System on a Chip (SoC), a Central Processing Unit (CPU), a Network Processor (NP), a Digital Signal Processor (DSP), a Microcontroller Unit (MCU), a Programmable Logic Controller (PLC) or other integrated chips.
[0228] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for displaying an application interface, characterized in that: Applied in an electronic device, the electronic device comprises a first cache and a second cache, the capacity of the first cache is greater than the capacity of the second cache; The priority of loading resources from the first cache is higher than the priority of loading resources from the second cache, and the method includes: Display the target interface; detecting a first operation instruction for the target interface, where the first operation instruction is used to trigger the electronic device to display a first interface of a first application; In response to the first operation instruction, firstly load a first resource from the first cache; the first resource is a resource required for constructing the first interface; the first resource is determined by a resource included in an application package of the first application; a storage space occupied by the first resource is smaller than a storage space occupied by all resources included in the application package of the first application; In the case where the first resource is not available in the first cache, the first resource is loaded from the second cache; the second cache is used to cache at least the second resource of the first application, the second resource including all resources included in the application package of the first application; the first resource includes a window attribute resource, the window attribute resource is an attribute resource used to draw the window of the first interface when the electronic device constructs the first interface; in the case where the first resource includes an animation resource, the animation resource is an animation used by the electronic device to construct the first interface; The first interface is displayed on the electronic device according to the first resource.
2. The method for displaying an application interface according to claim 1, characterized in that: The loading of the first resource from the second cache further includes: The first resource is stored in the first cache.
3. The method for displaying an application interface according to claim 1 or 2, characterized in that: The loading the first resource from the second cache includes: Acquire a second resource of the first application from the second cache; The first resource is determined according to the second resource.
4. The method for displaying an application interface according to claim 3, characterized in that: Acquiring the second resource of the first application from the second cache includes: If the second resource is in the second cache, acquiring the second resource from the second cache; When the second resource of the first application does not exist in the second cache, the second resource of the first application is acquired from the application package of the first application.
5. The method for displaying an application interface according to claim 4, characterized in that: The acquiring the second resource of the first application from the application package of the first application further includes: determining the first resource according to the second resource; The first resource is stored in the first cache.
6. The method for displaying an application interface according to claim 1, characterized in that: The motion effect resource is obtained based on the motion effect clone stored in the first cache and used to construct the first interface.
7. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A chip system, characterized in that: include: A processor and a memory; wherein the processor is coupled to the memory, and the memory is used to store programs or instructions, and when the programs or instructions are executed by the processor, the chip system implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Application program loading processing method, electronic equipment and medium
CN110543337A