CN111581438B - File analysis method and terminal - Google Patents

File analysis method and terminal Download PDF

Info

Publication number
CN111581438B
CN111581438B CN201910123937.0A CN201910123937A CN111581438B CN 111581438 B CN111581438 B CN 111581438B CN 201910123937 A CN201910123937 A CN 201910123937A CN 111581438 B CN111581438 B CN 111581438B
Authority
CN
China
Prior art keywords
xml
file
analysis
parsing
computer
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
CN201910123937.0A
Other languages
Chinese (zh)
Other versions
CN111581438A (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.)
Hisense Mobile Communications Technology Co Ltd
Original Assignee
Hisense Mobile Communications Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hisense Mobile Communications Technology Co Ltd filed Critical Hisense Mobile Communications Technology Co Ltd
Priority to CN201910123937.0A priority Critical patent/CN111581438B/en
Publication of CN111581438A publication Critical patent/CN111581438A/en
Application granted granted Critical
Publication of CN111581438B publication Critical patent/CN111581438B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a file analysis method and a terminal, relates to the field of file analysis, and is used for preventing file analysis abnormality. The file analysis method comprises the following steps: analyzing XML sentences in an extensible markup language (XML) file according to rows, and capturing analysis anomalies; when analysis abnormality occurs, only storing the XML statement with normal analysis to the XML file; and re-parsing the XML file. The embodiment of the application is applied to XML file parsing.

Description

