A process management method and device for application program
By setting the process of the application to be started as a foreground process in an electronic device at the first point in time, the slow startup speed caused by excessive resource occupancy of applications in the background is solved, and the startup performance and user experience of the application are improved .
Patent Information
- Application Number
- CN202310957348.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2043-07-31
AI Technical Summary
In electronic devices, multiple applications running in the background occupy too much system resources, resulting in slow application startup speed and negative experience to users.
By setting the process of the application to be started as a foreground process at the first point in time, using a processor with strong processing capabilities to run, thereby improving the startup performance of the application.
It improves the startup speed of the application, improves the user experience, and avoids the problems of resource preemption and scheduling delay.
Smart Images

Figure CN117724634B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminals, and in particular to a process management method and device for an application. Background Art
[0002] Currently, the operating system of an electronic device (e.g., Android operating system) can run some applications in the background. However, if there are too many applications running in the background, these applications will occupy more system resources such as the central processing unit (CPU) and memory of the electronic device. As a result, when a user opens an application (e.g., an application in the background), the application may start slowly due to insufficient system resources such as CPU and memory, which brings a negative experience to the user. Summary of the invention
[0003] The embodiments of the present application provide a method and device for managing the process of an application, which can improve the startup performance of the application when the electronic device is under a high load (for example, when multiple applications are running in the background).
[0004] In a first aspect, an embodiment of the present application provides a method for managing the process of an application, which is applied to an electronic device, on which a first application and a second application are installed, the method comprising: starting the first application, switching the first application from foreground operation to background operation; displaying a first interface of the second application, the first interface including an icon of the first application; at a first time point, receiving a first operation, the first operation being a pressing operation on the icon of the first application on the first interface; in response to the first operation, setting the process of the first application as a foreground process, and using a first central processing unit (CPU) to run the process of the first application; at a second time point, receiving a second operation, the second operation being a lifting operation, The second time point is later than the first time point; in response to the second operation, the process of the second application is set as a background process, and the second CPU is used to run the process of the second application, and the processing power of the first CPU is stronger than that of the second CPU; the process of the first application is killed; in response to the third operation, the first interface is displayed; at the third time point, the fourth operation is received, and the fourth operation is a pressing operation on the icon of the first application on the first interface; at the fourth time point, the fifth operation is received, and the fifth operation is a lifting operation, and the fourth time point is later than the third time point; in response to the fifth operation, the process of the second application is set as a background process, and the process of the first application is set as a foreground process.
[0005] Based on the method provided in the embodiment of the present application, in the scenario of hot starting an application (for example, a first application), at a first point in time, after receiving a press operation of the user on the first application, the process of the first application can be set as the foreground process in response to the press operation, so as to run the process of the first application on the first CPU (the first CPU has stronger processing power than the second CPU), thereby improving the startup performance of the application (for example, the first application).
[0006] In addition, in the case of a cold start of an application (for example, the first application), at the fourth time point, after receiving a lift operation (lift operation), the process of the second application is set as a background process, and the process of the first application is set as a foreground process. Compared with the scenario of a hot start of the application (for example, the first application), in the scenario of a cold start of the application (for example, the first application), the startup performance of the application is difficult to improve.
[0007] In one possible implementation, a third application is also installed on the electronic device, and the method also includes: starting the third application and switching the third application from foreground operation to background operation; displaying the second interface of the second application, the second interface including the icon of the third application; at a fifth time point, receiving a sixth operation, the sixth operation being a pressing operation on the icon of the third application on the second interface; at a sixth time point, receiving a seventh operation, the seventh operation being a lifting operation, the sixth time point being later than the fifth time point; in response to the seventh operation, setting the process of the second application as a background process and setting the process of the third application as a foreground process.
[0008] In the scenario of hot starting an application (e.g., a third application), at a sixth time point, a seventh operation is received, and in response to the seventh operation, the process of the second application is set as a background process, and the process of the third application is set as a foreground process. This results in poor startup performance of the third application. In comparison, in the scenario of hot starting an application (e.g., a first application), after receiving a user's press operation on the first application at a first time point, in response to the press operation, the process of the first application can be set as a foreground process, so that the process of the first application can be run on the first CPU (the first CPU has a stronger processing power than the second CPU), thereby improving the startup performance of the application (e.g., the first application).
[0009] In a possible implementation, in response to the first operation, setting the process of the first application as the foreground process includes: in response to the first operation, based on the first application being a preset application, setting the process of the first application as the foreground process. It should be noted that if the first application is a preset application, it means that the first application is an application that is frequently used by users and / or occupies more resources. If the startup performance of the first application is low, it will lead to a poor user experience. Therefore, setting the process of the first application as the foreground process can improve the startup performance of the first application, thereby improving the user experience.
[0010] In one possible implementation, based on the fact that the third application does not belong to the preset application, the process of the third application is not set as the foreground process between the fifth time point and the sixth time point. If the first application does not belong to the preset application, it means that the first application is not an application that is frequently used by users and / or occupies more resources, and the user has little perception of the startup performance of the first application, that is, the startup performance of the first application has little effect (or no effect) on the user experience. Therefore, the process of the first application may not be set as the foreground process. In this way, the first application will not be set as the foreground process in advance, and the process of the first application can be prevented from competing for resources with other foreground processes (for example, the process of the desktop application), thereby avoiding the problem of animation playback jamming due to insufficient resources or failure to be scheduled in a timely manner in the desktop application.
[0011] In a possible implementation, the electronic device further includes a fourth application and an activity management service AMS, and in response to the first operation, based on the first application belonging to a preset application, the process of the first application is set as a foreground process, including: the fourth application obtains application information of the first application, the application information includes the package name of the first application, and the fourth application is an application for managing the icon of the first application; the fourth application sends the application information of the first application to the AMS by calling the first interface; the AMS determines whether the first application belongs to the preset application according to the application information of the first application; the AMS sets the process of the first application as the foreground process based on the first application belonging to the preset application. In this way, the startup performance of the first application can be improved, thereby improving the user experience.
[0012] In a possible implementation, the preset application satisfies at least one of the following conditions: the usage frequency of the preset application is higher than a first threshold; or the resources occupied by running the preset application are greater than a second threshold.
[0013] In a possible implementation, the preset application includes a camera application, a video application, or a game application.
[0014] In a possible implementation, if after receiving the first operation, a second operation is received after a preset time, after setting the process of the first application as a foreground process in response to the first operation, the method further includes: setting the process of the first application as a background process. In this way, subsequent operations are not affected and the user experience is not reduced.
[0015] In a possible implementation, if after receiving the first operation, a second operation is received after a preset time, then in response to the second operation, the process of the second application is set as a background process, including: in response to the second operation, displaying a target menu, the target menu including a function entry of the first application; receiving a sixth operation on the target menu; in response to the sixth operation, setting the process of the second application as a background process. That is, when the user performs a long press operation, the electronic device can display the target menu, and in response to the user's sixth operation on the target menu, the process of the second application can be set as a background process.
[0016] In a possible implementation, the second application is a desktop application; the first interface includes a desktop interface or a multi-task management interface. Figure 5A The multi-task management interface can be as shown in (a) of FIG. Figure 5A Interface 511 shown in (b) in FIG.
[0017] In a possible implementation, the fourth application includes a desktop application or a system user interface application.
[0018] In a second aspect, the present application provides a chip system, which includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by lines. The above chip system can be applied to an electronic device including a communication module and a memory. The interface circuit is used to receive a signal from the memory of the electronic device and send the received signal to the processor, and the signal includes a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device can execute the method described in the first aspect and any possible design thereof.
[0019] In a third aspect, the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device (such as a mobile phone), the electronic device executes the method described in the first aspect and any possible design thereof.
[0020] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any possible design thereof.
[0021] In a fifth aspect, an embodiment of the present application provides a process management device for an application, including a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the device implements the method described in the first aspect and any possible design thereof. The device may be an electronic device or a server device; or may be a component of an electronic device or a server device, such as a chip.
[0022] In the sixth aspect, an embodiment of the present application provides a process management device for an application, which can be divided into different logical units or modules according to functions, and each unit or module performs different functions, so that the device executes the method described in the above-mentioned first aspect and any possible design method thereof.
[0023] It can be understood that the beneficial effects that can be achieved by the chip system described in the second aspect, the computer-readable storage medium described in the third aspect, the computer program product described in the fourth aspect, and the devices described in the fifth aspect and the sixth aspect provided above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of a method for switching process groups in the prior art;
[0025] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0026] Figure 3 A schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;
[0027] Figure 4 A schematic diagram of interaction between modules provided in an embodiment of the present application;
[0028] Figure 5A A display schematic diagram provided for an embodiment of the present application;
[0029] Figure 5B Another display schematic diagram provided for an embodiment of the present application;
[0030] Figure 5C Another display schematic diagram provided for an embodiment of the present application;
[0031] Figure 5D Another display schematic diagram provided for an embodiment of the present application;
[0032] Figure 6 A schematic diagram of resource locking provided in an embodiment of the present application;
[0033] Figure 7 A schematic diagram of the timing of switching process groups in the prior art;
[0034] Figure 8 A timing diagram of switching process groups provided in an embodiment of the present application;
[0035] Fig. 9 A schematic diagram of a method flow chart provided for an embodiment of the present application;
[0036] Fig.10 Another display schematic diagram provided for an embodiment of the present application;
[0037] Fig.11 Another display schematic diagram provided for an embodiment of the present application;
[0038] Fig.12 A schematic diagram of another method flow provided in an embodiment of the present application;
[0039] Fig.13 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to make the description of the following embodiments clear and concise, a brief introduction to the relevant concepts or technologies is first given:
[0041] Activity life cycle methods: The Android system provides many Activity life cycle methods, such as onResume method, onStart method, etc. Among them:
[0042] onCreate method: Initializes the data required by Activty. When this method is executed, Activty has been created.
[0043] onStart method: When this method is executed, the Activty has been started. The Activty changes from invisible to visible, but it is still in the background and cannot interact with the user.
[0044] onResume method: When this method is executed, the Activty is active and the user can interact with it.
[0045] Intent: can be used to solve the communication between components in the Android system application. Intent is responsible for describing the action of an operation in the application and the data involved in the action (for example, the package name). In the Android system, according to the description of this Intent, the corresponding component can be found, the Intent (such as the package name) can be passed to the called component, and the component call can be completed.
[0046] Touch event: A complete touch event can include a touch down / action down event and a touch up / action up event. Optionally, a touch down event can also be called a down event, a touch start event, or an action down event. A touch up event can also be called an up event, a touch end event, or an action up event. Optionally, a touch event can also include several touch move events (also called move events). Among them:
[0047] Touch down event: triggered when the user touches the screen of an electronic device (eg, a mobile phone) with a body part (eg, finger, elbow, etc.) or an input tool (eg, a stylus).
[0048] Touch move event: Triggered continuously when the user's body part or input tool moves or slides on the screen of the electronic device.
[0049] Touch up event: triggered when the user's body part or input tool leaves the screen of the electronic device.
[0050] Foreground process: A foreground process is a process that is visible and operable to the user. A foreground process can be run preferentially on a processor with stronger processing power (for example, a large core processor), has a fast execution speed, and has a higher scheduling priority.
[0051] Background process: A background process is a process that cannot be operated by the user (unless closed). The priority of a background process is lower than that of a foreground process. Background processes usually run on processors with weaker processing power (for example, small-core processors) and execute at a slower speed.
[0052] It should be understood that the processor may include multiple types, for example, a large-core processor (large-core CPU), a medium-core processor (medium-core CPU) and a small-core processor (small-core CPU). The processing capability of a large-core processor is stronger than that of a medium-core processor, and the processing capability of a medium-core processor is stronger than that of a small-core processor. It is understandable that the higher the processing capability of the processor, the higher the operating frequency and the faster the processing speed. Exemplarily, the operating frequency of a small-core processor may be, for example, 1.8 GHz. The operating frequency of a medium-core processor may be, for example, 2.0 GHz. The operating frequency of a large-core processor may be, for example, 2.6 GHz.
[0053] Foreground process group: The foreground process group can include one or more foreground processes.
[0054] Background process group: A background process group can include one or more background processes.
[0055] Foreground processes and background processes can be interchanged. For example, you can move a foreground process in a foreground process group into a background process group (i.e., switch the foreground process to a background process), or you can move a background process in a background process group into a foreground process group (i.e., switch the background process to a foreground process).
[0056] In some cases, if there are too many applications running in the background of an electronic device (i.e., too many background processes), the processes of these applications will occupy more system resources such as CPU and memory of the electronic device. In this way, when a user opens an application (for example, one of the applications running in the background), the startup speed of the application may be slow due to insufficient system resources such as CPU and memory, which brings a negative experience to the user. For example, when a user opens an application (for example, one of the applications running in the background), since the process of the application and the processes of other applications running in the background are in the background process group, they can only run on the small-core processor and need to grab resources from each other, resulting in the inability to schedule the application in time and slow startup, which brings a negative experience to the user.
[0057] For example, the application opened by the user is a camera application. Figure 1 As shown, in the related art, during the camera application startup process, you must first wait for the camera application interface to start, then adjust the desktop application process to the background process group, and then switch the camera application process to the foreground process group, so that the camera application process can run preferentially on the large-core processor. However, in the process of adjusting the desktop application to the background process group, the desktop application process may not be scheduled in time because other background application processes occupy resources. This will cause a delay in the execution time of switching the camera application to the foreground group, resulting in a slow startup speed of the camera application, which brings a negative experience to users.
[0058] An embodiment of the present application provides a method and device for managing the process of an application, which can optimize the process scheduling of the application when the electronic device is under high load (for example, when multiple applications are running in the background), and can set the process of the application to be started (one of the applications running in the background) as the foreground process in advance, so that the process of the application to be started can be quickly scheduled to a processor with stronger processing power (for example, a large-core processor) to run, thereby improving the startup performance of the application.
[0059] The application process management method provided in the embodiment of the present application can be applied to electronic devices. The electronic devices can be, for example, mobile phones, tablet computers, desktop computers, handheld computers, notebook computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), augmented reality (AR) and virtual reality (VR) devices, etc. The embodiment of the present application does not impose any special restrictions on the specific form of the electronic devices.
[0060] Figure 2 FIG. 1 is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application. Figure 2 As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0061] Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0062] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0063] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0064] The electronic device 100 can realize the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor. The ISP is used to process the data fed back by the camera 193. The camera 193 is used to capture static images or videos. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0065] The number of cameras 193 may be 1 to N. Each camera includes a photosensitive element (CCD / CMOS), which can sense light, collect photons and convert them into electric charges.
[0066] The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.
[0067] The software system of the electronic device 100 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 invention takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0068] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, the HAL layer, and the kernel layer. It should be noted that the embodiments of the present application are illustrated by taking the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.
[0069] Among them, the application layer can include a series of application packages.
[0070] like Figure 3 As shown, the application package may include desktop applications (Launcher), system user interface applications (system UI), camera, call, short message, setting, gallery, calendar, map, navigation, WLAN, Bluetooth, music, video and other applications.
[0071] Among them, the desktop application can perform processing such as gesture response and gesture interaction UI loading.
[0072] The functions of the system UI application may include status bar information display (such as battery, wifi signal, 3G / 4G and other icons), notification panel (such as system messages, third-party application messages) management, and recent task bar display panel (such as long pressing the recent task shortcut key to display recently used applications) management, etc.
[0073] Optionally, the application package may also include a smart capability application, which can be called by system applications or third-party applications to provide a quick application launch entry (e.g., a floating capsule) for the system applications or third-party applications.
[0074] The application framework layer provides an application programming interface (API) and a programming framework for the application programs in the application layer. The application framework layer includes some predefined functions. For example, it may include an activity manager / activity management service (AMS), a window manager, a content provider, a view system, a resource manager, a notification manager, etc., and the embodiments of the present application do not impose any restrictions on this.
[0075] Among them, AMS is used to manage the life cycle of each application (referred to as application). It is understandable that applications usually run in the operating system in the form of Activities. For each Activity, there will be a corresponding application record (Activity Record) in AMS, and this Activity Record records the status of the Activity of the application. AMS can use this Activity Record as an identifier to schedule the Activity process of the application.
[0076] In an embodiment of the present application, the AMS may also include an extension method, which may be used to determine whether the application (e.g., camera application) indicated by the application information (e.g., application information of the camera application) transmitted by the desktop application matches the application information of the preset application. That is, to determine whether the camera application is a preset application. Among them, the preset application may include a camera application (e.g., camera application), a video application, a game application, etc., or other types of applications, which are not limited in the embodiment of the present application.
[0077] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0078] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0079] 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 a text notification icon can include a view for displaying text and a view for displaying images.
[0080] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0081] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0082] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0083] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0084] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0085] OpenGL ES is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0086] SGL is a graphics engine for 2D graphics.
[0087] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0088] The HAL layer is an encapsulation of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the low-level hardware.
[0089] The HAL layer may include Wi-Fi HAL, audio HAL, camera HAL, etc.
[0090] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, etc.
[0091] The technical scheme in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Wherein, in the description of the present application, unless otherwise specified, "at least one" refers to one or more, and "a plurality of" refers to two or more than two. In addition, in order to facilitate the clear description of the technical scheme of the embodiment of the present application, in the embodiment of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art will understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit necessarily different.
[0092] For ease of understanding, a process management method for an application provided in an embodiment of the present application is specifically introduced below with reference to the accompanying drawings.
[0093] like Figure 4 As shown, an embodiment of the present application provides a process management method for an application program, which is applied to an electronic device, and the electronic device may be a mobile phone, on which a first application (for example, a camera application) and a second application (for example, a desktop application) are installed. The method includes:
[0094] 401. Start a camera application and switch the process of the camera application from foreground operation to background operation.
[0095] Exemplarily, in response to a user operating the icon of the camera application (e.g., clicking), the camera application may be started. Alternatively, the camera application may be started through a background service or broadcast. After the camera application is started, the camera application may be switched from foreground operation to background operation. In a possible implementation, switching the camera application from foreground operation to background operation may be switching the process of the camera application from a foreground process group to a background process group.
[0096] 402A: Display a desktop interface, where the desktop interface includes an application icon of a camera application.
[0097] For example, Figure 5A As shown in (a), the electronic device can display a desktop interface 501, and the desktop interface 501 includes an application icon 502 of a camera application.
[0098] 402B. At the first moment, the desktop application receives a pressing operation of the application icon of the camera application by the user.
[0099] Exemplarily, when a user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) touches the application icon of the camera application, a touch down event is triggered. That is, when the desktop application receives a user's pressing operation on the application icon of the camera application on the desktop interface, it receives a touch down event. The touch down event can carry the position coordinates of the application icon of the camera application. At the first moment, the camera application is running in the background, that is, the process of the camera application belongs to the background process.
[0100] For example, Figure 5A As shown in (a) in FIG. 8 , the mobile phone may receive an operation (eg, a pressing operation) performed by a user on an application icon 502 of a camera application.
[0101] In some embodiments, step 402A may be replaced by step 402C, and step 402B may be replaced by step 402D, as follows:
[0102] 402C. Display a multi-task management interface, where the multi-task management interface includes a card for a camera application.
[0103] For example, Figure 5A As shown in (b) , the electronic device may display a multitasking management interface 511 , and the multitasking management interface 511 may include a card 512 of a camera application.
[0104] 402D. At the second moment, the desktop application receives a pressing operation of the user on the card of the camera application.
[0105] Exemplarily, when the user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) touches the card of the camera application in the multitasking management interface, a touch down event is triggered. That is, when the desktop application receives the user's pressing operation on the card of the camera application in the multitasking management interface, it receives the touch down event. The touch down event can carry the position coordinates of the card of the camera application. At the second moment, the camera application is running in the background, that is, the process of the camera application belongs to the background process.
[0106] For example, Figure 5A As shown in (b) in FIG. 8 , the mobile phone may receive an operation (eg, a pressing operation) performed by the user on the card 512 of the camera application.
[0107] 403. The desktop application obtains application information of the camera application.
[0108] It should be noted that in step 403, the desktop application obtains the application information of the application corresponding to the application icon (or card) pressed by the user. In this embodiment, the application corresponding to the application icon (or card) pressed by the user is the camera application. Therefore, the application information of the camera application is obtained here.
[0109] After receiving the touch down event, the desktop application can obtain application information of the camera application according to the location coordinates carried in the touch down event.
[0110] The application information of the camera application may include the package name of the camera application. The package name of the camera application (eg, Honor Camera) may be, for example, com.hihonor.camera.
[0111] Optionally, if the camera application is a clone application (or an application clone is set for the camera application), the application information of the camera application may also include a user ID. Different clone applications may correspond to different user IDs.
[0112] 404. The desktop application calls the first extension interface to send application information of the camera application to the AMS.
[0113] The desktop application can interact with the AMS by calling the first extended interface (ie, the first interface) and send the application information of the camera application to the AMS.
[0114] Among them, the first extension interface can be an extension interface provided by the software development kit (SDK) of the system (for example, Magic OS). Among them, SDK can refer to a collection of relevant documents, examples and tools that assist in the development of a certain type of software (for example, Magic OS). The SDK of the system can be uniformly provided by a software manufacturer (for example, Honor). The SDK of the system can be integrated on an electronic device (for example, a mobile phone).
[0115] The function of the first extended interface is to enable the desktop application to access the AMS (ie, to enable the desktop application to interact with the AMS).
[0116] Exemplarily, the definition format of the first extended interface may include a function description and input parameters, wherein:
[0117] Functional description of the first extended interface: After receiving a touch down event, the desktop application obtains application information (for example, package name) according to the touch down event, and sends the obtained application information to the AMS, so that the AMS determines whether to set the process of the application indicated by the application information as the foreground process according to the application information.
[0118] Input parameters of the first extension interface: After receiving the touch down event, the desktop application obtains application information (eg, package name) according to the touch down event.
[0119] Optionally, the definition format of the first extended interface may further include return information. The return information is used to indicate whether the AMS sets the process of the application indicated by the application information as the foreground process. For example, the return information may indicate that the AMS sets the process of the application indicated by the application information as the foreground process, or the return information may indicate that the AMS does not set the process of the application indicated by the application information as the foreground process.
[0120] Exemplarily, the interface name of the first extended interface may be: preProcessApplicationForLauncher (String pkgName).
[0121] It should be understood that when the first extended interface is called, the camera application can be started according to the input parameters of the first extended interface (for example, the application information of the camera application). In other words, when the application (for example, the camera application) is started, the first extended interface can be called, and the input parameters of the first extended interface can be the application information of the camera application.
[0122] 405. The AMS determines whether the camera application is a preset application according to the application information of the camera application.
[0123] AMS can call an extension method to determine whether the camera application belongs to a preset application based on the application information (e.g., the application information of the camera application) transmitted by the desktop application. The extension method is a specific implementation of the first extension interface and can be written into AMS in advance. The method name of the extension method can be, for example, needPreProcessForLauncher(StringpkgName).
[0124] In one possible design, the application information (e.g., package name) of the preset application may be preset in the AMS. The preset application may include one or more. For example, the application information of the preset application may include the package name of one or more applications. Special functions may be customized for these preset applications. For example, the process of the preset application may be set as the foreground process in advance, thereby improving the startup performance of these preset applications.
[0125] In a possible implementation, there are multiple preset applications, and the AMS may traverse the application information of the preset applications. If it is determined that the application information of the camera application is the same as the application information of a preset application, the camera application is considered to belong to the preset application.
[0126] Among them, the preset applications may include applications that are used frequently by users (for example, the frequency of use is higher than the first threshold). Exemplarily, the first threshold may be N times / day or M times / week or P times / month, where N or M or P is an integer greater than or equal to 1. It should be noted that since applications that are used frequently by users are relatively important applications, users are more sensitive to the startup time of these applications. If the startup time of these applications is long and the startup performance is poor, the user experience will be greatly reduced. Therefore, applications that are used frequently by users can be used as preset applications and set as foreground processes in advance, thereby improving the startup performance of preset applications and improving the user experience.
[0127] Alternatively, the preset applications may include applications that require more resources to run (for example, the resources occupied are greater than a second threshold). Exemplarily, the second threshold may be the percentage of memory used (for example, 50%) or the CPU time occupied (for example, 500ms). It should be noted that since applications that occupy more resources take a long time to start up, the user has to wait for a long time, resulting in a low user experience. Therefore, applications that occupy more resources can be used as preset applications and set as foreground processes in advance, thereby improving the startup performance of the preset applications and improving the user experience.
[0128] Alternatively, the preset applications may include applications that are frequently used by the user and occupy more resources.
[0129] For example, assuming that Honor Camera, and The usage frequency is higher than the first threshold. and As a default application. and If the resources used during operation are greater than the second threshold, and Also used as a preset application. Taking the application information as a package name as an example, the application information of the preset application can be shown in Table 1.
[0130] Table 1
[0131]
[0132]
[0133] If the camera application is a preset application, step 406 may be executed; if the camera application is not a preset application, step 407 may be executed.
[0134] 406. If the camera application is a preset application, the AMS sets the process of the camera application as the foreground process.
[0135] The camera application is a preset application, which means that the camera application is an application that users use frequently and / or occupies more resources. If the startup performance of the camera application is low, it will lead to a poor user experience. Therefore, setting the process of the first application as the foreground process can improve the startup performance of the camera application, thereby improving the user experience.
[0136] In a possible implementation manner, the AMS sets the process of the camera application as the foreground process, which may be that the AMS switches the process of the camera application from the background process group to the foreground process group.
[0137] Exemplarily, the AMS may call the requestProcessGroupChange method to switch the camera application process from the background process group to the foreground process group. The requestProcessGroupChange method is used to request a change in the process group. The input parameters of the requestProcessGroupChange method may include the identifier of the process, the identifier of the process group in which the process is currently located, and the identifier of the process group to which the process is to be switched. According to the identifier of the process, a specific process (for example, the process of the camera application) can be determined, and according to the identifier of the process group in which the process is currently located and the identifier of the process group to which the process is to be switched, it can be determined from which process group to which the process (for example, the process of the camera application) is switched.
[0138] Exemplarily, in step 402A, when the desktop interface is displayed, the camera application is running in the background. In step 402B, at a first moment, the desktop application receives a user's pressing operation on the application icon of the camera application. In response to the pressing operation, in step 406, the camera application can be switched from background operation to foreground operation. Then, the camera application can exit the foreground and enter the multitasking management interface. In step 402C, when the multitasking management interface is displayed, the camera application is running in the background. In step 402B, at a second moment, the desktop application receives a user's pressing operation on the card of the camera application. In response to the pressing operation, in step 406, the camera application can be switched from background operation to foreground operation.
[0139] Optionally, after the camera application process is set as the foreground process, the camera application process can run on the big-core processor, thereby improving the startup performance of the application. Exemplarily, the AMS can run the camera application process on the big-core processor by calling the Setaffinity() method.
[0140] 407. If the camera application is not a preset application, there is no need to set the process of the camera application as the foreground process.
[0141] If the camera application is not a preset application, it means that the camera application may not be an application that is frequently used by users and / or occupies more resources. The user has little perception of the startup performance of the camera application, that is, the startup performance of the camera application has little (or no) impact on the user experience. Therefore, the process of the camera application can be set as the foreground process. In this way, the camera application will not be set as the foreground process in advance, which can avoid the resource grabbing of the camera application process and other foreground processes (for example, the process of the desktop application), and avoid the problem of animation playback jamming due to insufficient resources or failure to be scheduled in time for the desktop application.
[0142] 408. At the third moment, the desktop application receives a lift operation from the user.
[0143] In conjunction with step 402B, the desktop application receives a user's pressing operation on the application icon of the camera application. Here, the desktop application may receive a user's lifting operation (also referred to as a hand-lifting operation or a hand-off operation). That is, the user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) may leave the application icon of the camera application. When the desktop application receives a user's lifting operation on the application icon of the camera application on the desktop interface, a touch up event is triggered.
[0144] In conjunction with step 402D, the desktop application receives a user's pressing operation on the camera application card. Here, the desktop application may receive a lifting operation by the user. That is, the user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) leaves the camera application card. When the desktop application receives a user's lifting operation on the camera application card on the desktop interface, a touch up event is triggered.
[0145] It should be noted that there is no necessary execution sequence between step 408 and steps 403 to 407, and this embodiment does not specifically limit the execution sequence between the steps.
[0146] It should be understood that the touch down event in step 402B or step 402D and the touch up event in step 408 represent the start and end of a complete touch event. A touch event may include a click event and a long press event.
[0147] In some embodiments, if the user keeps the pressing state for a short time (for example, 60ms) and does not reach the preset time length (for example, 500ms), the onClick method can be called to determine that the user has performed a click operation. For example, at a first moment (for example, 07-12 15:00:50.023), the desktop application receives the user's pressing operation on the application icon of the camera application on the desktop interface, and at a third moment (for example, 07-12 15:00:50.083), the desktop application receives the user's pressing operation on the application icon of the camera application. That is, the user keeps the pressing state for 60ms, which does not reach the preset time length (for example, 500ms), that is, the user has performed a click operation. In the case where the user performs a click operation, after the desktop application receives the user's lifting operation on the application icon or card of the camera application, step 409 can be directly executed.
[0148] In other embodiments, if the user keeps pressing the button for a long time, reaching a preset time (e.g., 500ms), the onlongClick method can be called to determine that the user has performed a long press operation. For example, at the first moment (e.g., 07-12 15:00:53.023), after the desktop application receives the user's pressing operation on the application icon of the camera application on the desktop interface, if the user keeps pressing the button for a preset time (e.g., 500ms), the onlongClick method can be called, that is, the user has performed a long press operation. Then, at the third moment (e.g., 07-12 15:00:53.523), the desktop application receives the user's pressing operation on the application icon of the camera application.
[0149] When the user performs a long press operation, after receiving the user's lift operation on the application icon or card of the camera application, the desktop application can call the second extension interface (second interface) to switch the process of the camera application to a background process. Then, step 409 is executed.
[0150] The second extended interface may be an extended interface provided by the SDK of the system (eg, Magic OS). Exemplarily, the definition format of the second extended interface may include a function description and input parameters, wherein:
[0151] Functional description of the second extended interface: The desktop application determines that the user has performed a long press operation, requests the AMS to roll back, and switches the process of the application set as the foreground process to the background process.
[0152] Input parameter of the second extended interface: application information (eg, package name).
[0153] Exemplarily, the interface name of the second extended interface may be: revertPreProcessApplicationForLauncher(String pkgName).
[0154] It is understandable that after receiving the user's long press operation, the desktop application can display a shortcut menu (target menu), and the shortcut menu can include some shortcut functions. Figure 5B As shown, in response to a user's long press operation on the application icon 502 of the camera application, a shortcut menu 503 can be displayed. The shortcut menu 503 may include function entries such as dynamic photos, video recording, and selfies. The desktop application calls the second extended interface to switch the process of the camera application set as the foreground process to a background process. In this way, if the user cancels the shortcut menu (for example, the user clicks on the display area outside the shortcut menu) and enters other applications (for example, the user clicks on the application icon of the video application). In response to the user's click operation on the application icon of the video application, the process of the desktop application can be set to a background process, and then the process of the video application can be set to a foreground process. Since the camera application is not a foreground process, resource preemption between the camera application process and the video application process can be avoided.
[0155] In some embodiments, when the user performs a long press operation, the second extended interface may not be called, that is, there is no need to switch the process of the camera application to a background process, and the process of the camera application is the foreground process. In this way, in response to the user's operation on the shortcut menu (for example, clicking on a shortcut function (for example, selfie) in the shortcut menu), the mobile phone can start the selfie mode of the camera application (that is, start the camera application to directly enter the selfie mode), and set the process of the desktop application to the background process. Since the process of the camera application is the foreground process, it can enter the selfie mode faster, improving the user experience.
[0156] 409. The desktop application calls the third interface and sends the Intent parameter to the AMS.
[0157] Exemplarily, the third interface may be, for example, Context.startActivity(). Context.startActivity() may be used for cross-process communication. A desktop application may perform cross-process communication with AMS by calling Context.startActivity(). Context.startActivity() may carry an Intent parameter.
[0158] The Intent parameter can include the following two types of data:
[0159] The first type: the package name and Activity class name of the camera application. The desktop application can obtain the package name and Activity class name of the camera application through the getLaunchIntentForPackage() method of the package manager service (PMS).
[0160] The second type: Action data. Desktop applications can obtain Action data through the getApplicationInfo() method of PMS.
[0161] 410. AMS calls the startActivity method.
[0162] In some embodiments, after receiving the Intent parameter, the AMS obtains the package name of the camera application and the class name of the Activity by parsing the Intent parameter. The AMS then starts the Activity of the camera application according to the package name of the camera application and the class name of the Activity, that is, calls the startActivity method. The startActivity method is used to start the Activity of an application (e.g., a camera application). That is, the startActivity method is a method for starting an application. Among them, the startActivity method can carry the Intent parameter.
[0163] In other embodiments, after receiving the Intent parameter, the AMS obtains the Action data by parsing the Intent parameter. The AMS can parse the AndroidManifest.xml files of multiple applications through the PMS, and the AndroidManifest.xml file of each application may include the Activity corresponding to the application and the Action data configured by the Activity. The AMS determines the Activity to be started based on the Action data configured for each Activity. Since there are multiple Activities with the same Action data configured, a prompt box may pop up on the interface, and the prompt box may include the identifiers of multiple applications so that the user can select the identifier of the application they want to open in the prompt box. For example, in response to the user selecting the identifier of an application (e.g., a camera application) in the prompt box, the AMS can start the Activity of the camera application, that is, call the startActivity method. Among them, the startActivity method may carry the Intent parameter. The Intent parameter may include the package name of the camera application and the class name of the Activity.
[0164] 411. AMS calls the onResume method.
[0165] After the startActivity method is called, the onResume method is called.
[0166] Optionally, after the startActivity method is called and before the onResume method is called, methods such as onCreate and onStart may also be called, but this application does not limit this.
[0167] 412. Display the target interface of the camera application.
[0168] After the AMS calls the onResume method, the electronic device may display the target interface. For example, the target interface may be a preview interface of a camera application.
[0169] Combine step 402B and step 408, as Figure 5C As shown in (a) of FIG. 5 , the electronic device may display a desktop interface 501, and the desktop interface 501 includes an application icon 502 of a camera application. At a first moment, the desktop application may receive a touch down event of the application icon of the camera application (e.g., application icon 502) by the user, and at a third moment, the desktop application may receive a touch up event of the application icon of the camera application (e.g., application icon 502) by the user. Then, the AMS calls the startActivity method, such as Figure 5C As shown in (b) , the electronic device may display a shooting preview interface 504 .
[0170] Combine step 402D and step 408, such as Figure 5D As shown in (a) of FIG. 1 , the electronic device may display a multitasking management interface 511, and the multitasking management interface 511 includes a card 512 of a camera application. At a first moment, the desktop application may receive a touch down event of the camera application card (e.g., card 512) by the user, and at a third moment, the desktop application may receive a touch up event of the camera application card (e.g., card 512) by the user. Then, the AMS calls the startActivity method, such as Figure 5D As shown in (b) , the electronic device may display a shooting preview interface 513 .
[0171] 413. AMS sets the process of the desktop application as a background process.
[0172] In a possible implementation, the AMS sets the process of the desktop application as a background process, which may be that the AMS switches the process of the desktop application from a foreground process group to a background process group.
[0173] Exemplarily, the AMS may call the requestProcessGroupChange method to switch the process of the desktop application to the background process group.
[0174] In some possible cases, resource locking may occur when switching the desktop application process to the background process group. For example, assume that the background process group also includes processes of other applications (e.g., game applications). Figure 6 As shown, in the process of switching the process of the desktop application to the background process group, the process of the desktop application needs to access a resource object, and the resource object may have been locked by the process of other applications (e.g., game applications) in the background process group. The desktop application needs to wait for the game application to unlock the resource object before it can access the resource object. Among them, resource locking is a mechanism to prevent multiple processes from accessing resource objects at the same time. When a process is accessing a resource object, the resource object can be locked to prevent other processes from modifying the resource object and causing abnormal process execution. During the period when the resource object is locked, other processes cannot access the locked resource object and need to wait for the locked resource object to be released (the resource object is unlocked) before they can access it. Among them, the resource object may include a memory variable or a device node.
[0175] like Figure 7 As shown, in the related art, after the desktop application receives the lift event, AMS starts the camera application interface (calls startActivity) and calls the lifecycle method (for example, onResume method). Then, AMS switches the desktop application to the background process group, and finally switches the camera application to the foreground process group. In the process of switching the desktop application to the background process group, the desktop application process may not be scheduled in time because other background application processes occupy resources, resulting in a delay in the execution time of switching the camera application to the foreground process group, which causes the camera application to start slowly, giving users a negative experience.
[0176] like Figure 8 As shown, in an embodiment of the present application, after the desktop application receives a press event (the press event is triggered earlier than the lift event), AMS calls an extension method to switch the camera application process to the foreground process group in advance, without waiting for AMS to start the camera application interface, execute life cycle methods (for example, onResume method), and adjust the desktop application to the background process group. After switching the camera application process to the foreground process group, start the camera application interface, execute life cycle methods, and adjust the desktop application to the background process group. In this way, the camera application process can start running on the large-core processor in advance, thereby improving the startup performance of the application.
[0177] 414. Optionally, the AMS sets the process of the camera application as the foreground process.
[0178] In a possible implementation, the AMS may call the requestProcessGroupChange method to set the process of the camera application as the foreground process.
[0179] Among them, the input parameters of the requestProcessGroupChange method may include the identifier of the process, the identifier of the process group in which the process is currently located, and the identifier of the process group to which the process is to be switched. According to the identifier of the process, a specific process (for example, the process of the camera application) can be determined, and according to the identifier of the process group in which the process is currently located and the identifier of the process group to which the process is to be switched, it can be determined from which process group to which process group the process (for example, the process of the camera application) is switched. Among them, the identifier of the process group in which the process is currently located and the identifier of the process group to which the process is to be switched can be the same, for example, both are identifiers of the foreground process group. If the requestProcessGroupChange method determines that the identifier of the process group in which the process is currently located and the identifier of the process group to which the process is to be switched are the same, the method can be exited. For example, if the requestProcessGroupChange method determines that the process group in which the camera application process is currently located is the foreground process group, and the process group to be switched is also the foreground process group, the method can be exited. This method of exiting the method can be called an abnormal completion exit (Abrupt MethodInvocation Completion). This method of exiting the method by abnormal completion exit does not generate a return value.
[0180] Based on the method provided in the embodiment of the present application, at a first moment, after the electronic device receives a press operation on the application icon or card of a first application (e.g., a camera application) on the first interface (e.g., a desktop interface or a multi-tasking management interface) of a second application (e.g., a desktop application), the process of the first application can be switched to the foreground process group, so that the process of the first application can be run on a CPU with strong processing power, thereby improving the startup performance of the application.
[0181] Compared with the related art, after receiving the user's lifting operation on the application icon or card of the application (for example, the third application) (the lifting operation must occur after the pressing operation), the process of the desktop application is switched to the background process group, and then the process of the third application is switched to the foreground process group. This causes the third application to be switched to the foreground process group later, resulting in poor startup performance of the third application. Based on the method provided in the embodiment of the present application, at the first moment, after receiving the user's pressing operation on the first application, the process of the first application can be switched to the foreground process group, so that the process of the first application can be run on the first CPU (CPU with stronger processing power), thereby improving the startup performance of the application (for example, the first application).
[0182] like Fig. 9 As shown, an embodiment of the present application provides a process management method for an application program, which is applied to an electronic device, on which a first application, a second application, and a third application are installed. The method includes:
[0183] 901A. Start the first application and switch the first application from foreground operation to background operation.
[0184] For example, the first application may be a camera application. For step 901A, reference may be made to the relevant description of step 401 .
[0185] 901B. Display a first interface of the second application, where the first interface includes an icon of the first application.
[0186] In some embodiments, the second application may be a desktop application, and the first interface may be a desktop interface or a multitasking management interface. The icon of the first application may be an application icon (icon) or a card. For example, when the first interface is a desktop interface, the icon of the first application may be an application icon (icon) of the first application (e.g., a camera application). When the first interface is a multitasking management interface, the icon of the first application may be a card of the first application (e.g., a camera application).
[0187] In other embodiments, the second application may be a running system application or a third-party application, and the first interface may be a display interface of the system application or the third-party application. The icon of the first application may be a pop-up box or a suspended capsule (also referred to as a label or floating window) of the first application (e.g., a camera application).
[0188] For example, Fig.10 As shown in (a), when the mobile phone displays the first interface (e.g., interface 1001) of the second application (e.g., SMS application), a pop-up box 1002 may be popped up (displayed), and the pop-up box 1002 is the first application (e.g., The user can click on the pop-up box 1002 to enter the first application (for example, Application), that is, trigger the first application display interface. Fig.10 As shown in (b), the mobile phone can display The interface 1003 of the application.
[0189] like Fig.11 As shown in (a), when the mobile phone displays the first interface (e.g., interface 1101) of the second application (e.g., SMS application), a suspended capsule 1102 may be displayed. The suspended capsule 1102 is a first application (e.g., The user can click on the suspension capsule 1004 to enter the first application (for example, Application). Fig.11 As shown in (b), the mobile phone can display The interface 1103 of the application.
[0190] 902. At a first time point, a first operation is received, where the first operation is a user pressing an icon of a first application on a first interface.
[0191] Wherein, if the icon of the first application is an application icon of the first application (e.g., a camera application), reference may be made to the relevant description of step 402B, in which case the first time point may be the first moment. If the icon of the first application is a card of the first application (e.g., a camera application), reference may be made to the relevant description of step 402D, in which case the first time point may be the second moment.
[0192] When the icon of the first application is a pop-up box of the first application (for example, a camera application), a touch down event is triggered when the user's finger (or other body part (for example, elbow)) or input tool (for example, stylus) touches the pop-up box. That is, when the system user interface application (System UI) receives the user's press operation on the message pop-up box of the camera application on the desktop interface, it receives the touch down event. Among them, System UI can be used to manage the pop-up box and respond to the user's operation on the pop-up box.
[0193] For example, Fig.10 As shown in (a) in FIG. 1 , the mobile phone can receive an operation (eg, a pressing operation) performed by the user on the pop-up box 1002 of the camera application.
[0194] When the icon of the first application is a suspended capsule of the first application (e.g., a camera application), a touch down event is triggered when the user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) touches the suspended capsule. That is, when the smart ability application receives the user's pressing operation on the suspended capsule of the camera application, the touch down event is received. The smart ability application can be used to manage the suspended capsule and respond to the user's operation on the suspended capsule.
[0195] For example, Fig.11 As shown in (a) in FIG. 8 , the mobile phone can receive an operation (eg, a pressing operation) performed by a user on the suspended capsule 1102 of the camera application.
[0196] 903. In response to the first operation, set the process of the first application as the foreground process, and use the first CPU to run the process of the first application.
[0197] In some embodiments, in response to the first operation, based on the fact that the first application belongs to a preset application, the process of the first application is set as a foreground process.
[0198] Exemplarily, the fourth application can obtain the application information of the first application, and the application information includes the package name of the second application. Among them, the fourth application is an application for managing the icon of the first application, and the fourth application can be a desktop application, a System UI, or an intelligent capability application. When the second application is a desktop application, and the icon of the first application is the application icon or card of the first application (for example, a camera application), the fourth application is a desktop application. When the second application is a system application or a third-party application, when the icon of the first application is a pop-up box, the fourth application is the System UI, and the SystemUI can obtain the package name of the application to be started (that is, the application corresponding to the message pop-up box) through the context.getPackageName() method. When the icon of the first application is a floating capsule, the fourth application can be an intelligent capability application.
[0199] The fourth application sends the application information of the first application to the AMS by calling the first interface; the AMS determines whether the first application belongs to the preset application based on the application information of the first application; wherein the application information of the preset application is preset in the AMS; if the first application belongs to the preset application, the AMS sets the process of the first application as the foreground process.
[0200] For example, Fig.12As shown, taking the second application as a desktop application, the first interface as a desktop interface, the first application as a camera application, and the fourth application as a desktop application as an example, a method for setting the camera application as a foreground process is described. The method includes: step 1, pressing the icon of the camera application on the desktop interface; step 2, obtaining the application information of the camera application; step 3, the desktop application calls the first interface (first extension interface); step 4, the AMS calls the extension method; step 5, the process of the camera application is set to the foreground process. For the specific process, please refer to Figure 4 The relevant description of the illustrated embodiment will not be repeated here.
[0201] In a possible design, if after receiving the first operation, a second operation is received after a preset time (i.e., a long press operation is received), after setting the process of the first application as the foreground process, the process of the first application can be set as the background process. The specific process can refer to the relevant description of step 408, which will not be repeated here.
[0202] 904. At a second time point, a second operation is received, where the second operation is a lifting operation, and the second time point is later than the first time point.
[0203] Among them, if the icon of the first application is an application icon or card of the first application (for example, a camera application), reference can be made to the relevant description of step 408, and in this case, the second time point may be the third moment.
[0204] When the icon of the first application is a pop-up box of the first application (for example, a camera application), a touchup event is triggered when the user's finger (or other body part (for example, elbow)) or input tool (for example, stylus) leaves the pop-up box of the camera application. That is, when the System UI receives a lifting operation (also referred to as a hand-raising operation or a hand-leaving operation) of the user on the message pop-up box of the camera application on the desktop interface, the touchup event is received.
[0205] When the icon of the first application is a floating capsule of the first application (e.g., a camera application), a touch up event is triggered when the user's finger (or other body part (e.g., elbow)) or input tool (e.g., stylus) leaves the floating capsule of the camera application. That is, when the smart ability application receives a lifting operation (also referred to as a hand-lifting operation or a hand-off operation) of the floating capsule of the camera application by the user on the desktop interface, the touch up event is received.
[0206] 905. In response to the second operation, set the process of the second application as a background process, and use the second CPU to run the process of the second application.
[0207] The processing capability of the first CPU is stronger than that of the second CPU. Exemplarily, the first CPU may be a large-core CPU, and the second CPU may be a small-core CPU or a medium-core CPU. Alternatively, the first CPU may be a medium-core CPU, and the second CPU may be a small-core CPU. The operating frequency of the large-core CPU is higher than that of the small-core CPU or the medium-core CPU. For example, the operating frequency of the small-core processor may be 1.8 GHz. The operating frequency of the medium-core processor may be 2.0 GHz. The operating frequency of the large-core processor may be 2.6 GHz.
[0208] In a possible design, if a second operation is received after a preset time after receiving the first operation, the target menu may be displayed first in response to the second operation. The target menu includes a function entry of the first application; then a sixth operation of the user on the target menu is received; in response to the sixth operation, the process of the second application is set as a background process. The specific process can be referred to the relevant description of step 408, which will not be repeated here.
[0209] It should be noted that steps 901 to 905 are a process management method for a first application provided by the present application when the application (e.g., the first application) is hot-started. Based on steps 901 to 905, at a first time point, after receiving a user's press operation on the first application, the process of the first application can be set as a foreground process, so that the process of the first application can be run on the first CPU (a CPU with stronger processing power), thereby improving the startup performance of the application (e.g., the first application).
[0210] 906. Kill the process of the first application.
[0211] 907. In response to the third operation, display the first interface.
[0212] 908. At a third time point, a fourth operation is received, where the fourth operation is a pressing operation on the icon of the first application on the first interface.
[0213] 909. At a fourth time point, a fifth operation is received, the fifth operation is a lifting operation, and the fourth time point is later than the third time point.
[0214] 910. In response to the fifth operation, the process of the second application is set as a background process, and the process of the first application is set as a foreground process.
[0215] It should be noted that steps 906 to 910 are a process management method for the first application when the application (for example, the first application) is cold started. In this method, after receiving the user's lift operation on the icon of the first application (the lift operation must occur after the press operation), the process of the second application (for example, the desktop application) is set as the background process, and then the process of the first application is set as the foreground process. This is because when the first application is cold started, in response to the user's press operation on the icon of the first application, the process of the first application cannot be set as the foreground process because the process of the first application has not been created. Therefore, in the scenario of cold start of the application (for example, the first application), the startup performance of the application is difficult to improve.
[0216] 911. Start a third application, and switch the third application from running in the foreground to running in the background.
[0217] 912. Display a second interface of the second application, where the second interface includes an icon of a third application.
[0218] When the second application is a desktop application, the second interface includes a desktop interface or a multi-task management interface. The icon of the third application may include the third application.
[0219] 913. At the fifth time point, a sixth operation is received, where the sixth operation is a pressing operation on the icon of the third application on the second interface.
[0220] 914. At a sixth time point, a seventh operation is received, the seventh operation is a lifting operation, and the sixth time point is later than the fifth time point.
[0221] 915. In response to the seventh operation, the process of the second application is set as a background process, and the process of the third application is set as a foreground process.
[0222] It should be noted that steps 911-915 are a process management method of the related technology when an application (for example, a third application) is hot-started. In this method, after receiving the user's lifting operation on the icon of the third application (the lifting operation must occur after the pressing operation), the process of the second application (for example, a desktop application) is set as a background process, and then the process of the third application is set as a foreground process, which results in poor startup performance of the third application. Based on the method provided in the embodiment of the present application, in the scenario of hot-starting an application (for example, a first application), based on steps 901-905, at a first time point, after receiving the user's pressing operation on the first application, the process of the first application can be set as a foreground process, so that the process of the first application can be run on the first CPU (a CPU with stronger processing power), thereby improving the startup performance of the application (for example, the first application).
[0223] Some embodiments of the present application provide an electronic device, which may include: a touch screen, a memory, and one or more processors. The touch screen, the memory, and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor runs the computer instructions, the electronic device can perform the various functions or steps performed by the electronic device in the above method embodiment. The structure of the electronic device can refer to Figure 2 The structure of the electronic device 100 is shown.
[0224] The present application also provides a chip system (eg, a system on a chip (SoC)), such as Fig.13 As shown, the chip system includes at least one processor 1301 and at least one interface circuit 1302. The processor 1301 and the interface circuit 1302 can be interconnected via lines. For example, the interface circuit 1302 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 1302 can be used to send signals to other devices (such as a processor 1301 or a touch screen of an electronic device). Exemplarily, the interface circuit 1302 can read instructions stored in the memory and send the instructions to the processor 1301. When the instructions are executed by the processor 1301, the electronic device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.
[0225] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the electronic device (for example, a mobile phone) in the above-mentioned method embodiment.
[0226] The embodiment of the present application also provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes each function or step executed by the electronic device (eg, a mobile phone) in the above method embodiment.
[0227] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0228] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0229] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0230] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0231] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0232] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A process management method for an application, characterized in that: Applied to an electronic device, the electronic device has a first application, a second application, a fourth application and an activity management service AMS installed thereon, the method comprising: Starting the first application and switching the first application from foreground operation to background operation; Displaying a first interface of the second application, where the first interface includes an icon of the first application; At a first time point, receiving a first operation, where the first operation is a pressing operation on an icon of the first application on the first interface; The fourth application obtains application information of the first application, where the application information includes a package name of the first application, and the fourth application is used to manage an icon of the first application; The fourth application calls the first interface to send application information of the first application to the AMS; The AMS determines whether the first application is a preset application according to the application information of the first application; The AMS sets the process of the first application as a foreground process based on that the first application belongs to the preset application, and uses a first central processing unit (CPU) to run the process of the first application; At a second time point, receiving a second operation, where the second operation is a lifting operation, and the second time point is later than the first time point; In response to the second operation, the interface of the first application is started, the onResume method is executed, the process of the second application is set as a background process, and the process of the second application is run by the second CPU, and the processing capability of the first central processing unit CPU is stronger than the processing capability of the second CPU; Killing the process of the first application; In response to a third operation, displaying the first interface; At a third time point, receiving a fourth operation, where the fourth operation is a pressing operation on the icon of the first application on the first interface; At a fourth time point, a fifth operation is received, the fifth operation being a lifting operation, and the fourth time point is later than the third time point; In response to the fifth operation, the process of the second application is set as a background process, and the process of the first application is set as a foreground process.
2. The method according to claim 1, characterized in that The electronic device also has a third application installed thereon, and the method further includes: Starting the third application and switching the third application from foreground operation to background operation; Displaying a second interface of the second application, where the second interface includes an icon of the third application; At a fifth time point, receiving a sixth operation, where the sixth operation is a pressing operation on the icon of the third application on the second interface; At a sixth time point, a seventh operation is received, the seventh operation being a lifting operation, and the sixth time point is later than the fifth time point; In response to the seventh operation, the process of the second application is set as a background process, and the process of the third application is set as a foreground process.
3. The method according to claim 2, characterized in that Based on the fact that the third application does not belong to the preset application, the process of the third application is not set as the foreground process between the fifth time point and the sixth time point.
4. The method according to claim 1, characterized in that: The preset application meets at least one of the following conditions: The usage frequency of the preset application is higher than a first threshold; or The resources required to run the preset application are greater than a second threshold.
5. The method according to claim 1, characterized in that The preset application includes a camera application, a video application or a game application.
6. The method according to claim 1 or 2, characterized in that: If the second operation is received after a preset time after the first operation is received, after setting the process of the first application as the foreground process in response to the first operation, the method further includes: The process of the first application is set as a background process.
7. The method according to claim 1 or 2, characterized in that: If the second operation is received after a preset time after the first operation is received, then in response to the second operation, setting the process of the second application as a background process includes: In response to the second operation, displaying a target menu, the target menu including a function entry of the first application; receiving a sixth operation on the target menu; In response to the sixth operation, the process of the second application is set as a background process.
8. The method according to claim 1 or 2, characterized in that: The second application is a desktop application; The first interface includes a desktop interface or a multi-task management interface.
9. The method according to claim 1, characterized in that: The fourth application includes a desktop application or a system user interface application.
10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to run a computer program stored in a memory, so that the electronic device implements the method according to any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Process management method and device, electronic equipment and storage medium
CN112882624A
Application keep-alive method and terminal device
CN112988282A
