WO2019037374A1 - 用于安卓应用主进程唤醒的方法、存储介质、设备及系统 - Google Patents

用于安卓应用主进程唤醒的方法、存储介质、设备及系统 Download PDF

Info

Publication number
WO2019037374A1
WO2019037374A1 PCT/CN2017/119792 CN2017119792W WO2019037374A1 WO 2019037374 A1 WO2019037374 A1 WO 2019037374A1 CN 2017119792 W CN2017119792 W CN 2017119792W WO 2019037374 A1 WO2019037374 A1 WO 2019037374A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
main process
server
background
waking
Prior art date
Application number
PCT/CN2017/119792
Other languages
English (en)
French (fr)
Inventor
尹成
陈少杰
张文明
Original Assignee
武汉斗鱼网络科技有限公司
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 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019037374A1 publication Critical patent/WO2019037374A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Definitions

  • the present invention relates to the field of mobile software, and in particular, to a method, a storage medium, a device and a system for waking up an Android application main process.
  • the startup speed of APP is directly related to the user experience of APP, such as If the APP startup speed is too slow, it will directly reduce the user's friendliness to the current APP. Furthermore, it will directly cause the user to uninstall the current APP, thereby greatly reducing the installation amount of the APP, thereby affecting the activity rate of the APP. Therefore, the startup speed of the APP is improved.
  • APP developers are currently in urgent need of solving problems.
  • the more commonly used method is to maintain the main process of the application in the background for a long time, so that the application can be placed in the foreground without repeatedly launching the application, thereby improving the startup speed of the application.
  • the Android operating system when the main process of the application is closed by the operating system, there are various ways to wake up. The more common solutions are as follows:
  • Multi-process preservation mechanism an application is composed of multiple processes at runtime: one main process and multiple background processes.
  • any other background process detects that the main process is closed. After that, the main process wakes up.
  • the advantage of this scheme is that the technical implementation is difficult and does not need to be processed at the system level, such as the addition of the application whitelist, but the disadvantage is that once the background program is killed, the wakeup mechanism is unsustainable.
  • the association startup mechanism that is, when the terminal (the device running the Android operating system) is installed with multiple applications integrated with the same Wakeup SDK (Software Development Kit), when one of the applications is running
  • the background process will immediately search for the application of the current device and its similar integrated wake-up SDK. After the search is completed, the application wakes up randomly, but with the upgrade of the Android operating system version and the regulation of the background permissions, the association startup mechanism is in the high version.
  • the Android operating system cannot be expanded and there is a compatibility issue.
  • the present invention aims to provide a method, a storage medium, a device, and a system for waking up an Android application main process, which can effectively guarantee wake-up of an application main process.
  • the technical solution adopted by the present invention includes:
  • S1 Create a new background process for the application, and make a long connection between the application and the server through the newly created background process, and the priority of the background process runs the same as the priority of the application main process, and the background process includes the application for monitoring the application.
  • a monitoring service of a running state of a program main process wherein the server is a server that pushes a service for an application vendor;
  • the monitoring service Before the long connection between the application and the server is disconnected, the monitoring service monitors the running state of the main process of the application. If the running state of the main process of the application is the ending running state, the monitoring service wakes up the main process of the application, if After the running status of the application main process is in the normal running state, no processing is performed. After the long connection between the application and the server is disconnected, the server creates a notification message and sends it to the terminal device running the application.
  • S3 The system service of the Android operating system of the terminal device receives the notification message sent by the server, and determines the type of the received notification message. If the type of the notification message is a process wake-up message, the process goes to S4, and if not, the process ends. ;
  • S4 wake up the background process by the process wakeup message, and start the monitoring service of the newly created background process, and the monitoring service judges the running state of the application main process. If the application main process is the end running state, the newly created background process is applied to the application. The main process wakes up, and if not, it ends.
  • the long connection between the application and the server is based on Socket communication
  • the name of the application is used as the communication identifier between the application and the server;
  • the background process invokes a local service of the Android operating system to establish a long connection between the application and the server.
  • the background process determines the running state of the application main process, specifically:
  • the background process sends a broadcast to the application main process every predetermined time interval. After receiving the broadcast, the application main process returns a broadcast containing the running status information of the application main process to the background process, if the background process is in the next broadcast. A broadcast that receives feedback from the application's main process before it is sent indicates that the application's main process is running, and vice versa, the application's main process is down.
  • the background process sends a broadcast to the application main process through the trainer.
  • the Android operating system notification bar displays the process wake-up message for the user to select whether to wake up the application main process, if the user selects , wake up the background process and wake up the application main process, if the user chooses no, it ends.
  • the present invention also provides a storage medium having stored thereon a computer program that, when executed by a processor, implements the method described above.
  • the present invention also provides an apparatus for waking up an Android application main process, comprising a memory and a processor, the memory storing a computer program running on the processor, the processor executing the computer program to implement the above-mentioned method.
  • the invention also provides a system for waking up an Android application main process, comprising:
  • the newly created background process enables the application to establish a long connection with the server, and the background process runs at the same priority as the application main process, and the background process is included for monitoring.
  • a monitoring service of an application main process running state the server that pushes a service for an application vendor;
  • a judging module configured to determine whether the long connection between the application and the server is disconnected, and before the long connection between the application and the server is disconnected, the monitoring service monitors the running status of the main process of the application, if the main process of the application If the running status is the end running state, the monitoring service wakes up the application main process. If the running status of the application main process is normal, no processing is performed. After the long connection between the application and the server is disconnected, Indicates that the background process has finished running, and the server creates a notification message and sends it to the terminal device running the application;
  • a message receiving and process wake-up module configured to receive a notification message sent by the server, and determine the type of the received notification message, and if it is a non-process wake-up message, end, if the type of the notification message is a process wake-up message, Wake up the background process and start the monitoring service of the newly created background process.
  • the monitoring service judges the running status of the application main process. If the main process of the application is finished running, the newly created background process wakes up the main process of the application. If no, it ends.
  • the long connection between the application and the server is based on Socket communication
  • the name of the application is used as the communication identifier between the application and the server;
  • the background process invokes a local service of the Android operating system to establish a long connection between the application and the server.
  • the background process sends a broadcast to the application main process through the trainer.
  • the invention has the advantages that: by creating a background process in the application, the background process has the function of waking up and running state judgment of the application main process, and the long connection between the application and the server. Before disconnecting, the newly created background process can wake up the main process of the application that stops running.
  • the server sends a message to wake up the main process of the application, using multiple Wake up the insurance mechanism to ensure that the main process of the application is woken up, effectively avoiding the appearance of the application main process being unable to be woken up after all the processes of the application are closed, and the process wakes up the message sent by the server to the terminal device running the application.
  • it is up to the user to decide whether to wake up the main process of the application that has stopped running.
  • FIG. 1 is a flowchart of a method for waking up an Android application main process according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for waking up an Android application main process according to an embodiment of the present invention.
  • an embodiment of the present invention provides a method for waking up an Android application main process, which is used to wake up a closed or hibernating main process of an application in an Android operating system, thereby improving an application startup speed.
  • S1 Create a new background process for the application, and make a long connection between the application and the server through the newly created background process, and the priority of the background process runs the same as the priority of the application main process, and the background process includes the application for monitoring the application.
  • the monitoring service of the running status of the main process of the program, the server that pushes the service for the application manufacturer, and the server can send various types of messages to the application running in the Android operating system.
  • the priority setting of the background process in order to maintain the long-term freshness of the background process, it is necessary to set the priority setting of the background process to be the same as the priority of the application main process, which is the highest priority.
  • the application establishes a long connection with the server.
  • the long connection means that multiple data packets can be sent continuously on one connection. During the connection hold period, if there is no data packet to be sent, both parties need to send a link detection packet.
  • Long connection between the application and the server the long connection between the application and the server is based on Socket (socket) communication; the name of the application is used as the communication identifier between the application and the server; the background process calls the Android operating system.
  • the local service establishes a long connection between the application and the server. Therefore, when a long connection between the application and the server is established, it means that the newly created background process is activated.
  • the monitoring service monitors the running state of the main process of the application. If the running state of the main process of the application is the ending running state, the monitoring service wakes up the main process of the application, if After the running status of the application main process is normal, no processing is performed.
  • the server After the long connection between the application and the server is disconnected, the server creates a notification message and sends it to the terminal device running the application. Because the long connection between the application and the server is established by the newly created background process in the application, when the application is closed or stopped, the background process of the application may be terminated, so the application and the server A long connection between them is a disconnection.
  • a wake-up mode is adopted for the main process of the application that ends the operation, and after the long connection between the application and the server is disconnected, the subsequent application is adopted.
  • Another wake-up method of the main process of the program double insurance, effectively improves the wake-up rate of the main process of the application that stops running.
  • the newly created background process wakes up the application main process by starting the internal service of the application main process.
  • the background process determines the running status of the application's main process, specifically:
  • the background process sends a broadcast to the application main process every preset time interval, and the preset time interval may be 30 seconds.
  • the application main process After receiving the broadcast, the application main process returns a broadcast containing the running status information of the application main process itself. For the background process, if the background process receives the broadcast of the application main process feedback before the next broadcast is sent, it indicates that the application main process is running, and vice versa, the application main process is closed.
  • the newly created background process sends a broadcast to the application main process through the trainer, and the broadcast sent by the newly created background process to the application main process can be an empty message.
  • the system service of the Android operating system of the terminal device receives the notification message sent by the server, and determines the type of the received notification message. If the type of the notification message is a process wake-up message, the process goes to S4, and if not, the process ends. . Because the long connection between the application and the server is established by the background process established within the application, when the long connection between the application and the server is disconnected, it is most likely caused by the end of the application. Therefore, it is necessary to wake up the application main process by sending a notification to the terminal device through the server.
  • the terminal device is a smart phone or a tablet computer.
  • the type of the message sent by the server to the application in the terminal device exists in various forms, such as a notification message of a conventional class, etc.
  • the server sends the message to the terminal device.
  • the message type is a process wakeup message, and the process wakes up the message to achieve the purpose of waking up the application main process.
  • the present invention is concerned with the process wake-up message sent by the server to the terminal device, the process
  • the wake-up message is a message type defined by the embodiment of the present invention, and its main function is to implement the subsequent wake-up purpose for the main process of the application.
  • the format of the process wakeup message may be:
  • the message is received and processed by the system push service of the Android operating system running in the terminal device, because the system push service, and the system push service in the operating system will always run unless the terminal The device is shut down, otherwise the system push service will always be running, so it can ensure that the terminal device accepts the process wakeup message sent by the server.
  • the Android operating system notification bar displays the process wake-up message for the user to select.
  • the subsequent wake-up background process is performed and the operation of the main process of the application is awakened.
  • the process ends, and the operation right of the application is given to the user.
  • the running state of the main process of the application can also be determined by sending a broadcast, and the time interval for transmitting the broadcast can be freely set.
  • S4 wake up the background process by the process wakeup message, and start the monitoring service of the newly created background process, and the monitoring service judges the running state of the application main process. If the application main process is the end running state, the newly created background process is applied to the application. The main process wakes up, and if not, it ends.
  • the principle of the method for waking up the main process of the Android application in the present invention is that by creating a new background process in the application, the background process has the function of waking up and running the state of the main process of the application, and at the same time, the background process is established.
  • the long connection between the application and the server based on Socket communication enables the server to monitor the running status of the main process of the application.
  • the new background process can stop before the long connection between the application and the server is disconnected.
  • the main process of the running application wakes up, and when the long connection between the application and the server is disconnected, the server sends a message to the terminal device running the application, and wakes up the main process of the stopped application.
  • the multiple wake-up insurance mechanism is convenient to implement and ensures the wake-up of the application main process, which effectively prevents the application main process from being woken up after all the processes of the application are closed, and the application manufacturer does not need to cooperate with the terminal device manufacturer. Also avoids the application process when waking up Android For system version, while the process server sends to a terminal running the application wake-up message, using the friendly interaction, the user decide whether to host process has stopped running application to wake up.
  • the present invention further provides a storage medium, where the computer program is stored on the storage medium, and when the computer program is executed by the processor, the Android application described in each embodiment is implemented.
  • the steps of the method that the main process wakes up includes a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, and the like.
  • the medium of the code includes a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, and the like.
  • the present invention further provides a device for waking up an Android application main process, including a memory and a processor, where the memory is stored and run on the processor.
  • a computer program that implements the method of waking up the Android application main process of the above embodiments when the processor executes the computer program.
  • the present invention also provides a system for waking up an Android application main process based on the method for waking up the main process of the Android application, including a creation module, a determination module, and a message reception and process wake-up module.
  • the creation module is used to create a background process, and the newly created background process enables the application to establish a long connection with the server, and the background process runs at the same priority as the application main process, and the background process includes the application for monitoring the application.
  • the monitoring service of the running status of the main process the server is a server that pushes the service by the application manufacturer; the judging module is used to judge whether the long connection between the application and the server is disconnected, and the long connection between the application and the server is broken. Before the monitoring, the monitoring service monitors the running status of the main process of the application. If the running status of the main process of the application is the ending running state, the monitoring service wakes up the main process of the application.
  • the message receiving and process wake-up module is configured to receive the notification message sent by the server, and determine the type of the received notification message. If the message is a non-process wake-up message, the process ends. If the type of the notification message is a process wake-up message, the background is awakened. Process, and start the monitoring service of the newly created background process, and the monitoring service judges the running status of the application main process. If the main process of the application is the end running state, the newly created background process wakes up the main process of the application, if not Then it ends.
  • the long connection between the application and the server is based on Socket communication; the name of the application is used as the communication identifier between the application and the server; the background process calls the local service of the Android operating system to establish a long connection between the application and the server.
  • the background process sends a broadcast to the application main process through the trainer.
  • the principle of the system for waking up the main process of the Android application in the present invention is: creating a module by creating a background process in the application, the background process has the function of waking up and running state judgment of the main process of the application, and at the same time, the background process is established.
  • the long connection between the application and the server based on Socket communication realizes the monitoring of the running state of the main process of the application by the server, and judges whether the module disconnects the long connection between the application and the server, in the application and Before the long connection between the server ends, the newly created background process can wake up the main process of the application that stops running, and when the long connection between the application and the server is disconnected, the server goes to the terminal running the application.
  • the device sends a message to wake up the main process of the application that stops running, adopts multiple wake-up insurance mechanism, and is convenient to implement, ensuring wake-up of the application main process, effectively avoiding the application main process being unable to be closed after all processes of the application are closed. The appearance of a wake-up situation.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)
  • Telephone Function (AREA)

