CN105893129B - Method and device for processing application program in terminal - Google Patents

Method and device for processing application program in terminal Download PDF

Info

Publication number
CN105893129B
CN105893129B CN201610195147.XA CN201610195147A CN105893129B CN 105893129 B CN105893129 B CN 105893129B CN 201610195147 A CN201610195147 A CN 201610195147A CN 105893129 B CN105893129 B CN 105893129B
Authority
CN
China
Prior art keywords
application program
long connection
server
preset
terminal
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
CN201610195147.XA
Other languages
Chinese (zh)
Other versions
CN105893129A (en
Inventor
史大龙
孙超
林锦滨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201610195147.XA priority Critical patent/CN105893129B/en
Publication of CN105893129A publication Critical patent/CN105893129A/en
Application granted granted Critical
Publication of CN105893129B publication Critical patent/CN105893129B/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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure relates to a processing method and device of an application program in a terminal. The method comprises the following steps: monitoring a communication request of an application program in a terminal; calling a process in the terminal; sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server; and receiving response information returned by the server for the communication request through the process, and sending the response information to the application program. According to the technical scheme, long connections between all the application programs and the corresponding servers can be established and maintained through a process, and the long connections between the application programs and the corresponding servers are ensured not to disappear when the application programs are closed; meanwhile, the real-time performance of communication between the application program and the corresponding server can be ensured, and the power consumption of the system is reduced.

Description

Method and device for processing application program in terminal
Technical Field
The present disclosure relates to the field of terminal technologies, and in particular, to a method and an apparatus for processing an application program in a terminal.
Background
At present, with the rapid development of the mobile internet, many application programs increasingly depend on long connection of a TCP (Transmission Control Protocol), and instant messaging software or VOIP (Voice over internet Protocol) software needs to receive a message from a server at any time, which needs to establish and maintain connection with the server. However, in the prior art, a long connection established between an application and a server needs a process of the application to maintain the long connection, which has some problems, for example, when the application is closed, the long connection follows the message, or when the application falls back to a background, the system prohibits using the long connection, in order to solve these problems, a background process may be separately started to maintain the long connection, so that after the application is closed, the long connection may exist all the time, but this solution needs to separately create a process for each application, which consumes too much system resources, or a third-party push service is used to maintain the long connection, so that after the application is closed, the long connection may exist all the time, but the arrival rate and real-time performance of data cannot be guaranteed. In addition, the above two solutions can not solve the problem that after the application program runs to the background, the long connection still cannot be connected to the network, so that information is lost or the information is not received timely, and meanwhile, the system can be frequently awakened by any solution, so that electric quantity is wasted.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for processing an application program in a terminal. The technical scheme is as follows:
according to a first aspect of the embodiments of the present disclosure, a method for processing an application program in a terminal is provided, including:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
and receiving response information returned by the server aiming at the communication request through the process, and sending the response information to the application program.
In one embodiment, the method further comprises:
after the application program receives the response information, monitoring whether the application program runs in a background or is cleared from a memory;
and when the application program runs in the background or is cleared from the memory and the application program is not exited, waking up the application program according to a preset wake-up period so as to enable the server to keep the long connection with the process.
In one embodiment, the waking up the application program according to a preset wake-up cycle to enable the server to maintain the long connection with the process includes:
after the application program is awakened according to the preset awakening period, controlling the application program to send a heartbeat packet to the process;
sending, by the process, the heartbeat packet to the server to cause the server to maintain the long connection with the process.
In one embodiment, the method further comprises:
after the application program is awakened according to the preset awakening period, judging whether the application program returns to a background or not;
and when the application program returns to the background, closing the application program.
In one embodiment, the method further comprises:
determining the total times of returning to the background after the application program is awakened in a preset number of preset awakening periods;
determining whether the ratio of the total number of times to the preset number is greater than or equal to a preset ratio;
when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection closing notification to the process;
sending the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
In one embodiment, when the application program includes at least two, the method further includes:
judging whether the current residual capacity of the terminal is less than or equal to a preset residual capacity;
when the current residual capacity is less than or equal to the preset residual capacity, acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period;
and controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
In one embodiment, the controlling the target application to send a long connection close instruction to the process includes:
prompting the target application program and the current residual capacity to a user so that the user determines whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and when the long connection disconnection instruction is received, controlling the target application program to send the long connection disconnection instruction to the process.
In one embodiment, the process comprises: allowing background networked system processes.
According to a second aspect of the embodiments of the present disclosure, there is provided an apparatus for processing an application program in a terminal, including:
the monitoring module is used for monitoring the communication request of the application program in the terminal;
the calling module is used for calling a process in the terminal;
the first processing module is used for sending the communication request to a server corresponding to the application program through the process and establishing long connection between the process and the server;
and the second processing module is used for receiving response information returned by the server aiming at the communication request through the process and sending the response information to the application program.
In one embodiment, the apparatus further comprises:
the monitoring module is used for monitoring whether the application program runs in the background or is cleared from the memory after the application program receives the response information;
and the awakening module is used for awakening the application program according to a preset awakening period when the application program runs in the background or is cleared from the memory and the application program is not exited, so that the server keeps the long connection with the process.
In one embodiment, the wake-up module comprises:
the control submodule is used for controlling the application program to send a heartbeat packet to the process after the application program is awakened according to the preset awakening period;
and the sending submodule is used for sending the heartbeat packet to the server through the process so as to enable the server to maintain the long connection with the process.
In one embodiment, the apparatus further comprises:
the judging module is used for judging whether the application program returns to the background or not after the application program is awakened according to the preset awakening period;
and the third processing module is used for closing the application program when the application program returns to the background.
In one embodiment, the apparatus further comprises:
the first determining module is used for determining the total times of returning to the background after the application program is awakened in a preset number of preset awakening periods;
the second determining module is used for determining whether the ratio of the total times to the preset number is greater than or equal to a preset ratio;
the first control module is used for controlling the application program to send a long connection closing notification to the process when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods;
a sending module, configured to send the long connection closing notification to the server through the process, so that the server disconnects the long connection with the process.
In one embodiment, the apparatus further comprises:
the judging module is used for judging whether the current residual electric quantity of the terminal is less than or equal to the preset residual electric quantity or not when the number of the application programs is at least two;
the acquisition module is used for acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period when the current residual electric quantity is less than or equal to the preset residual electric quantity;
and the second control module is used for controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
In one embodiment, the second control module comprises:
the prompting submodule is used for prompting the target application program and the current residual capacity to a user so that the user can determine whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and the control submodule is used for controlling the target application program to send the long connection disconnection instruction to the process when the long connection disconnection instruction is received.
In one embodiment, the process comprises: allowing background networked system processes.
According to a third aspect of the embodiments of the present disclosure, there is provided a processing apparatus for an application program in a terminal, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
and receiving response information returned by the server aiming at the communication request through the process, and sending the response information to the application program.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
according to the technical scheme provided by the embodiment of the disclosure, when the communication request of the application program in the terminal is monitored, the process in the terminal is called, so that long connections between all the application programs and the corresponding servers can be established and maintained by using the process, and the long connections between the application programs and the corresponding servers can not disappear when the application programs are closed, so that the problem that the corresponding long connections need to be re-established after the application programs return to the foreground for operation is avoided, the operation is simplified, and the inevitable consumption of system resources is reduced; meanwhile, the real-time performance of communication between the application program and the corresponding server can be ensured, and the power consumption of the system is reduced.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flowchart illustrating a processing method of an application in a terminal according to an exemplary embodiment.
Fig. 2 is a flowchart illustrating a processing method of an application in another terminal according to an exemplary embodiment.
Fig. 3 is a flowchart illustrating a processing method of an application in another terminal according to an example embodiment.
Fig. 4 is a flowchart illustrating a processing method of an application in still another terminal according to an exemplary embodiment.
Fig. 5 is a flowchart illustrating a processing method of an application in still another terminal according to an exemplary embodiment.
Fig. 6 is a flowchart illustrating a processing method of an application in still another terminal according to an exemplary embodiment.
Fig. 7 is a flowchart illustrating a processing method of an application in still another terminal according to an exemplary embodiment.
Fig. 8 is a block diagram illustrating a processing device of an application in a terminal according to an example embodiment.
Fig. 9 is a block diagram illustrating another apparatus for processing an application in a terminal according to an example embodiment.
Fig. 10 is a block diagram illustrating a processing device of an application in yet another terminal according to an example embodiment.
Fig. 11 is a block diagram illustrating a processing device of an application in yet another terminal according to an example embodiment.
Fig. 12 is a block diagram illustrating a processing device of an application in yet another terminal according to an example embodiment.
Fig. 13 is a block diagram illustrating a processing device of an application in yet another terminal according to an example embodiment.
Fig. 14 is a block diagram illustrating a processing device of an application in yet another terminal according to an example embodiment.
Fig. 15 is a block diagram illustrating a processing device suitable for an application in a terminal according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
At present, with the rapid development of the mobile internet, many application programs increasingly depend on long connection of a TCP (Transmission Control Protocol), and instant messaging software or VOIP (Voice over internet Protocol) software needs to receive a message from a server at any time, which needs to establish and maintain connection with the server. However, in the prior art, a long connection established between an application and a server needs a process of the application to maintain the long connection, which has some problems, for example, when the application is closed, the long connection follows the message, or when the application falls back to a background, the system prohibits using the long connection, in order to solve these problems, a background process may be separately started to maintain the long connection, so that after the application is closed, the long connection may exist all the time, but this solution needs to separately create a process for each application, which consumes too much system resources, or a third-party push service is used to maintain the long connection, so that after the application is closed, the long connection may exist all the time, but the arrival rate and real-time performance of data cannot be guaranteed. In addition, the above two solutions can not solve the problem that after the application program runs to the background, the long connection still cannot be connected to the network, so that information is lost or the information is not received timely, and meanwhile, the system can be frequently awakened by any solution, so that electric quantity is wasted.
In order to solve the foregoing technical problem, an embodiment of the present disclosure provides a method for processing an application program in a terminal, where the method may be used in a processing program, a system, or an apparatus of the application program in the terminal, and an execution main body corresponding to the method may be a terminal installed with an android system and carried by a user, as shown in fig. 1, the method includes steps S101 to S104:
in step S101, a communication request of an application program in the terminal is monitored;
the communication request is a request for the application program to connect with a corresponding server for communication, and may be automatically generated when the application program receives an open operation action (such as clicking and long-pressing), or may be automatically generated when the application program receives an input instruction (such as inputting a search keyword) or a virtual icon of the application program is selected (such as clicking and long-pressing a virtual icon capable of page jump).
In step S102, a process in the terminal is called;
the process is a system process in the terminal and is a common process, and when all the application programs generate communication requests to expect to communicate with the corresponding servers, the communication requests are forwarded to the corresponding servers through the process.
In addition, the process may be automatically created by the system before monitoring the communication request of the application program, or may be automatically created by the system after monitoring the communication request generated by the first started application program after the terminal is started, or may be automatically created after generating the communication request after the terminal is started, and after the process is created, as long as the user does not manually clear the process, or the terminal is not powered off, or all the application programs are not logged out, the process may always exist in the system for invocation.
In step S103, the process sends the communication request to a server corresponding to the application program, and establishes a long connection between the process and the server, where the long connection means that a plurality of data packets can be continuously sent over one connection, and during the connection maintenance period, if no data packet is sent, both sides need to send a link detection packet;
the communication request is sent to the server corresponding to the application program through the process, and the long connection between the process and the server of the application program is established, so that the long connection between the application program and the server corresponding to the application program (namely, the long connection between the process and the server corresponding to the application program) still exists and cannot disappear when the application program is closed (namely, the application program is cleared from the memory but is not logged out), thereby avoiding the problem that the corresponding long connection needs to be re-established after the application program returns to the foreground for operation again, further simplifying the operation and reducing the unavoidable consumption of system resources;
in addition, only one process responsible for establishing long connections between all the application programs and the servers corresponding to the application programs is arranged in the terminal, so that the consumption of system resources is further reduced, the process for establishing the long connections is avoided being established for each application program, and meanwhile, the process is the process in the terminal and is not push service of a third party, so that the real-time performance of communication between the application programs and the servers corresponding to the application programs can be ensured.
In step S104, response information returned by the server in response to the communication request is received by the process, and the response information is sent to the application program.
After the server responds to the communication request sent by the corresponding application program forwarded by the process and establishes the corresponding long connection with the process, the process receives response information returned by the server aiming at the communication request, and at the moment, the process also sends the response information to the application program, so that the application program can confirm that the communication with the server can be started, and the communication efficiency is improved.
As shown in fig. 2, in one embodiment, the method further comprises:
in step S201, after the application receives the response message, monitoring whether the application runs in the background or is cleared from the memory;
in step S202, when the application program runs in the background or is cleared from the memory and the application program has not been exited yet, the application program is woken up according to a preset wake-up period, so that the server maintains the long connection with the process.
After the application receives the response message, it needs to monitor whether the application runs in the background or is cleared from the memory, and if it is monitored that the application still runs in the background or is cleared from the memory and the application has not been logged out, it indicates that the user is not currently using the application and the user has not completely logged out of the application, and therefore, the user is likely to need to continue using the application to communicate with its corresponding server (for example, to send a communication request to its corresponding server again), so the system may wake up the application according to a preset wake-up period to keep the server in a long connection with the process, so that the server confirms that its corresponding application is still in an "online" state, and avoid the server mistakenly believing that the application has been logged out and prematurely interrupting the long connection, and consequently, the system needs to re-establish the long connection when the user reuses the application.
As shown in fig. 3, in an embodiment, the step "waking up the application program according to a preset wake-up cycle to enable the server to maintain the long connection with the process" in the step S202 may be performed as follows:
in step a1, after waking up the application program according to the preset wake-up period, controlling the application program to send a heartbeat packet to the process;
in step a2, the heartbeat packet is sent by the process to the server to cause the server to maintain the long connection with the process.
After the application program is awakened according to a preset awakening period, the application program can be controlled to send the heartbeat packet to the process, so that the heartbeat packet is sent to the server through the process, the server confirms that the application program corresponding to the server is still in an 'online' state, and the long connection is prevented from being interrupted too early due to the fact that the server mistakenly thinks that the application program is quitted, and further the long connection needs to be reestablished by a system when a user reuses the application program.
In addition, when all the application programs establish long connection with the corresponding servers, the process needs to be passed through and the long connection between the process and the corresponding servers is established, so that the system regularly and uniformly wakes up the application programs and controls the application programs to uniformly send heartbeat packets to the process, the process uniformly sends all the received heartbeat packets to the corresponding servers, and the process uniformly maintains the long connection with the corresponding servers, so that the consumption of electric quantity can be reduced, and the problem of high electric consumption caused by the fact that the application programs ceaselessly and autonomously wake up the system and then send the heartbeat packets to maintain the corresponding long connection through the process is solved.
As shown in fig. 4, in one embodiment, the method further comprises:
after step S401, after waking up the application program according to the preset wake-up period, determining whether the application program returns to the background;
after step S402, when the application returns to the background, the application is closed.
After the application program is awakened according to the preset awakening period, whether the application program returns to the background needs to be judged, when the application program returns to the background, the application program can be automatically closed to clear the application program from the memory, so that some memory is released, and the phenomenon that the running performance of the system is influenced due to the fact that too much memory is occupied is avoided.
As shown in fig. 5, in one embodiment, the method further comprises:
in step S501, determining the total number of times that the application program returns to the background after being awakened in a preset number of preset awakening periods; the preset number of preset wakeup periods is N continuous preset wakeup periods.
In step S502, it is determined whether a ratio of the total number of times to the preset number is greater than or equal to a preset ratio; the preset ratio may be 0.7, etc.
In step S503, when the ratio is greater than or equal to the preset ratio and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection close notification to the process;
when the ratio is greater than or equal to the preset ratio, it is indicated that the application program is awakened each time, and in most cases, the user does not use the application program, and the application program is in an idle state and does not run for most of the time.
In step S504, the long connection close notification is sent to the server by the process, so that the server disconnects the long connection with the process.
And the process sends the long connection closing notification to the server corresponding to the application program, so that the server determines that the user does not frequently use the corresponding application program currently, and therefore, the long connection with the process can be automatically disconnected, and occupation of system resources by the long connection corresponding to the application program is reduced.
As shown in fig. 6, in one embodiment, when the application program includes at least two, the method further includes:
in step S601, determining whether the current remaining power of the terminal is less than or equal to a preset remaining power;
in step S602, when the current remaining power is less than or equal to the preset remaining power, acquiring a target application with the shortest foreground runtime among at least two applications within a preset historical time period;
in step S603, the target application is controlled to send a long connection disconnection instruction to the process, so that the process disconnects the long connection with the server corresponding to the target application.
When the current remaining power is less than or equal to the preset remaining power (for example, 30%), which indicates that the current remaining power is not enough, the target application with the shortest foreground running time among the at least two applications, that is, the application least frequently used by the user, may be automatically obtained within the preset historical time period, and then the target application is controlled to send a long connection disconnection instruction to the process, so that the process automatically disconnects the long connection with the server corresponding to the target application, thereby reducing the number of long connections in the system and reducing power consumption.
As shown in fig. 7, in one embodiment, the step S603 may be performed as:
in step B1, the target application program and the current remaining power are prompted to a user, so that the user determines whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current remaining power;
in step B2, upon receiving the long disconnection instruction, controlling the target application to send a long disconnection instruction to the process.
In order to avoid mistaken disconnection of the corresponding long connection, the target application program and the current remaining power can be prompted to the user, so that the user can autonomously determine whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current remaining power, and therefore the target application program can send a long connection disconnection instruction to the process only when the long connection disconnection instruction is received, and the mistaken disconnection of the important long connection is avoided.
In one embodiment, the process comprises: allowing background networked system processes.
The process can be a system process which allows background networking, so that even if the application program returns to the background or runs in the background, the process can still use the network and long connection between the process and the server corresponding to the application program still exists, so that the process can still normally receive information sent by the server, and the application program can also receive the information from the server in real time when the application program is in the background, thereby avoiding the problems of information loss or untimely receiving.
In addition, the mode of setting the process as the system process allowing background networking is also simple, and the process only needs to be added into a white list of application programs which are prestored in the system and allowed to perform background networking.
Corresponding to the method for processing the application program in the terminal provided by the embodiment of the present disclosure, an embodiment of the present disclosure further provides a device for processing the application program in the terminal, as shown in fig. 8, the device includes:
a monitoring module 801, configured to monitor a communication request of an application program in the terminal;
a calling module 802, configured to call a process in the terminal;
a first processing module 803, configured to send the communication request to a server corresponding to the application program through the process, and establish a long connection between the process and the server;
the second processing module 804 is configured to receive, by the process, response information returned by the server for the communication request, and send the response information to the application program.
As shown in fig. 9, in one embodiment, the apparatus further comprises:
a monitoring module 901, configured to monitor whether the application runs in a background or is cleared from a memory after the application receives the response message;
a wake-up module 902, configured to wake up the application program according to a preset wake-up period when the application program runs in the background or is cleared from the memory, and the application program has not been exited yet, so that the server maintains the long connection with the process.
As shown in fig. 10, in one embodiment, the wake-up module 902 includes:
the control sub-module 9021 is configured to control the application program to send a heartbeat packet to the process after the application program is awakened according to the preset awakening period;
a sending submodule 9022, configured to send the heartbeat packet to the server through the process, so that the server maintains the long connection with the process.
As shown in fig. 11, in one embodiment, the apparatus further comprises:
a determining module 1101, configured to determine whether the application program returns to a background after waking up the application program according to the preset wake-up period;
a third processing module 1102, configured to close the application program when the application program returns to the background.
As shown in fig. 12, in one embodiment, the apparatus further comprises:
a first determining module 1201, configured to determine a total number of times for returning to the background after the application is awakened in a preset number of preset awakening periods;
a second determining module 1202, configured to determine whether a ratio of the total number of times to the preset number is greater than or equal to a preset ratio;
a first control module 1203, configured to control the application program to send a long connection close notification to the process when the ratio is greater than or equal to the preset ratio and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods;
a sending module 1204, configured to send the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
As shown in fig. 13, in one embodiment, the apparatus further comprises:
a determining module 1301, configured to determine whether a current remaining power of the terminal is less than or equal to a preset remaining power when the number of the application programs is at least two;
an obtaining module 1302, configured to obtain, when the current remaining power is less than or equal to the preset remaining power, a target application with a shortest foreground running time among the at least two applications within a preset historical time period;
and a second control module 1303, configured to control the target application to send a long connection disconnection instruction to the process, so that the process disconnects the long connection with the server corresponding to the target application.
As shown in fig. 14, in one embodiment, the second control module 1303 includes:
a prompting submodule 13031, configured to prompt the target application program and the current remaining power to a user, so that the user determines, according to the current remaining power, whether to disconnect a long connection between the process and a server corresponding to the target application program;
the control submodule 13032 is configured to, when receiving the long disconnection instruction, control the target application to send the long disconnection instruction to the process.
In one embodiment, the process comprises: allowing background networked system processes.
According to a third aspect of the embodiments of the present disclosure, there is provided a processing apparatus for an application program in a terminal, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
and receiving response information returned by the server aiming at the communication request through the process, and sending the response information to the application program.
The processor may be further configured to:
the method further comprises the following steps:
after the application program receives the response information, monitoring whether the application program runs in a background or is cleared from a memory;
and when the application program runs in the background or is cleared from the memory and the application program is not exited, waking up the application program according to a preset wake-up period so as to enable the server to keep the long connection with the process.
The processor may be further configured to:
waking up the application program according to a preset wake-up period to enable the server to maintain the long connection with the process, including:
after the application program is awakened according to the preset awakening period, controlling the application program to send a heartbeat packet to the process;
sending, by the process, the heartbeat packet to the server to cause the server to maintain the long connection with the process.
The processor may be further configured to:
the method further comprises the following steps:
after the application program is awakened according to the preset awakening period, judging whether the application program returns to a background or not;
and when the application program returns to the background, closing the application program.
The processor may be further configured to:
the method further comprises the following steps:
determining the total times of returning to the background after the application program is awakened in a preset number of preset awakening periods;
determining whether the ratio of the total number of times to the preset number is greater than or equal to a preset ratio;
when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection closing notification to the process;
sending the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
The processor may be further configured to:
when the application program includes at least two, the method further includes:
judging whether the current residual capacity of the terminal is less than or equal to a preset residual capacity;
when the current residual capacity is less than or equal to the preset residual capacity, acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period;
and controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
The processor may be further configured to:
the controlling the target application program to send a long connection closing instruction to the process includes:
prompting the target application program and the current residual capacity to a user so that the user determines whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and when the long connection disconnection instruction is received, controlling the target application program to send the long connection disconnection instruction to the process.
The processor may be further configured to:
the process comprises the following steps: allowing background networked system processes.
Fig. 15 is a block diagram illustrating a processing apparatus 1500 for an application in a terminal, which is suitable for a terminal device according to an exemplary embodiment. For example, the apparatus 1500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 15, the apparatus 1500 may include one or at least two of the following components: processing components 1502, memory 1504, power components 1506, multimedia components 1508, audio components 1510, input/output (I/O) interfaces 1512, sensor components 1514, and communication components 1516.
The processing component 1502 generally controls overall operation of the device 1500, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 1502 may include one or at least two processors 1520 executing instructions to perform all or a portion of the steps of the methods described above. Further, processing component 1502 may include one or at least two modules that facilitate interaction between processing component 1502 and other components. For example, processing component 1502 may include a multimedia module to facilitate interaction between multimedia component 1508 and processing component 1502.
The memory 1504 is configured to store various types of data to support operation at the device 1500. Examples of such data include instructions for any stored object or method operating on the apparatus 1500, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1504 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 1506 provides power to the various components of the device 1500. The power supply components 1506 may include a power management system, one or at least two power supplies, and other components associated with generating, managing, and distributing power for the apparatus 1500.
The multimedia component 1508 includes a screen that provides an output interface between the device 1500 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or at least two touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, multimedia component 1508 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 1500 is in an operational mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 1510 is configured to output and/or input audio signals. For example, the audio component 1510 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 1500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 1504 or transmitted via the communication component 1516. In some embodiments, audio component 1510 also includes a speaker for outputting audio signals.
The I/O interface 1512 provides an interface between the processing component 1502 and peripheral interface modules, which can be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 1514 includes one or at least two sensors for providing status assessment of various aspects of the apparatus 1500. For example, the sensor assembly 1514 can detect an open/closed state of the device 1500, relative positioning of components, such as a display and keypad of the apparatus 1500, the sensor assembly 1514 can also detect a change in position of the apparatus 1500 or a component of the apparatus 1500, the presence or absence of user contact with the apparatus 1500, orientation or acceleration/deceleration of the apparatus 1500, and a change in temperature of the apparatus 1500. The sensor assembly 1514 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 1516 is configured to facilitate wired or wireless communication between the apparatus 1500 and other devices. The apparatus 1500 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1516 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1516 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 1500 may be implemented by one or at least two Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 1504 comprising instructions, executable by the processor 1520 of the apparatus 1500 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium, wherein instructions of the storage medium, when executed by a processor of the apparatus 1500, enable the apparatus 1500 to perform a processing method of an application program in a terminal, the method comprising:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
and receiving response information returned by the server aiming at the communication request through the process, and sending the response information to the application program.
In one embodiment, the method further comprises:
after the application program receives the response information, monitoring whether the application program runs in a background or is cleared from a memory;
and when the application program runs in the background or is cleared from the memory and the application program is not exited, waking up the application program according to a preset wake-up period so as to enable the server to keep the long connection with the process.
In one embodiment, the waking up the application program according to a preset wake-up cycle to enable the server to maintain the long connection with the process includes:
after the application program is awakened according to the preset awakening period, controlling the application program to send a heartbeat packet to the process;
sending, by the process, the heartbeat packet to the server to cause the server to maintain the long connection with the process.
In one embodiment, the method further comprises:
after the application program is awakened according to the preset awakening period, judging whether the application program returns to a background or not;
and when the application program returns to the background, closing the application program.
In one embodiment, the method further comprises:
determining the total times of returning to the background after the application program is awakened in a preset number of preset awakening periods;
determining whether the ratio of the total number of times to the preset number is greater than or equal to a preset ratio;
when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection closing notification to the process;
sending the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
In one embodiment, when the application program includes at least two, the method further includes:
judging whether the current residual capacity of the terminal is less than or equal to a preset residual capacity;
when the current residual capacity is less than or equal to the preset residual capacity, acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period;
and controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
In one embodiment, the controlling the target application to send a long connection close instruction to the process includes:
prompting the target application program and the current residual capacity to a user so that the user determines whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and when the long connection disconnection instruction is received, controlling the target application program to send the long connection disconnection instruction to the process.
In one embodiment, the process comprises: allowing background networked system processes.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (14)

1. A processing method of an application program in a terminal is characterized by comprising the following steps:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal, wherein the process is a public process and is used for establishing long connection between all application programs in the terminal and a server corresponding to the application programs;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
receiving, by the process, response information returned by the server for the communication request, and sending the response information to the application program, where the process includes: allowing a background networked system process;
the method further comprises the following steps:
determining the total number of times of returning to a background after the application program is awakened in a preset number of preset awakening periods;
determining whether the ratio of the total number of times to a preset number is greater than or equal to a preset ratio;
when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection closing notification to the process;
sending the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
2. The method of claim 1, further comprising:
after the application program receives the response information, monitoring whether the application program runs in a background or is cleared from a memory;
and when the application program runs in the background or is cleared from the memory and the application program is not exited, waking up the application program according to a preset wake-up period so as to enable the server to keep the long connection with the process.
3. The method of claim 2,
waking up the application program according to a preset wake-up period to enable the server to maintain the long connection with the process, including:
after the application program is awakened according to the preset awakening period, controlling the application program to send a heartbeat packet to the process;
sending, by the process, the heartbeat packet to the server to cause the server to maintain the long connection with the process.
4. The method of claim 2, further comprising:
after the application program is awakened according to the preset awakening period, judging whether the application program returns to a background or not;
and when the application program returns to the background, closing the application program.
5. The method according to any one of claims 1 to 4, wherein when the application program includes at least two, the method further comprises:
judging whether the current residual capacity of the terminal is less than or equal to a preset residual capacity;
when the current residual capacity is less than or equal to the preset residual capacity, acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period;
and controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
6. The method of claim 5,
the controlling the target application program to send a long connection closing instruction to the process includes:
prompting the target application program and the current residual capacity to a user so that the user determines whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and when the long connection disconnection instruction is received, controlling the target application program to send the long connection disconnection instruction to the process.
7. An apparatus for processing an application program in a terminal, comprising:
the monitoring module is used for monitoring the communication request of the application program in the terminal;
the calling module is used for calling a process in the terminal, wherein the process is a public process and is used for establishing long connection between all application programs in the terminal and the corresponding servers;
the first processing module is used for sending the communication request to a server corresponding to the application program through the process and establishing long connection between the process and the server;
a second processing module, configured to receive, through the process, response information returned by the server for the communication request, and send the response information to the application program, where the process includes: allowing a background networked system process;
the device further comprises:
the first determining module is used for determining the total times of returning to a background after the application program is awakened in a preset number of preset awakening periods;
the second determining module is used for determining whether the ratio of the total times to the preset number is greater than or equal to the preset ratio;
the first control module is used for controlling the application program to send a long connection closing notification to the process when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods;
a sending module, configured to send the long connection closing notification to the server through the process, so that the server disconnects the long connection with the process.
8. The apparatus of claim 7, further comprising:
the monitoring module is used for monitoring whether the application program runs in the background or is cleared from the memory after the application program receives the response information;
and the awakening module is used for awakening the application program according to a preset awakening period when the application program runs in the background or is cleared from the memory and the application program is not exited, so that the server keeps the long connection with the process.
9. The apparatus of claim 8,
the wake-up module comprises:
the control submodule is used for controlling the application program to send a heartbeat packet to the process after the application program is awakened according to the preset awakening period;
and the sending submodule is used for sending the heartbeat packet to the server through the process so as to enable the server to maintain the long connection with the process.
10. The apparatus of claim 8, further comprising:
the judging module is used for judging whether the application program returns to the background or not after the application program is awakened according to the preset awakening period;
and the third processing module is used for closing the application program when the application program returns to the background.
11. The apparatus of any one of claims 7 to 10, further comprising:
the judging module is used for judging whether the current residual electric quantity of the terminal is less than or equal to the preset residual electric quantity or not when the number of the application programs is at least two;
the acquisition module is used for acquiring a target application program with the shortest foreground running time in at least two application programs in a preset historical time period when the current residual electric quantity is less than or equal to the preset residual electric quantity;
and the second control module is used for controlling the target application program to send a long connection disconnection instruction to the process so as to disconnect the long connection between the process and the server corresponding to the target application program.
12. The apparatus of claim 11,
the second control module includes:
the prompting submodule is used for prompting the target application program and the current residual capacity to a user so that the user can determine whether to disconnect the long connection between the process and the server corresponding to the target application program according to the current residual capacity;
and the control submodule is used for controlling the target application program to send the long connection disconnection instruction to the process when the long connection disconnection instruction is received.
13. An apparatus for processing an application program in a terminal, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
monitoring a communication request of an application program in the terminal;
calling a process in the terminal, wherein the process is a public process and is used for establishing long connection between all application programs in the terminal and a server corresponding to the application programs;
sending the communication request to a server corresponding to the application program through the process, and establishing long connection between the process and the server;
receiving, by the process, response information returned by the server for the communication request, and sending the response information to the application program, where the process includes: allowing a background networked system process;
the processor is further configured to:
determining the total number of times of returning to a background after the application program is awakened in a preset number of preset awakening periods;
determining whether the ratio of the total number of times to the preset number is greater than or equal to a preset ratio;
when the proportion is larger than or equal to the preset proportion and the application program returns to the background again after being awakened for the last time in the preset number of preset awakening periods, controlling the application program to send a long connection closing notification to the process;
sending the long connection close notification to the server through the process, so that the server disconnects the long connection with the process.
14. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN201610195147.XA 2016-03-30 2016-03-30 Method and device for processing application program in terminal Active CN105893129B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610195147.XA CN105893129B (en) 2016-03-30 2016-03-30 Method and device for processing application program in terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610195147.XA CN105893129B (en) 2016-03-30 2016-03-30 Method and device for processing application program in terminal

Publications (2)

Publication Number Publication Date
CN105893129A CN105893129A (en) 2016-08-24
CN105893129B true CN105893129B (en) 2020-01-07

Family

ID=57014422

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610195147.XA Active CN105893129B (en) 2016-03-30 2016-03-30 Method and device for processing application program in terminal

Country Status (1)

Country Link
CN (1) CN105893129B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106941713A (en) * 2017-05-16 2017-07-11 努比亚技术有限公司 It is a kind of to reduce the method and its device of mobile terminal power consumption
CN107704274B (en) * 2017-08-24 2019-11-05 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system waken up for Android application host process
CN109526043B (en) * 2017-09-19 2024-07-19 北京搜狗科技发展有限公司 Application program setting method and device
CN108430116B (en) * 2018-03-02 2020-08-07 杭州朗和科技有限公司 Disconnected network reconnection method, medium, device and computing equipment
CN110266749A (en) * 2019-04-25 2019-09-20 郑州时空隧道信息技术有限公司 Order information method for pushing, device and terminal
CN110225106B (en) * 2019-06-04 2022-06-10 惠州Tcl移动通信有限公司 Data transmission method, device and storage medium
CN110362395B (en) * 2019-07-22 2022-02-08 Oppo广东移动通信有限公司 Background program management method and device, computer equipment and storage medium
CN110753086A (en) * 2019-09-12 2020-02-04 华为技术有限公司 Heartbeat awakening method for application and terminal equipment
CN112491810B (en) * 2020-11-09 2021-09-21 珠海格力电器股份有限公司 Data connection method and mobile terminal
CN112612526B (en) * 2020-12-24 2024-04-19 深圳市九洲电器有限公司 Application program control method, device, terminal equipment and storage medium
CN115705241B (en) * 2021-08-10 2023-12-15 荣耀终端有限公司 Application scheduling method and electronic equipment
CN114125023B (en) * 2021-11-12 2024-03-22 青岛海尔科技有限公司 Method and device for determining data connection, storage medium and electronic device
CN115866729B (en) * 2022-11-23 2024-06-11 东土科技(宜昌)有限公司 Control method and device for positioning beacon in indoor positioning system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9444872B2 (en) * 2012-12-14 2016-09-13 Tencent Technology (Shenzhen) Company Limited Method, server and system for data sharing
CN104303488A (en) * 2013-05-10 2015-01-21 华为技术有限公司 User plane event processing method, PCRF entity, and AF entity
CN103618738B (en) * 2013-12-09 2017-05-03 惠州华阳通用电子有限公司 Intelligent load distribution system and method for achieving TCP long connection and communication
CN104010001B (en) * 2014-06-17 2015-11-11 合一网络技术(北京)有限公司 In mobile terminal, the method and system connecting communication is carried out in similar networking request
CN104331353A (en) * 2014-10-17 2015-02-04 云南远信数通科技有限公司 Method for guaranteeing software high availability

Also Published As

Publication number Publication date
CN105893129A (en) 2016-08-24

Similar Documents

Publication Publication Date Title
CN105893129B (en) Method and device for processing application program in terminal
US10808940B2 (en) Cooking equipment running method and device
CN106375604B (en) The method and apparatus of controlling terminal electricity
CN106162768B (en) Wireless access point switching method and device
CN109565753B (en) Method and device for controlling beam failure recovery process
CN105979088B (en) Message pushing method and device
CN106792937B (en) Method and device for processing call request
EP3301857B1 (en) Prompting method, prompting device and prompting system
CN106357721B (en) Timing method and device
CN108781133B (en) Downlink control signaling detection method, device and storage medium
CN110730954A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN105912204B (en) Method and device for starting application interface
CN106231137A (en) Processing method and processing device based on electricity
CN111857763B (en) Data processing method, device, electronic equipment and storage medium
US20220046519A1 (en) System message transmission method and device, and system message reception method and device
CN109062625B (en) Application program loading method and device and readable storage medium
CN108347718B (en) Method, device and storage medium for monitoring communication packet
CN105227426B (en) Application interface switching method and device and terminal equipment
CN106507505B (en) Disconnection method and device for low-power-consumption Bluetooth connection
CN107371222B (en) Virtual card disabling method and device
CN111669818B (en) Wi-Fi control method and device and electronic equipment
CN104410900A (en) A method and apparatus for controlling an indicator light installed on an intelligent apparatus
CN111240456A (en) Power saving setting method, power saving setting device and computer storage medium
CN114286425A (en) Long connection establishing system, method and device, electronic equipment and storage medium
CN106060104B (en) Application management method and device

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