CN109144677B - Keep-alive process method and device for android system - Google Patents

Keep-alive process method and device for android system Download PDF

Info

Publication number
CN109144677B
CN109144677B CN201710457869.2A CN201710457869A CN109144677B CN 109144677 B CN109144677 B CN 109144677B CN 201710457869 A CN201710457869 A CN 201710457869A CN 109144677 B CN109144677 B CN 109144677B
Authority
CN
China
Prior art keywords
file
application
opposite
starting
ended
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710457869.2A
Other languages
Chinese (zh)
Other versions
CN109144677A (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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201710457869.2A priority Critical patent/CN109144677B/en
Publication of CN109144677A publication Critical patent/CN109144677A/en
Application granted granted Critical
Publication of CN109144677B publication Critical patent/CN109144677B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution

Abstract

The application discloses a keep-alive process method and device for an android system. One embodiment of the method comprises: responding to application starting, declaring two processes started by an android system for the application, namely a first process and a second process, wherein the first process and the second process respectively comprise components for starting the application; creating subfiles for the first process and the second process respectively, so that the first process and the second process acquire file locks through the subfiles respectively, and judging whether the opposite process is ended or not by monitoring the state of the file locks of the opposite process; and in response to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, restarting the application through a component which is contained in the opposite process and used for starting the application. The implementation method can improve the effectiveness of the keep-alive process of the android system.

Description

Keep-alive process method and device for android system
Technical Field
The application relates to the technical field of computers, in particular to the technical field of terminals, and particularly relates to a keep-alive process method and device for an android system.
Background
In the android system, a process keep-alive technology generally adopts a method of mutual protection of parent and child processes in a framework layer (such as a nativie layer). Specifically, parent and child processes guard against each other, and no matter who dies the two processes, the other process should perform keep-alive operation on the two processes. For example, in a system of a version below android 5.0, when the system finishes a process, a related process of a framework layer (e.g., a native layer) is not killed, a method of a fork process may be adopted in the native layer, two pipelines are established by a parent process and a child process to block a reading pipeline mutually, and if the reading pipeline can be read, a monitored process is killed, and a keep-alive operation is executed to protect the process. However, in the system of the version above 5.0 of the android, when the system finishes the process, all processes in the same group are finished together, and the meaning of the same group may include "history same group", for example, a sub-process in native layer fork, and the sub-process, whether being accepted by an init process or being in a group crossing, a session crossing, and jumping into a new process group through a setup function, will be recorded as history same group by the android system, and will be finished. The framework layer parent-child process keep-alive technology is invalid in the system above 5.0 android, and the process cannot be kept alive.
Therefore, a universal keep-alive process method for the android system is needed, and the effectiveness of the keep-alive process is improved.
Disclosure of Invention
The present application aims to provide an improved keep-alive process method and apparatus for android system, so as to solve the technical problems mentioned in the above background section.
In a first aspect, the present application provides a method for a keep-alive process of an android system, where the method includes: responding to application starting, declaring two processes started by an android system for the application, wherein the two processes are a first process and a second process respectively, and the first process and the second process respectively comprise components for starting the application; creating subfiles for the first process and the second process respectively so that the first process and the second process acquire file locks through the subfiles respectively and judge whether the opposite process is ended or not by monitoring the state of the file locks of the opposite process; and in response to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, restarting the application through a component which is contained in the opposite process and used for starting the application.
In some embodiments, creating subfiles for the first process and the second process, respectively, so that the first process and the second process obtain file locks through the subfiles, respectively, and determining whether the opposite process is ended by monitoring the state of the file lock of the opposite process includes: for each of the first and second processes: creating a first file and a second file, wherein the first file is used for acquiring a file lock, and the second file is used for reading the second file of the opposite process; and when the second file of the opposite process is read, in response to the completion of locking the first file, deleting the second file of the opposite process so that the opposite process can monitor the file lock state of the process.
In some embodiments, in response to determining that the peer process is ended according to the monitored file lock state of the peer process according to any one of the first process and the second process, the method further includes: ending the process of monitoring the process of the opposite side to be ended, so that the opposite side process monitors the process to be ended and restarts the process.
In some embodiments, restarting the application includes: and sending an intention of starting the component contained in the opposite process for starting the application to the android system.
In some embodiments, the intention of starting the component included in the opposite process for starting the application is generated when the first process or the second process is initialized, and the binding object of the process management service in the process is acquired so as to bind with the opposite process.
In some embodiments, the above method further comprises: and when the application is restarted, setting an application traceless starting mark.
In a second aspect, the present application further provides an apparatus for a keep-alive process of an android system, where the apparatus includes: the declaration module is configured to declare two processes started by the android system for the application in response to the application starting, wherein the two processes are a first process and a second process respectively, and the first process and the second process respectively comprise components for starting the application; the monitoring module is configured to respectively create subfiles for the first process and the second process so that the first process and the second process respectively acquire a file lock through the subfiles and judge whether the opposite process is ended or not by monitoring the state of the file lock of the opposite process; and the keep-alive module is configured to respond to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, and restart the application through a component which is contained in the opposite process and used for starting the application.
In some embodiments, the listening module is further configured to: for each of the first and second processes: creating a first file and a second file, wherein the first file is used for acquiring a file lock, and the second file is used for reading a second file of the opposite process; and when the second file of the opposite process is read, in response to the completion of locking the first file, deleting the second file of the opposite process so that the opposite process can monitor the file lock state of the process.
In some embodiments, in response to determining that the peer process is ended according to the monitored file lock status of the peer process according to any one of the first process and the second process, the keep-alive module is further configured to: ending the process of monitoring the process of the opposite side to be ended, so that the opposite side process monitors the process to be ended and restarts the process.
In some embodiments, the keep-alive module is further configured to: and sending an intention of starting the component, which is contained in the opposite process, of the application to the android system so as to restart the application.
In some embodiments, the intention of starting the component included in the opposite process for starting the application is generated when the first process or the second process is initialized, and the binding object of the process management service in the process is acquired so as to bind with the opposite process.
In some embodiments, the apparatus further comprises a setting module configured to: and when the application is restarted, setting an application traceless starting mark.
In a third aspect, the present application further provides a computing device comprising: one or more processors; storage means for storing one or more programs; when executed by the one or more processors, cause the one or more processors to implement the methods described above.
According to the method and the device for the keep-alive process of the android system, in response to application starting, two processes started by the android system are declared for the application and respectively comprise a first process and a second process, wherein the first process and the second process respectively comprise a component used for starting the application, then subfiles are respectively created for the first process and the second process, so that the first process and the second process respectively obtain file locks through the subfiles, whether the process of the opposite side is ended or not is judged by monitoring the file lock state of the process of the opposite side, then, in response to the fact that any one of the first process and the second process determines that the process of the opposite side is ended according to the monitored file lock state of the process of the opposite side, and the application is restarted through the component used for starting the application and contained in the process of the opposite side. The method has the advantages that the claimed processes started by the android system monitor the file sending state of the other side mutually to determine whether to keep alive or not, so that the two processes are prevented from being ended, and the effectiveness of the keep-alive process of the android system can be improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
FIG. 1 is a flow diagram of one embodiment of a method for keep-alive procedures for an android system, in accordance with the present application;
FIG. 2 is a schematic diagram of an application scenario of an embodiment of a method for keep-alive procedures for an android system according to the application;
FIG. 3 is a flow diagram of two processes keep alive with each other in the application scenario shown in FIG. 2;
fig. 4 is a schematic structural diagram of an embodiment of a keep-alive process apparatus for an android system according to the present application;
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Referring to fig. 1, a flow 100 of one embodiment of a method for keep-alive procedures for an android system in accordance with the subject application is shown. The process 100 may be applied to an electronic device with certain computing capabilities, and may include, but is not limited to, any of the following: smart phones, tablet computers, electronic book readers, MP3 players (Moving Picture Experts Group Audio Layer III, motion Picture Experts Group Audio Layer IV, motion Picture Experts Group Audio Layer 4), MP4 players, laptop portable computers, desktop computers, and the like. The keep-alive process method for the android system comprises the following steps:
step 101, in response to application starting, declaring two processes started by the android system for the application, namely a first process and a second process.
In this embodiment, an electronic device (for example, a smartphone) running a keep-alive process method for an android system may first obtain an application that needs to be kept alive, and when detecting that the application is started, declare two processes started by the android system for the application, where the two processes are a first process and a second process, respectively. Here, the first and second are only differences in naming, and there is no substantial difference between the two processes. The first process and the second process have the same function, and the first process and the second process are matched with each other in the keep-alive process method of the embodiment, and the positions can be interchanged. The first process and the second process respectively comprise components for starting the application, so that the first process and the second process are kept alive with each other, and the purpose of keeping the application alive is achieved.
The component for starting the application may include, but is not limited to, at least one of the following: activity components, service components, broadcast receiver components, and the like.
And 102, respectively creating subfiles for the first process and the second process, so that the first process and the second process respectively acquire file locks through the subfiles, and judging whether the opposite process is ended or not by monitoring the file lock state of the opposite process.
In this embodiment, an electronic device (for example, a smart phone) running a method for a keep-alive process of an android system may then create subfiles for a first process and a second process, respectively, so that the first process and the second process obtain a file lock through the subfiles, respectively, and determine whether the opposite process is ended by monitoring a state of the file lock of the opposite process.
In practice, the electronic device may assign a file lock to the initiated process. The first process and the second process simultaneously create subfiles and lock the subfiles. After locking the sub-file, a process can instruct the process to monitor the file lock state. The opposite process can judge whether the process is ended according to the file lock state of the process. For example, a process that acquires a file lock acquires the file lock and then performs a subfile lock, and another process cannot read the locked file or file lock. The released file lock may be read by another process only when the process is finished. For another example, the process of acquiring the file lock may set a file lock state flag, where different flag values represent different states of the file lock, such as a locked or released state. Thus, another process can determine whether the opposite process is finished by determining the lock or release state of the file lock. Specifically, the counterpart process is not ended when the file lock is in the locked state, and the counterpart process is ended when the file lock is in the released state.
In some optional implementation manners of this embodiment, the electronic device may create a first file and a second file for each of a first process and a second process, where the first file is used to obtain a file lock, and the second file is used to read a second file of an opposite process; and when the second file of the other process is read, in response to the completion of locking the first file, deleting the second file of the other process so that the file lock of the process can be read by the other process. As an example, the two processes added to the declaration of the electronic device are a first process a and a second process B, respectively. The electronic device creates a first file A1 for process A, and starts to create A2 after the creation and locking of the first file A1 is completed. Meanwhile, the electronic device creates a first file B1 for the process B, and the first file B1 starts to create B2 after acquiring the file lock. Since the process a and the process B are started simultaneously, it is uncertain which of the first file a1 and the first file B1 first acquired the file lock, a and B listen to the second file each other, when a hears that B2 exists, it indicates that B1 has acquired the file lock, and similarly, when B hears that a2 exists, it indicates that a1 has acquired the file lock. When A1 obtains the file lock, the electronic device allows process A to delete file B2. And B1 monitors that B2 is deleted, acquires the information that A1 locking is completed and starts monitoring the state of A1 file lock. Similarly, when B1 acquires the file lock, the electronic device allows process B to delete file A2. The A1 monitors that the A2 is deleted, acquires the information that the locking of the B1 is completed, and starts to monitor the state of the B1 file lock. Further, the processes A and B respectively determine whether the opposite process is ended according to the state of the file lock of the opposite process.
And 103, in response to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, restarting the application through a component which is included in the opposite process and used for starting the application.
In this embodiment, the electronic device (for example, a smart phone) running the method for the keep-alive process of the android system may further determine whether the opposite process is ended according to the file lock state of the opposite process monitored by the first process and the second process, and if it is determined that the opposite process of any process is ended, restart the application started in step 101 through a component included in the opposite process and used for starting the application.
It can be understood that, since the first process and the second process are processes started by the android system and used for keeping alive the application started in step 101, when any one of the first process and the second process is ended, it is described that the application started in step 101 is ended, and the application needs to be kept alive, at this time, the electronic device may restart the application by including a component for starting the application in the ended process.
When the application is restarted, the unfinished process in the first process and the second process can start the application according to the application starting component contained in the finished process. For example, in the above example, it is assumed that the a process includes an activity component for starting the application, and the B process includes a service component for starting the application, and when the B process reads the file lock of the subfile a1 of the a process and determines that the a process is ended, the B process may send the intent to run the activity component to the android system running on the electronic device, and the android system restarts the application by starting the activity component in the B process. In practice, if the android system detects that the B process is ended, the B process is started first, and then the activity component in the B process is operated to restart the application. In some implementations, the electronic device may generate, when the processes of the first process and the second process are initialized, an intention to start a component included in the other process for starting the application for them, and acquire a binding binder object of a process management service (activitymanager service) in the process to bind with the other process. Thus, once a process determines that another process is finished, the intent can be sent directly to start another process, saving time.
In some optional implementation manners of this embodiment, in response to determining that the opposite process is ended according to the file lock state monitored by the process monitoring the file lock state, after restarting the application by the process monitoring that the opposite process is ended, the electronic device may further: ending the process of monitoring the process of the opposite side to be ended. And the opposite side process is restarted, and the opposite side process monitors that the process is ended and restarts the process, so that the two processes are ensured to run.
In some optional implementation manners of this embodiment, when the electronic device restarts the application, an application traceless start flag may be set so as to prevent the android system running on the electronic device from detecting the start record, and thus ending the application again. In practice, the traceless browsing identifier may include, but is not limited to, at least one of the following flag bits being a preset value: when the flag bit is set to a preset value, the android system running on the electronic device cannot detect the start record of the application.
As an application scenario, the method for keep-alive process of the android system provided by the application can be applied to the smart phone 200. An android system can run on smartphone 200. As shown in fig. 2, an application client 201 of "x friend making" is installed in an android system running on a smartphone 200, and assuming that a user wishes the application 201 to remain running and timely receives a message, the user can add the application 201 to an application white list of the smartphone 200. Then, as shown in fig. 3, upon the start of the application 201, the electronic device may create process 1 and process 2 for the application. Process 1 and process 2 may each contain components for launching application 201. Process 1 and process 2 have equally interchangeable positions and will be described herein with process 1 as the primary. The smartphone 200 creates a file 11 for the process 1, locks the file 11, and creates a file 12 for the process 1 when the file 11 acquires the file lock, that is, when the file 11 is locked. At this point, process 1 polls to see if file 22 exists, and if so, deletes file 22. Similarly, process 2 performs similar operations. Meanwhile, after the file 12 is created, monitoring whether the file 12 still exists through the process 1, if not, representing that the process 2 locks the file 21, and deleting the file 12 by the process 2. At this point, process 1 begins reading the file lock from file 21 and determines whether the file lock of file 21 was read, and when so, determines that process 2 is finished. The smart phone 200 may send an intent of a component (such as an activity component) for starting the application 201 included in the process 2 to the android system running on the smart phone through the process 1, and if the android system runs the component-type discovery process 2 and is finished, the process 2 is run first, and then the component for starting the application 201 included in the process 2 is run, so that the keep-alive of the application 201 is realized. In practice, the process 1 can also end its own process after sending the intent. Then process 2 is restarted and process 1 is found to end, keeping process 1 alive in the same manner.
Therefore, according to the keep-alive process method for the android system, whether keep-alive is carried out or not is determined by monitoring the file sending states of the opposite sides mutually through the declared processes started by the android system, and the two processes are prevented from being ended, so that the effectiveness of the keep-alive process of the android system can be improved.
With further reference to fig. 4, as an implementation of the method for keep-alive process of android system, the present application provides an embodiment of a keep-alive process device for android system, where the embodiment of the device corresponds to the embodiment of the method shown in fig. 1.
As shown in fig. 4, the keep-alive process apparatus 400 for the android system of this embodiment includes: a declaration module 401, a listening module 402, and a keep-alive module 403. The declaration module 401 may be configured to, in response to application startup, declare two processes, namely a first process and a second process, started by the android system for the application, where the first process and the second process respectively include a component for starting the application; the monitoring module 402 may be configured to create subfiles for the first process and the second process, respectively, so that the first process and the second process obtain a file lock through the subfiles, respectively, and determine whether the opposite process is ended by monitoring a state of the file lock of the opposite process; the keep-alive module 403 may be configured to, in response to determining that the peer process is ended according to the monitored file lock state of the peer process by any one of the first process and the second process, restart the application through a component included in the peer process, where the component starts the application.
In some optional implementations of this embodiment, the listening module 402 may be further configured to: for each of the first process, the second process: creating a first file and a second file, wherein the first file is used for acquiring a file lock, and the second file is used for reading a second file of the opposite process; and when the second file of the opposite process is read, in response to the completion of locking the first file, deleting the second file of the opposite process so that the opposite process can monitor the file lock state of the process.
In some optional implementation manners of this embodiment, in response to determining that the peer process is ended according to the monitored file lock state of the peer process according to any one of the first process and the second process, the keep-alive module 403 may be further configured to: ending the process of monitoring the process of the opposite side to be ended, so that the opposite side process monitors the process to be ended and restarts the process.
In some optional implementations of this embodiment, the keep-alive module 403 may be further configured to: and sending an intention of starting the component of the application, which is contained in the opposite side process, to the android system so as to restart the application. In some implementations, the intention to start the component included in the counterpart process for starting the application is generated when the first process or the second process is initialized, respectively, and a binding object of the process management service in the process is acquired to bind with the counterpart process. This saves the time it takes to keep the process alive.
In some optional implementations of this embodiment, the apparatus 400 may further include a setting module (not shown) configured to: and when the application is restarted, setting an application traceless starting mark.
It is worth noting that the modules recited in the apparatus 400 for keep-alive procedure of the android system correspond to the respective steps in the method described with reference to fig. 1. Thus, the operations and features described above for the method are equally applicable to the apparatus 400 and the modules or units included therein, and are not described in detail here.
Those skilled in the art will appreciate that apparatus 400 for keep-alive procedures for an android system described above also includes some other well-known structure, such as a processor, memory, etc., which is not shown in fig. 4 in order to unnecessarily obscure embodiments of the present disclosure.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use in implementing embodiments of the present application. The computer system shown in fig. 5 is only an example, and should not bring any limitation to the function and the scope of use of the embodiments of the present application.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the system 500 are also stored. The CPU501, ROM502, and RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard or a touch panel; an output section 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), or the like; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 501. It should be noted that the non-volatile computer readable medium referred to in this application may be a non-volatile computer readable signal medium or a non-volatile computer readable storage medium or any combination of the two. A non-transitory computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the non-volatile computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a non-transitory computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present application may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a declaration module, a listening module, and a keep-alive module. Where the names of these modules do not constitute a limitation on the unit itself under certain circumstances, for example, the declaring module may also be described as a "module configured to declare two android-initiated processes for an application in response to the application launching.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: responding to application starting, declaring two processes started by an android system for the application, wherein the two processes are a first process and a second process respectively, and the first process and the second process respectively comprise components for starting the application; creating subfiles for the first process and the second process respectively so that the first process and the second process acquire file locks through the subfiles respectively and judge whether the opposite process is ended or not by monitoring the state of the file locks of the opposite process; and in response to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, restarting the application through a component which is contained in the opposite process and used for starting the application.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (8)

