[go: up one dir, main page]

CN105335171B - Method and device for application program resident in operating system background - Google Patents

Method and device for application program resident in operating system background Download PDF

Info

Publication number
CN105335171B
CN105335171B CN201410287640.5A CN201410287640A CN105335171B CN 105335171 B CN105335171 B CN 105335171B CN 201410287640 A CN201410287640 A CN 201410287640A CN 105335171 B CN105335171 B CN 105335171B
Authority
CN
China
Prior art keywords
keep
alive
host
main process
alive process
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.)
Expired - Fee Related
Application number
CN201410287640.5A
Other languages
Chinese (zh)
Other versions
CN105335171A (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 Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing 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 Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201410287640.5A priority Critical patent/CN105335171B/en
Priority to PCT/CN2015/082075 priority patent/WO2015196967A1/en
Publication of CN105335171A publication Critical patent/CN105335171A/en
Application granted granted Critical
Publication of CN105335171B publication Critical patent/CN105335171B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Telephonic Communication Services (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a kind of method and devices on application program resident operating system backstage.This method comprises: receiving destination application starting request, corresponding destination application is requested to create host process for destination application starting;The host process calls function creation host keep-alive process;Host's keep-alive process calls function creation keep-alive process, and after keep-alive process creation, by the keep-alive process trustship to operating system;Building host process is connect with keep-alive process, is triggered connection of the host process with keep-alive process based on building and is mutually monitored;After listening to host process or keep-alive process is closed, start pent process.With the application of the invention, application program length, which may be implemented, resides in operating system backstage.

Description

应用程序常驻操作系统后台的方法及装置Method and device for application program resident in operating system background

技术领域technical field

本发明涉及应用程序通信技术,具体涉及一种应用程序常驻操作系统后台的方法及装置。The invention relates to application program communication technology, in particular to a method and device for an application program to reside in the background of an operating system.

背景技术Background technique

随着互联网的普及,用户对网络通信服务的依耐性越来越强,对网络通信服务系统的稳定性、响应能力以及不间断(zero-downtime)的服务特性也有了越来越高的要求。通信设备作为承载网络通信服务的载体,通过安装操作系统,并基于安装的操作系统安装应用程序(App,Application),从而为用户提供便捷的互联网服务。With the popularization of the Internet, users are more and more resistant to network communication services, and have higher and higher requirements for the stability, responsiveness and zero-downtime service characteristics of network communication service systems. As a carrier for carrying network communication services, a communication device installs an operating system and installs an application program (App, Application) based on the installed operating system, thereby providing users with convenient Internet services.

以安卓(Android)操作系统为例,Android操作系统是一种应用于移动通信设备的操作系统,由google提供源码给各大厂商定制,应用程序是安装在Android上的可执行程序。在目前Android操作系统环境下,一些第三方App由于任务运行的需要,需要常驻在操作系统后台,例如,对于即时通讯类应用程序,需要实时从服务器更新最新消息,以保证正常服务。再例如,对于电子市场类应用程序,需要在后台监控通信设备中其他应用程序的安装、卸载情况,以上传通信设备中应用程序的安装、卸载数据,从而对用户的喜好行为特征进行分析。再例如,对于定位服务(LBS,Location Based Services)类应用程序,需要监控通信设备的地理位置信息,以实现运营商广告的精确投放。因此,如何实现第三方App常驻操作系统后台成为迫切需要解决的技术问题。Taking the Android operating system as an example, the Android operating system is an operating system applied to mobile communication devices. The source code is provided by google for customization by major manufacturers, and the application program is an executable program installed on the Android. In the current Android operating system environment, some third-party apps need to reside in the background of the operating system due to the needs of running tasks. For example, for instant messaging applications, the latest news needs to be updated from the server in real time to ensure normal services. For another example, for electronic market applications, it is necessary to monitor the installation and uninstallation of other applications in the communication device in the background, so as to upload the installation and uninstallation data of the application in the communication device, so as to analyze the user's preference behavior characteristics. For another example, for a Location Based Services (LBS, Location Based Services) application, it is necessary to monitor the geographic location information of the communication device, so as to realize the precise placement of the operator's advertisement. Therefore, how to realize a third-party App resident in the background of the operating system has become a technical problem that needs to be solved urgently.

现有技术中,由于Android操作系统允许第三方开发者开发的系统级应用程序驻留操作系统后台(简称后台),因而,通过获取通信设备上操作系统的根(Root)权限,修改操作系统中/system/build.prop文件的配置信息,可以实现第三方App在操作系统后台常驻,即利用操作系统配置文件的漏洞,从而实现后台常驻,具体流程如下:In the prior art, because the Android operating system allows system-level applications developed by third-party developers to reside in the operating system background (referred to as the background), therefore, by obtaining the root (Root) authority of the operating system on the communication device, modify the operating system. The configuration information of the /system/build.prop file can realize the permanent residence of the third-party App in the background of the operating system, that is, by exploiting the loopholes in the configuration file of the operating system, so as to realize the permanent residence in the background. The specific process is as follows:

首先,获取操作系统Root权限;接着,修改操作系统下的/system/build.prop文件的配置信息,在该build.prop文件的配置信息中加入sys.keep_App_1=xxx.xxx.xxx,其中,xxx.xxx.xxx是第三方App包名;然后,重启动通信设备后生效,并通过分叉函数(fork)构建针对该第三方App的父进程以及与父进程直接相关联的子进程。这样,由于在操作系统下的/system/build.prop文件的配置信息加入了第三方App相关信息,使得操作系统可以对该第三方App构建的父进程以及子进程进行管理和控制,在第三方App退出操作系统后,第三方App对应的父进程和子进程仍可驻留于后台,从而实现第三方App常驻操作系统后台。First, obtain the Root permission of the operating system; then, modify the configuration information of the /system/build.prop file under the operating system, and add sys.keep_App_1=xxx.xxx.xxx to the configuration information of the build.prop file, where xxx .xxx.xxx is the package name of the third-party App; then, it takes effect after restarting the communication device, and a parent process for the third-party App and a child process directly associated with the parent process are constructed through a fork function (fork). In this way, since the configuration information of the /system/build.prop file under the operating system is added with the relevant information of the third-party App, the operating system can manage and control the parent process and child process built by the third-party App. After the app exits the operating system, the parent process and child process corresponding to the third-party app can still reside in the background, so that the third-party app can reside in the operating system background.

但上述应用程序常驻操作系统后台的方法,首先,需要通信设备具有Root功能,但据不完全统计,目前Root的比率大致为20%,应用受到限制,适用性不广;其次,Android操作系统设置有任务管理器,用于记录应用程序对应的父进程以及与父进程直接相关联的子进程占用的内存资源等信息,由于基于Android操作系统中的进程是托管给操作系统的,因而,在操作系统后台运行的应用程序较多、占用大量内存资源导致操作系统内存资源不足,需要进行系统清理的情况下,由于通过获取操作系统Root权限构建的第三方App对应的父进程以及子进程由操作系统进行管理和控制,通过查询任务管理器,依据预先设置的规则,例如,按照内存资源占用量或应用程序优先级关闭(kill)一些应用程序对应的父进程以及与父进程直接相关联的子进程,从而终止该运用程序的运行,并能回收该运用程序占用的内存资源以保证操作系统的正常运行,导致驻留于后台的第三方App对应的父进程以及关联的子进程可能被操作系统清除掉以释放内存资源;或者,通信设备中安装的杀毒软件进行查杀毒的过程中,第三方App对应的父进程以及与父进程直接相关联的子进程也可能会被清除掉。在第三方App被清除掉的情况下,只有通过重新启动通信设备,并运行该第三方App,才能重新将第三方App置于后台运行方式。However, the above method of resident application in the background of the operating system, first of all, requires the communication device to have the root function, but according to incomplete statistics, the current ratio of root is about 20%, the application is limited, and the applicability is not wide; secondly, the Android operating system A task manager is provided to record information such as the parent process corresponding to the application and the memory resources occupied by the child process directly associated with the parent process. There are many applications running in the background of the operating system and occupy a large amount of memory resources, resulting in insufficient operating system memory resources. In the case of system cleanup, the parent process and child process corresponding to the third-party App built by obtaining the operating system root permission are operated by The system is managed and controlled by querying the task manager and according to preset rules, for example, according to the memory resource usage or application priority to close (kill) the parent process corresponding to some applications and the child process directly related to the parent process. process, thereby terminating the running of the application, and reclaiming the memory resources occupied by the application to ensure the normal operation of the operating system, resulting in the parent process and the associated child process corresponding to the third-party App residing in the background may be blocked by the operating system Clear to release memory resources; or, in the process of anti-virus software installed in the communication device for virus detection, the parent process corresponding to the third-party App and the child process directly associated with the parent process may also be cleared. When the third-party App is cleared, the third-party App can be placed in the background running mode again only by restarting the communication device and running the third-party App.

由上述可见,现有应用程序常驻操作系统后台的方法,由于驻留于后台的应用程序在操作系统内存资源不足时或在查杀毒的过程中被清除掉,不能实现第三方App常驻(例如24小时)操作系统后台,使得应用程序常驻后台的可靠性较低,从而给用户的正常通信业务带来不便,并影响用户通信业务的正常进行,降低了用户的通信业务体验。而通过通信设备的重启动加载应用程序以重新启动被关掉的进程驻留后台,不仅操作流程较为繁琐,实现应用程序驻留后台所需时间较长,更会导致整个通信设备通信的中断,对用户的通信业务体验影响更大。As can be seen from the above, the method for the existing application program resident in the operating system background, because the application program resident in the background is cleared when the operating system memory resources are insufficient or in the process of checking and killing viruses, the third-party App resident ( For example, 24 hours) operating system background, the reliability of the application program resident in the background is low, which brings inconvenience to the user's normal communication service, affects the normal operation of the user's communication service, and reduces the user's communication service experience. However, loading the application program through the restart of the communication device to restart the closed process resides in the background, not only the operation process is more cumbersome, it takes a long time to realize the application program resides in the background, but also causes the communication of the entire communication device to be interrupted. It has a greater impact on the user's communication service experience.

发明内容SUMMARY OF THE INVENTION

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的应用程序常驻操作系统后台的方法及装置。In view of the above problems, the present invention is proposed in order to provide a method and apparatus for an application program resident in the background of an operating system which overcomes the above problems or at least partially solves the above problems.

依据本发明的一个方面,提供了应用程序常驻操作系统后台的方法,该方法包括:According to one aspect of the present invention, there is provided a method for an application program to reside in the background of an operating system, the method comprising:

接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;Receive a target application startup request, and create a main process for the target application corresponding to the target application startup request;

所述主进程调用函数创建宿主保活进程;The main process calls a function to create a host keep-alive process;

宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;The host keep-alive process calls a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system;

构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;constructing a connection between the main process and the keep-alive process, triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

在监听到主进程或保活进程被关闭后,启动被关闭的进程。After listening to the main process or the keepalive process being shut down, start the shut down process.

优选地,所述操作系统包括但不限于安卓操作系统、Linux操作系统、塞班操作系统。Preferably, the operating system includes, but is not limited to, an Android operating system, a Linux operating system, and a Symbian operating system.

优选地,所述目标应用程序存储在预先设置的启动列表中,在通信设备每次启动后,自动触发向操作系统发起目标应用程序启动请求,操作系统根据接收的目标应用程序启动请求,获取预先设置的启动列表,自动加载启动列表中的应用程序,并为启动列表中的各应用程序分配相应的主进程。Preferably, the target application is stored in a preset startup list, and after each startup of the communication device, it is automatically triggered to initiate a target application startup request to the operating system, and the operating system obtains the preset startup request according to the received target application startup request. Set the startup list, automatically load the applications in the startup list, and assign the corresponding main process to each application in the startup list.

优选地,所述宿主保活进程将自身置于关闭状态,以使所述保活进程托管给操作系统。Preferably, the host keep-alive process places itself in a shutdown state so that the keep-alive process is hosted by the operating system.

优选地,所述将自身置于关闭状态包括:Preferably, said placing itself in a closed state comprises:

主进程在创建宿主保活进程时,为创建的所述宿主保活进程设置生命周期,在设置的生命周期结束后,所述宿主保活进程自然关闭。When creating a host keep-alive process, the main process sets a life cycle for the created host keep-alive process, and after the set life cycle ends, the host keep-alive process is closed naturally.

优选地,所述将自身置于关闭状态包括:Preferably, said placing itself in a closed state comprises:

宿主保活进程在接收到保活进程创建成功信息后,将自身的生命周期置零。After receiving the message that the keep-alive process is successfully created, the host keep-alive process resets its own life cycle to zero.

优选地,所述构建主进程与保活进程连接包括:Preferably, the linking of the building main process with the keep-alive process includes:

主进程创建服务端套接字,保活进程创建客户端套接字;The main process creates the server socket, and the keep-alive process creates the client socket;

绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;Bind the server socket address and listen to the client socket through the server socket;

等待客户端套接字连接;Waiting for client socket connection;

客户端套接字与服务端套接字建立套接字连接。The client socket establishes a socket connection with the server socket.

优选地,所述客户端套接字与服务端套接字建立套接字连接包括:Preferably, establishing a socket connection between the client socket and the server socket includes:

主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The main process creates a keep-alive process host object through the server socket, and allocates a corresponding keep-alive process identifier to the keep-alive process host object;

主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;The main process uses the created keep-alive process host object to start the keep-alive process, and sends a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle;

保活进程启动并接收来自主进程的复活指令;The keepalive process starts and receives the resurrection command from the main process;

所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;The keep-alive process creates a corresponding keep-alive process object through the client socket, and initializes the keep-alive process object;

所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;The keep-alive process object sends a start-up response message to the main process, and the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object;

主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。After receiving the start-up response message of the keep-alive process, the main process determines the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message, and sets the corresponding keep-alive process communication for the keep-alive process host object Interface handle.

优选地,所述在建立套接字连接后,所述方法进一步包括:Preferably, after establishing the socket connection, the method further includes:

所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;The main process receives data from the keep-alive process through the main process communication interface handle, and sends data to the corresponding keep-alive process through the keep-alive process communication interface handle of the keep-alive process host object;

所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。The keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle.

优选地,所述监听到主进程或保活进程被关闭包括:Preferably, the monitoring that the main process or the keep-alive process is shut down includes:

第一进程被关闭,处于关闭状态;The first process is closed and is in a closed state;

第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为0;The monitoring component corresponding to the first process side obtains that the first process is in a closed state, and sets the state parameter identifier of the first process to 0;

通过套接字连接的第二进程读取第一进程的状态参数标识;The second process connected through the socket reads the status parameter identifier of the first process;

第二进程确定第一进程的状态参数标识为0,确定对方进程被关闭。The second process determines that the state parameter identifier of the first process is 0, and determines that the opposite process is closed.

优选地,所述监听到主进程或保活进程被关闭包括:Preferably, the monitoring that the main process or the keep-alive process is shut down includes:

主进程和保活进程使用套接字连接互相监听,确定虚拟套接字连接断开,确定主进程或保活进程被关闭。The main process and the keep-alive process use the socket connection to monitor each other, determine that the virtual socket connection is disconnected, and determine that the main process or the keep-alive process is closed.

优选地,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:Preferably, after monitoring the shutdown of the main process or the keep-alive process, starting the shutdown process includes:

主进程监听到保活进程被关闭,调用复活指令启动保活进程。The main process monitors that the keep-alive process is closed, and calls the resurrection instruction to start the keep-alive process.

优选地,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:Preferably, after monitoring the shutdown of the main process or the keep-alive process, starting the shutdown process includes:

保活进程监听到主进程被关闭,调用复活指令启动主进程并触发启动的主进程执行所述调用函数创建宿主保活进程的流程,并在主进程启动成功后将自身置于关闭状态。The keepalive process monitors that the main process is shut down, invokes the resurrection instruction to start the main process and triggers the activated main process to execute the calling function to create the process of the host keepalive process, and puts itself in a closed state after the main process is successfully started.

优选地,所述保活进程在非安卓生命周期内启动主进程,并使用am指令在linux-C进程启动主进程。Preferably, the keep-alive process starts the main process in the non-Android life cycle, and uses the am instruction to start the main process in the linux-C process.

优选地,所述函数为分叉函数。Preferably, the function is a bifurcation function.

优选地,所述主进程与所述宿主保活进程为父子进程关系,所述宿主保活进程与所述保活进程为父子进程关系。Preferably, the main process and the host keep-alive process are in a parent-child process relationship, and the host keep-alive process and the keep-alive process are in a parent-child process relationship.

优选地,通过未被关闭的所述保活进程或所述主进程启动所述被关闭的进程。Preferably, the closed process is started by the keep-alive process or the main process that is not closed.

根据本发明的另一个方面提供了一种应用程序常驻操作系统后台的装置,该装置包括:主进程创建模块、宿主保活进程创建模块、保活进程创建模块、连接模块以及监听处理模块,其中,According to another aspect of the present invention, there is provided a device for an application program to reside in the background of an operating system, the device comprising: a main process creation module, a host keep-alive process creation module, a keep-alive process creation module, a connection module, and a monitoring processing module, in,

主进程创建模块,用于接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;The main process creation module is used to receive the target application startup request, and create a main process for the target application corresponding to the target application startup request;

宿主保活进程创建模块,用于触发主进程调用函数创建宿主保活进程;The host keep alive process creation module is used to trigger the main process to call the function to create the host keep alive process;

保活进程创建模块,用于触发宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;A keep-alive process creation module is used to trigger the host keep-alive process to call a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system;

连接模块,用于构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;a connection module, used for constructing a connection between the main process and the keep-alive process, and triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

监听处理模块,用于在监听到主进程或保活进程被关闭后,启动被关闭的进程。The monitoring processing module is used to start the closed process after monitoring that the main process or the keep-alive process is closed.

优选地,所述保活进程创建模块包括:保活进程创建单元、生命周期设置单元以及生命周期运行单元,其中,Preferably, the keep-alive process creation module includes: a keep-alive process creation unit, a life cycle setting unit, and a life cycle running unit, wherein,

保活进程创建单元,用于触发宿主保活进程调用函数创建保活进程;The keep-alive process creation unit is used to trigger the host keep-alive process to call a function to create a keep-alive process;

生命周期设置单元,用于为创建的所述宿主保活进程设置生命周期;a life cycle setting unit, used to set a life cycle for the created host keep-alive process;

生命周期运行单元,用于运行设置的生命周期,在设置的生命周期结束后,触发所述宿主保活进程自然关闭。The life cycle running unit is used to run the set life cycle, and after the set life cycle ends, trigger the host keep-alive process to shut down naturally.

优选地,所述连接模块包括:连接预处理单元、连接单元以及监听单元,其中,Preferably, the connection module includes: a connection preprocessing unit, a connection unit and a monitoring unit, wherein,

连接预处理单元,用于触发主进程创建服务端套接字,保活进程创建客户端套接字;使主进程绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;等待客户端套接字连接;The connection preprocessing unit is used to trigger the main process to create a server socket, and the keep alive process to create a client socket; make the main process bind the server socket address, and monitor the client socket through the server socket connect; wait for client socket connection;

连接单元,用于触发客户端套接字与服务端套接字建立套接字连接;The connection unit is used to trigger the client socket to establish a socket connection with the server socket;

监听单元,触发所述主进程与保活进程基于构建的连接进行相互监听。The monitoring unit triggers the main process and the keep-alive process to monitor each other based on the established connection.

优选地,所述连接单元包括:保活进程宿主对象创建子单元、启动子单元、保活进程启动子单元、初始化子单元、应答子单元以及应答处理子单元,其中,Preferably, the connection unit includes: a keep alive process host object creation subunit, a promoter subunit, a keep alive process starter subunit, an initialization subunit, a response subunit, and a response processing subunit, wherein,

保活进程宿主对象创建子单元,用于触发主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The keep-alive process host object creation subunit is used to trigger the main process to create a keep-alive process host object through the server socket, and assign a corresponding keep-alive process identifier to the keep-alive process host object;

启动子单元,用于触发主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;A start-up subunit, used to trigger the main process to use the created keep-alive process host object to start the keep-alive process, and send a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle ;

保活进程启动子单元,用于触发保活进程启动并接收来自主进程的复活指令;The keep-alive process startup subunit is used to trigger the start of the keep-alive process and receive the resurrection instruction from the main process;

初始化子单元,用于触发所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;an initialization subunit, configured to trigger the keep-alive process to create a corresponding keep-alive process object through the client socket, and initialize the keep-alive process object;

应答子单元,用于触发所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;a response subunit, configured to trigger the keep-alive process object to send a start-up response message to the main process, where the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object;

应答处理子单元,用于触发主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。The response processing subunit is used to trigger the main process to determine the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message after receiving the start-up response message of the keep-alive process, and host the keep-alive process The object sets the corresponding keepalive process communication interface handle.

优选地,所述连接单元进一步包括:数据传输子单元,用于触发所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。Preferably, the connection unit further comprises: a data transmission subunit, configured to trigger the main process to receive data from the keep-alive process through the main process communication interface handle, and to use the keep-alive process communication interface handle of the keep-alive process host object Send data to the corresponding keep-alive process; the keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle.

优选地,所述监听处理模块包括:状态参数标识设置单元、状态参数标识读取单元、状态参数标识确定单元以及进程重启动单元,其中,Preferably, the monitoring processing module includes: a state parameter identification setting unit, a state parameter identification reading unit, a state parameter identification determining unit, and a process restarting unit, wherein,

状态参数标识设置单元,用于在第一进程被关闭,处于关闭状态后,第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为关闭状态;a state parameter identifier setting unit, used for, after the first process is closed and is in the closed state, the monitoring component corresponding to the first process side acquires that the first process is in the closed state, and sets the state parameter identifier of the first process to the closed state;

状态参数标识读取单元,用于通过套接字连接的第二进程读取第一进程的状态参数标识;a state parameter identifier reading unit, used for reading the state parameter identifier of the first process through the second process connected by the socket;

状态参数标识确定单元,用于在第二进程确定第一进程的状态参数标识为关闭状态,确定第一进程被关闭;a state parameter identification determining unit, configured to determine, in the second process, that the state parameter identification of the first process is a closed state, and determine that the first process is closed;

进程重启动单元,用于启动被关闭的第一进程。The process restarting unit is used to start the closed first process.

根据本发明的应用程序常驻操作系统后台的方法及装置,在操作系统为应用程序创建主进程后,主进程再通过调用分叉函数fork()创建宿主保活进程,设置宿主保活进程再通过调用分叉函数fork()创建保活进程,并在保活进程创建成功后,结束自身的生命周期。由此通过两级进程分离用户进程,在宿主保活进程被关闭后,使得同一应用程序对应的主进程与保活进程之间不存在直接关联关系,解决了操作系统或杀毒软件依据直接关联关系进行查杀导致应用程序不能常驻后台的技术问题,取得了通过未被关闭的进程来启动关闭的进程,从而使得应用程序仍可以驻留在后台,可以很好地满足必须要7x24h后台运行的应用程序的业务需求、提升应用程序常驻后台的可靠性的有益效果;进一步地,该方法不管在Root还是非Root的通信设备上都能使用;而且,无需等待通信设备重启动重新加载配置文件以使得进程常驻,操作流程较为简单,实现应用程序驻留后台所需时间短,不影响通信设备通信,提升了用户的通信业务体验。According to the method and device for the application program resident in the background of the operating system of the present invention, after the operating system creates the main process for the application program, the main process creates the host keep-alive process by calling the fork function fork(), sets the host keep-alive process, and then creates the host keep-alive process. Create a keep-alive process by calling the fork function fork(), and end its own life cycle after the keep-alive process is successfully created. In this way, the user process is separated by two-level processes, and after the host keep-alive process is closed, there is no direct correlation between the main process corresponding to the same application and the keep-alive process, which solves the problem of direct correlation between the operating system or antivirus software. The technical problem that the application cannot be resident in the background due to the killing, and the closed process is started through the process that has not been closed, so that the application can still reside in the background, which can well meet the needs of 7x24h running in the background. The business requirements of the application program and the beneficial effect of improving the reliability of the application program resident in the background; further, the method can be used on both Root and non-Root communication devices; moreover, there is no need to wait for the communication device to restart and reload the configuration file In order to make the process resident, the operation process is relatively simple, the time required to realize the application program resident in the background is short, the communication of the communication device is not affected, and the user's communication service experience is improved.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, in order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand , the following specific embodiments of the present invention are given.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:

图1示出了本发明实施例应用程序常驻操作系统后台的方法流程;FIG. 1 shows a method flow of an application program resident in the background of an operating system according to an embodiment of the present invention;

图2示出了本发明实施例应用程序常驻操作系统后台的方法具体流程;以及,Fig. 2 shows the specific flow of the method for the application program to reside in the background of the operating system according to the embodiment of the present invention; and,

图3示出了本发明实施例应用程序常驻操作系统后台的装置结构。FIG. 3 shows an apparatus structure in which an application program resides in the background of an operating system according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art.

现有通过获取操作系统根权限,然后修改操作系统中/system/build.prop文件的配置信息,使得基于fork函数构建的父进程和与父进程直接相关联的子进程托管于操作系统实现应用程序常驻后台的方法,在应用程序退出前台后,前台运行的父进程以及后台运行的与父进程直接关联的子进程仍可处于激活状态,但驻留于后台的应用程序在操作系统内存资源不足时或在查杀毒的过程中,处于激活状态的父进程以及与父进程直接关联的子进程可能被清除掉,不能实现第三方App常驻(例如24小时)操作系统后台;而通过通信设备的重启动加载应用程序以重新启动被关掉的进程驻留后台,不仅操作流程较为繁琐,实现应用程序驻留后台所需时间较长,更会导致整个通信设备通信的中断。At present, by obtaining the operating system root authority, and then modifying the configuration information of the /system/build.prop file in the operating system, the parent process built based on the fork function and the child process directly associated with the parent process are hosted on the operating system to implement the application. The method of resident in the background, after the application exits the foreground, the parent process running in the foreground and the child process directly related to the parent process running in the background can still be activated, but the application residing in the background is insufficient in the operating system memory resources From time to time or in the process of virus checking, the active parent process and the child process directly related to the parent process may be cleared, and the third-party App cannot be resident (for example, 24 hours) in the operating system background; Restarting and loading an application program to restart the shut-down process resides in the background, not only the operation process is more cumbersome, it takes a long time to realize the application program resides in the background, but also causes the communication of the entire communication device to be interrupted.

由于应用程序通过fork函数创建父进程以及与父进程直接关联的子进程,可以实现应用程序常驻操作系统后台,如果能在应用程序对应的两进程中的一进程在被操作系统或杀毒软件关闭后,能够通过另一进程及时地启动关闭的进程,这样,可以确保关闭进程在操作系统后台的及时复活,使得进程对应的应用程序可以恢复并驻留在后台。但由于现有为应用程序创建的父进程以及子进程之间存在直接关联关系,因而,在任务管理器释放内存资源时,会将父进程以及存在直接关联关系的子进程占用的资源一同释放,从而使得父进程以及子进程同时被关闭,使得不存在应用程序对应的两进程中的一进程被操作系统或杀毒软件关闭的情形。Since the application creates the parent process and the child process directly associated with the parent process through the fork function, the application can be resident in the operating system background. If one of the two processes corresponding to the application is closed by the operating system or antivirus software After that, another process can be used to start the closed process in time, so that it can ensure the timely resurrection of the closed process in the background of the operating system, so that the application program corresponding to the process can be restored and reside in the background. However, due to the existing direct relationship between the parent process and the child process created for the application, when the task manager releases the memory resources, the resources occupied by the parent process and the directly related child process will be released together. Therefore, the parent process and the child process are closed at the same time, so that there is no situation in which one of the two processes corresponding to the application is closed by the operating system or antivirus software.

分叉函数fork()源于操作系统(OS,Operation System)中多线程任务的需要,应用程序在前台启动后,操作系统首先为该应用程序分配进程,并通过操作系统调用,创建一个与原进程(父进程)几乎完全相同的进程(子进程)。其中,两个进程可以执行完全相同的功能,也可以执行不同的功能。当父进程调用fork()函数后,操作系统先给新的进程(子进程)分配资源,例如存储数据和代码的空间;然后将原进程的所有资源都复制到新的新进程中,当然,在完成fork之后也可以自行修改被复制的资源。这样,在fork函数执行完毕后,出现两个进程,一个是子进程,一个是父进程。在子进程中,fork函数返回0,在父进程中,fork返回新创建子进程的进程ID。因而,在应用程序退出后,子进程可以驻留在后台。The fork function fork() originates from the needs of multi-threaded tasks in the operating system (OS, Operation System). After the application is started in the foreground, the operating system first allocates a process for the application, and calls it through the operating system to create a A process (parent process) is an almost identical process (child process). Among them, two processes can perform exactly the same function, or they can perform different functions. When the parent process calls the fork() function, the operating system first allocates resources to the new process (child process), such as space for storing data and code; then copies all the resources of the original process to the new new process, of course, After completing the fork, you can also modify the copied resources yourself. In this way, after the fork function is executed, two processes appear, one is the child process and the other is the parent process. In the child process, the fork function returns 0, and in the parent process, fork returns the process ID of the newly created child process. Thus, the child process can reside in the background after the application exits.

本发明实施例中,考虑操作系统通过调用分叉函数fork()为父进程创建子进程后,再通过调用分叉函数fork()为子进程创建下级子进程。这样,父进程与下级子进程之间不存在直接关联关系,在子进程被关闭后,则下级子进程成为孤儿进程,从而会被托管给操作系统进程,而由于下级子进程与子进程都对应同一应用程序,因而,后续使用中,在系统内存资源不足或杀毒软件在查杀毒过程中,由于父进程与下级子进程不存在直接关联关系,因而,在任务管理器依据关联关系进行进程关闭处理时,两个进程被操作系统同时清除或被杀毒软件同时查杀的概率较低,这样,可以通过未被关闭的进程来启动关闭的进程,从而使得父进程与下级子进程可以驻留在后台,从而保障应用程序在后台持续运行,可以很好地满足必须要7x24h后台运行的(第三方)应用程序的业务需求。相比采用Root的技术方案,本发明实施例不管在Root还是非Root的通信设备上都能使用,基本不受杀毒软件(杀软)影响,而且功耗很低。In the embodiment of the present invention, it is considered that after the operating system creates a child process for the parent process by calling the fork function fork(), it then creates a subordinate child process for the child process by calling the fork function fork(). In this way, there is no direct relationship between the parent process and the lower-level child process. After the child process is closed, the lower-level child process becomes an orphan process, which will be hosted by the operating system process. The same application, therefore, in subsequent use, when the system memory resources are insufficient or the anti-virus software is in the process of anti-virus checking, since there is no direct relationship between the parent process and the subordinate child process, the task manager will process the process shutdown according to the relationship. When the two processes are simultaneously cleared by the operating system or killed by anti-virus software at the same time, the probability is low , so as to ensure that the application runs continuously in the background, which can well meet the business needs of (third-party) applications that must run in the background 7x24h. Compared with the technical solution using Root, the embodiments of the present invention can be used on both Root and non-Root communication devices, are basically not affected by anti-virus software (anti-software), and have low power consumption.

图1示出了本发明实施例应用程序常驻操作系统后台的方法流程。参见图1,该流程包括:FIG. 1 shows a flow of a method for an application program to reside in the background of an operating system according to an embodiment of the present invention. Referring to Figure 1, the process includes:

步骤101,接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;Step 101, receiving a target application startup request, and creating a main process for the target application corresponding to the target application startup request;

本步骤中,目标应用程序为需要常驻操作系统后台的应用程序,例如,即时通讯类应用程序、电子市场类应用程序以及定位服务类应用程序等,其中,即时通讯类应用程序可以是QQ、微信、微博等。In this step, the target application is an application that needs to reside in the background of the operating system, for example, an instant messaging application, an electronic market application, and a positioning service application, etc., where the instant messaging application may be QQ, WeChat, Weibo, etc.

本发明实施例中,作为可选实施例,由操作系统接收目标应用程序启动请求,操作系统包括但不限于安卓操作系统、Linux操作系统、塞班操作系统等。In the embodiment of the present invention, as an optional embodiment, the target application startup request is received by the operating system, and the operating system includes but is not limited to the Android operating system, the Linux operating system, the Symbian operating system, and the like.

本发明实施例中,操作系统后台是指前台应用程序在关闭后,驻留在操作系统中所处的位置为操作系统后台。In the embodiment of the present invention, the operating system background refers to the operating system background where the foreground application program resides in the operating system after it is closed.

实际应用中,可以预先将需要常驻操作系统后台的应用程序设置为通信设备开机启动的启动列表中。即所述目标应用程序存储在预先设置的启动列表中。这样,在通信设备每次启动后,自动触发向操作系统发起目标应用程序启动请求,操作系统根据接收的目标应用程序启动请求,获取预先设置的启动列表,自动加载启动列表中的应用程序,并为启动列表中的各应用程序分配相应的主进程。In practical applications, the application programs that need to reside in the background of the operating system can be set in the startup list for startup of the communication device in advance. That is, the target application is stored in a preset startup list. In this way, after each startup of the communication device, it is automatically triggered to initiate a target application startup request to the operating system, and the operating system obtains a preset startup list according to the received target application startup request, automatically loads the applications in the startup list, and Assign the corresponding master process to each application in the startup list.

当然,作为可选实施例,也可以是由用户在启动通信设备后,点击需要启动的常驻操作系统后台的应用程序,触发向操作系统发起目标应用程序启动请求。这样,用户可以根据自身实际需要,选取需要常驻操作系统后台的一个或多个应用程序。Of course, as an optional embodiment, after starting the communication device, the user can also click on the application program that needs to be started and reside in the background of the operating system, to trigger the starting request of the target application program to the operating system. In this way, the user can select one or more application programs that need to reside in the background of the operating system according to their actual needs.

本发明实施例中,为目标应用程序创建主进程的流程为公知技术,在此略去详述。In the embodiment of the present invention, the process of creating the main process for the target application is a known technology, and the detailed description is omitted here.

步骤102,所述主进程调用函数创建宿主保活进程;Step 102, the main process calls a function to create a host keep-alive process;

本步骤中,作为可选实施例,函数为分叉函数。对于主进程和宿主保活进程,主进程对应父进程,宿主保活进程对应子进程。In this step, as an optional embodiment, the function is a bifurcation function. For the main process and the host keep-alive process, the main process corresponds to the parent process, and the host keep-alive process corresponds to the child process.

本发明实施例中,父进程调用fork函数产生子进程,子进程具有与父进程相同的资源。In the embodiment of the present invention, the parent process calls the fork function to generate a child process, and the child process has the same resources as the parent process.

步骤103,宿主保活进程调用分叉函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;Step 103, the host keep-alive process calls the fork function to create the keep-alive process, and after the keep-alive process is created, the keep-alive process is managed to the operating system;

本步骤中,宿主保活进程调用分叉函数创建保活进程的流程与主进程调用分叉函数创建宿主保活进程的流程相同,在此略去详述。In this step, the process of the host keep-alive process calling the fork function to create the keep-alive process is the same as the process of the main process calling the fork function to create the host keep-alive process, and details are omitted here.

本发明实施例中,对于宿主保活进程和保活进程,宿主保活进程对应父进程,保活进程对应子进程。In the embodiment of the present invention, for the host keep-alive process and the keep-alive process, the host keep-alive process corresponds to the parent process, and the keep-alive process corresponds to the child process.

在主进程、宿主保活进程以及保活进程中,设置有状态参数标识,例如,当状态参数标识为1时,表示进程处于正常状态;当状态参数标识为0时,表示进程处于关闭状态。也就是说,如果进程处于关闭状态,则该进程对应的状态参数标识被自动设置为0。这样,后续应用中,对端进程通过读取该进程对应的状态参数标识,使得所述对端进程在生命周期内能够主动地,及时知道该端进程是否存活或被关闭。当然,实际应用中,也可以设置当状态参数标识为0时,表示进程处于正常状态;当状态参数标识为1时,表示进程处于关闭状态。In the main process, the host keep-alive process and the keep-alive process, a state parameter identifier is set. For example, when the state parameter identifier is 1, it means that the process is in a normal state; when the state parameter identifier is 0, it means that the process is in a closed state. That is, if the process is in the shutdown state, the state parameter flag corresponding to the process is automatically set to 0. In this way, in subsequent applications, the peer process reads the state parameter identifier corresponding to the process, so that the peer process can actively and timely know whether the process is alive or closed during the life cycle. Of course, in practical applications, it can also be set that when the status parameter identifier is 0, it indicates that the process is in a normal state; when the status parameter identifier is 1, it indicates that the process is in a closed state.

本发明实施例中,以Linux操作系统为例,在Linux操作系统上,当宿主保活进程被关闭,保活进程变成孤儿进程,同时,变为孤儿进程的保活进程会被托管给最早fork出来的进程,即操作系统进程。这样,通过两级进程分离用户进程,可以使得主进程与保活进程之间不存在直接关联关系,从而可以有效防止任务管理器或杀毒软件依据直接关联关系对进程进行查杀时,避免主进程与保活进程都被查杀。也就是说,例如,任务管理器或杀毒软件在查杀到主进程并需要清除主进程时,依据存储的该主进程的直接关联关系,查询到宿主保活进程,但由于该宿主保活进程已被关闭,因而,将主进程关闭以释放内存资源,在后续保活进程没有被查杀到的情况下,未被查杀到的保活进程可以复活被查杀的主进程,使得主进程和保活进程对应的应用程序仍可驻留于操作系统后台。In the embodiment of the present invention, taking the Linux operating system as an example, on the Linux operating system, when the host keep-alive process is closed, the keep-alive process becomes an orphan process. Fork out of the process, that is, the operating system process. In this way, by separating the user process by two-level process, there can be no direct relationship between the main process and the keep-alive process, so that the task manager or antivirus software can effectively prevent the main process from killing the process according to the direct relationship. And keep alive processes are killed. That is to say, for example, when the task manager or antivirus software detects and kills the main process and needs to clear the main process, it can query the host keep-alive process according to the stored direct relationship of the main process, but because the host keep-alive process is It has been closed. Therefore, the main process is closed to release memory resources. In the case that the subsequent keep-alive process is not killed, the keep-alive process that has not been killed can revive the killed main process, making the main process. Applications corresponding to keep-alive processes can still reside in the operating system background.

作为可选实施例,所述宿主保活进程将自身置于关闭状态,以使所述保活进程托管给操作系统。As an optional embodiment, the host keep-alive process puts itself in a shutdown state, so that the keep-alive process is hosted by the operating system.

其中,将自身置于关闭状态包括:Among them, placing itself in a closed state includes:

主进程在创建宿主保活进程时,为创建的所述宿主保活进程设置生命周期,在设置的生命周期结束后,所述宿主保活进程自然关闭。When creating a host keep-alive process, the main process sets a life cycle for the created host keep-alive process, and after the set life cycle ends, the host keep-alive process is closed naturally.

本步骤中,主进程在为创建的所述宿主保活进程设置生命周期时,考虑后续宿主保活进程创建保活进程所需的时间,使得设置的生命周期大于或等于宿主保活进程创建保活进程所需的时间即可。In this step, when setting the life cycle for the created host keep-alive process, the main process considers the time required for the subsequent host keep-alive process to create the keep-alive process, so that the set life cycle is greater than or equal to the host keep-alive process creation life cycle. The time required for the live process is sufficient.

作为另一可选实施例,将自身置于关闭状态也可以包括:As another optional embodiment, placing itself in an off state may also include:

宿主保活进程在接收到保活进程创建成功信息后,将自身的生命周期置零。After receiving the message that the keep-alive process is successfully created, the host keep-alive process resets its own life cycle to zero.

本步骤中,主进程在为创建的所述宿主保活进程设置生命周期时,默认为操作系统设置的最大值,即默认生命周期为无限长,宿主保活进程创建保活进程,保活进程在创建成功后,向宿主保活进程返回创建成功信息。因而,可以设置宿主保活进程在接收到保活进程创建成功信息后,将自身的生命周期置零,以使宿主保活进程自然死亡。In this step, when the main process sets the life cycle for the created host keep-alive process, it defaults to the maximum value set by the operating system, that is, the default life cycle is infinitely long, the host keep-alive process creates a keep-alive process, and the keep-alive process After the creation is successful, the creation success information is returned to the host keep-alive process. Therefore, it is possible to set the host keep-alive process to zero its own life cycle after receiving the successful message of the keep-alive process creation, so that the host keep-alive process naturally dies.

步骤104,构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;Step 104, constructing a connection between the main process and the keep-alive process, triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

本步骤中,作为可选实施例,构建主进程与保活进程连接包括:In this step, as an optional embodiment, establishing a connection between the main process and the keep-alive process includes:

A11,主进程创建服务端套接字(LocalServerSocket),保活进程创建客户端套接字(LocalSocket);A11, the main process creates a server socket (LocalServerSocket), and the keep alive process creates a client socket (LocalSocket);

本步骤中,在基于多个传输控制协议(TCP,Transmission Control Protocol)进行连接或存在多个应用程序进程的情况下,可能需要通过同一个TCP协议端口传输数据。为了区别不同的应用程序进程和连接,计算机操作系统为应用程序与传输控制协议/网际协议(TCP/IP,Transfer Control Protocol/Internet Protocol)交互提供了称为套接字(Socket)的接口。其中,套接字用于区分不同应用程序进程间的网络通信和连接,是支持TCP/IP协议的网络通信的基本操作单元,是不同主机之间的进程进行双向通信的端点,也就是说,通信的两方可以通过套接字中的相关函数来完成通信过程。In this step, when connections are made based on multiple Transmission Control Protocols (TCP, Transmission Control Protocol) or there are multiple application programs, data may need to be transmitted through the same TCP protocol port. In order to distinguish different application processes and connections, a computer operating system provides an interface called a socket (Socket) for the interaction between applications and Transmission Control Protocol/Internet Protocol (TCP/IP, Transfer Control Protocol/Internet Protocol). Among them, the socket is used to distinguish the network communication and connection between different application processes. It is the basic operation unit of network communication that supports the TCP/IP protocol, and is the endpoint for two-way communication between processes between different hosts. That is to say, The two communicating parties can complete the communication process through the related functions in the socket.

本发明实施例中,主进程与保活进程采用客户端/服务端(C/S,Client/Service)模式进行通信。主进程创建服务器端Unix域套接字,即LocalServerSocket作为服务端使用,建立socket监听客户端请求,保活进程创建客户端套接字(LocalSocket),客户端套接字运行在保活进程中。In the embodiment of the present invention, the main process and the keep-alive process communicate in a client/server (C/S, Client/Service) mode. The main process creates a server-side Unix domain socket, that is, LocalServerSocket is used as a server, establishes a socket to monitor client requests, and the keep-alive process creates a client socket (LocalSocket), and the client socket runs in the keep-alive process.

本发明实施例中,以创建服务端套接字为例,采用文件描述符创建已经存在的服务端套接字,例如,在init.rc中指定服务端套接字资源地址dev/socket/……,创建作为服务端的套接字,程序代码段如下:In the embodiment of the present invention, taking creating a server socket as an example, a file descriptor is used to create an existing server socket, for example, the server socket resource address dev/socket/… is specified in init.rc ..., create a socket as a server, the program code segment is as follows:

LocalServerSocket socket=new LocalServerSocket(createFileDescriptor(fi leDesc))。LocalServerSocket socket=new LocalServerSocket(createFileDescriptor(fileDesc)).

作为可选实施例,本发明实施例中,基于TCP/IP协议的套接字类型可以包括:流套接字(SOCK_STREAM)、数据报套接字(SOCK_DGRAM)以及原始套接字(SOCK_RAW)。关于套接字类型为公知技术,在此略去详述。As an optional embodiment, in this embodiment of the present invention, the socket types based on the TCP/IP protocol may include: a stream socket (SOCK_STREAM), a datagram socket (SOCK_DGRAM), and a raw socket (SOCK_RAW). The socket type is a well-known technology, and the detailed description is omitted here.

套接字内容包括:通信的目的IP地址、使用的传输层协议,例如,TCP协议或用户数据报协议(UDP,User Datagram Protocol),以及使用的端口号。The content of the socket includes: the destination IP address of the communication, the used transport layer protocol, for example, the TCP protocol or the User Datagram Protocol (UDP, User Datagram Protocol), and the used port number.

A12,绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;A12, bind the server socket address, and monitor the client socket through the server socket;

本步骤中,服务端套接字不定位具体的客户端套接字,而是处于等待连接的状态,并实时监控网络状态。In this step, the server socket does not locate a specific client socket, but is in a state of waiting for a connection, and monitors the network state in real time.

绑定服务端套接字地址,并通过服务端套接字监听客户端套接字的程序段代码可以如下:The program code that binds the server socket address and listens to the client socket through the server socket can be as follows:

//绑定地址// bind address

localAddress=new LocalSocketAddress(name);localAddress=new LocalSocketAddress(name);

impl.bind(localAddress);impl.bind(localAddress);

//监听//monitor

impl.listen(LISTEN_BACKLOG);impl.listen(LISTEN_BACKLOG);

A13,等待客户端套接字连接;A13, waiting for client socket connection;

本步骤中,客户端设置连接地址,并建立连接。具体来说,保活进程的客户端套接字发送连接请求,携带通信目的IP地址,该通信目的IP地址为服务器端套接字。也就是说,客户端套接字首先描述需要连接的服务器套接字,写入服务器套接字的地址和端口号,然后再向服务器端套接字发送连接请求。In this step, the client sets the connection address and establishes the connection. Specifically, the client socket of the keep-alive process sends a connection request, which carries the communication destination IP address, where the communication destination IP address is the server-side socket. That is, the client socket first describes the server socket that needs to be connected, writes the address and port number of the server socket, and then sends a connection request to the server socket.

设置连接地址的程序代码段可以如下:The program code segment for setting the connection address can be as follows:

LocalSocketAddress address=new LocalSocketAddress("installd",LocalSocketAddress.Namespace.RESERVED);LocalSocketAddress address=new LocalSocketAddress("installd", LocalSocketAddress.Namespace.RESERVED);

/建立连接/establish connection

mSocket.connect(address);mSocket.connect(address);

A14,客户端套接字与服务端套接字建立套接字连接。A14, the client socket establishes a socket connection with the server socket.

本步骤中,当服务器端套接字监听或接收到客户端套接字发送的连接请求后,响应客户端套接字的请求,建立一个新的线程,并将服务器端套接字的信息发送给客户端套接字对应的保活进程,保活进程确认该套接字连接。具体来说,该步骤包括:In this step, after the server-side socket monitors or receives the connection request sent by the client-side socket, it responds to the client-side socket request, establishes a new thread, and sends the information of the server-side socket. Give the keep-alive process corresponding to the client socket, and the keep-alive process confirms the socket connection. Specifically, this step includes:

A01,主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;A01, the main process creates a keep-alive process host object through the server socket, and allocates a corresponding keep-alive process identifier for the keep-alive process host object;

本步骤中,主进程创建并管理保活进程宿主对象,每个保活进程宿主对象对应一个保活进程,并拥有与所对应保活进程相同的保活进程标识。In this step, the main process creates and manages a keep-alive process host object, each keep-alive process host object corresponds to a keep-alive process, and has the same keep-alive process identifier as the corresponding keep-alive process.

A02,主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;A02, the main process uses the created keep-alive process host object to start the keep-alive process, and sends a resurrection instruction to the keep-alive process, and the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle;

本步骤中,保活进程宿主对象中提供了创建和启动保活进程的方法,并提供数据通信接口用于向保活进程发送复活指令。具体来说,主进程以命令行的方式通过调用保活进程宿主对象提供的进程创建方法创建一个新的保活进程,所述命令行包括所述复活指令。In this step, the keep-alive process host object provides a method for creating and starting the keep-alive process, and provides a data communication interface for sending a resurrection instruction to the keep-alive process. Specifically, the main process uses a command line to create a new keep alive process by calling a process creation method provided by the keep alive process host object, and the command line includes the resurrection instruction.

A03,保活进程启动并接收来自主进程的复活指令;A03, the keep alive process starts and receives the resurrection instruction from the main process;

A04,所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;A04, the keep-alive process creates a corresponding keep-alive process object through the client socket, and initializes the keep-alive process object;

本步骤中,在初始化过程中,保活进程对接收到的复活指令中携带的保活进程标识、主进程通信接口句柄等命令行参数进行保存。In this step, during the initialization process, the keep-alive process saves the command-line parameters such as the keep-alive process identifier and the main process communication interface handle carried in the received resurrection instruction.

A05,所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;A05, the keep-alive process object sends a start-up response message to the main process, where the start-up response message carries the keep-alive process communication interface handle and keep-alive process identifier corresponding to the keep-alive process object;

本步骤中,完成初始化后,保活进程对象使用进程间通信(IPC,Inter-ProcessCommunication)向主进程发送启动应答消息。In this step, after completing the initialization, the keep-alive process object sends a start-up response message to the main process by using Inter-Process Communication (IPC, Inter-Process Communication).

A06,主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。A06, after receiving the activation response message of the keep-alive process, the main process determines the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message, and sets the corresponding keep-alive process host object for the keep-alive process host object Process communication interface handle.

这样,主进程中的保活进程宿主对象就拥有了与其对应的保活进程对象的保活进程通信接口句柄,而保活进程也获得了对应主进程的通信接口句柄。基于获得的保活进程通信接口句柄,保活进程宿主对象对外提供与对应的保活进程对象进行进程间通信的通信接口,使得主进程能够通过调用所述通信接口向对应的保活进程发送数据。In this way, the keep-alive process host object in the main process has the keep-alive process communication interface handle of its corresponding keep-alive process object, and the keep-alive process also obtains the communication interface handle corresponding to the main process. Based on the obtained keep-alive process communication interface handle, the keep-alive process host object externally provides a communication interface for inter-process communication with the corresponding keep-alive process object, so that the main process can send data to the corresponding keep-alive process by calling the communication interface .

在建立套接字连接后,主进程与保活进程都处于监听状态,监听对方的状态。After the socket connection is established, both the main process and the keep-alive process are in a listening state, monitoring the state of each other.

进一步地,在建立套接字连接后,该方法还可以进一步包括:Further, after establishing the socket connection, the method may further include:

A15,主进程和保活进程建立通信通道进行数据传输。A15, the main process and the keep-alive process establish a communication channel for data transmission.

该步骤可以具体包括:This step can specifically include:

所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;The main process receives data from the keep-alive process through the main process communication interface handle, and sends data to the corresponding keep-alive process through the keep-alive process communication interface handle of the keep-alive process host object;

所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。The keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle.

步骤105,在监听到主进程或保活进程被关闭后,启动被关闭的进程。Step 105, after monitoring that the main process or the keep-alive process is shut down, start the shut down process.

本步骤中,主进程和保活进程互为对方进程,也就是在监听到对方进程被关闭后,启动被关闭的进程。In this step, the main process and the keep-alive process are each other's processes, that is, after monitoring that the other process is closed, the closed process is started.

作为可选实施例,监听到对方进程被关闭包括:As an optional embodiment, monitoring that the peer process is shut down includes:

B11,第一进程被关闭,处于关闭状态;B11, the first process is closed and is in a closed state;

本步骤中,第一进程既可以是主进程,也可以是保活进程。进程被关闭,可能是由于操作系统在内存资源不足时,需要释放内存资源而将该进程关闭;也可能是杀毒软件在查杀毒过程中,查杀该进程而将该进程关闭;还可能是其它情形下关闭进程。In this step, the first process may be either a main process or a keep-alive process. If the process is closed, it may be because the operating system needs to release memory resources to close the process when the memory resources are insufficient; it may also be that the antivirus software kills the process and closes the process during the antivirus detection process; it may also be other In this case, close the process.

B12,第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为0;B12, the monitoring component corresponding to the first process side acquires that the first process is in a closed state, and sets the state parameter identifier of the first process to 0;

B13,通过套接字连接的第二进程读取第一进程的状态参数标识;B13, read the status parameter identifier of the first process through the second process connected by the socket;

本步骤中,如果第一进程为主进程,则第二进程为保活进程;如果第一进程为保活进程,则第二进程为主进程。In this step, if the first process is the main process, the second process is the keep-alive process; if the first process is the keep-alive process, the second process is the main process.

B14,第二进程确定第一进程的状态参数标识为0,确定对方进程被关闭。B14, the second process determines that the state parameter identifier of the first process is 0, and determines that the opposite process is closed.

作为另一可选实施例,监听到对方进程被关闭包括:As another optional embodiment, monitoring that the opposite process is shut down includes:

主进程和保活进程使用套接字连接互相监听,确定虚拟套接字连接断开,确定对方进程被关闭。The main process and the keep-alive process use the socket connection to monitor each other, determine that the virtual socket connection is disconnected, and determine that the other process is closed.

本发明实施例中,采用套接字连接进行互相监听,功耗小且稳定,不易出错。In the embodiment of the present invention, the socket connection is used to monitor each other, the power consumption is small and stable, and it is not easy to make mistakes.

较佳地,操作系统或杀毒软件关闭进程后,进一步释放所述关闭进程的所有资源,从而使得操作系统可自动回收该关闭进程占用的内存、CPU等系统资源。Preferably, after the operating system or antivirus software closes the process, all resources of the closed process are further released, so that the operating system can automatically reclaim system resources such as memory and CPU occupied by the closed process.

作为可选实施例,在监听到对方进程被关闭后,启动关闭的进程可以包括:As an optional embodiment, after monitoring that the opposite process is shut down, starting the shut down process may include:

主进程监听到保活进程被关闭,调用复活指令启动保活进程。The main process monitors that the keep-alive process is closed, and calls the resurrection instruction to start the keep-alive process.

作为另一可选实施例,在监听到对方进程被关闭后,启动关闭的进程还可以包括:As another optional embodiment, after monitoring that the opposite process is shut down, starting the shut down process may further include:

保活进程监听到主进程被关闭,调用复活指令启动主进程并触发启动的主进程执行所述调用分叉函数创建宿主保活进程的流程,并在主进程启动成功后将自身置于关闭状态。The keep-alive process monitors that the main process is shut down, calls the resurrection instruction to start the main process and triggers the activated main process to execute the process of calling the fork function to create the host keep-alive process, and puts itself in a closed state after the main process is successfully started .

本步骤中,为避免复活的主进程通过创建宿主保活进程,并传入复活指令创建保活进程,使得操作系统存在冗余的保活进程,从而占用不必要的操作系统内存。因而,当保活进程启动主进程后,结束自身的生命周期,退出操作系统后台。In this step, in order to avoid the resurrected main process creating a host keep-alive process and passing in a resurrection instruction to create a keep-alive process, redundant keep-alive processes exist in the operating system, thus occupying unnecessary operating system memory. Therefore, when the keep-alive process starts the main process, it ends its own life cycle and exits the operating system background.

较佳地,保活进程在非Android生命周期内启动主进程,并使用am指令在linux-C进程启动主进程,从而恢复Android的服务,使得应用程序可以驻留在操作系统后台。Preferably, the keep-alive process starts the main process in the non-Android life cycle, and uses the am instruction to start the main process in the linux-C process, thereby restoring the Android service, so that the application program can reside in the operating system background.

图2示出了本发明实施例应用程序常驻操作系统后台的方法具体流程。参见图2,以主进程被关闭为例,该流程包括:FIG. 2 shows a specific flow of a method for an application program to reside in the background of an operating system according to an embodiment of the present invention. Referring to Figure 2, taking the main process being shut down as an example, the process includes:

步骤201,主进程启动后,调用fork函数创建宿主保活进程,并向创建的宿主保活进程传入复活指令,指示启动保活进程;Step 201, after the main process is started, call the fork function to create a host keep-alive process, and transmit a resurrection instruction to the created host keep-alive process, instructing to start the keep-alive process;

步骤202,宿主保活进程接收传入的复活指令,调用fork函数创建保活进程;Step 202, the host keep-alive process receives the incoming resurrection instruction, and calls the fork function to create the keep-alive process;

本步骤中,通过调用操作系统中的fork函数中的fork指令,复制出保活进程,从而创建出保活进程。In this step, the keep-alive process is created by calling the fork instruction in the fork function in the operating system to copy the keep-alive process.

步骤203,宿主保活进程生命周期结束,自然死亡;Step 203, the life cycle of the host keep-alive process ends, and it dies naturally;

本步骤中,在生命周期结束后,宿主保活进程关闭自己。In this step, after the life cycle ends, the host keepalive process shuts down itself.

步骤204,主进程创建LocalServerSocket并等待连接;Step 204, the main process creates LocalServerSocket and waits for connection;

步骤205,保活进程连接到主进程,并互相监听;Step 205, the keep-alive process is connected to the main process and monitors each other;

本步骤,保活进程与主进程监听对方的状态,即读取对方的状态参数标识。In this step, the keep-alive process and the main process monitor the state of the other party, that is, read the state parameter identifier of the other party.

步骤206,保活进程监听到主进程被杀死(关闭),调用复活指令复活主进程;Step 206, the keep alive process monitors that the main process is killed (closed), and invokes the resurrection instruction to revive the main process;

本步骤中,保活进程监听到与主进程的连接断开,则调用复活指令复活主进程,返回执行步骤201。In this step, if the keep-alive process detects that the connection with the main process is disconnected, it calls the resurrection instruction to resurrect the main process, and returns to step 201 .

步骤207,保活进程生命周期结束,自然死亡。Step 207, the life cycle of the keep-alive process ends, and it dies naturally.

本步骤中,当保活进程的生命周期结束时,退出操作系统后台,以避免复活的主进程通过创建宿主保活进程,并传入复活指令创建保活进程,使得操作系统存在冗余的保活进程,从而占用不必要的操作系统内存。In this step, when the life cycle of the keep-alive process ends, exit the operating system background, so as to prevent the resurrected main process from creating a host keep-alive process by creating a host keep-alive process and passing in a resurrection instruction to create a keep-alive process, so that the operating system has redundant keep-alive processes. live processes, thus occupying unnecessary operating system memory.

本发明实施例中,操作系统为应用程序创建主进程后,主进程再通过调用分叉函数fork()创建宿主保活进程,宿主保活进程再通过调用分叉函数fork()创建保活进程,并在保活进程创建成功后,结束自身的生命周期。这样,通过两级进程分离用户进程,在宿主保活进程被关闭后,则保活进程成为孤儿进程,从而会被托管给操作系统进程,并使得主进程与保活进程之间不存在直接关联关系。因而,后续应用中,在主进程和保活进程中的一个进程被关闭的情况下,由于主进程与保活进程不存在直接关联关系,使得依据直接关联关系进行查杀的另一个进程被同时关闭的概率较低,这样,可以通过未被关闭的进程来启动关闭的进程,从而使得应用程序仍可以驻留在后台,可以很好地满足必须要7x24h后台运行的应用程序的业务需求。相比采用Root(即获得超级管理员权限)的技术方案,本发明实施例的方法不管在Root还是非Root的通信设备上都能使用,适用范围广,而且功耗很低,从而以较低的代价实现第三方应用程序常驻后台运行,对于那些必须常驻后台的软硬结合的应用尤其重要,使得应用程序常驻后台的可靠性高;进一步地,由于主进程没有退出,所有资源均没有变化,产生的保活进程继承主进程的资源,可以确保保活进程资源不变,从而确保应用程序可靠运行;而且,在应用程序对应的一进程被关闭时,可以通过该应用程序对应的另一进程即时复活,无需通过通信设备的重启动加载应用程序以重新启动被关掉的进程驻留后台,不仅操作流程较为简单,实现应用程序驻留后台所需时间短,更不会导致整个通信设备通信的中断,有效提升了用户的通信业务体验。In the embodiment of the present invention, after the operating system creates the main process for the application, the main process creates the host keep-alive process by calling the fork function fork(), and the host keep-alive process creates the keep-alive process by calling the fork function fork(). , and ends its own life cycle after the keep-alive process is successfully created. In this way, the user process is separated by two-level processes. After the host keep-alive process is closed, the keep-alive process becomes an orphan process, which will be hosted by the operating system process, and there is no direct relationship between the main process and the keep-alive process. relation. Therefore, in the subsequent application, when one of the main process and the keep-alive process is closed, because the main process and the keep-alive process do not have a direct relationship, the other process that is killed according to the direct relationship is simultaneously killed. The probability of closing is low, so that the closed process can be started by the process that is not closed, so that the application can still reside in the background, which can well meet the business needs of the application that must run in the background 7x24h. Compared with the technical solution of using Root (that is, obtaining super administrator authority), the method of the embodiment of the present invention can be used on both Root and non-Root communication devices, has a wide range of applications, and has low power consumption, so that it can be used at a lower cost. It is especially important for applications that combine software and hardware that must reside in the background, so that the reliability of the application in the background is high; further, since the main process does not exit, all resources are There is no change, the generated keep-alive process inherits the resources of the main process, which can ensure that the resources of the keep-alive process remain unchanged, thereby ensuring the reliable operation of the application; Another process is instantly revived, and there is no need to load the application through the restart of the communication device to restart the closed process to stay in the background. The interruption of the communication of the communication device effectively improves the user's communication service experience.

图3示出了本发明实施例应用程序常驻操作系统后台的装置结构。参见图3,该装置为通信设备,包括:主进程创建模块、宿主保活进程创建模块、保活进程创建模块、连接模块以及监听处理模块,其中,FIG. 3 shows an apparatus structure in which an application program resides in the background of an operating system according to an embodiment of the present invention. Referring to Figure 3, the device is a communication device, including: a main process creation module, a host keep-alive process creation module, a keep-alive process creation module, a connection module and a monitoring processing module, wherein,

主进程创建模块,用于接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;The main process creation module is used to receive the target application startup request, and create a main process for the target application corresponding to the target application startup request;

本发明实施例中,操作系统接收目标应用程序启动请求,并创建主进程,包括但不限于安卓操作系统、Linux操作系统、塞班操作系统等。In the embodiment of the present invention, the operating system receives the target application startup request, and creates a main process, including but not limited to the Android operating system, the Linux operating system, the Symbian operating system, and the like.

作为可选实施例,将目标应用程序存储在预先设置的启动列表中。这样,在通信设备每次启动后,自动触发向操作系统发起目标应用程序启动请求,操作系统根据接收的目标应用程序启动请求,获取预先设置的启动列表,自动加载启动列表中的应用程序,并为启动列表中的各应用程序分配相应的主进程。As an optional embodiment, the target application is stored in a preset startup list. In this way, after each startup of the communication device, it is automatically triggered to initiate a target application startup request to the operating system, and the operating system obtains a preset startup list according to the received target application startup request, automatically loads the applications in the startup list, and Assign the corresponding master process to each application in the startup list.

宿主保活进程创建模块,用于触发主进程调用函数创建宿主保活进程;The host keep alive process creation module is used to trigger the main process to call the function to create the host keep alive process;

本发明实施例中,函数为分叉函数。In this embodiment of the present invention, the function is a bifurcation function.

保活进程创建模块,用于触发宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;A keep-alive process creation module is used to trigger the host keep-alive process to call a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system;

本发明实施例中,主进程、宿主保活进程以及保活进程设置有用于表示进程是否处于关闭状态的状态参数标识。In this embodiment of the present invention, the main process, the host keep-alive process, and the keep-alive process are provided with a state parameter identifier used to indicate whether the process is in a closed state.

作为可选实施例,保活进程创建模块包括:保活进程创建单元、生命周期设置单元以及生命周期运行单元(图中未示出),其中,As an optional embodiment, the keep-alive process creation module includes: a keep-alive process creation unit, a life cycle setting unit, and a life cycle running unit (not shown in the figure), wherein,

保活进程创建单元,用于触发宿主保活进程调用分叉函数创建保活进程;The keep-alive process creation unit is used to trigger the host keep-alive process to call the fork function to create the keep-alive process;

生命周期设置单元,用于为创建的所述宿主保活进程设置生命周期;a life cycle setting unit, used to set a life cycle for the created host keep-alive process;

生命周期运行单元,用于运行设置的生命周期,在设置的生命周期结束后,触发所述宿主保活进程自然死亡。The life cycle running unit is used to run the set life cycle, and after the set life cycle ends, trigger the natural death of the host keep-alive process.

本发明实施例中,主进程在为创建的所述宿主保活进程设置生命周期时,考虑后续宿主保活进程创建保活进程所需的时间,使得设置的生命周期大于或等于宿主保活进程创建保活进程所需的时间即可。In the embodiment of the present invention, when setting the life cycle for the created host keep-alive process, the main process considers the time required for the subsequent host keep-alive process to create the keep-alive process, so that the set life cycle is greater than or equal to the host keep-alive process The time required to create the keepalive process is sufficient.

连接模块,用于构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;a connection module, used for constructing a connection between the main process and the keep-alive process, and triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

作为可选实施例,连接模块包括:连接预处理单元、连接单元以及监听单元(图中未示出),其中,As an optional embodiment, the connection module includes: a connection preprocessing unit, a connection unit, and a monitoring unit (not shown in the figure), wherein,

连接预处理单元,用于触发主进程创建服务端套接字,保活进程创建客户端套接字;使主进程绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;等待客户端套接字连接;The connection preprocessing unit is used to trigger the main process to create a server socket, and the keep alive process to create a client socket; make the main process bind the server socket address, and monitor the client socket through the server socket connect; wait for client socket connection;

连接单元,用于触发客户端套接字与服务端套接字建立套接字连接;The connection unit is used to trigger the client socket to establish a socket connection with the server socket;

本发明实施例中,连接单元包括:保活进程宿主对象创建子单元、启动子单元、保活进程启动子单元、初始化子单元、应答子单元以及应答处理子单元,其中,In the embodiment of the present invention, the connection unit includes: a keep alive process host object creation subunit, a promoter subunit, a keep alive process starter subunit, an initialization subunit, a response subunit, and a response processing subunit, wherein,

保活进程宿主对象创建子单元,用于触发主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The keep-alive process host object creation subunit is used to trigger the main process to create a keep-alive process host object through the server socket, and assign a corresponding keep-alive process identifier to the keep-alive process host object;

启动子单元,用于触发主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;A start-up subunit, used to trigger the main process to use the created keep-alive process host object to start the keep-alive process, and send a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle ;

保活进程启动子单元,用于触发保活进程启动并接收来自主进程的复活指令;The keep-alive process startup subunit is used to trigger the start of the keep-alive process and receive the resurrection instruction from the main process;

初始化子单元,用于触发所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;an initialization subunit, configured to trigger the keep-alive process to create a corresponding keep-alive process object through the client socket, and initialize the keep-alive process object;

应答子单元,用于触发所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;a response subunit, configured to trigger the keep-alive process object to send a start-up response message to the main process, where the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object;

应答处理子单元,用于触发主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。The response processing subunit is used to trigger the main process to determine the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message after receiving the start-up response message of the keep-alive process, and host the keep-alive process The object sets the corresponding keepalive process communication interface handle.

作为可选实施例,连接单元还可以进一步包括:As an optional embodiment, the connection unit may further include:

数据传输子单元,用于触发所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。The data transmission subunit is used to trigger the main process to receive data from the keep-alive process through the main process communication interface handle, and send data to the corresponding keep-alive process through the keep-alive process communication interface handle of the keep-alive process host object; The keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle.

监听单元,用于触发所述主进程与保活进程基于构建的连接进行相互监听。The monitoring unit is configured to trigger the main process and the keep-alive process to monitor each other based on the established connection.

监听处理模块,用于在监听到对方进程被关闭后,启动关闭的进程。The monitoring processing module is used to start the closed process after monitoring that the other process is closed.

本发明实施例中,监听处理模块包括:状态参数标识设置单元、状态参数标识读取单元、状态参数标识确定单元以及进程重启动单元(图中未示出),其中,In the embodiment of the present invention, the monitoring processing module includes: a state parameter identification setting unit, a state parameter identification reading unit, a state parameter identification determining unit, and a process restarting unit (not shown in the figure), wherein,

状态参数标识设置单元,用于在第一进程被关闭,处于关闭状态后,第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为关闭状态;a state parameter identifier setting unit, used for, after the first process is closed and is in the closed state, the monitoring component corresponding to the first process side acquires that the first process is in the closed state, and sets the state parameter identifier of the first process to the closed state;

本发明实施例中,第一进程既可以是主进程,也可以是保活进程。进程被关闭,可能是由于操作系统在内存资源不足时,需要释放内存资源而将该进程关闭;也可能是杀毒软件在查杀毒过程中,查杀该进程而将该进程关闭;还可能是其它情形下关闭进程。In this embodiment of the present invention, the first process may be either a main process or a keep-alive process. If the process is closed, it may be because the operating system needs to release memory resources to close the process when the memory resources are insufficient; it may also be that the antivirus software kills the process and closes the process during the antivirus detection process; it may also be other In this case, close the process.

状态参数标识读取单元,用于通过套接字连接的第二进程读取第一进程的状态参数标识;a state parameter identifier reading unit, used for reading the state parameter identifier of the first process through the second process connected by the socket;

本发明实施例中,如果第一进程为主进程,则第二进程为保活进程;如果第一进程为保活进程,则第二进程为主进程。In this embodiment of the present invention, if the first process is the main process, the second process is the keep-alive process; if the first process is the keep-alive process, the second process is the main process.

状态参数标识确定单元,用于在第二进程确定第一进程的状态参数标识为关闭状态,确定第一进程被关闭;a state parameter identification determining unit, configured to determine, in the second process, that the state parameter identification of the first process is a closed state, and determine that the first process is closed;

进程重启动单元,用于启动第一进程。The process restarting unit is used to start the first process.

本发明实施例中,主进程监听到保活进程被关闭,调用复活指令启动保活进程;或者,In the embodiment of the present invention, the main process monitors that the keep-alive process is closed, and invokes the resurrection instruction to start the keep-alive process; or,

保活进程监听到主进程被关闭,调用复活指令启动主进程并触发启动的主进程执行所述调用分叉函数创建宿主保活进程的流程,并在主进程启动成功后将自身置于关闭状态。The keep-alive process monitors that the main process is shut down, calls the resurrection instruction to start the main process and triggers the activated main process to execute the process of calling the fork function to create the host keep-alive process, and puts itself in a closed state after the main process is successfully started .

较佳地,保活进程在非Android生命周期内启动主进程,并使用am指令在linux-C进程启动主进程,从而恢复Android的服务,使得应用程序可以驻留在操作系统后台。Preferably, the keep-alive process starts the main process in the non-Android life cycle, and uses the am instruction to start the main process in the linux-C process, thereby restoring the Android service, so that the application program can reside in the operating system background.

在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with teaching based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not directed to any particular programming language. It is to be understood that various programming languages may be used to implement the inventions described herein, and that the descriptions of specific languages above are intended to disclose the best mode for carrying out the invention.

在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. It will be understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.

类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it is to be understood that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or its description. This disclosure, however, should not be construed as reflecting an intention that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.

本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. The modules or units or components in the embodiments may be combined into one module or unit or component, and further they may be divided into multiple sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method so disclosed may be employed in any combination, unless at least some of such features and/or procedures or elements are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.

此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will appreciate that although some of the embodiments described herein include certain features, but not others, included in other embodiments, that combinations of features of different embodiments are intended to be within the scope of the invention within and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.

本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的应用程序常驻操作系统后台的装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站服务器上下载得到,或者在载体信号上提供,或者以任何其他形式提供。Various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of some or all of the components of the apparatus in which the application program resides in the background of the operating system according to the embodiment of the present invention. Full functionality. The present invention can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet web servers, or provided on carrier signals, or in any other form.

应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-described embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by those skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.

本发明公开了A1.一种应用程序常驻操作系统后台的方法,包括:The invention discloses A1. A method for an application program to reside in the background of an operating system, comprising:

接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;Receive a target application startup request, and create a main process for the target application corresponding to the target application startup request;

所述主进程调用函数创建宿主保活进程;The main process calls a function to create a host keep-alive process;

宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;The host keep-alive process calls a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system;

构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;constructing a connection between the main process and the keep-alive process, triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

在监听到主进程或保活进程被关闭后,启动被关闭的进程。After listening to the main process or the keepalive process being shut down, start the shut down process.

A2.根据A1所述的方法,所述操作系统包括但不限于安卓操作系统、Linux操作系统、塞班操作系统。A2. The method according to A1, the operating systems include but are not limited to Android operating systems, Linux operating systems, and Symbian operating systems.

A3.根据A1所述的方法,所述目标应用程序存储在预先设置的启动列表中,在通信设备每次启动后,自动触发向操作系统发起目标应用程序启动请求,操作系统根据接收的目标应用程序启动请求,获取预先设置的启动列表,自动加载启动列表中的应用程序,并为启动列表中的各应用程序分配相应的主进程。A3. The method according to A1, the target application program is stored in a preset startup list, and after each startup of the communication device, it is automatically triggered to initiate a target application program startup request to the operating system, and the operating system is based on the received target application program. A program startup request, obtains a preset startup list, automatically loads the applications in the startup list, and assigns a corresponding main process to each application program in the startup list.

A4.根据A1所述的方法,所述宿主保活进程将自身置于关闭状态,以使所述保活进程托管给操作系统。A4. The method of A1, wherein the host keep-alive process places itself in a shutdown state so that the keep-alive process is hosted by the operating system.

A5.根据A4所述的方法,所述将自身置于关闭状态包括:A5. The method according to A4, wherein the placing itself in an off state comprises:

主进程在创建宿主保活进程时,为创建的所述宿主保活进程设置生命周期,在设置的生命周期结束后,所述宿主保活进程自然关闭。When creating a host keep-alive process, the main process sets a life cycle for the created host keep-alive process, and after the set life cycle ends, the host keep-alive process is closed naturally.

A6.根据A4所述的方法,所述将自身置于关闭状态包括:A6. The method according to A4, wherein the placing itself in an off state comprises:

宿主保活进程在接收到保活进程创建成功信息后,将自身的生命周期置零。After receiving the message that the keep-alive process is successfully created, the host keep-alive process resets its own life cycle to zero.

A7.根据A1所述的方法,所述构建主进程与保活进程连接包括:A7. The method according to A1, wherein the building the connection between the main process and the keep-alive process includes:

主进程创建服务端套接字,保活进程创建客户端套接字;The main process creates the server socket, and the keep-alive process creates the client socket;

绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;Bind the server socket address and listen to the client socket through the server socket;

等待客户端套接字连接;Waiting for client socket connection;

客户端套接字与服务端套接字建立套接字连接。The client socket establishes a socket connection with the server socket.

A8.根据A7所述的方法,所述客户端套接字与服务端套接字建立套接字连接包括:A8. The method according to A7, wherein establishing a socket connection between the client socket and the server socket includes:

主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The main process creates a keep-alive process host object through the server socket, and allocates a corresponding keep-alive process identifier to the keep-alive process host object;

主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;The main process uses the created keep-alive process host object to start the keep-alive process, and sends a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle;

保活进程启动并接收来自主进程的复活指令;The keepalive process starts and receives the resurrection command from the main process;

所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;The keep-alive process creates a corresponding keep-alive process object through the client socket, and initializes the keep-alive process object;

所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;The keep-alive process object sends a start-up response message to the main process, and the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object;

主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。After receiving the start-up response message of the keep-alive process, the main process determines the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message, and sets the corresponding keep-alive process communication for the keep-alive process host object Interface handle.

A9.根据A8所述的方法,所述在建立套接字连接后,所述方法进一步包括:A9. The method according to A8, after the socket connection is established, the method further comprises:

所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;The main process receives data from the keep-alive process through the main process communication interface handle, and sends data to the corresponding keep-alive process through the keep-alive process communication interface handle of the keep-alive process host object;

所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。The keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle.

A10.根据A1所述的方法,所述监听到主进程或保活进程被关闭包括:A10. The method according to A1, the monitoring that the main process or the keep-alive process is shut down includes:

第一进程被关闭,处于关闭状态;The first process is closed and is in a closed state;

第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为0;The monitoring component corresponding to the first process side obtains that the first process is in a closed state, and sets the state parameter identifier of the first process to 0;

通过套接字连接的第二进程读取第一进程的状态参数标识;The second process connected through the socket reads the status parameter identifier of the first process;

第二进程确定第一进程的状态参数标识为0,确定对方进程被关闭。The second process determines that the state parameter identifier of the first process is 0, and determines that the opposite process is closed.

A11.根据A1所述的方法,所述监听到主进程或保活进程被关闭包括:A11. The method according to A1, the monitoring that the main process or the keep-alive process is shut down comprises:

主进程和保活进程使用套接字连接互相监听,确定虚拟套接字连接断开,确定主进程或保活进程被关闭。The main process and the keep-alive process use the socket connection to monitor each other, determine that the virtual socket connection is disconnected, and determine that the main process or the keep-alive process is closed.

A12.根据A1所述的方法,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:A12. The method according to A1, after monitoring that the main process or the keep-alive process is closed, starting the closed process includes:

主进程监听到保活进程被关闭,调用复活指令启动保活进程。The main process monitors that the keep-alive process is closed, and calls the resurrection instruction to start the keep-alive process.

A13.根据A1所述的方法,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:A13. The method according to A1, after monitoring that the main process or the keep-alive process is closed, starting the closed process includes:

保活进程监听到主进程被关闭,调用复活指令启动主进程并触发启动的主进程执行所述调用函数创建宿主保活进程的流程,并在主进程启动成功后将自身置于关闭状态。The keepalive process monitors that the main process is shut down, invokes the resurrection instruction to start the main process and triggers the activated main process to execute the calling function to create the process of the host keepalive process, and puts itself in a closed state after the main process is successfully started.

A14.根据A12或13所述的方法,所述保活进程在非安卓生命周期内启动主进程,并使用am指令在linux-C进程启动主进程。A14. The method according to A12 or 13, wherein the keep-alive process starts the main process in the non-Android life cycle, and uses the am instruction to start the main process in the linux-C process.

A15.根据A1所述的方法,所述函数为分叉函数。A15. The method according to A1, wherein the function is a bifurcation function.

A16.根据A1所述的方法,所述主进程与所述宿主保活进程为父子进程关系,所述宿主保活进程与所述保活进程为父子进程关系。A16. The method according to A1, wherein the main process and the host keep-alive process have a parent-child process relationship, and the host keep-alive process and the keep-alive process have a parent-child process relationship.

A17.根据A1所述的方法,通过未被关闭的所述保活进程或所述主进程启动所述被关闭的进程。A17. The method according to A1, starting the shut down process through the keep-alive process or the main process that has not been shut down.

A18.一种应用程序常驻操作系统后台的装置,该装置包括:主进程创建模块、宿主保活进程创建模块、保活进程创建模块、连接模块以及监听处理模块,其中,A18. A device for an application program resident in the background of an operating system, the device comprising: a main process creation module, a host keep-alive process creation module, a keep-alive process creation module, a connection module and a monitoring processing module, wherein,

主进程创建模块,用于接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;The main process creation module is used to receive the target application startup request, and create a main process for the target application corresponding to the target application startup request;

宿主保活进程创建模块,用于触发主进程调用函数创建宿主保活进程;The host keep alive process creation module is used to trigger the main process to call the function to create the host keep alive process;

保活进程创建模块,用于触发宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;A keep-alive process creation module is used to trigger the host keep-alive process to call a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system;

连接模块,用于构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;a connection module, used for constructing a connection between the main process and the keep-alive process, and triggering the main process and the keep-alive process to monitor each other based on the constructed connection;

监听处理模块,用于在监听到主进程或保活进程被关闭后,启动被关闭的进程。The monitoring processing module is used to start the closed process after monitoring that the main process or the keep-alive process is closed.

A19.根据A18所述的装置,所述保活进程创建模块包括:保活进程创建单元、生命周期设置单元以及生命周期运行单元,其中,A19. The device according to A18, wherein the keep-alive process creation module comprises: a keep-alive process creation unit, a life cycle setting unit, and a life cycle running unit, wherein,

保活进程创建单元,用于触发宿主保活进程调用函数创建保活进程;The keep-alive process creation unit is used to trigger the host keep-alive process to call a function to create a keep-alive process;

生命周期设置单元,用于为创建的所述宿主保活进程设置生命周期;a life cycle setting unit, used to set a life cycle for the created host keep-alive process;

生命周期运行单元,用于运行设置的生命周期,在设置的生命周期结束后,触发所述宿主保活进程自然关闭。The life cycle running unit is used to run the set life cycle, and after the set life cycle ends, trigger the host keep-alive process to shut down naturally.

A20.根据A18所述的装置,所述连接模块包括:连接预处理单元、连接单元以及监听单元,其中,A20. The device according to A18, wherein the connection module comprises: a connection preprocessing unit, a connection unit and a monitoring unit, wherein,

连接预处理单元,用于触发主进程创建服务端套接字,保活进程创建客户端套接字;使主进程绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;等待客户端套接字连接;The connection preprocessing unit is used to trigger the main process to create a server socket, and the keep alive process to create a client socket; make the main process bind the server socket address, and monitor the client socket through the server socket connect; wait for client socket connection;

连接单元,用于触发客户端套接字与服务端套接字建立套接字连接;The connection unit is used to trigger the client socket to establish a socket connection with the server socket;

监听单元,触发所述主进程与保活进程基于构建的连接进行相互监听。The monitoring unit triggers the main process and the keep-alive process to monitor each other based on the established connection.

A21.根据A20所述的装置,所述连接单元包括:保活进程宿主对象创建子单元、启动子单元、保活进程启动子单元、初始化子单元、应答子单元以及应答处理子单元,其中,A21. The device according to A20, wherein the connection unit comprises: a keep-alive process host object creation subunit, a promoter subunit, a keep-alive process starter subunit, an initialization subunit, a response subunit, and a response processing subunit, wherein,

保活进程宿主对象创建子单元,用于触发主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The keep-alive process host object creation subunit is used to trigger the main process to create a keep-alive process host object through the server socket, and assign a corresponding keep-alive process identifier to the keep-alive process host object;

启动子单元,用于触发主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;A start-up subunit, used to trigger the main process to use the created keep-alive process host object to start the keep-alive process, and send a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle ;

保活进程启动子单元,用于触发保活进程启动并接收来自主进程的复活指令;The keep-alive process startup subunit is used to trigger the start of the keep-alive process and receive the resurrection instruction from the main process;

初始化子单元,用于触发所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;an initialization subunit, configured to trigger the keep-alive process to create a corresponding keep-alive process object through the client socket, and initialize the keep-alive process object;

应答子单元,用于触发所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;a response subunit, configured to trigger the keep-alive process object to send a start-up response message to the main process, where the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object;

应答处理子单元,用于触发主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄。The response processing subunit is used to trigger the main process to determine the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message after receiving the start-up response message of the keep-alive process, and host the keep-alive process The object sets the corresponding keepalive process communication interface handle.

A22.根据A21所述的装置,所述连接单元进一步包括:数据传输子单元,用于触发所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。A22. The device according to A21, wherein the connection unit further comprises: a data transmission subunit, configured to trigger the main process to receive data from the keep-alive process through the main process communication interface handle, and pass the data of the keep-alive process host object The keepalive process communication interface handle sends data to the corresponding keepalive process; the keepalive process receives data from the main process through the keepalive process communication interface handle, and sends data to the main process through the main process communication interface handle.

A23.根据A18所述的装置,所述监听处理模块包括:状态参数标识设置单元、状态参数标识读取单元、状态参数标识确定单元以及进程重启动单元,其中,A23. The device according to A18, the monitoring processing module comprises: a state parameter identification setting unit, a state parameter identification reading unit, a state parameter identification determining unit and a process restarting unit, wherein,

状态参数标识设置单元,用于在第一进程被关闭,处于关闭状态后,第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为关闭状态;a state parameter identifier setting unit, used for, after the first process is closed and is in the closed state, the monitoring component corresponding to the first process side acquires that the first process is in the closed state, and sets the state parameter identifier of the first process to the closed state;

状态参数标识读取单元,用于通过套接字连接的第二进程读取第一进程的状态参数标识;a state parameter identifier reading unit, used for reading the state parameter identifier of the first process through the second process connected by the socket;

状态参数标识确定单元,用于在第二进程确定第一进程的状态参数标识为关闭状态,确定第一进程被关闭;a state parameter identification determining unit, configured to determine, in the second process, that the state parameter identification of the first process is a closed state, and determine that the first process is closed;

进程重启动单元,用于启动被关闭的第一进程。The process restarting unit is used to start the closed first process.

Claims (19)

1.一种应用程序常驻操作系统后台的方法,包括:1. A method for an application program to reside in the background of an operating system, comprising: 接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;Receive a target application startup request, and create a main process for the target application corresponding to the target application startup request; 所述主进程调用函数创建宿主保活进程;The main process calls a function to create a host keep-alive process; 宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;The host keep-alive process calls a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system; 构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;所述构建主进程与保活进程连接包括:主进程创建服务端套接字,保活进程创建客户端套接字;绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;等待客户端套接字连接;客户端套接字与服务端套接字建立套接字连接,包括:主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;保活进程启动并接收来自主进程的复活指令;所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄;Building a connection between the main process and the keep-alive process, triggering the main process and the keep-alive process to monitor each other based on the constructed connection; the building the connection between the main process and the keep-alive process includes: the main process creates a server socket, and the keep-alive process Create a client socket; bind the server socket address, and listen to the client socket through the server socket; wait for the client socket to connect; the client socket and the server socket are established The socket connection includes: the main process creates a keep-alive process host object through the server socket, and assigns a corresponding keep-alive process identifier to the keep-alive process host object; the main process uses the created keep-alive process host object to start Keep-alive process, and send a revival instruction to the keep-alive process, the revival instruction carries the keep-alive process identifier and the main process communication interface handle; the keep-alive process starts and receives the revival instruction from the main process; the keep-alive process The process creates a corresponding keep-alive process object through the client socket, and initializes the keep-alive process object; the keep-alive process object sends a startup response message to the main process, and the startup response message carries the keep-alive The keepalive process communication interface handle and the keepalive process identifier corresponding to the process object; after receiving the start response message of the keepalive process, the main process determines the corresponding keepalive process host object according to the keepalive process identifier in the start response message, and setting a corresponding keep-alive process communication interface handle for the keep-alive process host object; 在监听到主进程或保活进程被关闭后,启动被关闭的进程。After listening to the main process or the keepalive process being shut down, start the shut down process. 2.如权利要求1所述的方法,所述操作系统包括但不限于安卓操作系统、Linux操作系统、塞班操作系统。2. The method of claim 1, wherein the operating systems include but are not limited to Android operating systems, Linux operating systems, and Symbian operating systems. 3.如权利要求1所述的方法,所述目标应用程序存储在预先设置的启动列表中,在通信设备每次启动后,自动触发向操作系统发起目标应用程序启动请求,操作系统根据接收的目标应用程序启动请求,获取预先设置的启动列表,自动加载启动列表中的应用程序,并为启动列表中的各应用程序分配相应的主进程。3. The method according to claim 1, wherein the target application program is stored in a preset startup list, and after each startup of the communication device, it is automatically triggered to initiate a target application program startup request to the operating system, and the operating system is based on the received The target application starts a request, obtains a preset startup list, automatically loads the applications in the startup list, and assigns a corresponding main process to each application in the startup list. 4.如权利要求1所述的方法,所述宿主保活进程将自身置于关闭状态,以使所述保活进程托管给操作系统。4. The method of claim 1, the host keepalive process places itself in a shutdown state so that the keepalive process is hosted by the operating system. 5.如权利要求4所述的方法,所述将自身置于关闭状态包括:5. The method of claim 4, said placing itself in an off state comprising: 主进程在创建宿主保活进程时,为创建的所述宿主保活进程设置生命周期,在设置的生命周期结束后,所述宿主保活进程自然关闭。When creating a host keep-alive process, the main process sets a life cycle for the created host keep-alive process, and after the set life cycle ends, the host keep-alive process is closed naturally. 6.如权利要求4所述的方法,所述将自身置于关闭状态包括:6. The method of claim 4, said placing itself in an off state comprising: 宿主保活进程在接收到保活进程创建成功信息后,将自身的生命周期置零。After receiving the message that the keep-alive process is successfully created, the host keep-alive process resets its own life cycle to zero. 7.如权利要求1所述的方法,在所述建立套接字连接之后,所述方法进一步包括:7. The method of claim 1, after said establishing a socket connection, the method further comprising: 所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;The main process receives data from the keep-alive process through the main process communication interface handle, and sends data to the corresponding keep-alive process through the keep-alive process communication interface handle of the keep-alive process host object; 所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。The keep-alive process receives data from the main process through the keep-alive process communication interface handle, and sends data to the main process through the main process communication interface handle. 8.如权利要求1所述的方法,所述监听到主进程或保活进程被关闭包括:8. The method of claim 1, wherein monitoring that the main process or the keep-alive process is shut down comprises: 第一进程被关闭,处于关闭状态;The first process is closed and is in a closed state; 第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为0;The monitoring component corresponding to the first process side obtains that the first process is in a closed state, and sets the state parameter identifier of the first process to 0; 通过套接字连接的第二进程读取第一进程的状态参数标识;The second process connected through the socket reads the status parameter identifier of the first process; 第二进程确定第一进程的状态参数标识为0,确定对方进程被关闭。The second process determines that the state parameter identifier of the first process is 0, and determines that the opposite process is closed. 9.如权利要求1所述的方法,所述监听到主进程或保活进程被关闭包括:9. The method of claim 1, wherein monitoring that the main process or the keep-alive process is shut down comprises: 主进程和保活进程使用套接字连接互相监听,确定虚拟套接字连接断开,确定主进程或保活进程被关闭。The main process and the keep-alive process use the socket connection to monitor each other, determine that the virtual socket connection is disconnected, and determine that the main process or the keep-alive process is closed. 10.如权利要求1所述的方法,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:10. The method according to claim 1, wherein after monitoring that the main process or the keep-alive process is closed, starting the closed process comprises: 主进程监听到保活进程被关闭,调用复活指令启动保活进程。The main process monitors that the keep-alive process is closed, and calls the resurrection instruction to start the keep-alive process. 11.如权利要求1所述的方法,所述在监听到主进程或保活进程被关闭后,启动被关闭的进程包括:11. The method of claim 1, wherein after monitoring that the main process or the keep-alive process is closed, starting the closed process comprises: 保活进程监听到主进程被关闭,调用复活指令启动主进程并触发启动的主进程执行所述调用函数创建宿主保活进程的流程,并在主进程启动成功后将自身置于关闭状态。The keepalive process monitors that the main process is shut down, invokes the resurrection instruction to start the main process and triggers the activated main process to execute the calling function to create the process of the host keepalive process, and puts itself in a closed state after the main process is successfully started. 12.如权利要求10或11所述的方法,所述保活进程在非安卓生命周期内启动主进程,并使用am指令在linux-C进程启动主进程。12. The method according to claim 10 or 11, wherein the keep-alive process starts the main process in the non-Android life cycle, and uses the am instruction to start the main process in the linux-C process. 13.如权利要求1所述的方法,所述函数为分叉函数。13. The method of claim 1, the function is a bifurcation function. 14.如权利要求1所述的方法,所述主进程与所述宿主保活进程为父子进程关系,所述宿主保活进程与所述保活进程为父子进程关系。14. The method of claim 1, wherein the main process and the host keep-alive process are in a parent-child process relationship, and the host keep-alive process and the keep-alive process are in a parent-child process relationship. 15.如权利要求1所述的方法,通过未被关闭的所述保活进程或所述主进程启动所述被关闭的进程。15. The method of claim 1, the shut down process is started by the keep alive process or the main process that is not shut down. 16.一种应用程序常驻操作系统后台的装置,该装置包括:主进程创建模块、宿主保活进程创建模块、保活进程创建模块、连接模块以及监听处理模块,其中,16. A device for an application program to reside in the background of an operating system, the device comprising: a main process creation module, a host keep-alive process creation module, a keep-alive process creation module, a connection module and a monitoring processing module, wherein, 主进程创建模块,用于接收目标应用程序启动请求,为该目标应用程序启动请求对应的目标应用程序创建主进程;The main process creation module is used to receive the target application startup request, and create a main process for the target application corresponding to the target application startup request; 宿主保活进程创建模块,用于触发主进程调用函数创建宿主保活进程;The host keep alive process creation module is used to trigger the main process to call the function to create the host keep alive process; 保活进程创建模块,用于触发宿主保活进程调用函数创建保活进程,并在保活进程创建后,将所述保活进程托管给操作系统;A keep-alive process creation module is used to trigger the host keep-alive process to call a function to create a keep-alive process, and after the keep-alive process is created, the keep-alive process is entrusted to the operating system; 连接模块,用于构建主进程与保活进程连接,触发所述主进程与保活进程基于构建的连接进行相互监听;a connection module, used for constructing a connection between the main process and the keep-alive process, and triggering the main process and the keep-alive process to monitor each other based on the constructed connection; 所述连接模块包括:连接预处理单元、连接单元以及监听单元,其中,The connection module includes: a connection preprocessing unit, a connection unit and a monitoring unit, wherein, 连接预处理单元,用于触发主进程创建服务端套接字,保活进程创建客户端套接字;使主进程绑定服务端套接字地址,并通过服务端套接字监听客户端套接字;等待客户端套接字连接;The connection preprocessing unit is used to trigger the main process to create a server socket, and the keep alive process to create a client socket; make the main process bind the server socket address, and monitor the client socket through the server socket connect; wait for client socket connection; 连接单元,用于触发客户端套接字与服务端套接字建立套接字连接;The connection unit is used to trigger the client socket to establish a socket connection with the server socket; 监听单元,触发所述主进程与保活进程基于构建的连接进行相互监听;a monitoring unit, which triggers the main process and the keep-alive process to monitor each other based on the established connection; 所述连接单元包括:保活进程宿主对象创建子单元、启动子单元、保活进程启动子单元、初始化子单元、应答子单元以及应答处理子单元,其中,The connection unit includes: a keep-alive process host object creation sub-unit, a promoter sub-unit, a keep-alive process promoter sub-unit, an initialization sub-unit, a response sub-unit, and a response processing sub-unit, wherein, 保活进程宿主对象创建子单元,用于触发主进程通过服务端套接字创建保活进程宿主对象,并为所述保活进程宿主对象分配对应的保活进程标识;The keep-alive process host object creation subunit is used to trigger the main process to create a keep-alive process host object through the server socket, and assign a corresponding keep-alive process identifier to the keep-alive process host object; 启动子单元,用于触发主进程使用创建的保活进程宿主对象启动保活进程,并向所述保活进程发送复活指令,所述复活指令携带所述保活进程标识、主进程通信接口句柄;A start-up subunit, used to trigger the main process to use the created keep-alive process host object to start the keep-alive process, and send a resurrection instruction to the keep-alive process, where the resurrection instruction carries the keep-alive process identifier and the main process communication interface handle ; 保活进程启动子单元,用于触发保活进程启动并接收来自主进程的复活指令;The keep-alive process startup subunit is used to trigger the start of the keep-alive process and receive the resurrection instruction from the main process; 初始化子单元,用于触发所述保活进程通过客户端套接字创建对应的保活进程对象,并初始化所述保活进程对象;an initialization subunit, configured to trigger the keep-alive process to create a corresponding keep-alive process object through the client socket, and initialize the keep-alive process object; 应答子单元,用于触发所述保活进程对象向所述主进程发送启动应答消息,所述启动应答消息携带所述保活进程对象对应的保活进程通信接口句柄、保活进程标识;a response subunit, configured to trigger the keep-alive process object to send a start-up response message to the main process, where the start-up response message carries a keep-alive process communication interface handle and a keep-alive process identifier corresponding to the keep-alive process object; 应答处理子单元,用于触发主进程收到保活进程的启动应答消息后,根据所述启动应答消息中的保活进程标识确定对应的保活进程宿主对象,并为所述保活进程宿主对象设置对应的保活进程通信接口句柄;The response processing subunit is used to trigger the main process to determine the corresponding keep-alive process host object according to the keep-alive process identifier in the start-up response message after receiving the start-up response message of the keep-alive process, and host the keep-alive process The object sets the corresponding keepalive process communication interface handle; 监听处理模块,用于在监听到主进程或保活进程被关闭后,启动被关闭的进程。The monitoring processing module is used to start the closed process after monitoring that the main process or the keep-alive process is closed. 17.如权利要求16所述的装置,所述保活进程创建模块包括:保活进程创建单元、生命周期设置单元以及生命周期运行单元,其中,17. The apparatus according to claim 16, wherein the keep-alive process creation module comprises: a keep-alive process creation unit, a life cycle setting unit and a life cycle running unit, wherein, 保活进程创建单元,用于触发宿主保活进程调用函数创建保活进程;The keep-alive process creation unit is used to trigger the host keep-alive process to call a function to create a keep-alive process; 生命周期设置单元,用于为创建的所述宿主保活进程设置生命周期;a life cycle setting unit, used to set a life cycle for the created host keep-alive process; 生命周期运行单元,用于运行设置的生命周期,在设置的生命周期结束后,触发所述宿主保活进程自然关闭。The life cycle running unit is used to run the set life cycle, and after the set life cycle ends, trigger the host keep-alive process to shut down naturally. 18.如权利要求16所述的装置,所述连接单元进一步包括:数据传输子单元,用于触发所述主进程通过主进程通信接口句柄接收来自保活进程的数据,并通过保活进程宿主对象的保活进程通信接口句柄向对应的保活进程发送数据;所述保活进程通过保活进程通信接口句柄接收来自主进程的数据,并通过主进程通信接口句柄向主进程发送数据。18. The apparatus according to claim 16, wherein the connection unit further comprises: a data transmission subunit, configured to trigger the main process to receive data from the keep-alive process through the main process communication interface handle, and host the keep-alive process through the main process The keepalive process communication interface handle of the object sends data to the corresponding keepalive process; the keepalive process receives data from the main process through the keepalive process communication interface handle, and sends data to the main process through the main process communication interface handle. 19.如权利要求16所述的装置,所述监听处理模块包括:状态参数标识设置单元、状态参数标识读取单元、状态参数标识确定单元以及进程重启动单元,其中,19. The apparatus according to claim 16, wherein the monitoring processing module comprises: a state parameter identification setting unit, a state parameter identification reading unit, a state parameter identification determining unit and a process restarting unit, wherein, 状态参数标识设置单元,用于在第一进程被关闭,处于关闭状态后,第一进程端对应的监听组件获取该第一进程处于关闭状态,将第一进程的状态参数标识设置为关闭状态;a state parameter identifier setting unit, used for, after the first process is closed and is in the closed state, the monitoring component corresponding to the first process side acquires that the first process is in the closed state, and sets the state parameter identifier of the first process to the closed state; 状态参数标识读取单元,用于通过套接字连接的第二进程读取第一进程的状态参数标识;a state parameter identifier reading unit, used for reading the state parameter identifier of the first process through the second process connected by the socket; 状态参数标识确定单元,用于在第二进程确定第一进程的状态参数标识为关闭状态,确定第一进程被关闭;a state parameter identification determining unit, configured to determine, in the second process, that the state parameter identification of the first process is a closed state, and determine that the first process is closed; 进程重启动单元,用于启动被关闭的第一进程。The process restarting unit is used to start the closed first process.
CN201410287640.5A 2014-06-24 2014-06-24 Method and device for application program resident in operating system background Expired - Fee Related CN105335171B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410287640.5A CN105335171B (en) 2014-06-24 2014-06-24 Method and device for application program resident in operating system background
PCT/CN2015/082075 WO2015196967A1 (en) 2014-06-24 2015-06-23 Method and apparatus for application to permanently reside in background of operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410287640.5A CN105335171B (en) 2014-06-24 2014-06-24 Method and device for application program resident in operating system background

Publications (2)

Publication Number Publication Date
CN105335171A CN105335171A (en) 2016-02-17
CN105335171B true CN105335171B (en) 2019-05-10

Family

ID=54936799

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410287640.5A Expired - Fee Related CN105335171B (en) 2014-06-24 2014-06-24 Method and device for application program resident in operating system background

Country Status (2)

Country Link
CN (1) CN105335171B (en)
WO (1) WO2015196967A1 (en)

Families Citing this family (39)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11424931B2 (en) 2016-01-27 2022-08-23 Blackberry Limited Trusted execution environment
US10599409B2 (en) * 2016-02-02 2020-03-24 Blackberry Limited Application lifecycle operation queueing
CN105930215A (en) * 2016-04-07 2016-09-07 珠海市魅族科技有限公司 Control method and control device for mobile terminal
CN106055365B (en) * 2016-05-31 2019-10-25 Oppo广东移动通信有限公司 A kind of closing application program method and apparatus
CN106201690A (en) * 2016-07-07 2016-12-07 乐视控股(北京)有限公司 Application progress control method and device
CN106371911A (en) * 2016-09-06 2017-02-01 北京海誉动想科技股份有限公司 Method for rebooting guarded process by daemon processes
CN106775642B (en) * 2016-11-24 2018-03-13 广州赛意信息科技股份有限公司 The unlimited backstage localization method and system of a kind of Mobile solution
CN106775652A (en) * 2016-11-24 2017-05-31 武汉斗鱼网络科技有限公司 The method and device waken up to the application program of terminal
CN106648863B (en) * 2016-12-08 2020-01-03 武汉斗鱼网络科技有限公司 Android application installation package, application target process keep-alive method and system
CN107342981B (en) * 2017-06-07 2021-11-12 北京小鸟看看科技有限公司 Sensor data transmission method and device and virtual reality head-mounted equipment
CN107341052A (en) * 2017-06-07 2017-11-10 努比亚技术有限公司 A kind of message treatment method and device
CN109240809B (en) * 2017-07-11 2022-08-23 阿里巴巴集团控股有限公司 Process maintenance management method, container maintenance method, device and operating system
CN107729128B (en) * 2017-07-24 2019-09-24 深圳壹账通智能科技有限公司 Application data restoration methods, device, computer equipment and storage medium
CN107391199A (en) * 2017-07-27 2017-11-24 珠海市魅族科技有限公司 Using startup method and device, terminal and computer-readable recording medium
CN108287761B (en) * 2017-08-09 2020-11-06 珠海市魅族科技有限公司 Memory recovery method and device, terminal equipment and computer readable storage medium
CN108153620A (en) * 2017-12-27 2018-06-12 深圳豪客互联网有限公司 A kind of course control method and device
CN109669838B (en) * 2018-11-14 2022-05-27 百度在线网络技术(北京)有限公司 Method and device for realizing application resident, computer equipment and storage medium
CN109683974B (en) * 2018-12-26 2022-05-31 北京金山安全软件有限公司 Awakening method for application background service process in mobile terminal and related equipment
CN109992310B (en) * 2019-03-12 2024-04-05 中国平安财产保险股份有限公司 Application program keep-alive method, device, computer equipment and storage medium
CN111782347A (en) * 2019-04-03 2020-10-16 安克创新科技股份有限公司 Mobile phone application keep alive method, device, system and storage medium
CN112445530B (en) * 2019-08-29 2023-03-14 成都鼎桥通信技术有限公司 Method and device for keeping third-party application program alive
CN110688319B (en) * 2019-09-30 2023-05-02 RealMe重庆移动通信有限公司 Application keep-alive capability test method and related device
CN110879726B (en) * 2019-10-24 2023-09-26 深圳数位大数据科技有限公司 Keep-alive method and keep-alive device for mobile terminal application program
CN111538541A (en) * 2019-12-06 2020-08-14 杭州当虹科技股份有限公司 Method for enabling Android App to stably run in background for long time
CN111399924B (en) * 2020-03-18 2023-06-16 山东车微联信息技术股份有限公司 Method, terminal and storage medium for keeping application process alive under android platform
CN113760561B (en) * 2020-06-17 2024-10-18 北京沃东天骏信息技术有限公司 Data processing method and device
CN111913851B (en) * 2020-07-31 2024-11-22 平安科技(深圳)有限公司 Process monitoring method, system, terminal and storage medium
CN111966425B (en) * 2020-08-19 2024-12-31 惠州Tcl云创科技有限公司 Process cleaning method, device, storage medium and mobile terminal
CN114116040A (en) * 2020-08-31 2022-03-01 华为技术有限公司 Method for accelerating application starting, electronic equipment and computer storage medium
CN112162783B (en) * 2020-09-27 2021-09-14 珠海格力电器股份有限公司 Music playing application keep-alive processing method and system, storage medium and electronic equipment
CN112612589B (en) * 2020-12-26 2024-10-15 吉林亿联银行股份有限公司 Keep-alive method and device for application program
CN112860408A (en) * 2021-03-03 2021-05-28 苏州沁游网络科技有限公司 Process keep-alive method, device and system in cloud reality machine and storage medium
CN115113946A (en) * 2021-03-17 2022-09-27 广东小天才科技有限公司 Method and device for optimizing starting of camera
CN115525356A (en) * 2021-06-26 2022-12-27 荣耀终端有限公司 Keep-alive method of video application and electronic equipment
CN113377543A (en) * 2021-06-28 2021-09-10 上海商汤科技开发有限公司 Task processing system, electronic device, and storage medium
CN113360271B (en) * 2021-07-21 2025-02-07 深圳前海微众银行股份有限公司 Process management method, device, equipment, storage medium and program product
CN116263718A (en) * 2021-12-13 2023-06-16 北京有竹居网络技术有限公司 Process management method, device, storage medium and electronic device
CN114697377B (en) * 2022-04-07 2023-09-05 深信服科技股份有限公司 Keep-alive method, keep-alive system, keep-alive device and readable storage medium for client products
CN114816546A (en) * 2022-04-28 2022-07-29 合肥高维数据技术有限公司 Client application multiple keep-alive method and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3588916A1 (en) * 2009-10-01 2020-01-01 Telefonaktiebolaget LM Ericsson (publ) A method and arrangement for managing persistent rich internet applications
US9104476B2 (en) * 2010-04-07 2015-08-11 Apple Inc. Opportunistic multitasking of VOIP applications
CN103324536A (en) * 2012-03-23 2013-09-25 宇龙计算机通信科技(深圳)有限公司 Terminal and application program protection method
US9092247B2 (en) * 2012-03-29 2015-07-28 Microsoft Technology Licensing, Llc Persistent and resilient worker processes
US8843930B2 (en) * 2012-07-10 2014-09-23 Sap Ag Thread scheduling and control framework
CN103577224A (en) * 2013-10-21 2014-02-12 杭州魔品科技有限公司 Method for improving detection on upgrade of Android phone demons by PC terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
6种进程防杀方案和源码;rovahomoimi;《https://www.xuebuyuan.com/839976.html》;20130912;第1-4页

Also Published As

Publication number Publication date
CN105335171A (en) 2016-02-17
WO2015196967A1 (en) 2015-12-30

Similar Documents

Publication Publication Date Title
CN105335171B (en) Method and device for application program resident in operating system background
US11461154B2 (en) Localized device coordinator with mutable routing information
US10728168B2 (en) Method for providing a connection of a client to an unmanaged service in a client-server remote access system
AU2017363366B2 (en) On-demand code execution in a localized device coordinator
JP6363796B2 (en) Dynamic code deployment and versioning
US10417049B2 (en) Intra-code communication in a localized device coordinator
US10452439B2 (en) On-demand code execution in a localized device coordinator
CN107534647B (en) Systems, computing devices, and storage media for delivering startup scripts
WO2018103521A1 (en) Monitoring method for server, device, and storage medium
CN104346559B (en) Authority request response method and corresponding device
US20130275596A1 (en) Methods and apparatuses for remote application provisioning automation over virtualized it infrastructure
US10372486B2 (en) Localized device coordinator
EP3545408B1 (en) Localized device coordinator with on-demand code execution capabilities
US20180150317A1 (en) Localized device coordinator with on-demand code execution capabilities
US11132187B2 (en) Bare metal provisioning of software defined infrastructure
US20170026306A1 (en) Systems and methods for autonomous resource discovery, management, and stitching
CN101820387B (en) Method for rapidly deploying extensible cluster
CN108769124A (en) Application deployment method, device, server and storage medium of PaaS platform
CN102427481A (en) System for managing cloud computing service and cloud computing management method
US11372654B1 (en) Remote filesystem permissions management for on-demand code execution
CN105094929A (en) PXE based linux operating system installation method and system
CN114553693B (en) Gateway upgrading method and device
WO2020024978A1 (en) Device, method, apparatus, and readable storage medium for virtual machine migration
US7917614B2 (en) Fault tolerance in a client side pre-boot execution
US9851980B1 (en) Distributed update service enabling update requests

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20190510

Termination date: 20210624