Abstract

一种用于安卓应用主进程唤醒的方法、存储介质、设备及系统,该方法包括:给应用程序新建一后台进程,应用程序与服务端建立长连接(S1);应用程序与服务端间长连接断开前,若应用程序主进程为结束运行状态,则唤醒应用程序主进程,若应用程序主进程为正常运行状态,则不做处理,应用程序与服务端间长连接断开后,则创建一通知消息并下发至终端设备(S2);终端设备接收通知消息,若通知消息类型为进程唤醒消息,则转到S4,若否,则结束(S3);唤醒后台进程,判断应用程序主进程运行状态,若为结束运行状态,则对应用程序的主进程进行唤醒,若否,则结束(S4)。该方法能够有效保证对应用程序主进程的唤醒。

Description

用于安卓应用主进程唤醒的方法、存储介质、设备及系统 技术领域
本发明涉及移动软件领域,具体涉及一种用于安卓应用主进程唤醒的方法、存储介质、设备及系统。
背景技术
在日益激烈的移动互联网领域,提高APP(Application,应用程序)的活跃率是各大APP开发商颇为关注的事情,其中,APP的启动速度更是直接关系到用户对于APP的使用体验,如APP启动速度过慢则会直接减少用户对当前APP使用友善度,严重的甚至会直接导致用户卸载当前APP,进而大幅降低APP的安装量,进而影响APP的活跃率,因此提高APP的启动速度是APP开发人员当前迫切需要解决的难题。
当前,对于APP启动速度的提升,较常采用的做法是维持应用的主进程在后台长期运行,从而可以在不重复启动应用的情况下瞬间将应用置于前台,从而提高应用程序的启动速度。对于Android操作系统,当应用程序的主进程被操作系统关闭后,进行唤醒的方式有多种,较为常见的方案有如下三种:
(1)将应用程序加入启动白名单,当应用程序的主进程被关闭或异常退出时,操作系统随即采用唤醒机制,对应用程序的主进程进行唤醒。该方案的优点是主进程由操作系统唤醒,主进程唤醒成功率高,缺点是需要应用程序的厂商和操作系统厂商或手机厂商进行合作,方可将应用程序加入到启动白名单中。
(2)多进程保鲜机制,一个应用程序在运行时由多个进程组成:一个主进程和多个后台进程,当主进程被关闭或异常退出时,其它任意后台进程检测到主进程被关闭的警报后,随即开展主进程唤醒。该方案的优点是技术实现难度低,且无需做系统层面的处理,如应用程序白名单的添加,但缺点是一旦后台程序一并被杀死,唤醒机制则难以为继。
(3)关联启动机制,即当终端(运行Android操作系统的设备)中安装有多个集成了相同唤醒SDK(Software Development Kit,软件开发工具包)的应用程序,当其中一个应用程序处于运行状态,其后台进程则会随即开展搜索当前设备与其相似集成唤醒SDK的应用,搜索完成后随机进行应用唤醒,但随着Android操作系统版本的升级以及对后台权限的管制加强,关联启动机制在高版本的Android操作系统则无法展开,存在兼容性的问题。
发明内容
针对现有技术中存在的缺陷,本发明的目的在于提供一种用于安卓应用主进程唤醒的方法、存储介质、设备及系统,能够有效保证对应用程序主进程的唤醒。
为达到以上目的,本发明采取的技术方案是,包括:
S1:给应用程序新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状态的监控服务,所述服务端为应用程序厂商推送服务的服务器;
S2:在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状 态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开后,服务端创建一通知消息并下发至运行应用程序的终端设备;
S3:终端设备的Android操作系统的系统服务接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若通知消息的类型为进程唤醒消息,则转到S4,若否,则结束;
S4:通过进程唤醒消息唤醒后台进程,并启动新建的后台进程的监控服务,监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程序的主进程进行唤醒,若否,则结束。
在上述技术方案的基础上,
所述应用程序与服务端间的长连接基于Socket通信;
所述应用程序与服务端间以应用程序的名称作为通信标识;
所述后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。
在上述技术方案的基础上,在应用程序与服务端间的长连接断开之前,后台进程对应用程序主进程的运行状态的判断,具体为:
后台进程每隔一预设时间间隔向应用程序主进程发送一条广播,应用程序主进程接受到广播后回馈一条包含有应用程序主进程自身运行状态信息的广播给后台进程,若后台进程在下一条广播发出前接收到应用程序主进程回馈的广播,则表示应用程序主进程为运行状态,反之,应用程序主进程为关闭状态。
在上述技术方案的基础上,所述后台进程通过轮训器向应用程序主进程发送广播。
在上述技术方案的基础上,若终端设备接收到的通知消息的类型 为进程唤醒消息,则Android操作系统通知栏对进程唤醒消息进行展示以供用户选择是否唤醒应用程序主进程,若用户选择是,则唤醒后台进程并唤醒应用程序主进程,若用户选择否,则结束。
本发明还提供一种存储介质,该存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述所述的方法。
本发明还提供一种用于安卓应用主进程唤醒的设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述所述的方法。
本发明还提供一种用于安卓应用主进程唤醒的系统,包括:
创建模块,其用于新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状态的监控服务,所述服务端为应用程序厂商推送服务的服务器;
判断模块,其用于判断应用程序与服务端间的长连接是否断开,在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开后,则表示后台进程已结束运行,则服务端创建一通知消息并下发至运行应用程序的终端设备;
消息接收及进程唤醒模块,其用于接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若为非进程唤醒消息,则结束,若通知消息的类型为进程唤醒消息,则唤醒后台进程,并启动新建的后台进程的监控服务,同时监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程 序的主进程进行唤醒,若否,则结束。
在上述技术方案的基础上,所述应用程序与服务端间的长连接基于Socket通信;
所述应用程序与服务端间以应用程序的名称作为通信标识;
所述后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。
在上述技术方案的基础上,所述后台进程通过轮训器向应用程序主进程发送广播。
与现有技术相比,本发明的优点在于:通过在应用程序中新建一个后台进程,后台进程具有对应用程序主进程进行唤醒和运行状态判断的功能,在应用程序与服务端间的长连接断开前,新建的后台进程能对停止运行的应用程序的主进程进行唤醒,当应用程序与服务端间的长连接断开后,服务端发送消息对应用程序的主进程进行唤醒,采用多重唤醒保险机制,确保应用程序主进程被唤醒,有效避免了应用程序所有进程被关闭后,应用程序主进程无法被唤醒情况的出现,且服务端向运行应用程序的终端设备发送的进程唤醒消息,采用友好的交互方式,由用户自己决定是否对已停止运行的应用程序的主进程进行唤醒。
附图说明
图1为本发明实施例中一种用于安卓应用主进程唤醒的方法的流程图;
图2为本发明实施例中用于安卓应用主进程唤醒的设备的结构示意图。
具体实施方式
以下结合附图及实施例对本发明作进一步详细说明。
参见图1所示,本发明实施例提供一种用于安卓应用主进程唤醒的方法,用于对Android操作系统中应用程序的已关闭或休眠的主进程进行唤醒,从而提升应用程序的启动速度。
本发明实施例的用于安卓应用主进程唤醒的方法具体包括:
S1:给应用程序新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状态的监控服务,服务端为应用程序厂商推送服务的服务器,服务端能够发送各种类型消息至Android操作系统中运行的应用程序。对于新建的后台进程的优先级,为了保持后台进程的长期鲜活性,因此需要将后台进程运行的优先级设置和应用程序主进程的优先级相同,即为最高优先级。
通过新建的后台进程,应用程序与服务端间建立长连接,长连接是指在一个连接上可以连续发送多个数据包,在连接保持期间,如果没有数据包发送,需要双方发链路检测包。对于应用程序与服务端间的长连接:应用程序与服务端间的长连接基于Socket(套接字)通信;应用程序与服务端间以应用程序的名称作为通信标识;后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。因此,当应用程序与服务端间的长连接建立后,即代表新建的后台进程被激活。
S2:在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开 后,则服务端创建一通知消息并下发至运行应用程序的终端设备。因为应用程序与服务端间的长连接是由应用程序内新建的后台进程所建立的,因此当应用程序被关闭或停止运行时,应用程序的后台进程也有可能被终止,因此应用程序与服务端间的长连接是会出现断开的情况的。因此,在应用程序与服务端间的长连接断开前,对于结束运行的应用程序的主进程采用一种唤醒方式,在应用程序与服务端间的长连接断开后,采用后续的对应用程序主进程的另一种唤醒方式,双重保险,有效提高停止运行的应用程序主进程的唤醒率。对于关闭或停止运行的应用程序主进程的唤醒,新建的后台进程通过启动应用程序主进程的内部服务的方式来唤醒应用程序主进程。
新建的后台进程和应用程序主进程间的运行在本质上是相互不存在干扰的,因此,为了达到进程的间的状态同步,需要建立长期的进程间的通信机制,本发明实施例采用的是发送广播的方式来实现新建的后台进程和应用程序主进程间的状态同步。
同样的,在应用程序与服务端间的长连接断开之前,后台进程对应用程序主进程的运行状态的判断,具体为:
后台进程每隔一预设时间间隔向应用程序主进程发送一条广播,预设的时间间隔可以为30秒,应用程序主进程接受到广播后回馈一条包含有应用程序主进程自身运行状态信息的广播给后台进程,若后台进程在下一条广播发出前接收到应用程序主进程回馈的广播,则表示应用程序主进程为运行状态,反之,应用程序主进程为关闭状态。新建的后台进程通过轮训器向应用程序主进程发送广播,新建的后台进程发送给应用程序主进程的广播可以为空消息。
S3:终端设备的Android操作系统的系统服务接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若通知消息的类型 为进程唤醒消息,则转到S4,若否,则结束。因为应用程序与服务端间的长连接是由应用程序内建立的后台进程建立的,因此当应用程序与服务端间的长连接断开,则极有可能是因为应用程序结束运行而导致的,因此需要通过服务端向终端设备发送通知的方式来对应用程序主进程进行唤醒。本发明实施例中,终端设备为智能手机或平板电脑。
服务端发送给终端设备中应用程序的消息的类型存在多种形式,如常规类的通知消息等等,这里,当应用程序与服务端间的长连接断开后,服务端发送给终端设备的消息类型为进程唤醒消息,通过进程唤醒消息来达到对应用程序主进程唤醒的目的。对于服务端发送给终端设备常规类型消息,按照常规的处理,如启动APP、跳转指定页面等等,这里与本发明无关,本发明关注的是服务端发送给终端设备的进程唤醒消息,进程唤醒消息是本发明实施例定义的一种消息类型,其主要作用是为了实现后续的对应用程序主进程进行唤醒目的。例如,对于某直播软件的主进程的唤醒,进程唤醒消息的格式可以为:
{
"msg_id":"uu481201399440513912",//消息id
"msg_type":1001,                //消息类型,1001代表进程唤醒
"display_type":"notification",//展示形式
"body":{
"title":"斗鱼直播",
"ticker":"精彩直播尽在斗鱼直播",
"text":"null",
"after_click":"process_awaken",//点击的操作—唤醒
"url":"com.douyu.android.socket.process",//后台进程包名
"activity":"null",//只启动进程,不展示任何界面
"custom":"null",    //无任何其他参数
"play_vibrate":"false",//禁止震动
"play_sound":"false",    //禁止响铃
"play_lights":"false"//禁止开启灯光
},
}
同时,由于服务端发送给终端设备的消息,消息由终端设备中运行的Android操作系统的系统推送服务接收并处理,由于是系统推送服务,且操作系统中的系统推送服务会一直运行,除非终端设备关机,不然系统推送服务会一直处于运行状态,因此可以确保终端设备接受到服务端发送的进程唤醒消息。
进一步地,为提高应用程序厂商服务的人性化,还能够增添以下步骤,若终端设备接收到的通知消息的类型为进程唤醒消息,则Android操作系统通知栏对进程唤醒消息进行展示以供用户选择是否唤醒应用程序主进程,若用户选择是,则进行后续的唤醒后台进程并唤醒应用程序主进程的操作,若用户选择否,则结束,将应用程序的运行权交给用户。此时,对于应用程序主进程是否存活的判断,同样可以采用发送广播的方式对应用程序主进程的运行状态进行判断,发送广播的时间间隔可以自由设定。
S4:通过进程唤醒消息唤醒后台进程,并启动新建的后台进程的监控服务,监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程序的主进程进行唤醒,若否,则结束。
本发明的一种用于安卓应用主进程唤醒的方法的原理在于,通过在应用程序中新建一个后台进程,后台进程具有对应用程序主进程进 行唤醒和运行状态判断的功能,同时,后台进程建立基于Socket通信的应用程序与服务端间的长连接,实现服务端对应用程序主进程运行状态的监控,同时,在应用程序与服务端间的长连接断开前,新建的后台进程能对停止运行的应用程序的主进程进行唤醒,且当应用程序与服务端间的长连接断开后,服务端向运行应用程序的终端设备发送消息,对停止运行的应用程序的主进程进行唤醒,采用多重唤醒保险机制,实施方便,确保应用程序主进程的唤醒,有效避免了应用程序所有进程被关闭后,应用程序主进程无法被唤醒情况的出现,且应用程序厂商无需与终端设备厂商进行合作,也同时避免了应用程序进程唤醒时Android操作系统版本问题,同时,服务端向运行应用程序的终端设备发送的进程唤醒消息,采用友好的交互方式,由用户自己决定是否对已停止运行的应用程序的主进程进行唤醒。
另外,对应上述用于安卓应用主进程唤醒的方法,本发明还提供一种存储介质,存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述各实施例所述的用于安卓应用主进程唤醒的方法的步骤。需要说明的是,所述存储介质包括U盘、移动硬盘、ROM(Read-Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、磁碟或者光盘等各种可以存储程序代码的介质。
参见图2所示,对应上述用于安卓应用主进程唤醒的方法,本发明还提供一种用于安卓应用主进程唤醒的设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,处理器执行计算机程序时实现上述各实施例的安卓应用主进程唤醒的方法。
本发明还提供一种基于上述安卓应用主进程唤醒的方法的安卓应用主进程唤醒的系统,包括创建模块、判断模块和消息接收及进程唤醒模块。
创建模块用于新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状态的监控服务,所述服务端为应用程序厂商推送服务的服务器;判断模块用于判断应用程序与服务端间的长连接是否断开,在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开后,则表示后台进程已结束运行,则服务端创建一通知消息并下发至运行应用程序的终端设备;
消息接收及进程唤醒模块用于接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若为非进程唤醒消息,则结束,若通知消息的类型为进程唤醒消息,则唤醒后台进程,并启动新建的后台进程的监控服务,同时监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程序的主进程进行唤醒,若否,则结束。
应用程序与服务端间的长连接基于Socket通信;应用程序与服务端间以应用程序的名称作为通信标识;后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。后台进程通过轮训器向应用程序主进程发送广播。
本发明的用于安卓应用主进程唤醒的系统的原理在于:创建模块通过在应用程序中新建一个后台进程,后台进程具有对应用程序主进程进行唤醒和运行状态判断的功能,同时,后台进程建立基于Socket通信的应用程序与服务端间的长连接,实现服务端对应用程序主进程运行状态的监控,同时判断模块对应用程序与服务端间的长连接是否 断开进行判断,在应用程序与服务端间的长连接断开前,新建的后台进程能对停止运行的应用程序的主进程进行唤醒,且当应用程序与服务端间的长连接断开后,服务端向运行应用程序的终端设备发送消息,对停止运行的应用程序的主进程进行唤醒,采用多重唤醒保险机制,实施方便,确保应用程序主进程的唤醒,有效避免了应用程序所有进程被关闭后,应用程序主进程无法被唤醒情况的出现。
本发明不局限于上述实施方式,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围之内。本说明书中未作详细描述的内容属于本领域专业技术人员公知的现有技术。

Claims (10)

  1. 一种用于安卓应用主进程唤醒的方法,用于对Android操作系统中应用程序的主进程进行唤醒,其特征在于,包括:
    S1:给应用程序新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状态的监控服务,所述服务端为应用程序厂商推送服务的服务器;
    S2:在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开后,服务端创建一通知消息并下发至运行应用程序的终端设备;
    S3:终端设备的Android操作系统的系统服务接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若通知消息的类型为进程唤醒消息,则转到S4,若否,则结束;
    S4:通过进程唤醒消息唤醒后台进程,并启动新建的后台进程的监控服务,监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程序的主进程进行唤醒,若否,则结束。
  2. 如权利要求1所述的一种用于安卓应用主进程唤醒的方法,其特征在于:
    所述应用程序与服务端间的长连接基于Socket通信;
    所述应用程序与服务端间以应用程序的名称作为通信标识;
    所述后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。
  3. 如权利要求1所述的一种用于安卓应用主进程唤醒的方法,其特征在于:在应用程序与服务端间的长连接断开之前,后台进程对应用程序主进程的运行状态的判断,具体为:
    后台进程每隔一预设时间间隔向应用程序主进程发送一条广播,应用程序主进程接受到广播后回馈一条包含有应用程序主进程自身运行状态信息的广播给后台进程,若后台进程在下一条广播发出前接收到应用程序主进程回馈的广播,则表示应用程序主进程为运行状态,反之,应用程序主进程为关闭状态。
  4. 如权利要求1所述的一种用于安卓应用主进程唤醒的方法,其特征在于:所述后台进程通过轮训器向应用程序主进程发送广播。
  5. 如权利要求1所述的一种用于安卓应用主进程唤醒的方法,其特征在于:若终端设备接收到的通知消息的类型为进程唤醒消息,则Android操作系统通知栏对进程唤醒消息进行展示以供用户选择是否唤醒应用程序主进程,若用户选择是,则唤醒后台进程并唤醒应用程序主进程,若用户选择否,则结束。
  6. 一种存储介质,该存储介质上存储有计算机程序,其特征在于:所述计算机程序被处理器执行时实现权利要求1至5任一项所述的方法。
  7. 一种用于安卓应用主进程唤醒的设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,其特征在于:所述处理器执行所述计算机程序时实现权利要求1至5任一项所述的方法。
  8. 一种用于安卓应用主进程唤醒的系统,其特征在于,包括:
    创建模块,其用于新建一后台进程,通过新建的后台进程使得应用程序与服务端建立长连接,且后台进程运行的优先级和应用程序主进程的优先级相同,且后台进程包含用于监控应用程序主进程运行状 态的监控服务,所述服务端为应用程序厂商推送服务的服务器;
    判断模块,其用于判断应用程序与服务端间的长连接是否断开,在应用程序与服务端间的长连接断开前,监控服务监控应用程序主进程的运行状态,若应用程序主进程的运行状态为结束运行状态,则监控服务唤醒应用程序主进程,若应用程序主进程的运行状态为正常运行状态,则不做处理,在应用程序与服务端间的长连接断开后,则表示后台进程已结束运行,则服务端创建一通知消息并下发至运行应用程序的终端设备;
    消息接收及进程唤醒模块,其用于接收服务端发送的通知消息,并对接收的通知消息的类型进行判断,若为非进程唤醒消息,则结束,若通知消息的类型为进程唤醒消息,则唤醒后台进程,并启动新建的后台进程的监控服务,同时监控服务判断应用程序主进程的运行状态,若应用程序主进程为结束运行状态,则新建的后台进程对应用程序的主进程进行唤醒,若否,则结束。
  9. 如权利要求8所述的一种用于安卓应用主进程唤醒的系统,其特征在于:
    所述应用程序与服务端间的长连接基于Socket通信;
    所述应用程序与服务端间以应用程序的名称作为通信标识;
    所述后台进程调用Android操作系统的本地服务建立应用程序与服务端间的长连接。
  10. 如权利要求8所述的一种用于安卓应用主进程唤醒的系统,其特征在于:所述后台进程通过轮训器向应用程序主进程发送广播。
PCT/CN2017/119792 2017-08-24 2017-12-29 用于安卓应用主进程唤醒的方法、存储介质、设备及系统 WO2019037374A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710737057.3A CN107704274B (zh) 2017-08-24 2017-08-24 用于安卓应用主进程唤醒的方法、存储介质、设备及系统
CN201710737057.3 2017-08-24

Publications (1)

Publication Number Publication Date
WO2019037374A1 true WO2019037374A1 (zh) 2019-02-28

Family

ID=61169781

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/119792 WO2019037374A1 (zh) 2017-08-24 2017-12-29 用于安卓应用主进程唤醒的方法、存储介质、设备及系统

Country Status (2)

Country Link
CN (1) CN107704274B (zh)
WO (1) WO2019037374A1 (zh)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321203B (zh) * 2018-03-29 2021-07-30 武汉斗鱼网络科技有限公司 后台进程假死处理方法及客户端
CN108710534A (zh) * 2018-05-22 2018-10-26 广州优视网络科技有限公司 多进程的调起方法、装置、终端设备及计算机存储介质
CN109379337B (zh) * 2018-09-18 2021-01-26 四川长虹电器股份有限公司 一种安卓平台下应用进程的保活方法
CN109495549B (zh) * 2018-10-30 2021-07-20 上海尚往网络科技有限公司 一种应用拉活的方法、设备和计算机存储介质
CN109683974B (zh) * 2018-12-26 2022-05-31 北京金山安全软件有限公司 针对移动终端中应用后台服务进程的唤醒方法及相关设备
CN110007981B (zh) * 2019-02-28 2021-12-24 Oppo广东移动通信有限公司 启动应用程序的方法、装置、电子设备及介质
CN111176809A (zh) * 2019-12-18 2020-05-19 任子行网络技术股份有限公司 安卓平台下含长连接通讯进程的应用保活处理方法及系统
CN111464642A (zh) * 2020-04-01 2020-07-28 北京四维智联科技有限公司 车机消息推送的方法和装置
CN111831373A (zh) * 2020-06-09 2020-10-27 上海容易网电子商务股份有限公司 一种用于安卓互动屏应用启动状态的检测处理方法
CN112181731A (zh) * 2020-10-26 2021-01-05 江苏特思达电子科技股份有限公司 一种应用程序的保活方法、装置及计算机设备
CN112860408A (zh) * 2021-03-03 2021-05-28 苏州沁游网络科技有限公司 一种云真机中的进程保活方法、装置、系统及存储介质
CN115378989B (zh) * 2022-08-10 2023-08-15 深圳华芯信息技术股份有限公司 基于唤醒通道的mqtt主题订阅系统、方法、终端及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101383690A (zh) * 2008-10-27 2009-03-11 西安交通大学 一种基于socket的容错计算机系统的网络同步方法
CN102999317A (zh) * 2012-12-30 2013-03-27 北京讯鸟软件有限公司 面向多租户的弹性多进程服务处理方法
US20140289745A1 (en) * 2013-03-25 2014-09-25 Seven Networks, Inc. Intelligent alarm manipulator and resource tracker
CN105893129A (zh) * 2016-03-30 2016-08-24 北京小米移动软件有限公司 终端中应用程序的处理方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9032413B2 (en) * 2011-09-01 2015-05-12 Microsoft Technology Licensing, Llc Decoupling background work and foreground work
CN105610888A (zh) * 2015-09-08 2016-05-25 华南师范大学 基于安卓的利用socket推送消息的方法和系统
CN106201690A (zh) * 2016-07-07 2016-12-07 乐视控股(北京)有限公司 应用运行控制方法及装置
CN106686056A (zh) * 2016-11-25 2017-05-17 济南中维世纪科技有限公司 一种安卓客户端通信装置及与服务器进行连接通信的方法
CN106708617B (zh) * 2016-12-23 2019-12-03 武汉斗鱼网络科技有限公司 一种基于Service的应用进程保活系统及保活方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101383690A (zh) * 2008-10-27 2009-03-11 西安交通大学 一种基于socket的容错计算机系统的网络同步方法
CN102999317A (zh) * 2012-12-30 2013-03-27 北京讯鸟软件有限公司 面向多租户的弹性多进程服务处理方法
US20140289745A1 (en) * 2013-03-25 2014-09-25 Seven Networks, Inc. Intelligent alarm manipulator and resource tracker
CN105893129A (zh) * 2016-03-30 2016-08-24 北京小米移动软件有限公司 终端中应用程序的处理方法及装置

Also Published As

Publication number Publication date
CN107704274B (zh) 2019-11-05
CN107704274A (zh) 2018-02-16

Similar Documents

Publication Publication Date Title
WO2019037374A1 (zh) 用于安卓应用主进程唤醒的方法、存储介质、设备及系统
US9998522B2 (en) Fast join of peer to peer group with power saving mode
JP5826932B2 (ja) 通信ネットワークにおける電力セーブプロキシ
US9215654B2 (en) System wakeup on wireless network messages
KR101171533B1 (ko) 모바일 네트워크 장치 배터리 보존 시스템 및 방법들
WO2016165078A1 (zh) 一种控制应用程序的方法及终端
WO2017054462A1 (zh) 视频解码的方法、服务器和移动终端
US10154106B2 (en) Method for sending heartbeat message and mobile terminal
JP2015097107A (ja) モバイルオペレーティング環境のための、イベント制御された連続的なロギングを提供すること
JP2022003796A (ja) スリープ状態にあるアクセサリの低電力でのアクティブ化
KR100989716B1 (ko) 컨텐츠 송수신 중지 및 재개 방법
CN105573777B (zh) 应用中服务的控制方法及装置
CN110381489B (zh) 蓝牙连接方法、显示终端及电视机
CN109982355B (zh) 保存和恢复网络通路的方法及其装置、终端和存储介质
CN107831886B (zh) 关联启动应用的管控方法、装置、存储介质及智能终端
WO2011113383A2 (zh) 一种业务处理的方法和服务器
CN107391274B (zh) 离线消息的处理方法及装置
TW201538010A (zh) 用於管理網路連線的行動裝置和方法以及存儲媒體
CN111488207B (zh) 应用进程保活方法、装置、网络设备及存储介质
US9930101B2 (en) Receiving a communication event
CN110691401B (zh) 一种系统应用的管理方法及装置
TWI407765B (zh) 行動裝置、省電方法及電腦可執行媒體
CN105930215A (zh) 一种移动终端的控制方法及控制装置
JP2005228301A (ja) 暗黙の構成可能なメッセージキューベースのユーザインターフェースオートメーション同期化のためのシステムおよび方法
CN110377293B (zh) 一种下载方法、终端及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17922390

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17922390

Country of ref document: EP

Kind code of ref document: A1