1. A method for keep-alive procedures for an android system, the method comprising:
responding to application starting, declaring two processes started by an android system for the application, wherein the two processes are a first process and a second process respectively, and the first process and the second process respectively comprise components for starting the application;
creating subfiles for the first process and the second process respectively so that the first process and the second process acquire file locks through the subfiles respectively and judge whether the opposite process is ended or not by monitoring the state of the file locks of the opposite process;
determining that the opposite process is ended according to the monitored file lock state of the opposite process in response to any one of the first process and the second process, and restarting the application through a component for starting the application, which is included in the opposite process;
ending the process of monitoring the process of the opposite side to be ended so that the opposite side process monitors the process to be ended and restarts the process;
when the application is restarted, setting an application traceless starting mark;
wherein the restarting the application comprises: and sending an intention for starting the component of the application, which is contained in the process of the other side, to the android system, wherein the intention is generated when the processes of the first process and the second process are initialized.
2. The method of claim 1, wherein the creating subfiles for the first process and the second process respectively, so that the first process and the second process respectively obtain the file lock through the subfiles, and determining whether the process of the opposite side is finished by monitoring the state of the file lock of the process of the opposite side comprises:
for each of the first and second processes:
creating a first file and a second file, wherein the first file is used for acquiring a file lock, and the second file is used for reading a second file of the opposite process;
and when the second file of the opposite process is read, in response to the completion of locking the first file, deleting the second file of the opposite process so that the opposite process can monitor the file lock state of the process.
3. The method of claim 1, wherein the intention to start the component for starting the application included in the opposite process is generated when the first process or the second process is initialized, respectively, and a binding object of the process management service in the process is acquired to bind with the opposite process.
4. An apparatus for keep-alive procedures for an android system, the apparatus comprising:
the declaration module is configured to declare, in response to application startup, two processes started by the android system for the application, namely a first process and a second process, wherein the first process and the second process respectively comprise components for starting the application;
the monitoring module is configured to respectively create subfiles for the first process and the second process, so that the first process and the second process respectively acquire file locks through the subfiles, and judge whether the opposite process is ended or not by monitoring the state of the file locks of the opposite process;
the keep-alive module is configured to respond to the fact that any one of the first process and the second process determines that the opposite process is ended according to the monitored file lock state of the opposite process, and restart the application through a component which is included in the opposite process and used for starting the application;
the keep-alive module is further configured to: ending the process of monitoring the process of the opposite side to be ended so that the opposite side process monitors the process to be ended and restarts the process;
a setup module configured to: when the application is restarted, setting an application traceless starting mark;
the keep-alive module is further configured to: and sending an intention for starting the component of the application, which is contained in the process of the other side, to the android system so as to restart the application, wherein the intention is generated when the processes of the first process and the second process are initialized.
5. The apparatus of claim 4, wherein the listening module is further configured to:
for each of the first and second processes:
creating a first file and a second file, wherein the first file is used for acquiring a file lock, and the second file is used for reading a second file of the opposite process;
and when the second file of the opposite process is read, in response to the completion of locking the first file, deleting the second file of the opposite process so that the opposite process can monitor the file lock state of the process.
6. The apparatus according to claim 4, wherein the intention to start the component for starting the application included in the counterpart process is generated when the first process or the second process is initialized, respectively, and a binding object of the process management service in the process is acquired to bind with the counterpart process.
7. A computing device, comprising:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-3.
8. A non-transitory computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method of any one of claims 1-3.
CN201710457869.2A 2017-06-16 2017-06-16 Keep-alive process method and device for android system Active CN109144677B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710457869.2A CN109144677B (en) 2017-06-16 2017-06-16 Keep-alive process method and device for android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710457869.2A CN109144677B (en) 2017-06-16 2017-06-16 Keep-alive process method and device for android system