File analysis method and terminal
Technical Field
The present disclosure relates to the field of file parsing, and in particular, to a method and a terminal for file parsing.
Background
In an Android system, some system configurations are usually stored in an extensible markup language (extensible markup language, XML) type file, and during the starting or running process of the Android system, some system services or applications need to read data in the XML file to complete corresponding functions, so that the parsing of the XML file may be involved.
When the analysis XML file is abnormal, fault-tolerant processing is not carried out on the analysis XML file in the original design of the Android system, so that system service or application operation is abnormal. For example, if such an abnormality occurs in the system service starting process during startup, the Android system may not be started normally, and a phenomenon of startup screen fixation occurs, that is, the screen always displays startup animation, and cannot be started truly, so that the use of the Android system is greatly affected.
Disclosure of Invention
The embodiment of the application provides a file analysis method and a terminal, which are used for preventing file analysis abnormality.
In order to achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
in a first aspect, an embodiment of the present application provides a method for parsing a file, including:
analyzing XML sentences in an extensible markup language (XML) file according to rows, and capturing analysis anomalies;
when analysis abnormality occurs, only storing the XML statement with normal analysis to the XML file;
and re-parsing the XML file.
In a second aspect, there is provided a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computer, cause the computer to perform the file parsing method of the first aspect.
In a third aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the file parsing method as described in the first aspect.
In a fourth aspect, there is provided a terminal comprising: a processor and a memory for storing a program, the processor calling the program stored in the memory to perform the file parsing method as described in the first aspect.
According to the file analysis method and the terminal provided by the embodiment of the application, XML sentences in the extensible markup language XML file are analyzed according to the rows, and analysis anomalies are captured; when analysis abnormality occurs, only storing the XML statement with normal analysis to an XML file; the XML file is parsed again. The method can distinguish abnormal XML sentences and normal XML sentences in the XML file, save the normal XML sentences, reduce data loss of users as much as possible, and prevent file analysis abnormality.
Drawings
Fig. 1 is a schematic structural diagram of a terminal according to an embodiment of the present application;
fig. 2 is a flow chart of a file parsing method according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a terminal and a display method, which can be applied to an iOS system developed by apple corporation, an Android system developed by Google corporation, a Windows system developed by Microsoft corporation and the like. The embodiment of the present application is described by taking an Android system as an example, but is not limited thereto. The terminal can be a mobile phone, a television, a computer, a smart watch and other devices.
As shown in fig. 1, a configuration of a terminal will be described using the terminal as an example of a mobile phone.
The terminal 100 may include: radio Frequency (RF) circuitry 110, memory 120, input unit 130, display unit 140, sensor 150, audio circuitry 160, wireless fidelity (wireless fidelity, wi-Fi) module 170, processor 180, bluetooth module 181, and power supply 190.
The RF circuit 110 may be used for receiving and transmitting signals during the process of receiving and transmitting information or communication, and may receive downlink data of the base station and then transmit the downlink data to the processor 180 for processing; uplink data may be sent to the base station. Typically, RF circuitry includes, but is not limited to, antennas, at least one amplifier, transceivers, couplers, low noise amplifiers, diplexers, and the like.
Memory 120 may be used to store software programs and data. The processor 180 performs various functions of the terminal 100 and data processing by running software programs or data stored in the memory 120. Memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Memory 120 stores an operating system, such as developed by apple corporation, that enables terminal 100 to operateOperating System, developed by Google Corp->Open source operating System, developed by Microsoft corporationAn operating system, etc. The memory 120 in the present application may store an operating system and various application programs, and may also store code for performing the methods described in the embodiments of the present application.
An input unit 130 (e.g., a touch screen) may be used to receive input digital or character information, and generate signal inputs related to user settings and function control of the terminal 100. In particular, the input unit 130 may include a touch screen 131 disposed at the front of the terminal 100, on or near which touch operations by a user may be collected.
The display unit 140 (i.e., display screen) may be used to display information input by a user or information provided to the user and a graphical user interface (graphical user interface, GUI) of various menus of the terminal 100. The display unit 140 may include a display screen 141 provided on the front surface of the terminal 100. The display screen 141 may be configured in the form of a liquid crystal display, a light emitting diode, or the like. The display unit 140 may be used to display various graphical user interfaces described in this application. The touch screen 131 may cover the display screen 141, or the touch screen 131 and the display screen 141 may be integrated to implement input and output functions of the terminal 100, and after integration, the touch screen may be simply referred to as a touch display screen.
The terminal 100 may also include at least one sensor 150, such as a light sensor, a motion sensor. The terminal 100 may also be configured with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, and the like.
Audio circuitry 160, speaker 161, microphone 162 can provide an audio interface between the user and terminal 100. The audio circuit 160 may transmit the received electrical signal converted from audio data to the speaker 161, and the electrical signal is converted into a sound signal by the speaker 161 to be output; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, which is output to the RF circuit 110 for transmission to, for example, another terminal, or to the memory 120 for further processing.
Wi-Fi belongs to a short-range wireless transmission technology, and the terminal 100 can help a user to send and receive e-mail, browse web pages, access streaming media and the like through the Wi-Fi module 170, so that wireless broadband internet access is provided for the user.
The processor 180 is a control center of the terminal 100, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal 100 and processes data by running or executing software programs stored in the memory 120 and calling data stored in the memory 120. In some embodiments, the processor 180 may include one or more processing units; the processor 180 may also integrate an application processor that primarily handles operating systems, user interfaces, applications, etc., and a baseband processor that primarily handles wireless communications. It will be appreciated that the baseband processor described above may not be integrated into the processor 180. The processor 180 may run an operating system, application programs, user interface displays and touch responses, and methods according to embodiments of the present application.
The bluetooth module 181 is configured to perform information interaction with other bluetooth devices having a bluetooth module through a bluetooth protocol. For example, the terminal 100 may establish a bluetooth connection with a wearable electronic device (e.g., a smart watch) also provided with a bluetooth module through the bluetooth module 181, thereby performing data interaction.
The terminal 100 also includes a power supply 190 (e.g., a battery) that provides power to the various components. The power supply may be logically connected to the processor 180 through a power management system, so that functions of managing charge, discharge, power consumption, etc. are implemented through the power management system.
In the Android system, some functional modules store data in XML format files. When the function module stores data into the XML file, if the system is unstable or other reasons, the stored XML file has a disordered format. When the XML files with disordered formats are analyzed, abnormality occurs, and the Android device is sometimes seriously influenced by a user. At present, fault tolerance processing is not carried out on the original design of the Android system.
For example, a settings Provider (settings Provider) is a Provider (Provider) in an Android System that provides sharing of System settings data, and the Provider contains a System (System) type table, where the data in the System table is stored in XML files/data/data/systems/users/0/settings_systems.
In the Android system startup process, a mobile security service (mobile security service) needs to read and write system setting data as a system service, and needs to acquire and initialize settingsProvider first, where the settingsProvider will parse the XML file setting_ system. Illustratively, the contents of a normal settings_system.xml file may begin with a < settings > tag and end with a </settings > tag, after which no text data can be located any more, as shown in example 1 below.
Example 1:
illustratively, in the case of an exception, the contents of the settingsystem xml file may be as shown in example 2 below, with text data (as shown in bold) following the end tag </setting >. Or as shown in example 3 below, no end tag. Or as shown in example 4 below, the XML statement is incomplete (e.g., "<" and "/>" do not appear in pairs), and so on. Because the XML format specification is not met, the analysis of the settingsystem.xml file fails, so that the mobile security service fails to acquire and initialize the settingsProvider to generate a starting exception, and the starting exception of the system service can cause the starting failure of the Android system.
Example 2:
example 3:
example 4:
for another example, in the Android system, fingerprint information entered by a user is stored in the XML file/data/data/system/users/0/fingerprint XML, and when the Android system is just started, a screen locking program analyzes the fingerprint XML file through an interface in fingerprint service (fingerprint service) to obtain relevant fingerprint information. If the fingerprint file is analyzed to be abnormal at this time, the screen locking process is abnormal, so that the starting of a whole system user interface (SystemUI) function module is affected, and finally, a user cannot unlock the Android device normally.
As shown in fig. 2, an embodiment of the present application provides a file parsing method, which is applied to the above terminal, and the method includes:
s101, analyzing XML sentences in an XML file according to rows, and capturing analysis anomalies.
In the embodiment of the application, the parsing exception refers to parsing exception caused by that XML sentences in an XML file do not accord with XML specifications. For example, there are XML statements following an end tag, no end tag, incomplete XML statements (e.g., where "<" and "/>" occur unpaired), etc., and the present application is not limited.
Specifically, the XML statements in the XML file may be parsed by the XmlPullParser tool class. Further, the code that calls the xmlpullParser tool class may be rewritten, and a try { … } catch { … } statement may be added to the code that calls the xmlpullParser tool class to capture the resolution exception.
Illustratively, the case of parsing an abnormal file in settingsystem.xml as shown in example 2 will be described, and the parsing by line means: first resolve the first line? xml version= '1.0' encoding= ' UTF-8' standby anon= ' yes? The second line < setting version= "148" >, and so on, is then resolved. The analysis exception is captured by the try { … } catch { … } statement during the analysis.
S102, when analysis abnormality occurs, only the XML sentences with normal analysis are saved in an XML file.
Optionally, in one manner, when no parsing exception occurs, storing the XML statement with normal parsing to a preset position according to a line, where the preset position may be a user-defined system variable; when the analysis abnormality occurs, the XML file is emptied, and the XML sentence stored in the preset position is stored in the XML file.
Illustratively, the case of the setting_system.xml file parsing exception shown in example 2 is taken as an example for explanation, and the XML statements that are parsed normal are parsed line by line until the XML statements are parsed normal, and the parsed normal XML statements are saved into the custom system variables.
When the XML statement value= "1" defaultSysSet= "true"/>, when the parsing proceeds from the end tag, since the end tag is the end tag, there should be no XML statement after the end tag, so the try { … } catch { … } statement captures the parsing exception. At this time, the settings_system.xml file may be emptied, and the contents in the custom system variable may be saved to the settings_system.xml file.
Further, when the parsing exception occurs, if the last XML sentence of the parsing exception is not the end tag sentence, the end tag sentence is added according to the XML specification after the last XML sentence of the parsing exception is parsed. Adding an end tag statement according to the XML specification refers to adding an end tag statement corresponding to the start tag statement. For example, the start tag statement is < setting >, and the corresponding end tag statement is </settings >.
Illustratively, the case of parsing an exception for a set_system.xml file shown in example 3 is taken as an example, and since the last XML statement < set id= "8" name= "mut_streams_completed" value= "46"/>, which is normal, is not an end tag statement, a parsing exception still occurs if the parsing is resumed. Thus, the end tag statement may be added following the XML statement in accordance with the XML specification. The final saved settingsystem xml file results are shown in example 1.
Alternatively, in another manner, the XML statement and subsequent XML statements in the XML file that resolve the exception may be deleted, and the XML file may be saved.
Illustratively, the case of parsing exception of the set_system.xml file shown in example 2 is taken as an example, the XML statement is parsed normally from line to line, when the parsing is continued, it is found that there is an XML statement after the tag is ended, and the try { … } catch { … } statement captures the parsing exception. At this time, XML statements following the XML statement of the settingS-system-XML file may be deleted directly, and the settingS-system-XML file may be saved.
S103, re-analyzing the XML file.
Illustratively, the parsing exception will not occur again for the settingsystem.xml file shown in example 1.
By the method, the problem of screen fixation during startup caused by abnormal analysis of the XML file can be effectively avoided.
According to the file analysis method and the terminal provided by the embodiment of the application, XML sentences in the extensible markup language XML file are analyzed according to the rows, and analysis anomalies are captured; when analysis abnormality occurs, only storing the XML statement with normal analysis to an XML file; the XML file is parsed again. The method can distinguish abnormal XML sentences and normal XML sentences in the XML file, save the normal XML sentences, reduce data loss of users as much as possible, and prevent file analysis abnormality.
Embodiments of the present application provide a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computer, cause the computer to perform a file parsing method as described in fig. 2.
Embodiments of the present application provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform a file parsing method as described in fig. 2.
The embodiment of the application provides a terminal, which comprises: a processor and a memory for storing a program, the processor invoking the program stored in the memory to perform the file parsing method as described in fig. 2.
Since the terminal, the computer readable storage medium, and the computer program product in the embodiments of the present application may be applied to the above-mentioned file parsing method, the technical effects that can be obtained by the method may also refer to the above-mentioned method embodiments, and the embodiments of the present application are not described herein again.
The above units may be individually set up processors, may be integrated into one of the processors of the controller, or may be stored in the memory of the controller in the form of program codes, and the functions of the above units may be called and executed by one of the processors of the controller. The processor described herein may be a central processing unit (Central Processing Unit, CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits configured to implement embodiments of the present application.
It should be understood that, in various embodiments of the present application, the sequence numbers of the foregoing processes do not mean the order of execution, and the order of execution of the processes should be determined by the functions and internal logic thereof, and should not constitute any limitation on the implementation process of the embodiments of the present application.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, indirect coupling or communication connection of devices or units, electrical, mechanical, or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.

Claims (4)

1. A method for parsing a file, comprising:
analyzing XML sentences in an extensible markup language (XML) file according to rows, and capturing analysis anomalies;
when analysis abnormality does not occur, storing the XML statement with normal analysis to a preset position according to lines, wherein the preset position is a user-defined system variable;
when analysis abnormality occurs, deleting XML sentences and subsequent XML sentences of the analysis abnormality in the XML file, and storing the XML file; or, clearing the XML file, and storing the XML statement stored in the preset position to the XML file; the method comprises the steps of,
when the analysis exception occurs, if the analysis of the last normal XML sentence is not the end tag sentence, adding the end tag sentence according to the XML specification after the analysis of the last normal XML sentence;
and re-parsing the XML file.
2. A computer readable storage medium storing one or more programs, wherein the one or more programs comprise instructions, which when executed by a computer, cause the computer to perform the file parsing method of claim 1.
3. A computer program product comprising instructions which, when run on a computer, cause the computer to perform the file parsing method of claim 1.
4. A terminal, comprising: a processor and a memory for storing a program, the processor invoking the program stored in the memory to perform the file parsing method according to claim 1.
CN201910123937.0A 2019-02-19 2019-02-19 File analysis method and terminal Active CN111581438B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910123937.0A CN111581438B (en) 2019-02-19 2019-02-19 File analysis method and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910123937.0A CN111581438B (en) 2019-02-19 2019-02-19 File analysis method and terminal

Publications (2)

Publication Number Publication Date
CN111581438A CN111581438A (en) 2020-08-25
CN111581438B true CN111581438B (en) 2024-01-23

Family

ID=72112924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910123937.0A Active CN111581438B (en) 2019-02-19 2019-02-19 File analysis method and terminal

Country Status (1)

Country Link
CN (1) CN111581438B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090126A (en) * 2021-11-23 2022-02-25 浩云科技股份有限公司 Method and device for customizing system variable, terminal equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101052945A (en) * 2004-08-02 2007-10-10 佳思腾软件公司 Approach for creating a tag or an attribute in a markup language document
CN101452408A (en) * 2007-11-28 2009-06-10 国际商业机器公司 System and method for implementing error report in software application program
CN102163233A (en) * 2011-04-18 2011-08-24 北京神州数码思特奇信息技术股份有限公司 Method and system for converting webpage markup language format
CN103544260A (en) * 2013-10-16 2014-01-29 银江股份有限公司 Method for converting large XML (extensive makeup language) document
CN104699611A (en) * 2015-03-18 2015-06-10 北京航空航天大学 Defect information extraction method based on open-source software defect code modification mode
CN109347812A (en) * 2018-09-27 2019-02-15 国网湖北省电力有限公司电力科学研究院 A kind of industry control bug excavation method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AUPQ849500A0 (en) * 2000-06-30 2000-07-27 Canon Kabushiki Kaisha Hash compact xml parser

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101052945A (en) * 2004-08-02 2007-10-10 佳思腾软件公司 Approach for creating a tag or an attribute in a markup language document
CN101452408A (en) * 2007-11-28 2009-06-10 国际商业机器公司 System and method for implementing error report in software application program
CN102163233A (en) * 2011-04-18 2011-08-24 北京神州数码思特奇信息技术股份有限公司 Method and system for converting webpage markup language format
CN103544260A (en) * 2013-10-16 2014-01-29 银江股份有限公司 Method for converting large XML (extensive makeup language) document
CN104699611A (en) * 2015-03-18 2015-06-10 北京航空航天大学 Defect information extraction method based on open-source software defect code modification mode
CN109347812A (en) * 2018-09-27 2019-02-15 国网湖北省电力有限公司电力科学研究院 A kind of industry control bug excavation method and system

Also Published As

Publication number Publication date
CN111581438A (en) 2020-08-25

Similar Documents

Publication Publication Date Title
US11750444B2 (en) Implementation of compliance settings by a mobile device for compliance with a configuration scenario
CN110351325B (en) Data processing method and related equipment
KR20050074335A (en) Client provisioning with flag parameters
CN111581438B (en) File analysis method and terminal
CN112000566B (en) Method and device for generating test cases
CN113179511B (en) Communication terminal with SIM card for abnormal processing of card and method thereof
CN111435318A (en) Dex optimization method of application program and terminal
CN103685491A (en) Application service providing method, system and related equipment
US9128731B2 (en) Communication between a mobile computing device and an accessory device using a reconfigurable accessory communication protocol
CN110944318A (en) Lock card setting method and device, storage medium and terminal
CN110264035A (en) Configuration method, device, terminal and the storage medium of workflow
CN112395138B (en) Method and device for checking parameters
KR102506155B1 (en) Electronic device, application executing system and control methods thereof
CN111182153B (en) System language setting method and device, storage medium and mobile terminal
CN111061518A (en) Data processing method, system, terminal device and storage medium based on drive node
CN113965476B (en) Inspection method, device and equipment based on application
CN114189562B (en) Data processing method, device, terminal and storage medium
CN113271305B (en) Attack detection method and device and web application level intrusion prevention system WAF
US11797422B2 (en) Cloud controlled bug recovery
CN112988406B (en) Remote calling method, device and storage medium
CN113179322B (en) Remote interaction method, device, electronic equipment and storage medium
CN114745153B (en) Link tracking method combining WCF and log4net
WO2022160304A1 (en) Exchange method and apparatus for multi-subscriber identification module characteristic information, and communication device
CN117632333A (en) Method, system, device and equipment for realizing link-skip route
CN107329845B (en) Image processing method and device, terminal and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11

Applicant after: Qingdao Hisense Mobile Communication Technology Co.,Ltd.

Address before: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11

Applicant before: HISENSE MOBILE COMMUNICATIONS TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant