Device connection status recovery method, device, equipment and storage medium
By creating user interface automation operation objects and executing preset recovery scripts when the device connection status changes, the problem of device connection status being unable to be restored in time is solved, automated recovery is achieved, and the reliability of device operation is improved.
Patent Information
- Application Number
- CN202010714232.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-22
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-07-22
AI Technical Summary
In the existing technology, when the connection status of the device changes, it cannot be restored in time, causing the device to be unable to operate for a long time, which has a great impact.
By detecting changes in the connection status, it creates a user interface automation operation object, obtains the current page form information, and executes the interface operation sequence according to the preset recovery script to restore the connection status.
It achieves timely response and automatic recovery of equipment connection status, avoids dependence on manual maintenance, and improves the reliability of equipment operation.
Smart Images

Figure CN113971059B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of equipment maintenance, and in particular to a method, device, equipment and storage medium for restoring equipment connection status. Background Art
[0002] For devices to communicate or transmit data, they need to establish a connection first. In addition, debugging or charging the device also depends on a specific connection status. Currently, the connection status between devices needs to be maintained manually. When maintenance personnel find that the connection between devices is disconnected, they need to manually restore it. In most cases, it is impossible to set up too much manpower to monitor the equipment in real time. Therefore, after the device connection is disconnected or the connection mode changes, it cannot be discovered and restored in time, resulting in the device being unable to operate for a long time, causing many adverse effects.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a device connection status recovery method, apparatus, device and storage medium, aiming to solve the technical problem in the prior art that the device connection status cannot be restored in time when the device connection status changes.
[0005] To achieve the above object, the present invention provides a method for restoring a device connection state, the method comprising the following steps:
[0006] When a connection status change is detected, a UI automation operation object is created;
[0007] Obtaining the current page form information through the user interface automation operation object;
[0008] Obtaining a preset recovery script, and determining a corresponding interface operation sequence according to the preset recovery script;
[0009] Based on the current page form information, the auxiliary function object is called to execute the interface operation sequence, so that the connection state is restored to the target connection state.
[0010] Optionally, the step of creating a user interface automation operation object when a connection state change is detected specifically includes:
[0011] When a connection state change is detected, the thread operation object and the user interface automation operation object are initialized;
[0012] The UI automation operation object is created by calling the UI automation operation object constructor through a preset reflection path.
[0013] Optionally, the step of obtaining the current page form information through the user interface automation operation object specifically includes:
[0014] Calling the connection function of the user interface automation operation object through the preset reflection path to connect with the preset application program interface;
[0015] The auxiliary window object is called through the preset application program interface to obtain the current page window information.
[0016] Optionally, after the step of calling the auxiliary function object based on the current page form information to execute the interface operation sequence so as to restore the connection state to the target connection state, the step further includes:
[0017] When it is detected that the connection state is restored to the target connection state, calling the disconnection function of the user interface automation operation object through the preset reflection path to disconnect from the preset application program interface;
[0018] The resource release function of the thread operation object is called to release the user interface automation operation object.
[0019] Optionally, the step of calling the auxiliary function object based on the current page form information to execute the interface operation sequence so as to restore the connection state to the target connection state specifically includes:
[0020] Determine the control to be operated according to the interface operation sequence;
[0021] Determine a corresponding target control in the current page form information according to the control to be operated;
[0022] The auxiliary function object is called according to the interface operation sequence to operate the target control so as to restore the connection state to the target connection state.
[0023] Optionally, the step of calling the auxiliary function object to operate the target control according to the interface operation sequence to restore the connection state to the target connection state specifically includes:
[0024] Calling the auxiliary function object to operate the target control according to the interface operation sequence, so as to operate the user interface to modify the connection state;
[0025] Determine whether the interface operation sequence is completed;
[0026] When the interface operation sequence is not completed, obtaining the unexecuted controls corresponding to the uncompleted sequence;
[0027] Calling the auxiliary window object through the preset application program interface to obtain the intermediate page window information;
[0028] Determine the corresponding target control in the intermediate page form information based on the unexecuted control, and return to the step of calling the auxiliary function object to operate the target control according to the interface operation sequence until the interface operation sequence is completed, so that the connection state is restored to the target connection state.
[0029] Optionally, before the step of creating a user interface automation operation object when a connection state change is detected, the step further includes:
[0030] When a connection is detected with an external device, obtaining connection port information;
[0031] Determine a current connection state according to the connection port information, and record a first maintenance time of the current connection state;
[0032] Determining whether the first maintenance time is greater than a first preset threshold;
[0033] When the first maintaining time is greater than the first preset threshold, the current connection state is determined as a target connection state.
[0034] Optionally, the step of creating a user interface automation operation object when a connection state change is detected specifically includes:
[0035] When a connection status change is detected, the connection status before the change is obtained;
[0036] Determining whether the connection state before the change is the same as the target connection state;
[0037] When the connection state before the change is the same as the target connection state, a user interface automation operation object is created.
[0038] Optionally, when the connection state before the change is the same as the target connection state, the step of creating a user interface automation operation object specifically includes:
[0039] Acquire the connection state after the change, and record the second maintenance time of the connection state after the change;
[0040] When the connection state before the change is the same as the target connection state, determining whether the second maintenance time is greater than a second preset threshold;
[0041] When the second maintenance time is greater than the second preset threshold, a user interface automation operation object is created.
[0042] Optionally, the step of obtaining a preset recovery script and determining a corresponding interface operation sequence according to the preset recovery script specifically includes:
[0043] Get target connection status information;
[0044] Searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information, wherein the mapping relationship includes a corresponding relationship between the connection state and the recovery script;
[0045] The preset recovery script is parsed to obtain an interface operation sequence.
[0046] Optionally, after the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state, the method further includes:
[0047] When the corresponding preset recovery script is not found, the historical connection status record information is obtained;
[0048] Acquire reference connection state information from the historical connection state record information according to a preset reference condition, and use the reference connection state information as target connection state information;
[0049] Return to the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information.
[0050] Optionally, after the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state, the method further includes:
[0051] When the corresponding preset recovery script is not found, the target connection status information is displayed through a preset window;
[0052] When receiving a file input based on the preset window, obtaining file information of the file;
[0053] Determining whether the file information meets a preset condition;
[0054] When the file information meets the preset condition, the file is used as a preset recovery script.
[0055] In addition, to achieve the above-mentioned purpose, the present invention further proposes a device connection status recovery device, the device connection status recovery device comprising:
[0056] An object creation model for creating a user interface automation operation object when a connection state change is detected;
[0057] A form information acquisition model, used to acquire the form information of the current page through the user interface automation operation object;
[0058] A sequence generation module, used to obtain a preset recovery script and determine a corresponding interface operation sequence according to the preset recovery script;
[0059] The execution model is used to call the auxiliary function object based on the current page form information to execute the interface operation sequence so as to restore the connection state to the target connection state.
[0060] Optionally, the object creation model is further used to initialize the thread operation object and the user interface automation operation object when a change in the connection state is detected;
[0061] The object creation model is also used to call the user interface automation operation object constructor through a preset reflection path to create a user interface automation operation object.
[0062] Optionally, the form information acquisition model is further used to call the connection function of the user interface automation operation object through the preset reflection path to connect with the preset application program interface;
[0063] The form information acquisition model is also used to acquire the current page form information by calling the auxiliary form object through the preset application program interface.
[0064] Optionally, the execution model is further used to determine the control to be operated according to the interface operation sequence;
[0065] The execution model is further used to determine the corresponding target control in the current page form information according to the control to be operated;
[0066] The execution model is further used to call the auxiliary function object to operate the target control according to the interface operation sequence, so as to restore the connection state to the target connection state.
[0067] Optionally, the device connection status recovery apparatus further includes a connection status judgment module;
[0068] The connection status judgment module is used to obtain the connection port information when detecting that a connection is established with an external device;
[0069] The connection status judgment module is further used to determine the current connection status according to the connection port information, and record the first maintenance time of the current connection status;
[0070] The connection status judgment module is further used to judge whether the first maintenance time is greater than a first preset threshold;
[0071] The connection state determination module is further configured to determine the current connection state as a target connection state when the first maintenance time is greater than the first preset threshold.
[0072] Optionally, the sequence generation module is further used to obtain target connection status information;
[0073] The sequence generation module is further used to search for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information, wherein the mapping relationship includes a corresponding relationship between the connection state and the recovery script;
[0074] The sequence generation module is further used to parse the preset recovery script to obtain an interface operation sequence.
[0075] In addition, to achieve the above-mentioned purpose, the present invention also proposes a device connection status recovery device, which includes: a memory, a processor, and a device connection status recovery program stored in the memory and executable on the processor, and when the device connection status recovery program is executed by the processor, the steps of the device connection status recovery method described above are implemented.
[0076] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a device connection status recovery program is stored, and when the device connection status recovery program is executed by a processor, the steps of the device connection status recovery method described above are implemented.
[0077] In the present invention, when a connection state change is detected, a user interface automation operation object is created; the current page form information is obtained through the user interface automation operation object; a preset recovery script is obtained, and a corresponding interface operation sequence is determined according to the preset recovery script; based on the current page form information, an auxiliary function object is called to execute the interface operation sequence, so that the connection state is restored to the target connection state. The present invention can respond to changes in the device connection state in a timely manner, and obtain the current page form information through the created user interface automation operation object; at the same time, a preset recovery script is obtained, and the preset operation sequence in the script is executed to realize the automated operation of the page, thereby restoring the device connection state in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 It is a structural diagram of a device connection status recovery device in a hardware operating environment involved in an embodiment of the present invention;
[0079] Figure 2 A schematic diagram of a flow chart of a first embodiment of a method for restoring a device connection state according to the present invention;
[0080] Figure 3 A schematic diagram of a flow chart of a second embodiment of a method for restoring a device connection state according to the present invention;
[0081] Figure 4 A schematic diagram of a flow chart of a third embodiment of a method for restoring a device connection state according to the present invention;
[0082] Figure 5A schematic diagram of a flow chart of a fourth embodiment of a method for restoring a device connection state according to the present invention;
[0083] Figure 6 A schematic diagram of a flow chart of a fifth embodiment of a method for restoring a device connection state according to the present invention;
[0084] Figure 7 This is a structural block diagram of the first embodiment of the device connection status recovery apparatus of the present invention.
[0085] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0086] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0087] Reference Figure 1 , Figure 1 The present invention is a schematic diagram of a device connection status recovery device structure in a hardware operating environment according to an embodiment of the present invention.
[0088] like Figure 1 As shown, the device connection status recovery device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection communication between these components. The user interface 1003 may include a display screen (Display), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable memory (Non-volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0089] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the device connection status recovery device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0090] like Figure 1As shown, the memory 1005 identified as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device connection status recovery program.
[0091] exist Figure 1 In the device connection status recovery device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the user device; the device connection status recovery device calls the device connection status recovery program stored in the memory 1005 through the processor 1001, and executes the device connection status recovery method provided by the embodiment of the present invention.
[0092] Based on the above hardware structure, an embodiment of a method for restoring a device connection status of the present invention is proposed.
[0093] Reference Figure 2 , Figure 2 The figure is a flow chart of the first embodiment of the method for restoring the connection status of a device of the present invention, and provides the first embodiment of the method for restoring the connection status of a device of the present invention.
[0094] In a first embodiment, the device connection status recovery method comprises the following steps:
[0095] Step S10: When a connection status change is detected, a user interface automation operation object is created.
[0096] It should be understood that the executor of this embodiment is a device connection status recovery device, which has functions such as data communication and program running. The device connection status recovery device can be a computer device such as a mobile phone, tablet, computer or server. Of course, it can also be other devices with similar functions, and this embodiment does not limit this.
[0097] It should be noted that the connection state refers to the connection mode between devices, taking the connection between a mobile phone and a computer as an example. The mobile phone is connected to the computer via a USB cable. At this time, the connection states that can be selected include charging mode, data transmission mode or debugging mode, etc. When the user needs to execute the corresponding function after the mobile phone is connected to the computer, the corresponding mode needs to be set. For example, when the user needs to debug the mobile phone through the computer, the connection state needs to be set to debugging mode; at this time, if the connection mode between the mobile phone and the computer becomes charging mode, it is determined that the connection state has changed. Of course, the connection state can also have other modes, or even other types of devices can be connected, which is not limited in this embodiment.
[0098] Taking a mobile phone as an example, this embodiment can be run in the background of the mobile phone in the form of a Java process. When it is detected that the mobile phone is connected to the computer, the process is automatically called up to poll the connection status in real time. When the connection status is detected to have changed, a user interface automation operation object is created. Among them, the user interface automation operation object refers to the UiAutomation object, and the UiAutomation object is used for explanation below.
[0099] Step S20: obtaining the current page form information through the user interface automation operation object.
[0100] It should be noted that the current page form information refers to the display information of the current device UI interface, including the page width, the controls contained in the page, and the position information of the controls in the page.
[0101] It should be noted that the UiAutomation object can register auxiliary functions to realize the automated operation of the device. The auxiliary functions can provide operations such as obtaining, operating, and sensing changes in the device display page. In this example, the method in the UiAutomation object is called through the reflection mechanism to call the page form information acquisition function and obtain the form information of the current device display page.
[0102] Step S30: Obtain a preset recovery script, and determine a corresponding interface operation sequence according to the preset recovery script.
[0103] It should be noted that the interface operation sequence refers to the operation process in the user page, such as clicking an application icon, sliding a page, clicking an option, etc. The interface operation sequence includes the location information of the application icon, the location information of the option control, the page sliding distance, etc. The above information is written into the script in the form of code to form a preset recovery script.
[0104] It should be noted that a script library is pre-set in this embodiment, and the maintenance personnel can store the prepared scripts in the script library so that the device connection status recovery device can obtain the corresponding recovery script from the script library.
[0105] Step S40: Based on the current page form information, the auxiliary function object is called to execute the interface operation sequence to restore the connection state to the target connection state.
[0106] It should be noted that the corresponding operation flow in the interface operation sequence can be implemented through auxiliary functions. Therefore, the auxiliary functions are called through the UiAutomation object to implement the corresponding page operations in sequence according to the operation flow in the interface operation sequence, thereby realizing the recovery of the connection status.
[0107] For example, the connection between the mobile phone and the computer is in debug mode, but the USB cable between the mobile phone and the computer may have a poor contact problem, resulting in a disconnection. Although the connection is restored, the connection state is in charging mode. In order to use the corresponding functions normally, the connection state needs to be restored to debug mode. At this time, get the debug mode recovery script, in which the preset operation process is to return to the main page, click the settings icon, slide the page, click the connection option, and click the debug option. The UiAutomation object is used to call the auxiliary function to implement the click function and the slide function in turn. At the same time, when clicking and sliding, the location information and sliding distance of the setting icon, connection option, and debug option are determined according to the current page form information.
[0108] In the first embodiment, when a connection state change is detected, a user interface automation operation object is created; the current page form information is obtained through the user interface automation operation object; a preset recovery script is obtained, and a corresponding interface operation sequence is determined according to the preset recovery script; based on the current page form information, an auxiliary function object is called to execute the interface operation sequence, so that the connection state is restored to the target connection state. This embodiment can respond to changes in the device connection state in a timely manner, and obtain the current page form information through the created user interface automation operation object; at the same time, a preset recovery script is obtained, and the operation sequence preset in the script is executed to realize the automated operation of the page, thereby restoring the device connection state in a timely manner.
[0109] Reference Figure 3 , Figure 3 This is a flow chart of a second embodiment of the device connection status recovery method of the present invention. Figure 2 The first embodiment shown provides a second embodiment of the device connection status recovery method of the present invention.
[0110] In the second embodiment, the step S10 specifically includes:
[0111] Step S101: when a connection state change is detected, the thread operation object and the user interface automation operation object are initialized.
[0112] It should be noted that the thread operation object is a HandlerThread object. This embodiment runs in the background of the mobile phone as a Java process. When it is detected that the mobile phone is connected to the computer, the process is called up by initializing the HandlerThread object. At the same time, the UiAutomation object is initialized, specifically the UiAutomationConnection object is initialized. The specific initialization process is common knowledge in this field and will not be repeated here.
[0113] Step S102: calling the user interface automation operation object constructor through a preset reflection path to create a user interface automation operation object.
[0114] Since the Java process is already running, the UiAutomation object cannot be called directly, so a reflection mechanism needs to be established to call the UiAutomation construction method according to the reflection path to create a UiAutomation object. This allows cross-process execution.
[0115] In the second embodiment, the step S20 specifically includes:
[0116] Step S201: calling a connection function of a user interface automation operation object through the preset reflection path to connect with a preset application program interface.
[0117] It should be noted that the preset application program interface refers to the program interface of the UiAutomation API library. Similarly, the UiAutomation#connect method is called through reflection to connect to the UiAutomation API library, thereby establishing a foundation for subsequent calls to the UiAutomation API.
[0118] Step S202: calling the auxiliary window object through the preset application program interface to obtain the current page window information.
[0119] It should be noted that various auxiliary function objects can be called through the UiAutomation API library to implement corresponding automated operations, such as interface click operations, page sliding operations, or form information acquisition operations. This embodiment obtains the form information of the current user page through the auxiliary form object in the UiAutomation API.
[0120] In the second embodiment, after step S40, the method further includes:
[0121] S50: When it is detected that the connection state is restored to the target connection state, the disconnection function of the user interface automation operation object is called through the preset reflection path to disconnect from the preset application program interface.
[0122] It should be noted that when the Java process is running the automated operation service, it is not allowed to run other registered services. Therefore, the automated operation service needs to be released in time so that the system allows the execution of automated test cases.
[0123] In the specific implementation, when the connection state is restored, the disconnect function of the UiAutomation object is called through reflection to disconnect and unregister the automation operation service.
[0124] S60: Calling a resource release function of the thread operation object to release the user interface automation operation object.
[0125] It should be noted that after the automatic operation service is deregistered, the Java process has completed the corresponding function and can be released at the same time to save resources, and will be reawakened when the connection state changes next time. Specifically, the quite method (i.e., resource release function) of the HandlerThread object is called to release the Java process resources.
[0126] In the second embodiment, the auxiliary function is executed across processes through the UiAutomation object, and the UiAutomation API library is connected through UiAutomation, and the auxiliary function is registered to obtain the page form information. In addition, the registration and deregistration functions of the automated operation function are implemented through the reflection system interface inside the Java process, and resources are released to allow the system to execute automated test cases to avoid resource occupation.
[0127] Reference Figure 4 , Figure 4 This is a flow chart of the third embodiment of the device connection status recovery method of the present invention. Based on the first and second embodiments, the third embodiment of the device connection status recovery method of the present invention is proposed. This embodiment is described based on the first embodiment.
[0128] In the third embodiment, the step S40 specifically includes:
[0129] Step S401: determining a control to be operated according to the interface operation sequence.
[0130] It should be noted that the interface operation sequence refers to the operation process in the user page, such as clicking an application icon, sliding a page, clicking an option, etc. The interface operation sequence includes the location information of the application icon, the location information of the option control, the page sliding distance, etc.
[0131] Taking the restoration of debugging mode as an example, the interface operation sequence includes returning to the main page, clicking the settings icon, sliding the page, clicking the connection option, and clicking the debugging option. To ensure the accuracy of subsequent operations, the controls to be operated are first determined. Specifically, the controls to be operated include the main interface button, the settings icon button, the connection option, and the debugging option.
[0132] Step S402: determining a corresponding target control in the current page form information according to the control to be operated.
[0133] It should be noted that in order to ensure that the corresponding controls to be operated can be accurately operated, it is necessary to locate the controls to be operated according to the current page form information. Specifically, the control information in the current page form information can be matched with the controls to be operated to determine the operable target controls in the current page form information.
[0134] Step S403: calling the auxiliary function object to operate the target control according to the interface operation sequence, so as to restore the connection state to the target connection state.
[0135] Since different controls are located on different pages, the corresponding controls may not exist in the current page form information. For example, there is a setting icon in the main page, but there is no connection option and debugging option. Therefore, step S403 may specifically include: calling the auxiliary function object to operate the target control according to the interface operation sequence to operate the user interface to modify the connection status; judging whether the interface operation sequence has been completed; when the interface operation sequence has not been completed, obtaining the unexecuted control corresponding to the uncompleted sequence; calling the auxiliary form object through the preset application interface to obtain the intermediate page form information; determining the corresponding target control in the intermediate page form information according to the unexecuted control, and returning to the step of calling the auxiliary function object to operate the target control according to the interface operation sequence until the interface operation sequence is completed, so that the connection state is restored to the target connection state.
[0136] In the specific implementation, firstly, the operation is performed according to the control existing in the current page form information, such as clicking the setting image in the main interface. At this time, since the connection option does not exist in the main page, the operation sequence is terminated. However, since the page has changed, the connection option can be relocated by re-obtaining the page form information, and then the connection option can be clicked. In this way, the execution of the interface operation sequence is completed, and the user interface is operated to restore the connection state to the target connection state.
[0137] In the third embodiment, the accuracy of the operation is ensured by locating the controls to be operated in the interface operation sequence in the page form information. At the same time, when the user page changes, the page form information is re-acquired to locate the controls that are not executed in the interface operation sequence, so as to completely execute the interface operation sequence and restore the connection state to the target connection state.
[0138] Reference Figure 5 , Figure 5 This is a flow chart of a fourth embodiment of a method for restoring a device connection state of the present invention. Based on the first and second embodiments, the fourth embodiment of a method for restoring a device connection state of the present invention is proposed. This embodiment is described based on the first embodiment.
[0139] In the fourth embodiment, before step S10, the method further includes:
[0140] Step S001: when it is detected that a connection is established with an external device, connection port information is obtained.
[0141] It should be noted that, in order to monitor the device connection status in real time, this embodiment starts monitoring when it detects that a connection is established with an external device. The external device may include a mobile phone, a computer or a tablet.
[0142] It should be noted that the connection establishment method includes USB connection or wireless network connection. When a USB port is detected to be plugged in, it is determined to establish a connection with the external device; or when a WiFi port is detected to be connected, it is determined to establish a connection with the external device. At the same time, the corresponding connection port information is obtained for real-time monitoring, and the connection port information includes the port status.
[0143] Step S002: determining a current connection state according to the connection port information, and recording a first maintenance time of the current connection state.
[0144] It should be noted that the connection status of the current port can be determined by monitoring the status. Usually, when the device establishes a preliminary connection, it will be set to a default connection mode, such as a charging mode. The operator needs to switch the status, and in some cases, multiple switches are required due to misoperation. Therefore, in the early stage of establishing a connection, in order to ensure that Java is not mistakenly started, corresponding restrictions need to be set. This embodiment uses the state maintenance time as a restriction.
[0145] Step S003: determining whether the first maintaining time is greater than a first preset threshold.
[0146] It should be noted that, usually, the operator will immediately switch the unnecessary connection state and maintain the necessary connection state. Therefore, the connection state required by the operator can be determined by maintenance. For example, the first preset threshold is 1 minute or 2 minutes, and of course it can be other values, which is not limited in this embodiment.
[0147] Step S004: when the first maintenance time is greater than the first preset threshold, determining the current connection state as a target connection state.
[0148] It is understandable that when the connection state is maintained for a time longer than the preset threshold, it means that the corresponding connection state is the connection state required by the operator, and the connection state is set as the target connection state, and when the target connection state changes, the automatic operation service is registered to achieve connection state recovery. If the connection state is maintained for a time longer than the preset threshold, it means that the corresponding connection state is not the connection state required by the operator, and the process returns to step S002 to continue detection.
[0149] In the fourth embodiment, the step S10 specifically includes: when a change in the connection status is detected, obtaining the connection status before the change; determining whether the connection status before the change is the same as the target connection status; and when the connection status before the change is the same as the target connection status, creating a user interface automation operation object.
[0150] It should be noted that when the operator makes an error operation, in order to further prevent the process from being started by mistake, it is necessary to determine whether the state before the change is the target connection state. If not, it will not be started. For example, the operator connects the device, and the default connection state is charging mode. The operator needs to switch it to debugging mode, but due to an error operation, it is first switched to transmission mode and then to debugging mode. At this time, the connection state has changed, but since neither the charging mode nor the transmission mode is the target connection state, it will not be started.
[0151] In addition, in actual operation, when the connection state changes due to an erroneous operation, the operator discovers the situation and manually restores the connection state. Therefore, in order to avoid conflicts between process operations and manual operations, the step of creating a user interface automation operation object when the connection state before the change is the same as the target connection state specifically includes: obtaining the connection state after the change and recording the second maintenance time of the connection state after the change; when the connection state before the change is the same as the target connection state, determining whether the second maintenance time is greater than a second preset threshold; and creating a user interface automation operation object when the second maintenance time is greater than the second preset threshold.
[0152] It should be noted that the time that an operator can discover a situation is often short, so conflicts can also be avoided by setting time conditions. For example, if the second maintenance time is set to 30 seconds, if the connection state is not restored after 30 seconds, it means that the operator has not discovered the situation, and an automated operation is required to restore the connection state.
[0153] In the fourth embodiment, the target connection state can be determined by monitoring the maintenance time of the connection state; and when the connection state changes, it can be determined whether it is necessary to create a user interface automation operation object to perform automation operations to restore the connection state, thereby avoiding false startup.
[0154] Reference Figure 6 , Figure 6 This is a flow chart of the fifth embodiment of the device connection status recovery method of the present invention. Based on the first and second embodiments, the fifth embodiment of the device connection status recovery method of the present invention is proposed. This embodiment is described based on the first embodiment.
[0155] In the fifth embodiment, the step S30 specifically includes:
[0156] Step S301: Obtain target connection status information.
[0157] It is understandable that when restoring the connection state, it is necessary to determine the corresponding target connection state information. Usually, the connection state information before the change is used as the target connection state information. The target connection state information can be specifically a state category, such as a debugging mode or a transmission mode.
[0158] Step S302: searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information, wherein the mapping relationship includes a corresponding relationship between a connection state and a recovery script.
[0159] It should be noted that this embodiment is pre-set with a script library, and the maintenance personnel can store the prepared scripts in the script library so that the device connection status recovery device can obtain the corresponding recovery script from the script library. At the same time, a corresponding relationship between the recovery script and the connection status is established, for example, the debugging mode corresponds to script A, and the transmission mode corresponds to script B. When the target connection state is the debugging mode, script A is obtained.
[0160] Step S303: Parse the preset recovery script to obtain an interface operation sequence.
[0161] It should be noted that the interface operation sequence refers to the operation process in the user page, such as clicking an application icon, sliding a page, clicking an option, etc. The interface operation sequence includes the location information of the application icon, the location information of the option control, the page sliding distance, etc. The above information is written into the script in the form of code, and the interface operation sequence can be obtained by parsing the recovery script.
[0162] It should be noted that in order to further ensure that the recovery script corresponding to the target connection state can be found, after the step of searching for the corresponding preset recovery script in the preset mapping relationship according to the target connection state, it also includes: when the corresponding preset recovery script is not found, obtaining historical connection state record information; obtaining reference connection state information from the historical connection state record information according to preset reference conditions, and using the reference connection state information as the target connection state information; returning to the step of searching for the corresponding preset recovery script in the preset mapping relationship according to the target connection state information.
[0163] It should be noted that the historical connection state record information refers to the target connection state that has been recorded. Since the operator will operate the device in multiple connection states in sequence, the connection mode determined to be the target connection state is recorded in this embodiment to obtain the historical connection state record information. The preset reference condition can be a correlation threshold between the connection mode corresponding to the historical connection state record information and the current target connection state information. The correlation can be determined according to the functions that can be realized by the connection mode. The more the same functions that can be realized, the higher the correlation. When the correlation is greater than the preset threshold, it is determined that the reference condition is met.
[0164] It should be noted that since the operator may not have stored the corresponding script for the corresponding connection mode, it is impossible to find the corresponding recovery script based on the mapping relationship. At this time, the recovery script corresponding to the connection state with relevant functions can be found based on the historical connection state record information. For example, the target connection state is the data transmission mode, but the corresponding script cannot be found based on the mapping relationship. However, the historical connection state record information includes the debug mode. Since the debug mode has a specific data transmission function, the debug mode can be used as the target connection state.
[0165] In this embodiment, in order to ensure the accuracy of connection status recovery, the target connection status information can also be displayed through a preset window when the corresponding preset recovery script is not found; when a file input based on the preset window is received, the file information of the file is obtained; it is determined whether the file information meets the preset conditions; when the file information meets the preset conditions, the file is used as the preset recovery script.
[0166] It should be noted that the window is used to prompt the user, for example, "xx mode recovery script is missing" can be displayed in the window. At the same time, the window also includes an input window for the user to input files. The user can enter the file path in the input window, and the window obtains the corresponding file according to the file path. The file information includes file format, size and other information. Among them, the file format can be determined by identifying the file suffix. In this embodiment, the script is similar to a shell script, so the preset condition can be that the file format is a shell file.
[0167] In the fifth embodiment, by searching for the corresponding preset recovery script through the mapping relationship, the corresponding script can be quickly obtained, thereby improving the connection state recovery efficiency. At the same time, when the corresponding preset recovery script is not found, the recovery script corresponding to the reference connection state is selected for recovery, thereby ensuring that the restored connection mode has the same function. Alternatively, by providing a window to prompt the user and waiting for the user to enter the recovery script, the stable operation of the connection state recovery process is ensured.
[0168] In addition, an embodiment of the present invention further provides a storage medium, on which a device connection state recovery program is stored. When the device connection state recovery program is executed by a processor, the steps of the device connection state recovery method described above are implemented.
[0169] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0170] In addition, refer to Figure 7 The embodiment of the present invention further provides a device for restoring the connection status of a device, the device for restoring the connection status of a device comprising:
[0171] The object creation model 10 is used to create a user interface automation operation object when a connection state change is detected.
[0172] It should be noted that the connection state refers to the connection mode between devices, taking the connection between a mobile phone and a computer as an example. The mobile phone is connected to the computer via a USB cable. At this time, the connection states that can be selected include charging mode, data transmission mode or debugging mode, etc. When the user needs to execute the corresponding function after the mobile phone is connected to the computer, the corresponding mode needs to be set. For example, when the user needs to debug the mobile phone through the computer, the connection state needs to be set to debugging mode; at this time, if the connection mode between the mobile phone and the computer becomes charging mode, it is determined that the connection state has changed. Of course, the connection state can also have other modes, or even other types of devices can be connected, which is not limited in this embodiment.
[0173] The form information acquisition model 20 is used to acquire the form information of the current page through the user interface automation operation object.
[0174] It should be noted that the current page form information refers to the display information of the current device UI interface, including the page width, the controls contained in the page, and the position information of the controls in the page.
[0175] It should be noted that the UiAutomation object can register auxiliary functions to realize the automated operation of the device. The auxiliary functions can provide operations such as obtaining, operating, and sensing changes in the device display page. In this example, the method in the UiAutomation object is called through the reflection mechanism to call the page form information acquisition function and obtain the form information of the current device display page.
[0176] The sequence generation module 30 is used to obtain a preset recovery script and determine a corresponding interface operation sequence according to the preset recovery script.
[0177] It should be noted that the interface operation sequence refers to the operation process in the user page, such as clicking an application icon, sliding a page, clicking an option, etc. The interface operation sequence includes the location information of the application icon, the location information of the option control, the page sliding distance, etc. The above information is written into the script in the form of code to form a preset recovery script.
[0178] It should be noted that a script library is pre-set in this embodiment, and the maintenance personnel can store the prepared scripts in the script library so that the execution model 30 can obtain the corresponding recovery script from the script library.
[0179] The execution model 40 is used to call the auxiliary function object to execute the interface operation sequence based on the current page form information, so as to restore the connection state to the target connection state.
[0180] It should be noted that the corresponding operation flow in the interface operation sequence can be implemented through auxiliary functions. Therefore, the auxiliary functions are called through the UiAutomation object to implement the corresponding page operations in sequence according to the operation flow in the interface operation sequence, thereby realizing the recovery of the connection status.
[0181] For example, the connection between the mobile phone and the computer is in debug mode, but the USB cable between the mobile phone and the computer may have a poor contact problem, resulting in a disconnection. Although the connection is restored, the connection state is in charging mode. In order to use the corresponding functions normally, the connection state needs to be restored to debug mode. At this time, get the debug mode recovery script, in which the preset operation process is to return to the main page, click the settings icon, slide the page, click the connection option, and click the debug option. The UiAutomation object is used to call the auxiliary function to implement the click function and the slide function in turn. At the same time, when clicking and sliding, the location information and sliding distance of the setting icon, connection option, and debug option are determined according to the current page form information.
[0182] In this embodiment, when a connection state change is detected, a user interface automation operation object is created; the current page form information is obtained through the user interface automation operation object; a preset recovery script is obtained, and a corresponding interface operation sequence is determined according to the preset recovery script; based on the current page form information, an auxiliary function object is called to execute the interface operation sequence, so that the connection state is restored to the target connection state. This embodiment can respond to changes in the device connection state in a timely manner, and obtain the current page form information through the created user interface automation operation object; at the same time, a preset recovery script is obtained, and the preset operation sequence in the script is executed to realize the automated operation of the page, thereby restoring the device connection state in a timely manner.
[0183] In one embodiment, the object creation model 10 is also used to initialize the thread operation object and the user interface automation operation object when a change in the connection state is detected; the object creation model is also used to create the user interface automation operation object by calling the user interface automation operation object constructor through a preset reflection path.
[0184] In one embodiment, the window information acquisition model 20 is also used to call the connection function of the user interface automation operation object through the preset reflection path to connect with the preset application interface; the window information acquisition model is also used to call the auxiliary window object through the preset application interface to obtain the current page window information.
[0185] In one embodiment, the execution model 40 is also used to determine the control to be operated according to the interface operation sequence; the execution model is also used to determine the corresponding target control in the current page form information according to the control to be operated; the execution model is also used to call the auxiliary function object to operate the target control according to the interface operation sequence, so as to restore the connection state to the target connection state.
[0186] In one embodiment, the device connection status recovery device also includes a connection status judgment module; the connection status judgment module is used to obtain connection port information when detecting that a connection is established with an external device; the connection status judgment module is also used to determine the current connection status based on the connection port information, and record the first maintenance time of the current connection status; the connection status judgment module is also used to determine whether the first maintenance time is greater than a first preset threshold; the connection status judgment module is also used to determine the current connection status as the target connection status when the first maintenance time is greater than the first preset threshold.
[0187] In one embodiment, the sequence generation module 30 is also used to obtain target connection status information; the sequence generation module is also used to search for a corresponding preset recovery script in a preset mapping relationship based on the target connection status information, and the mapping relationship includes a correspondence between the connection status and the recovery script; the sequence generation module is also used to parse the preset recovery script to obtain an interface operation sequence.
[0188] Other embodiments or specific implementations of the device connection status recovery apparatus of the present invention may refer to the above-mentioned method embodiments, which will not be described in detail here.
[0189] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0190] The serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In a unit claim that lists several means, several of these means may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order and these words may be interpreted as names.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0192] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for restoring a device connection status, It is characterized in that The device connection status recovery method comprises the following steps: When a connection status change is detected, a UI automation operation object is created; Obtaining the current page form information through the user interface automation operation object; Obtaining a preset recovery script, and determining a corresponding interface operation sequence according to the preset recovery script; Based on the current page form information, calling the auxiliary function object to execute the interface operation sequence, so as to restore the connection state to the target connection state; The step of calling the auxiliary function object based on the current page form information to execute the interface operation sequence so as to restore the connection state to the target connection state specifically includes: Determine the control to be operated according to the interface operation sequence; Determine a corresponding target control in the current page form information according to the control to be operated; Calling the auxiliary function object to operate the target control according to the interface operation sequence, so as to operate the user interface to modify the connection state; Determine whether the interface operation sequence is completed; When the interface operation sequence is not completed, obtaining the unexecuted controls corresponding to the uncompleted sequence; Call the auxiliary form object through the preset application program interface to obtain the intermediate page form information; Determine the corresponding target control in the intermediate page form information based on the unexecuted control, and return to the step of calling the auxiliary function object to operate the target control according to the interface operation sequence until the interface operation sequence is completed, so that the connection state is restored to the target connection state.
2. The device connection status recovery method according to claim 1, It is characterized in that The step of creating a user interface automation operation object when a connection state change is detected specifically includes: When a connection state change is detected, the thread operation object and the user interface automation operation object are initialized; The UI automation operation object is created by calling the UI automation operation object constructor through a preset reflection path.
3. The device connection status recovery method according to claim 2, It is characterized in that The step of obtaining the current page form information through the user interface automation operation object specifically includes: Calling the connection function of the user interface automation operation object through the preset reflection path to connect with the preset application program interface; The auxiliary window object is called through the preset application program interface to obtain the current page window information.
4. The device connection status recovery method according to claim 3, It is characterized in that After the step of calling the auxiliary function object based on the current page form information to execute the interface operation sequence so as to restore the connection state to the target connection state, the method further includes: When it is detected that the connection state is restored to the target connection state, calling the disconnection function of the user interface automation operation object through the preset reflection path to disconnect from the preset application program interface; The resource release function of the thread operation object is called to release the user interface automation operation object.
5. The device connection status recovery method according to any one of claims 1 to 4, It is characterized in that Before the step of creating a user interface automation operation object when a connection state change is detected, the method further includes: When a connection is detected with an external device, obtaining connection port information; Determine a current connection state according to the connection port information, and record a first maintenance time of the current connection state; Determining whether the first maintenance time is greater than a first preset threshold; When the first maintaining time is greater than the first preset threshold, the current connection state is determined as a target connection state.
6. The device connection status recovery method according to claim 5, wherein the step of creating a user interface automation operation object when a connection status change is detected is as follows: include: When a connection status change is detected, the connection status before the change is obtained; Determining whether the connection state before the change is the same as the target connection state; When the connection state before the change is the same as the target connection state, a user interface automation operation object is created.
7. The device connection status recovery method according to claim 6, wherein when the connection status before the change is the same as the target connection status, the step of creating a user interface automation operation object comprises: include: Acquire the connection state after the change, and record the second maintenance time of the connection state after the change; When the connection state before the change is the same as the target connection state, determining whether the second maintenance time is greater than a second preset threshold; When the second maintenance time is greater than the second preset threshold, a user interface automation operation object is created.
8. The device connection status recovery method according to any one of claims 1 to 4, It is characterized in that The step of obtaining a preset recovery script and determining a corresponding interface operation sequence according to the preset recovery script specifically includes: Get target connection status information; Searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information, wherein the mapping relationship includes a corresponding relationship between the connection state and the recovery script; The preset recovery script is parsed to obtain an interface operation sequence.
9. The device connection status recovery method according to claim 8, after the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection status, further comprising: include: When the corresponding preset recovery script is not found, the historical connection status record information is obtained; Acquire reference connection state information from the historical connection state record information according to a preset reference condition, and use the reference connection state information as target connection state information; Return to the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information.
10. The device connection status recovery method according to claim 9, after the step of searching for a corresponding preset recovery script in a preset mapping relationship according to the target connection status, further comprising: include: When the corresponding preset recovery script is not found, the target connection status information is displayed through a preset window; When receiving a file input based on the preset window, obtaining file information of the file; Determining whether the file information meets a preset condition; When the file information meets the preset condition, the file is used as a preset recovery script.
11. A device connection status recovery device, It is characterized in that The device connection status recovery device comprises: An object creation model for creating a user interface automation operation object when a connection state change is detected; A form information acquisition model, used to acquire the form information of the current page through the user interface automation operation object; A sequence generation module, used to obtain a preset recovery script and determine a corresponding interface operation sequence according to the preset recovery script; An execution model, for calling an auxiliary function object to execute the interface operation sequence based on the current page form information, so as to restore the connection state to a target connection state; The execution model is also used to: Determine the control to be operated according to the interface operation sequence; Determine a corresponding target control in the current page form information according to the control to be operated; Calling the auxiliary function object to operate the target control according to the interface operation sequence, so as to operate the user interface to modify the connection state; Determine whether the interface operation sequence is completed; When the interface operation sequence is not completed, obtaining the unexecuted controls corresponding to the uncompleted sequence; Call the auxiliary form object through the preset application program interface to obtain the intermediate page form information; Determine the corresponding target control in the intermediate page form information based on the unexecuted control, and execute the operation of calling the auxiliary function object to operate the target control according to the interface operation sequence until the interface operation sequence is completed, so that the connection state is restored to the target connection state.
12. The device connection status recovery apparatus according to claim 11, wherein the object creation model is further used to initialize the thread operation object and the user interface automation operation object when a change in the connection status is detected; The object creation model is also used to call the user interface automation operation object constructor through a preset reflection path to create a user interface automation operation object.
13. The device connection status recovery apparatus according to claim 12, wherein the window information acquisition model is further used to call the connection function of the user interface automation operation object through the preset reflection path to connect with the preset application program interface; The form information acquisition model is also used to acquire the current page form information by calling the auxiliary form object through the preset application program interface.
14. The device connection status recovery device according to any one of claims 11 to 13, further comprising a connection status determination module; The connection status judgment module is used to obtain the connection port information when detecting that a connection is established with an external device; The connection status judgment module is further used to determine the current connection status according to the connection port information, and record the first maintenance time of the current connection status; The connection status judgment module is further used to judge whether the first maintenance time is greater than a first preset threshold; The connection state judgment module is further configured to judge the current connection state as a target connection state when the first maintenance time is greater than the first preset threshold.
15. The device connection status recovery apparatus according to any one of claims 11 to 13, wherein the sequence generation module is further used to obtain target connection status information; The sequence generation module is further used to search for a corresponding preset recovery script in a preset mapping relationship according to the target connection state information, wherein the mapping relationship includes a corresponding relationship between the connection state and the recovery script; The sequence generation module is further used to parse the preset recovery script to obtain an interface operation sequence.
16. A device connection status recovery device, It is characterized in that The device connection status recovery device includes: a memory, a processor, and a device connection status recovery program stored in the memory and executable on the processor. When the device connection status recovery program is executed by the processor, the steps of the device connection status recovery method according to any one of claims 1 to 10 are implemented.
17. A storage medium, It is characterized in that The storage medium stores a device connection status recovery program, and when the device connection status recovery program is executed by the processor, the steps of the device connection status recovery method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Equipment fault recovery method and device
CN108429629A
Script step processing method, device and system
CN109947650A