Publications (2)

Publication Number Publication Date
CN109144677A CN109144677A (en) 2019-01-04
CN109144677B true CN109144677B (en) 2022-08-26

Family

ID=64830630

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710457869.2A Active CN109144677B (en) 2017-06-16 2017-06-16 Keep-alive process method and device for android system

Country Status (1)

Country Link
CN (1) CN109144677B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112445530B (en) * 2019-08-29 2023-03-14 成都鼎桥通信技术有限公司 Method and device for keeping third-party application program alive
CN111399924B (en) * 2020-03-18 2023-06-16 山东车微联信息技术股份有限公司 Method, terminal and storage medium for keeping application process alive under android platform
CN113760492A (en) * 2020-11-04 2021-12-07 北京沃东天骏信息技术有限公司 Program process keep-alive method, system, device, equipment and storage medium
CN112860408A (en) * 2021-03-03 2021-05-28 苏州沁游网络科技有限公司 Process keep-alive method, device and system in cloud reality machine and storage medium
CN117407068B (en) * 2023-12-08 2024-03-29 厦门她趣信息技术有限公司 Method for activating Android process by multiple strategies

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484223A (en) * 2014-12-16 2015-04-01 北京奇虎科技有限公司 Android system application closing method and android system application closing device
CN106162510A (en) * 2015-04-08 2016-11-23 株式会社日立制作所 Security procedure managing device and security procedure management method
CN106355060A (en) * 2016-10-31 2017-01-25 Tcl集团股份有限公司 Application-lock implementation method and system based on android system
CN106371911A (en) * 2016-09-06 2017-02-01 北京海誉动想科技股份有限公司 Method for rebooting guarded process by daemon processes
CN106648863A (en) * 2016-12-08 2017-05-10 武汉斗鱼网络科技有限公司 Live keeping method and system of Android application installation package and application target process
CN106708617A (en) * 2016-12-23 2017-05-24 武汉斗鱼网络科技有限公司 Service-based application process keep-alive system and keep-alive method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484223A (en) * 2014-12-16 2015-04-01 北京奇虎科技有限公司 Android system application closing method and android system application closing device
CN106162510A (en) * 2015-04-08 2016-11-23 株式会社日立制作所 Security procedure managing device and security procedure management method
CN106371911A (en) * 2016-09-06 2017-02-01 北京海誉动想科技股份有限公司 Method for rebooting guarded process by daemon processes
CN106355060A (en) * 2016-10-31 2017-01-25 Tcl集团股份有限公司 Application-lock implementation method and system based on android system
CN106648863A (en) * 2016-12-08 2017-05-10 武汉斗鱼网络科技有限公司 Live keeping method and system of Android application installation package and application target process
CN106708617A (en) * 2016-12-23 2017-05-24 武汉斗鱼网络科技有限公司 Service-based application process keep-alive system and keep-alive method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Android进程常驻(4)和(5);猫九爷阳果果;《csdn https://blog.csdn.net/marswin89/article/details/50916631》;20160317;第1-15页 *

