[go: up one dir, main page]

CN111722919B - Method, device, storage medium and electronic device for running background application - Google Patents

Method, device, storage medium and electronic device for running background application Download PDF

Info

Publication number
CN111722919B
CN111722919B CN201910218703.4A CN201910218703A CN111722919B CN 111722919 B CN111722919 B CN 111722919B CN 201910218703 A CN201910218703 A CN 201910218703A CN 111722919 B CN111722919 B CN 111722919B
Authority
CN
China
Prior art keywords
application
target application
usage time
cpu
background
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910218703.4A
Other languages
Chinese (zh)
Other versions
CN111722919A (en
Inventor
刘立伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201910218703.4A priority Critical patent/CN111722919B/en
Publication of CN111722919A publication Critical patent/CN111722919A/en
Application granted granted Critical
Publication of CN111722919B publication Critical patent/CN111722919B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure relates to a method, an apparatus, a storage medium, and an electronic device for running an application program, where the method includes: determining a target application program operated by a foreground; monitoring whether the target application program is switched from a foreground operation to a background operation; and when the target application program is switched from the foreground operation to the background operation, limiting the use time of the target application program to the CPU of the central processing unit so as to improve the use time of the application program running in the foreground to the CPU.

Description

运行后台应用程序的方法、装置、存储介质及电子设备Method, device, storage medium and electronic device for running background application

技术领域Technical Field

本公开涉及通信技术领域,尤其涉及一种运行后台应用程序的方法、装置、存储介质及电子设备。The present disclosure relates to the field of communication technology, and in particular to a method, device, storage medium and electronic device for running a background application.

背景技术Background technique

如今电子设备中的应用程序在不使用时,会进入电子设备的后台,但是,维持后台应用程序的正常运行需要消耗CPU(Central Processing Unit,中央处理器)资源,可能会引起前台程序卡顿、功率消耗过大等问题。Nowadays, when applications in electronic devices are not in use, they will enter the background of the electronic devices. However, maintaining the normal operation of background applications requires consuming CPU (Central Processing Unit) resources, which may cause problems such as foreground program lag and excessive power consumption.

发明内容Summary of the invention

为克服相关技术中存在的问题,本公开提供一种运行后台应用程序的方法、装置、存储介质及电子设备。In order to overcome the problems existing in the related art, the present disclosure provides a method, device, storage medium and electronic device for running a background application.

根据本公开实施例的第一方面,提供一种运行后台应用程序的方法,包括确定前台运行的目标应用程序;监测所述目标应用程序是否由前台运行切换为后台运行;在所述目标应用程序由所述前台运行切换为所述后台运行时,限制所述目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对所述CPU的使用时间。According to a first aspect of an embodiment of the present disclosure, a method for running a background application is provided, including determining a target application running in the foreground; monitoring whether the target application switches from foreground operation to background operation; and when the target application switches from foreground operation to background operation, limiting the usage time of a central processing unit (CPU) by the target application to increase the usage time of the CPU by the application running in the foreground.

可选地,所述限制所述目标应用程序对CPU的使用时间包括:获取预先设置的后台应用分组,其中,所述后台应用分组中全部应用程序对所述CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;所述第一使用时间占用率为所述后台应用分组中,每个应用程序对所述CPU的使用时间的总和与所述CPU的总使用时间的比值;将所述目标应用程序添加至所述后台应用分组。Optionally, limiting the CPU usage time of the target application includes: obtaining a preset background application group, wherein a first usage time occupancy rate of the CPU usage time of all applications in the background application group is less than or equal to a first preset occupancy rate threshold; the first usage time occupancy rate is the ratio of the sum of the CPU usage time of each application in the background application group to the total CPU usage time; and adding the target application to the background application group.

可选地,所述限制所述目标应用程序对CPU的使用时间包括:控制所述目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,所述第二使用时间占用率为所述目标应用程序对CPU的使用时间与所述CPU的总使用时间的比值。Optionally, limiting the CPU usage time of the target application includes: controlling a second CPU usage time occupancy rate of the target application to be less than or equal to a second preset occupancy rate threshold, the second CPU usage time occupancy rate being the ratio of the CPU usage time of the target application to the total CPU usage time.

可选地,在限制所述目标应用程序对CPU的使用时间前,所述方法还包括:确定所述目标应用程序是否为预先设置的可信任应用程序;所述限制所述目标应用程序对CPU的使用时间包括:在确定所述目标应用程序不是所述可信任应用程序时,限制所述目标应用程序对所述CPU的使用时间。Optionally, before limiting the target application's CPU usage time, the method further includes: determining whether the target application is a pre-set trusted application; limiting the target application's CPU usage time includes: when it is determined that the target application is not the trusted application, limiting the target application's CPU usage time.

可选地,在限制所述目标应用程序对CPU的使用时间后,所述方法还包括:在所述目标应用程序由所述后台运行切换为所述前台运行时,取消所述目标应用程序对所述CPU的使用时间的限制。Optionally, after limiting the usage time of the CPU by the target application, the method further comprises: when the target application switches from running in the background to running in the foreground, canceling the limitation on the usage time of the CPU by the target application.

根据本公开实施例的第二方面,提供一种运行应用程序的装置,包括目标确定模块,被配置为确定前台运行的目标应用程序;监测模块,被配置为监测所述目标应用程序是否由前台运行切换为后台运行;处理模块,被配置为在所述目标应用程序由所述前台运行切换为所述后台运行时,限制所述目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对所述CPU的使用时间。According to a second aspect of an embodiment of the present disclosure, a device for running an application is provided, comprising a target determination module, configured to determine a target application running in the foreground; a monitoring module, configured to monitor whether the target application is switched from foreground operation to background operation; and a processing module, configured to limit the usage time of a central processing unit (CPU) by the target application when the target application is switched from foreground operation to background operation, so as to increase the usage time of the CPU by the application running in the foreground.

可选地,所述处理模块被配置为:在所述目标应用程序由所述前台运行切换为所述后台运行时,获取预先设置的后台应用分组,其中,所述后台应用分组中全部应用程序对所述CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;所述第一使用时间占用率为所述后台应用分组中,每个应用程序对所述CPU的使用时间的总和与所述CPU的总使用时间的比值;将所述目标应用程序添加至所述后台应用分组。Optionally, the processing module is configured to: when the target application switches from the foreground operation to the background operation, obtain a pre-set background application group, wherein a first usage time occupancy rate of the CPU usage time of all applications in the background application group is less than or equal to a first preset occupancy rate threshold; the first usage time occupancy rate is the ratio of the sum of the CPU usage time of each application in the background application group to the total CPU usage time; and add the target application to the background application group.

可选地,所述处理模块被配置为:在所述目标应用程序由所述前台运行切换为所述后台运行时,控制所述目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,所述第二使用时间占用率为所述目标应用程序对CPU的使用时间与所述CPU的总使用时间的比值。Optionally, the processing module is configured to: when the target application switches from the foreground operation to the background operation, control the second usage time occupancy rate of the target application on the CPU to be less than or equal to a second preset occupancy rate threshold, and the second usage time occupancy rate is the ratio of the CPU usage time of the target application to the total CPU usage time.

可选地,所述装置还包括:信任确定模块,被配置为确定所述目标应用程序是否为预先设置的可信任应用程序;所述处理模块,被配置为在所述目标应用程序由所述前台运行切换为所述后台运行时,在确定所述目标应用程序不是所述可信任应用程序时,限制所述目标应用程序对所述CPU的使用时间。Optionally, the device also includes: a trust determination module, configured to determine whether the target application is a pre-set trusted application; the processing module, configured to limit the target application's use of the CPU time when it is determined that the target application is not the trusted application when the target application switches from the foreground operation to the background operation.

可选地,所述装置还包括:取消限制模块,被配置为在所述目标应用程序由所述后台运行切换为所述前台运行时,取消所述目标应用程序对所述CPU的使用时间的限制。Optionally, the device further comprises: a restriction cancelling module configured to cancel the restriction on the CPU usage time of the target application when the target application switches from running in the background to running in the foreground.

根据本公开实施例的第三方面,提供一种计算机可读存储介质,其上存储有计算机程序指令,该程序指令被处理器执行时实现本公开第一方面所提供的运行应用程序的方法的步骤。According to a third aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the method for running an application provided in the first aspect of the present disclosure are implemented.

根据本公开实施例的第四方面,提供一种电子设备,包括本公开第二方面所提供的运行应用程序的装置。According to a fourth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising the device for running an application provided by the second aspect of the present disclosure.

本公开的实施例提供的技术方案可以在应用程序进入后台时,限制后台应用程序对CPU的使用,从而减少后台应用程序对CPU功率的消耗,并且提高了前台运行的应用程序对CPU的使用,增加了前台应用程序的运行性能。The technical solution provided by the embodiments of the present disclosure can limit the use of the CPU by background applications when the applications enter the background, thereby reducing the consumption of CPU power by background applications, and improve the use of the CPU by applications running in the foreground, thereby increasing the operating performance of the foreground applications.

应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

图1是根据一示例性实施例示出的一种运行应用程序的方法的流程图。Fig. 1 is a flowchart showing a method for running an application according to an exemplary embodiment.

图2是根据另一示例性实施例示出的一种运行应用程序的方法的流程图。Fig. 2 is a flow chart showing a method for running an application according to another exemplary embodiment.

图3是根据另一示例性实施例示出的一种运行应用程序的方法的流程图。Fig. 3 is a flowchart showing a method for running an application according to another exemplary embodiment.

图4是根据一示例性实施例示出的一种运行应用程序的装置的框图。Fig. 4 is a block diagram showing a device for running an application according to an exemplary embodiment.

图5是根据另一示例性实施例示出的一种运行应用程序的装置的框图。Fig. 5 is a block diagram showing a device for running an application according to another exemplary embodiment.

图6是根据另一示例性实施例示出的一种运行应用程序的装置的框图。Fig. 6 is a block diagram showing a device for running an application according to another exemplary embodiment.

图7是根据一示例性实施例示出的一种电子设备的框图。Fig. 7 is a block diagram of an electronic device according to an exemplary embodiment.

具体实施方式Detailed ways

这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

图1是根据一示例性实施例示出的一种运行后台应用程序的方法的流程图,如图1所示,该方法可以应用于电子设备,该方法包括以下步骤。Fig. 1 is a flow chart showing a method for running a background application according to an exemplary embodiment. As shown in Fig. 1 , the method can be applied to an electronic device, and the method includes the following steps.

在步骤S101中,确定前台运行的目标应用程序。In step S101, a target application running in the foreground is determined.

在步骤S102中,监测该目标应用程序是否由前台运行切换为后台运行。In step S102, it is monitored whether the target application is switched from foreground operation to background operation.

其中,当目标应用程序被打开并正在被用户使用时,目标应用程序会在前台运行,其操作页面也会在前台显示,当退出该目标应用程序的操作页面但未关闭该目标应用程序时,该目标应用程序会在后台运行。When the target application is opened and being used by the user, the target application will run in the foreground and its operation page will also be displayed in the foreground. When the operation page of the target application is exited but the target application is not closed, the target application will run in the background.

在本实施例中,目标应用程序可以运行在该电子设备上,该电子设备可以为具有不同操作系统的手机,例如安卓(Android)手机、苹果手机等。In this embodiment, the target application can be run on the electronic device, and the electronic device can be a mobile phone with different operating systems, such as an Android phone, an Apple phone, etc.

当该电子设备为安卓手机时,该手机可以基于Android系统提供的组件管理服务注册监听器,并通过该监听器监测当前应用程序的前后台切换状态。When the electronic device is an Android phone, the phone can register a listener based on the component management service provided by the Android system, and monitor the foreground and background switching status of the current application through the listener.

当然,上述应用程序前后台运行具体的监测过程可以参考现有技术中应用程序前后台运行的监测,此处不再赘述。Of course, the specific monitoring process of the foreground and background running of the above application can refer to the monitoring of the foreground and background running of the application in the prior art, which will not be repeated here.

在步骤S103中,在该目标应用程序由该前台运行切换为该后台运行时,限制该目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对该CPU的使用时间。In step S103, when the target application is switched from the foreground operation to the background operation, the usage time of the central processing unit (CPU) by the target application is limited to increase the usage time of the CPU by the foreground application.

在本步骤中,可以通过以下两种实现方式中的任一种限制该目标应用程序对中央处理器CPU的使用时间:In this step, the target application can limit the CPU usage time by using either of the following two implementation methods:

方式一,获取预先设置的后台应用分组,并将该目标应用程序添加至该后台应用分组。Method 1: obtain a preset background application group, and add the target application to the background application group.

其中,该后台应用分组中全部应用程序对该CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;该第一使用时间占用率为该后台应用分组中每个应用程序对该CPU的使用时间的总和与该CPU的总使用时间的比值。该第一使用时间占用率可以通过修改后台应用分组的CPU.shares文件中的CPU时间占用值实现,该后台应用分组的CPU.shares文件中的CPU时间占用值即可表征后台应用分组中的全部应用程序对该CPU的使用时间,当该CPU时间占用值越大,则表示该后台应用分组中的全部应用程序使用该CPU的时间越长,该CPU时间占用值的默认值为1024,该CPU时间占用值与默认值的比值即为CPU的使用时间占用率。Among them, the first usage time occupancy rate of the usage time of the CPU by all applications in the background application group is less than or equal to the first preset occupancy rate threshold; the first usage time occupancy rate is the ratio of the sum of the usage time of the CPU by each application in the background application group to the total usage time of the CPU. The first usage time occupancy rate can be achieved by modifying the CPU time occupancy value in the CPU.shares file of the background application group. The CPU time occupancy value in the CPU.shares file of the background application group can represent the usage time of the CPU by all applications in the background application group. The larger the CPU time occupancy value, the longer the CPU is used by all applications in the background application group. The default value of the CPU time occupancy value is 1024. The ratio of the CPU time occupancy value to the default value is the CPU usage time occupancy rate.

例如,当目标应用程序从前台运行切换为后台运行时,将该目标应用程序加入后台应用分组,该第一预设占用率阈值可以为5%,则可以将该后台应用分组的CPU.shares文件中的CPU时间占用值预先设置为52,即该后台应用分组的CPU使用时间为CPU总使用时间的5%(52÷1024×100%=5%);当该后台应用分组中有一个目标应用程序时,该目标应用程序的CPU使用时间为CPU总使用时间的5%,当该后台应用分组中有两个目标应用程序时,该两个目标应用程序(即该后台应用分组中的所有应用程序)的CPU使用时间为CPU总使用时间的5%。For example, when the target application switches from foreground operation to background operation, the target application is added to the background application group. The first preset occupancy rate threshold may be 5%, and the CPU time occupancy value in the CPU.shares file of the background application group may be pre-set to 52, that is, the CPU usage time of the background application group is 5% of the total CPU usage time (52÷1024×100%=5%); when there is one target application in the background application group, the CPU usage time of the target application is 5% of the total CPU usage time; when there are two target applications in the background application group, the CPU usage time of the two target applications (that is, all applications in the background application group) is 5% of the total CPU usage time.

方式二,控制该目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,该第二使用时间占用率为该目标应用程序对CPU的使用时间与该CPU的总使用时间的比值。同样地,该第二使用时间占用率也可以通过修改应用程序的CPU.shares文件中的CPU时间占用值实现,同样地,该应用程序的CPU时间占用值即可表征该应用程序对该CPU的使用时间,当该CPU时间占用值越大,则表示该应用程序使用该CPU的时间越长,该CPU时间占用值的默认值为1024。Method 2: Control the second usage time occupancy rate of the target application to be less than or equal to the second preset occupancy rate threshold, and the second usage time occupancy rate is the ratio of the usage time of the target application to the total usage time of the CPU. Similarly, the second usage time occupancy rate can also be achieved by modifying the CPU time occupancy value in the CPU.shares file of the application. Similarly, the CPU time occupancy value of the application can represent the usage time of the application on the CPU. The larger the CPU time occupancy value, the longer the application uses the CPU. The default value of the CPU time occupancy value is 1024.

例如,该第二预设占用率阈值可以为2.5%,当该目标应用程序从前台运行切换为后台运行时,可以将该目标应用程序的CPU时间占用值被设置为25,则该第二使用时间占用率为25/1024即2.4%,该应用程序的CPU使用时间为CPU总使用时间的2.4%,可以在不关闭该应用程序的前提下限制该应用程序对CPU的占用时间。For example, the second preset occupancy rate threshold can be 2.5%. When the target application switches from foreground operation to background operation, the CPU time occupancy value of the target application can be set to 25. Then the second usage time occupancy rate is 25/1024, which is 2.4%. The CPU usage time of the application is 2.4% of the total CPU usage time. The CPU occupancy time of the application can be limited without closing the application.

需要说明的是,上述方式一和方式二的区别在于,方式一限制的是全部后台运行的应用程序对CPU的使用时间的总和,而方式二则是限制每个后台运行的应用程序对CPU的使用时间。It should be noted that the difference between the above-mentioned method 1 and method 2 is that method 1 limits the total CPU usage time of all background running applications, while method 2 limits the CPU usage time of each background running application.

在一种可能的实现方式中,在该目标应用程序由该后台运行切换为该前台运行时,取消该目标应用程序对该CPU的使用时间的限制。对应地,当使用方式一限制该目标应用程序对CPU的使用时间时,可以在该目标应用程序由后台运行切换为前台运行时,将该目标应用程序从该后台分组中移除;当使用方式二限制该目标应用程序对CPU的使用时间时,可以在该目标应用程序由后台运行切换为前台运行时还原对目标应用程序的CPU时间占用值的修改。In a possible implementation, when the target application is switched from the background operation to the foreground operation, the restriction on the CPU usage time of the target application is cancelled. Correspondingly, when the first method is used to limit the CPU usage time of the target application, the target application can be removed from the background group when the target application is switched from the background operation to the foreground operation; when the second method is used to limit the CPU usage time of the target application, the modification of the CPU time occupancy value of the target application can be restored when the target application is switched from the background operation to the foreground operation.

通过这种方法,在应用程序进入后台时,限制后台应用程序对CPU的使用,从而减少后台应用程序对CPU功率的消耗,并且提高了前台运行的应用程序对CPU的使用,增加了前台应用程序的运行性能。Through this method, when an application enters the background, the use of the CPU by the background application is limited, thereby reducing the CPU power consumption of the background application, and increasing the use of the CPU by the foreground application, thereby improving the running performance of the foreground application.

图2是根据另一示例性实施例示出的一种运行后台应用程序的方法的流程图。参照图2,该方法包括以下步骤。Fig. 2 is a flow chart showing a method for running a background application according to another exemplary embodiment. Referring to Fig. 2 , the method includes the following steps.

在步骤S201中,确定前台运行的目标应用程序。In step S201, a target application running in the foreground is determined.

在步骤S202中,监测该目标应用程序是否由前台运行切换为后台运行。In step S202, it is monitored whether the target application is switched from foreground operation to background operation.

其中,当目标应用程序被打开并正在被用户使用时,目标应用程序会在前台运行,其操作页面也会在前台显示,当退出该目标应用程序的操作页面但未关闭该目标应用程序时,该目标应用程序会在后台运行。When the target application is opened and being used by the user, the target application will run in the foreground and its operation page will also be displayed in the foreground. When the operation page of the target application is exited but the target application is not closed, the target application will run in the background.

在本实施例中,目标应用程序可以运行在电子设备上,该电子设备可以为具有不同操作系统的手机,例如安卓(Android)手机、苹果手机等。In this embodiment, the target application may be run on an electronic device, which may be a mobile phone with different operating systems, such as an Android phone, an Apple phone, etc.

当该电子设备为安卓手机时,该手机可以基于Android系统提供的组件管理服务注册监听器,并通过该监听器监测当前应用程序的前后台切换状态。When the electronic device is an Android phone, the phone can register a listener based on the component management service provided by the Android system, and monitor the foreground and background switching status of the current application through the listener.

当然,上述应用程序前后台运行具体的监测过程可以参考现有技术中应用程序前后台运行的监测,此处不再赘述。Of course, the specific monitoring process of the foreground and background running of the above application can refer to the monitoring of the foreground and background running of the application in the prior art, which will not be repeated here.

当该目标应用程序未由该前台运行切换为该后台运行时,不限制目标应用程序对CPU的使用时间占用率。When the target application is not switched from the foreground operation to the background operation, the CPU usage time occupancy rate of the target application is not limited.

当该目标应用程序由该前台运行切换为该后台运行时,执行步骤S203。When the target application is switched from the foreground operation to the background operation, step S203 is executed.

步骤S203中,确定该目标应用程序是否为预先设置的可信任应用程序。In step S203, it is determined whether the target application is a preset trusted application.

在本步骤中,可以获取可信任应用程序的列表,并判断该目标应用程序是否在该可信任应用程序的列表中。当该目标应用程序在该可信任应用程序的列表中时,可以确定该目标应用程序为可信任的应用程序,当该目标应用程序不在该可信任应用程序的列表中时,可以确定该目标应用程序不是该可信任应用程序。In this step, a list of trusted applications can be obtained, and it can be determined whether the target application is in the list of trusted applications. When the target application is in the list of trusted applications, it can be determined that the target application is a trusted application, and when the target application is not in the list of trusted applications, it can be determined that the target application is not the trusted application.

当确定该目标应用程序为可信任的应用程序时,不限制目标应用程序对CPU的使用时间占用率。When the target application is determined to be a trusted application, the CPU usage time occupancy rate of the target application is not restricted.

当确定该目标应用程序不是该可信任应用程序时,执行步骤S204。When it is determined that the target application is not the trusted application, step S204 is executed.

在步骤204中,获取预先设置的后台应用分组,其中,该后台应用分组中的全部应用程序对该CPU的使用时间占有率总和小于或者等于预设占用率阈值。In step 204, a preset background application group is obtained, wherein the total usage time occupancy of the CPU by all application programs in the background application group is less than or equal to a preset occupancy threshold.

其中,该后台应用分组中的全部应用程序对该CPU的使用时间占有率总和是该后台应用分组中的全部应用程序对该CPU的使用时间总和与该CPU的总使用时间的比值。通过限制该后台应用分组的CPU使用时间,可以限制该分组中的应用程序的CPU使用时间,使该后台应用分组中的全部应用程序对该CPU的使用时间总和与该CPU的总使用时间的比值小于或者等于预设占用率阈值。使用时间占用率可以通过修改后台应用分组的CPU.shares文件中的CPU时间占用值实现,该后台应用分组的CPU.shares文件中的CPU时间占用值即可表征后台应用分组中的全部应用程序对该CPU的使用时间,当该CPU时间占用值越大,则表示该后台应用分组中的全部应用程序使用该CPU的时间越长,该CPU时间占用值的默认值为1024,该CPU时间占用值与默认值的比值即为CPU的使用时间占用率。Among them, the sum of the usage time occupancy of all applications in the background application group on the CPU is the ratio of the sum of the usage time of all applications in the background application group on the CPU to the total usage time of the CPU. By limiting the CPU usage time of the background application group, the CPU usage time of the applications in the group can be limited, so that the ratio of the sum of the usage time of all applications in the background application group on the CPU to the total usage time of the CPU is less than or equal to the preset occupancy threshold. The usage time occupancy rate can be achieved by modifying the CPU time occupancy value in the CPU.shares file of the background application group. The CPU time occupancy value in the CPU.shares file of the background application group can represent the usage time of all applications in the background application group on the CPU. The larger the CPU time occupancy value, the longer the time all applications in the background application group use the CPU. The default value of the CPU time occupancy value is 1024, and the ratio of the CPU time occupancy value to the default value is the CPU usage time occupancy rate.

例如,该预设占用率阈值可以为5%,则可以将该后台应用分组的CPU.shares文件中的CPU时间占用值预先设置为52,即该后台应用分组的CPU使用时间为CPU总使用时间的5%(52÷1024×100%=5%);当该后台应用分组中有一个目标应用程序时,该目标应用程序的CPU使用时间为CPU总使用时间的5%,当该后台应用分组中有两个目标应用程序时,该两个目标应用程序(即该后台应用分组中的所有应用程序)的CPU使用时间为CPU总使用时间的5%。For example, the preset occupancy rate threshold may be 5%, and the CPU time occupancy value in the CPU.shares file of the background application group may be pre-set to 52, that is, the CPU usage time of the background application group is 5% of the total CPU usage time (52÷1024×100%=5%); when there is one target application in the background application group, the CPU usage time of the target application is 5% of the total CPU usage time; when there are two target applications in the background application group, the CPU usage time of the two target applications (that is, all applications in the background application group) is 5% of the total CPU usage time.

步骤S205中,将该目标应用程序添加至该后台应用分组。In step S205, the target application is added to the background application group.

当该目标应用程序被添加至该后台应用分组以后,由于该后台应用分组中的所有应用程序的CPU使用时间对CPU总使用时间会被限制,所以该目标应用程序对CPU的使用时间会被限制。例如,当该后台应用分组的CPU使用时间占用率为5%时,该目标应用程序的最大CPU使用时间占用率为5%,当该后台应用分组中还有其他目标应用程序时,该目标应用程序与该其他目标应用程序对CPU总使用时间占用率的最大值为5%。After the target application is added to the background application group, the CPU usage time of the target application will be limited because the CPU usage time of all applications in the background application group will be limited to the total CPU usage time. For example, when the CPU usage time occupancy rate of the background application group is 5%, the maximum CPU usage time occupancy rate of the target application is 5%. When there are other target applications in the background application group, the maximum value of the total CPU usage time occupancy rate of the target application and the other target applications is 5%.

步骤S206中,在该目标应用程序由该后台运行切换为该前台运行时,将该目标应用程序从该后台应用分组中移除。In step S206, when the target application is switched from the background operation to the foreground operation, the target application is removed from the background application group.

当该目标应用程序由后台运行切换为前台运行时,可以将该目标应用程序从该后台应用分组中去除,在离开该后台应用分组后,该目标应用程序对CPU的使用时间将不受该后台应用分组对CPU的使用时间的限制。When the target application is switched from background operation to foreground operation, the target application can be removed from the background application group. After leaving the background application group, the CPU usage time of the target application will not be limited by the CPU usage time of the background application group.

通过这种方法,在应用程序进入后台时,限制后台应用程序对CPU的使用,从而减少后台应用程序对CPU功率的消耗,并且提高了前台运行的应用程序对CPU的使用,增加了前台应用程序的运行性能。Through this method, when an application enters the background, the use of the CPU by the background application is limited, thereby reducing the CPU power consumption of the background application, and increasing the use of the CPU by the foreground application, thereby improving the running performance of the foreground application.

图3是根据另一示例性实施例示出的一种运行后台应用程序的方法的流程图。参照图3,该方法包括以下步骤。Fig. 3 is a flow chart showing a method for running a background application according to another exemplary embodiment. Referring to Fig. 3 , the method includes the following steps.

在步骤S301中,确定前台运行的目标应用程序。In step S301, a target application running in the foreground is determined.

在步骤S302中,监测该目标应用程序是否由前台运行切换为后台运行。In step S302, it is monitored whether the target application is switched from foreground operation to background operation.

其中,当目标应用程序被打开并正在被用户使用时,目标应用程序会在前台运行,其操作页面也会在前台显示,当退出该目标应用程序的操作页面但未关闭该目标应用程序时,该目标应用程序会在后台运行。When the target application is opened and being used by the user, the target application will run in the foreground and its operation page will also be displayed in the foreground. When the operation page of the target application is exited but the target application is not closed, the target application will run in the background.

在本实施例中,目标应用程序可以运行在电子设备上,该电子设备可以为具有不同操作系统的手机,例如安卓(Android)手机、苹果手机等。In this embodiment, the target application may be run on an electronic device, which may be a mobile phone with different operating systems, such as an Android phone, an Apple phone, etc.

当该电子设备为安卓手机时,该手机可以基于Android系统提供的组件管理服务注册监听器,并通过该监听器监测当前应用程序的前后台切换状态。When the electronic device is an Android phone, the phone can register a listener based on the component management service provided by the Android system, and monitor the foreground and background switching status of the current application through the listener.

当然,上述应用程序前后台运行具体的监测过程可以参考现有技术中应用程序前后台运行的监测,此处不再赘述。Of course, the specific monitoring process of the foreground and background running of the above application program can refer to the monitoring of the foreground and background running of the application program in the prior art, which will not be repeated here.

当该目标应用程序未由该前台运行切换为该后台运行时,不限制目标应用程序对CPU的使用时间占用率。When the target application is not switched from the foreground operation to the background operation, the CPU usage time occupancy rate of the target application is not limited.

当该目标应用程序由该前台运行切换为该后台运行时,执行步骤S303。When the target application is switched from the foreground operation to the background operation, step S303 is executed.

步骤S303中,确定该目标应用程序是否为预先设置的可信任应用程序。In step S303, it is determined whether the target application is a preset trusted application.

在本步骤中,可以获取可信任应用程序的列表,并判断该目标应用程序是否在该可信任应用程序的列表中。当该目标应用程序在该可信任应用程序的列表中时,可以确定该目标应用程序为可信任的应用程序,当该目标应用程序不在该可信任应用程序的列表中时,可以确定该目标应用程序不是该可信任应用程序。In this step, a list of trusted applications can be obtained, and it can be determined whether the target application is in the list of trusted applications. When the target application is in the list of trusted applications, it can be determined that the target application is a trusted application, and when the target application is not in the list of trusted applications, it can be determined that the target application is not the trusted application.

当确定该目标应用程序为可信任的应用程序时,不限制目标应用程序对CPU的使用时间占用率。When the target application is determined to be a trusted application, the CPU usage time occupancy rate of the target application is not restricted.

当确定该目标应用程序不是该可信任应用程序时,执行步骤S304。When it is determined that the target application is not the trusted application, step S304 is executed.

在步骤S304中,控制该目标应用程序对CPU的使用时间占用率小于或者等于预设占用率阈值。In step S304, the CPU usage time occupancy rate of the target application is controlled to be less than or equal to a preset occupancy rate threshold.

在本步骤中,该使用时间占用率为该目标应用程序对CPU的使用时间与该CPU的总使用时间的比值。该使用时间占用率可以通过修改应用程序的CPU.shares文件中的CPU时间占用值实现,该后台应用分组的CPU.shares文件中的CPU时间占用值即可表征后台应用分组中的全部应用程序对该CPU的使用时间,当该CPU时间占用值越大,则表示该后台应用分组中的全部应用程序使用该CPU的时间越长,该CPU时间占用值的默认值为1024,该CPU时间占用值与默认值的比值即为CPU的使用时间占用率。In this step, the usage time occupancy rate is the ratio of the CPU usage time of the target application to the total CPU usage time. The usage time occupancy rate can be achieved by modifying the CPU time occupancy value in the CPU.shares file of the application. The CPU time occupancy value in the CPU.shares file of the background application group can represent the CPU usage time of all applications in the background application group. The larger the CPU time occupancy value, the longer the CPU is used by all applications in the background application group. The default value of the CPU time occupancy value is 1024. The ratio of the CPU time occupancy value to the default value is the CPU usage time occupancy rate.

例如,该预设占用率阈值可以为2.5%,当该目标应用程序从前台运行切换为后台运行时,可以将该CPU时间占用值被设置为25,则该预设占用率为25/1024即2.4%,该应用程序的CPU使用时间为CPU总使用时间的2.4%,可以在不关闭该应用程序的前提下限制该应用程序对CPU的占用时间。For example, the preset occupancy threshold can be 2.5%. When the target application switches from foreground to background, the CPU time occupancy value can be set to 25. The preset occupancy rate is 25/1024, which is 2.4%. The CPU usage time of the application is 2.4% of the total CPU usage time. The CPU occupancy time of the application can be limited without closing the application.

在步骤S305中,在该目标应用程序由该后台运行切换为该前台运行时,取消该目标应用程序对CPU使用时间占用率的限制。In step S305, when the target application is switched from the background operation to the foreground operation, the restriction on the CPU usage time occupancy rate by the target application is cancelled.

在本步骤中,可以通过还原对CPU时间占用值的修改实现。In this step, the modification of the CPU time usage value can be restored.

通过这种方法,在应用程序进入后台时,限制后台应用程序对CPU的使用,从而减少后台应用程序对CPU功率的消耗,并且提高了前台运行的应用程序对CPU的使用,增加了前台应用程序的运行性能。Through this method, when an application enters the background, the use of the CPU by the background application is limited, thereby reducing the CPU power consumption of the background application, and increasing the use of the CPU by the foreground application, thereby improving the running performance of the foreground application.

图4是根据一示例性实施例示出的一种运行应用程序的装置框图。参照图4,该装置400包括目标确定模块401,监测模块402和处理模块403。Fig. 4 is a block diagram of a device for running an application according to an exemplary embodiment. Referring to Fig. 4 , the device 400 includes a target determination module 401 , a monitoring module 402 and a processing module 403 .

该目标确定模块401被配置为确定前台运行的目标应用程序。The target determination module 401 is configured to determine a target application running in the foreground.

该监测模块402被配置为监测该目标应用程序是否由前台运行切换为后台运行。The monitoring module 402 is configured to monitor whether the target application is switched from foreground operation to background operation.

该处理模块403被配置为在该目标应用程序由该前台运行切换为该后台运行时,限制该目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对该CPU的使用时间。The processing module 403 is configured to limit the usage time of the central processing unit (CPU) of the target application when the target application switches from the foreground operation to the background operation, so as to increase the usage time of the CPU of the foreground application.

可选地,该处理模块403被配置为在该目标应用程序由该前台运行切换为该后台运行时,获取预先设置的后台应用分组,其中,该后台应用分组中全部应用程序对该CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;该第一使用时间占用率为该后台应用分组中,每个应用程序对该CPU的使用时间的总和与该CPU的总使用时间的比值,并将该目标应用程序添加至该后台应用分组。Optionally, the processing module 403 is configured to obtain a pre-set background application group when the target application switches from the foreground operation to the background operation, wherein a first usage time occupancy rate of the CPU usage time of all applications in the background application group is less than or equal to a first preset occupancy rate threshold; the first usage time occupancy rate is the ratio of the sum of the usage time of the CPU by each application in the background application group to the total usage time of the CPU, and the target application is added to the background application group.

可选地,该处理模块403被配置为在该目标应用程序由该前台运行切换为该后台运行时,控制该目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,该第二使用时间占用率为该目标应用程序对CPU的使用时间与该CPU的总使用时间的比值。Optionally, the processing module 403 is configured to control the second CPU usage time occupancy rate of the target application to be less than or equal to a second preset occupancy rate threshold when the target application switches from the foreground operation to the background operation, and the second CPU usage time occupancy rate is the ratio of the CPU usage time of the target application to the total CPU usage time.

可选地,如图5所示,该装置400还包括信任确定模块404。Optionally, as shown in FIG. 5 , the device 400 further includes a trust determination module 404 .

该信任确定模块404被配置为确定该目标应用程序是否为预先设置的可信任应用程序。The trust determination module 404 is configured to determine whether the target application is a preset trusted application.

该处理模块403被配置为在该目标应用程序由该前台运行切换为该后台运行时,在确定该目标应用程序不是该可信任应用程序时,限制该目标应用程序对该CPU的使用时间。The processing module 403 is configured to limit the time the target application uses the CPU when it is determined that the target application is not the trusted application when the target application switches from the foreground operation to the background operation.

可选地,如图6所示,该装置400还包括取消限制模块405。Optionally, as shown in FIG6 , the device 400 further includes a restriction cancellation module 405 .

该取消限制模块405被配置为在该目标应用程序由该后台运行切换为该前台运行时,取消该目标应用程序对该CPU的使用时间的限制。The restriction canceling module 405 is configured to cancel the restriction on the CPU usage time of the target application when the target application switches from the background operation to the foreground operation.

采用上述装置,在应用程序进入后台时,限制后台应用程序对CPU的使用,从而减少后台应用程序对CPU功率的消耗,并且提高了前台运行的应用程序对CPU的使用,增加了前台应用程序的运行性能。By adopting the above device, when an application enters the background, the use of the CPU by the background application is limited, thereby reducing the consumption of CPU power by the background application, and increasing the use of the CPU by the foreground application, thereby improving the operating performance of the foreground application.

关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

本公开还提供一种计算机可读存储介质,其上存储有计算机程序指令,该程序指令被处理器执行时实现本公开提供的运行应用程序的方法的步骤。The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implements the steps of the method for running an application provided by the present disclosure.

图7是根据一示例性实施例示出的一种运行应用程序的电子设备700的框图。例如,电子设备700可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。7 is a block diagram of an electronic device 700 running an application according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

参照图7,电子设备700可以包括以下一个或多个组件:处理组件702,存储器704,电力组件706,多媒体组件708,音频组件710,输入/输出(I/O)的接口712,传感器组件714,以及通信组件716。7 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input/output (I/O) interface 712 , a sensor component 714 , and a communication component 716 .

处理组件702通常控制电子设备700的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件702可以包括一个或多个处理器720来执行指令,以完成运行应用程序的方法的全部或部分步骤。此外,处理组件702可以包括一个或多个模块,便于处理组件702和其他组件之间的交互。例如,处理组件702可以包括多媒体模块,以方便多媒体组件708和处理组件702之间的交互。The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the method of running the application. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.

存储器704被配置为存储各种类型的数据以支持在电子设备700的操作。这些数据的示例包括用于在电子设备700上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器704可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。The memory 704 is configured to store various types of data to support operations on the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

电力组件706为电子设备700的各种组件提供电力。电力组件706可以包括电源管理系统,一个或多个电源,及其他与为电子设备700生成、管理和分配电力相关联的组件。The power component 706 provides power to the various components of the electronic device 700. The power component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.

多媒体组件708包括在该电子设备700和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。该触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与该触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件708包括一个前置摄像头和/或后置摄像头。当电子设备700处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and/or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

音频组件710被配置为输出和/或输入音频信号。例如,音频组件710包括一个麦克风(MIC),当电子设备700处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器704或经由通信组件716发送。在一些实施例中,音频组件710还包括一个扬声器,用于输出音频信号。The audio component 710 is configured to output and/or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.

I/O接口712为处理组件702和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。I/O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

传感器组件714包括一个或多个传感器,用于为电子设备700提供各个方面的状态评估。例如,传感器组件714可以检测到电子设备700的打开/关闭状态,组件的相对定位,例如该组件为电子设备700的显示器和小键盘,传感器组件714还可以检测电子设备700或电子设备700一个组件的位置改变,用户与电子设备700接触的存在或不存在,电子设备700方位或加速/减速和电子设备700的温度变化。传感器组件714可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件714还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件714还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open/closed state of the electronic device 700, the relative positioning of the components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration/deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

通信组件716被配置为便于电子设备700和其他设备之间有线或无线方式的通信。电子设备700可以接入基于通信标准的无线网络,如WiFi,2G或3G,或它们的组合。在一个示例性实施例中,通信组件716经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,该通信组件716还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

在示例性实施例中,电子设备700可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行运行应用程序的方法。In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute a method for running an application.

在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器704,上述指令可由电子设备700的处理器720执行以完成运行应用程序的方法。例如,该非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, which can be executed by a processor 720 of an electronic device 700 to complete the method of running an application. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

本领域技术人员在考虑说明书及实践本公开后,将容易想到本公开的其它实施方案。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1.一种运行应用程序的方法,其特征在于,包括:1. A method for running an application, comprising: 确定前台运行的目标应用程序;Determine the target application running in the foreground; 监测所述目标应用程序是否由前台运行切换为后台运行;Monitoring whether the target application is switched from foreground operation to background operation; 在所述目标应用程序由所述前台运行切换为所述后台运行时,限制所述目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对所述CPU的使用时间;When the target application is switched from the foreground operation to the background operation, limiting the usage time of the central processing unit (CPU) by the target application to increase the usage time of the CPU by the foreground application; 其中,所述限制所述目标应用程序对CPU的使用时间包括:The limiting the CPU usage time of the target application program includes: 获取预先设置的后台应用分组,其中,所述后台应用分组中全部应用程序对所述CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;所述第一使用时间占用率为所述后台应用分组中,每个应用程序对所述CPU的使用时间的总和与所述CPU的总使用时间的比值;Obtaining a preset background application group, wherein a first usage time occupancy rate of the CPU usage time of all application programs in the background application group is less than or equal to a first preset occupancy rate threshold; the first usage time occupancy rate is a ratio of the sum of the CPU usage time of each application program in the background application group to the total CPU usage time; 将所述目标应用程序添加至所述后台应用分组。The target application is added to the background application group. 2.根据权利要求1所述的方法,其特征在于,所述限制所述目标应用程序对CPU的使用时间包括:2. The method according to claim 1, wherein limiting the CPU usage time of the target application comprises: 控制所述目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,所述第二使用时间占用率为所述目标应用程序对CPU的使用时间与所述CPU的总使用时间的比值。The second usage time occupancy rate of the target application on the CPU is controlled to be less than or equal to a second preset occupancy rate threshold, where the second usage time occupancy rate is the ratio of the usage time of the target application on the CPU to the total usage time of the CPU. 3.根据权利要求1所述的方法,其特征在于,在限制所述目标应用程序对CPU的使用时间前,所述方法还包括:3. The method according to claim 1, characterized in that before limiting the CPU usage time of the target application, the method further comprises: 确定所述目标应用程序是否为预先设置的可信任应用程序;Determining whether the target application is a preset trusted application; 所述限制所述目标应用程序对CPU的使用时间包括:The limiting the CPU usage time of the target application comprises: 在确定所述目标应用程序不是所述可信任应用程序时,限制所述目标应用程序对所述CPU的使用时间。When it is determined that the target application is not the trusted application, the usage time of the CPU by the target application is limited. 4.根据权利要求1至3任一项所述的方法,其特征在于,在限制所述目标应用程序对CPU的使用时间后,所述方法还包括:4. The method according to any one of claims 1 to 3, characterized in that after limiting the CPU usage time of the target application, the method further comprises: 在所述目标应用程序由所述后台运行切换为所述前台运行时,取消所述目标应用程序对所述CPU的使用时间的限制。When the target application is switched from the background operation to the foreground operation, the restriction on the use time of the CPU by the target application is cancelled. 5.一种运行应用程序的装置,其特征在于,包括:5. A device for running an application, comprising: 目标确定模块,被配置为确定前台运行的目标应用程序;a target determination module, configured to determine a target application running in the foreground; 监测模块,被配置为监测所述目标应用程序是否由前台运行切换为后台运行;A monitoring module is configured to monitor whether the target application is switched from foreground operation to background operation; 处理模块,被配置为在所述目标应用程序由所述前台运行切换为所述后台运行时,限制所述目标应用程序对中央处理器CPU的使用时间,以提高前台运行的应用程序对所述CPU的使用时间;A processing module is configured to limit the usage time of a central processing unit (CPU) of the target application when the target application switches from the foreground operation to the background operation, so as to increase the usage time of the CPU of the application running in the foreground; 其中,所述处理模块具体被配置为:Wherein, the processing module is specifically configured as follows: 在所述目标应用程序由所述前台运行切换为所述后台运行时,获取预先设置的后台应用分组,其中,所述后台应用分组中全部应用程序对所述CPU的使用时间的第一使用时间占用率小于或者等于第一预设占用率阈值;所述第一使用时间占用率为所述后台应用分组中,每个应用程序对所述CPU的使用时间的总和与所述CPU的总使用时间的比值;When the target application is switched from the foreground operation to the background operation, a preset background application group is obtained, wherein a first usage time occupancy rate of the CPU usage time of all the applications in the background application group is less than or equal to a first preset occupancy rate threshold; and the first usage time occupancy rate is a ratio of the sum of the CPU usage time of each application in the background application group to the total CPU usage time; 将所述目标应用程序添加至所述后台应用分组。The target application is added to the background application group. 6.根据权利要求5所述的装置,其特征在于,所述处理模块被配置为:6. The device according to claim 5, characterized in that the processing module is configured to: 在所述目标应用程序由所述前台运行切换为所述后台运行时,控制所述目标应用程序对CPU的第二使用时间占用率小于或者等于第二预设占用率阈值,所述第二使用时间占用率为所述目标应用程序对CPU的使用时间与所述CPU的总使用时间的比值。When the target application is switched from the foreground operation to the background operation, a second usage time occupancy rate of the CPU by the target application is controlled to be less than or equal to a second preset occupancy rate threshold, and the second usage time occupancy rate is the ratio of the CPU usage time of the target application to the total CPU usage time. 7.根据权利要求5所述的装置,其特征在于,所述装置还包括:7. The device according to claim 5, characterized in that the device further comprises: 信任确定模块,被配置为确定所述目标应用程序是否为预先设置的可信任应用程序;A trust determination module, configured to determine whether the target application is a preset trusted application; 所述处理模块,被配置为在所述目标应用程序由所述前台运行切换为所述后台运行时,在确定所述目标应用程序不是所述可信任应用程序时,限制所述目标应用程序对所述CPU的使用时间。The processing module is configured to limit the use time of the CPU by the target application when it is determined that the target application is not the trusted application when the target application is switched from the foreground operation to the background operation. 8.根据权利要求5至7中任一所述的装置,其特征在于,所述装置还包括:8. The device according to any one of claims 5 to 7, characterized in that the device further comprises: 取消限制模块,被配置为在所述目标应用程序由所述后台运行切换为所述前台运行时,取消所述目标应用程序对所述CPU的使用时间的限制。The restriction canceling module is configured to cancel the restriction on the CPU usage time of the target application when the target application switches from the background operation to the foreground operation. 9.一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,该程序指令被处理器执行时实现权利要求1至4中任一项所述方法的步骤。9. A computer-readable storage medium having computer program instructions stored thereon, wherein the program instructions implement the steps of the method according to any one of claims 1 to 4 when executed by a processor. 10.一种电子设备,其特征在于,包括权利要求5至8中任一项所述的装置。10. An electronic device, characterized by comprising the device according to any one of claims 5 to 8.
CN201910218703.4A 2019-03-21 2019-03-21 Method, device, storage medium and electronic device for running background application Active CN111722919B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910218703.4A CN111722919B (en) 2019-03-21 2019-03-21 Method, device, storage medium and electronic device for running background application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910218703.4A CN111722919B (en) 2019-03-21 2019-03-21 Method, device, storage medium and electronic device for running background application

Publications (2)

Publication Number Publication Date
CN111722919A CN111722919A (en) 2020-09-29
CN111722919B true CN111722919B (en) 2024-06-04

Family

ID=72562170

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910218703.4A Active CN111722919B (en) 2019-03-21 2019-03-21 Method, device, storage medium and electronic device for running background application

Country Status (1)

Country Link
CN (1) CN111722919B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022100009A1 (en) * 2020-11-13 2022-05-19 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method and system for dynamic categorization of applications in user devices
CN114416271B (en) * 2022-01-30 2025-08-12 维沃移动通信有限公司 Application management method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788926A (en) * 2009-12-28 2010-07-28 中兴通讯股份有限公司 Resource allocation method and device for switching J2ME (Java 2 Micro Edition) application platform
CN105573896A (en) * 2015-12-21 2016-05-11 魅族科技(中国)有限公司 Running reminding method and device for application program
CN106648032A (en) * 2016-12-30 2017-05-10 维沃移动通信有限公司 Control method for application program operating in background and mobile terminal
CN107526637A (en) * 2017-08-01 2017-12-29 广东欧珀移动通信有限公司 Applied program processing method, device, mobile terminal and storage medium
CN107526638A (en) * 2017-08-01 2017-12-29 广东欧珀移动通信有限公司 Applied program processing method, device, mobile terminal and storage medium
CN107634867A (en) * 2017-10-25 2018-01-26 广东欧珀移动通信有限公司 Network management method and related products
CN107665038A (en) * 2016-07-29 2018-02-06 三星电子株式会社 Electronic equipment and the method for operating the electronic equipment
CN107729125A (en) * 2017-10-31 2018-02-23 努比亚技术有限公司 Application program resides the management method and mobile terminal on backstage

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788926A (en) * 2009-12-28 2010-07-28 中兴通讯股份有限公司 Resource allocation method and device for switching J2ME (Java 2 Micro Edition) application platform
CN105573896A (en) * 2015-12-21 2016-05-11 魅族科技(中国)有限公司 Running reminding method and device for application program
CN107665038A (en) * 2016-07-29 2018-02-06 三星电子株式会社 Electronic equipment and the method for operating the electronic equipment
CN106648032A (en) * 2016-12-30 2017-05-10 维沃移动通信有限公司 Control method for application program operating in background and mobile terminal
CN107526637A (en) * 2017-08-01 2017-12-29 广东欧珀移动通信有限公司 Applied program processing method, device, mobile terminal and storage medium
CN107526638A (en) * 2017-08-01 2017-12-29 广东欧珀移动通信有限公司 Applied program processing method, device, mobile terminal and storage medium
CN107634867A (en) * 2017-10-25 2018-01-26 广东欧珀移动通信有限公司 Network management method and related products
CN107729125A (en) * 2017-10-31 2018-02-23 努比亚技术有限公司 Application program resides the management method and mobile terminal on backstage

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Power Management for Android Platform by Set CPU;Memon, MH等;《PROCEEDINGS OF THE 10TH INDIACOM - 2016 3RD INTERNATIONAL CONFERENCE ON COMPUTING FOR SUSTAINABLE GLOBAL DEVELOPMENT》;20170104;全文 *
一种基于进程执行行为分析的图形界面交互系统性能评测方法;宋博;陈明宇;樊建平;;计算机学报;20090715(07);全文 *
安卓平台下优化大师软件的设计与实现;方浩;《中国优秀硕士学位论文全文数据库 信息科技辑》;20181215;全文 *

Also Published As

Publication number Publication date
CN111722919A (en) 2020-09-29

Similar Documents

Publication Publication Date Title
US9860844B2 (en) Method and apparatus of temperature control
EP3188066B1 (en) A method and an apparatus for managing an application
KR101723556B1 (en) Method, device, program and recording medium for deleting smart scene
EP2993584A1 (en) Method and device for controlling background application
RU2644533C2 (en) Method and device for displaying message
US20170060320A1 (en) Method for controlling a mobile terminal using a side touch panel
EP3151117A1 (en) Method and device for delaying information broadcasting
CN105183364A (en) Application switching method, application switching device and application switching equipment
CN109669730B (en) Process keep-alive method, device, electronic equipment and medium
US20180139790A1 (en) Methods, apparatuses and storage medium for controlling a wireless connection
CN105653236A (en) Sound volume control method and device and mobile terminal
US20170293494A1 (en) Method and device for starting application interface
CN109413157B (en) Message shielding method and device
CN105653903A (en) Application program authority management method and device
KR102258742B1 (en) Touch signal processing method, apparatus and medium
CN111722919B (en) Method, device, storage medium and electronic device for running background application
US20190012201A1 (en) Method and apparatus for monitoring virtual document object model
CN107436782B (en) Application silent installation method and device
CN105868624A (en) Application program authority management method and device
CN105227426B (en) Application interface switching method and device and terminal equipment
CN109922203B (en) Terminal, screen-off method and device
CN112083841B (en) Information input method, device and storage medium
CN111506234B (en) Method, device, storage medium and electronic device for preventing accidental touch on edge of touch screen
CN112187326A (en) Antenna control method, device, equipment and storage medium
CN111225111A (en) Function control method, function control device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TG01 Patent term adjustment
TG01 Patent term adjustment