Also Published As

Publication number Publication date
CN109144677A (en) 2019-01-04

Similar Documents

Publication Publication Date Title
CN109144677B (en) Keep-alive process method and device for android system
US8774778B2 (en) Mobile location identifier for social check-in applications
CN109995877B (en) Information pushing method and device
CN107644075B (en) Method and device for collecting page information
CN110069919B (en) Information acquisition method and device
WO2019015272A1 (en) Information processing method and device
CN109408481B (en) Log collection rule updating method and device, electronic equipment and readable medium
CN103810010A (en) Information processing method and first electronic device terminal
CN112596920A (en) Message processing method and device, electronic equipment and storage medium
CN110365745B (en) Data processing system, method, apparatus, server and computer readable medium
CN110046000B (en) Applet running method and device
CN109828830B (en) Method and apparatus for managing containers
CN111510466A (en) Data updating method and device for client, electronic equipment and readable medium
CN111460432B (en) On-line document authority control method, device, equipment and computer readable medium
CN111381965B (en) Method and apparatus for processing requests
CN103975301A (en) Event service for local client applications through local server
CN110233791B (en) Data deduplication method and device
CN109218338B (en) Information processing system, method and device
CN110941658A (en) Data export method, device, server and storage medium
CN110048991B (en) Method and device for realizing signal interaction reliability
CN114625458A (en) Page data processing method and device, electronic equipment and storage medium
US8527580B2 (en) Saving multiple data items using partial-order planning
CN110365839B (en) Shutdown method, shutdown device, shutdown medium and electronic equipment
US20190258726A1 (en) File and data migration to storage system
CN110855767B (en) Method, device, equipment and storage medium for responding operation request

Legal Events

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