Analysis and detection method for display defects related to Android application zoom settings
By preprocessing and view tree construction of Android applications, combining measurement and calculation rules, anti-patterns are defined for four types of display defects, which solves the problem of difficulty in detecting page inconsistency of Android applications in the existing technology, and achieves efficient and detailed defect detection and report generation.
Patent Information
- Application Number
- CN202411939316.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-13
AI Technical Summary
The existing technology is difficult to effectively detect page inconsistency issues after Android applications are adjusted to scale settings, and it is impossible to deeply analyze the fundamental factors that lead to interface inconsistency, resulting in reports that cannot help developers locate defective view components.
By preprocessing the APK files and interface view hierarchy files of Android applications, a complete view tree is built, and measurement and calculation rules are written for commonly used Android views to obtain the coordinates of the view after changing the zoom settings. Four anti-patterns are defined for four types of display defects. If the coordinates of the node in the view tree meet any anti-pattern conditions, the node is identified as a violation view and detailed defect information is generated.
It realizes effective detection of display defects related to Android application scaling settings, can run mobile applications under default settings, and has higher detection efficiency. It can generate detailed defect reports based on the root cause of display defects, helping developers quickly locate defect views.
Smart Images

Figure CN119988192A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of program analysis and testing and software defect detection, and in particular to an analysis and detection method for display defects related to Android application zoom settings. Background Art
[0002] With the popularity of mobile devices and the development of the Internet, mobile applications play an increasingly important role in modern people's daily lives. Mobile applications provide users with services such as communication, interaction, navigation, entertainment, and finance with smart devices. The Android operating system currently occupies the largest share of the global smartphone operating system market, so Android applications are an important category of Internet applications today, accounting for about 40-50% of mobile Web and application traffic. Given the importance of Android mobile applications, ensuring that they can be used equally by everyone, including people with disabilities, and as a bridge between users and software, the graphical user interface is crucial to the accessibility of applications.
[0003] The most common barriers that affect users' use of mobile applications are visual and motor control disorders. Users facing these problems usually increase the "font size" and "display size" in the settings to make it easier to operate the device. However, the graphical user interface of many applications is designed only for the font and display size under the default settings. When scaling up from the default settings to a larger font or display size, this can cause inconsistencies in the graphical user interface. In particular, the user interface may have problems such as text not responding to changes in the "font size" setting, incomplete text display, incomplete views (for example, views that exceed the screen boundaries), and overlapping views (for example, text becomes longer and covers icons due to adjusting the zoom settings). These problems can cause users to encounter difficulties in operation and information acquisition during the use of the application, and may even make the application unavailable, greatly affecting the user experience.
[0004] Existing work has been done on detecting display defects related to the zoom settings of Android applications, but there are still many deficiencies. Existing computer vision-based methods often fail to effectively detect screenshots that lack obvious visual features, such as screenshots that lack view components and text that does not respond to setting changes. Existing methods based on detecting inconsistencies in application pages before and after adjusting zoom settings not only require running mobile applications under two settings, namely the default zoom setting and the enlarged zoom setting, but also fail to deeply analyze and identify the root causes of interface inconsistencies, and the generated reports cannot help developers locate defective view components. Summary of the invention
[0005] The present application provides an analysis and detection method for display defects related to the zoom settings of Android applications, which can be used to solve the technical problem of existing methods for detecting inconsistencies in application pages before and after adjusting the zoom settings, and requiring the mobile application to be run under two settings.
[0006] This application provides an analysis and detection method for display defects related to Android application zoom settings, the method comprising:
[0007] The method takes an Android application APK file and an interface view hierarchy file when the application is running as input, and takes detailed information of display defects related to the application zoom setting detected as output results; the method comprises:
[0008] Step 1, preprocess the APK file to obtain a static resource file, and construct a complete view tree by combining the view hierarchy file and resource file when the Android application is running;
[0009] Step 2, by writing measurement and calculation rules for common Android views, apply the Android view to the view tree constructed in step 1, and obtain the coordinates of the view after the zoom setting is changed;
[0010] Step 3: Four anti-patterns are defined for the four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output to the report file.
[0011] Compared with the prior art, the present invention has the following significant advantages: (1) It can detect four types of display defects related to zoom settings, namely, text unresponsiveness, incomplete text display, and incomplete view display and view overlap, and the method is more effective; (2) It only needs to run the mobile application under the default settings, without having to run the mobile application after adjusting the zoom settings, which has the significant advantage of higher detection efficiency. (3) It defines four anti-patterns based on the root causes of display defects, and generates a detailed report of defective views in combination with the resource files of the mobile application, helping developers to quickly locate defective views. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a flow chart of a display defect tool related to Android application zoom setting provided by the present invention.
[0013] Figure 2 This is an example of a display defect provided by the present invention where the text does not respond to changes in the zoom setting.
[0014] Figure 3 This is an example of a display defect in which text is not fully displayed as provided by the present invention.
[0015] Figure 4This is an example of a display defect in which the view provided by the present invention is not fully displayed.
[0016] Figure 5 This is an example of a display defect of view overlap provided by the present invention.
[0017] Figure 6 This is an example of a report file showing defect detection results related to zoom settings. DETAILED DESCRIPTION
[0018] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0019] The following first introduces the embodiments of the present application in conjunction with the accompanying drawings.
[0020] The present invention is a method for detecting display defects related to Android application zoom settings, which takes an Android application APK file and an interface view hierarchy file when the application is running as input, and takes detailed information of the detected display defects related to the application zoom settings as output results, and the specific steps are as follows:
[0021] Step 1: Use the Apktool tool to preprocess the APK file to obtain static resource files, and construct a complete view tree by combining the view hierarchy file and resource files when the Android application is running.
[0022] Step 2, by writing measurement and calculation rules for commonly used Android views, apply the Android view to the view tree constructed in step 1, and obtain the coordinates of the view after the zoom setting is changed.
[0023] Step 3: Four anti-patterns are defined for the four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output to the report file.
[0024] As a specific example, as described in step 1, the APK file is preprocessed using the Apktool tool to obtain a static resource file, and a complete view tree is constructed by combining the view hierarchy file and resource file when the Android application is running. The specific steps are as follows:
[0025] Step 1-1, use the Apktool tool to decompile the APK file, obtain the .xml resource file, and analyze the resource file to obtain the application's interface definition, layout configuration, string resources and other configuration information;
[0026] Step 1-2, traverse each view hierarchy file; for each view hierarchy file, traverse each node therein; by comparing the resource-id attribute value of each node with the id attribute value of the view node in the application layout resource file, identify the corresponding view node pair;
[0027] Step 1-3, according to the view node pair set obtained in step 1-2, recursively add the parent node of each pair of view nodes to the node pair set;
[0028] Steps 1-4, traverse each pair of view nodes in the collection, add the view node attributes in the layout file to the attribute collection of the corresponding node in the view hierarchy file, and finally build a view tree with relatively complete structure and attributes.
[0029] As a specific example, as described in step 2, by writing measurement and calculation rules for common Android views and applying the Android views to the view tree constructed in step 1, the coordinates of the view after the zoom setting is changed are obtained. The specific steps are as follows:
[0030] Step 2-1 defines specific measurement and calculation rules for common view component types in Android, including components such as text view, editable text view, button, and layouts such as linear layout, relative layout, and constraint layout;
[0031] Different layout methods may have different effects on the size and position of views. The size of a view is affected by its own properties (such as width, height, margins, content, etc.) and the size of its parent view. The properties of the layout components will affect the arrangement of subviews. For example, in a linear layout, subcomponents are arranged in the horizontal or vertical order according to the definition order; in a relative layout, subcomponents can define the relative position relationship between each other or between the parent component;
[0032] Step 2-2, in the view tree constructed in step 1, recursively apply corresponding measurement and calculation rules to each view node to calculate the coordinates and size of the view node after the zoom setting is changed;
[0033] As a specific example, as described in step 3, four anti-patterns are defined for four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output to the report file. The specific steps are as follows:
[0034] Step 3-1 defines corresponding anti-patterns for four common display defects. The anti-patterns are derived based on the relationship between the coordinates and properties of the view and common display problems. Each anti-pattern corresponds to a specific type of display defect, including: 1. Unresponsive text: the text size of the text view does not use the correct unit (such as sp unit); 2. Incomplete text: the content of the text view exceeds the display area, resulting in part of the text being obscured; 3. Incomplete view: the size of the view exceeds the boundaries of the parent view, resulting in part of the view being cropped or lost; 4. Overlapping views: two views overlap in the layout, resulting in incorrect display.
[0035] Step 3-2, traverse each node in the view tree, and check whether the coordinates and size of each node meet any of the anti-patterns; if the coordinates, size or other attributes of a view node meet the conditions of an anti-pattern, the node is identified as an illegal view.
[0036] Step 3-3, generating detailed defect information for the determined illegal view, including defect type, specific attributes of the defect view (such as resource-id, class name, coordinates, etc.), outputting it to the detection report file, and dumping it to a local text file.
[0037] Example
[0038] The present invention is a method for detecting display defects related to the scaling settings of Android applications. By detecting Android applications, display defect results related to the scaling settings of the application are generated. The specific work is as follows: Figure 1 As shown in the figure. First, the APK file of a specific application to be tested is preprocessed to obtain a static resource file, and a complete view tree is constructed by combining the interface view hierarchy file and resource file when the application is running; then, coordinate calculation rules are written for commonly used Android views and applied to the constructed view tree to obtain the coordinates of the view after the zoom setting is changed; finally, four anti-patterns are defined for four types of display defects. If a node in the view tree meets the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output.
[0039] In this implementation, the method comprises the following steps:
[0040] Step 1-1, use the Apktool tool to decompile the APK file, obtain the .xml resource file, and analyze the resource file to obtain the application's interface definition, layout configuration, string resources and other configuration information;
[0041] Step 1-2, traverse each view hierarchy file. For each view hierarchy file, further traverse each node therein. By comparing the resource-id attribute value of each node with the id attribute value of the view node in the application layout resource file, identify the corresponding view node pair;
[0042] Step 1-3, based on the view node pair set obtained in the previous step, recursively add the parent node of each pair of view nodes to the node pair set;
[0043] Steps 1-4, traverse each pair of view nodes in the collection, add the view node attributes in the layout file to the attribute collection of the corresponding node in the view hierarchy file, and finally build a view tree with relatively complete structure and attributes, such as Figure 2 shown.
[0044] Step 2, by writing measurement and calculation rules for common Android views and applying them to the view tree constructed in the first step, get the coordinates of the view after changing the zoom setting. The specific steps are as follows:
[0045] Step 2-1 defines specific measurement and calculation rules for common view component types in Android, such as text views, editable text views, buttons, and layouts such as linear layouts, relative layouts, and constraint layouts. Different layout methods may have different effects on the size and position of views. The size of a view is affected by its own properties (such as width, height, margins, content, etc.) and the size of its parent view. The nature of the layout component will affect the arrangement of child views. For example, in a linear layout, child components will be sorted in the horizontal or vertical direction in the order of definition, while in a relative layout, child components can define relative position relationships between each other or with the parent component;
[0046] Step 2-2, in the view tree constructed in step 1, recursively apply corresponding measurement and calculation rules to each view node to calculate the coordinates and size of the view node after the zoom setting is changed;
[0047] Step 3: Four anti-patterns are defined for the four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output to the report file. The specific steps are as follows:
[0048] In step 3-1, we define corresponding anti-patterns for four common display defects. These anti-patterns are derived based on the relationship between the coordinates and properties of the view and common display problems. Each anti-pattern corresponds to a specific type of display defect, including: (1) Unresponsive text: The text size of the text view does not use the correct unit (such as sp unit), such as Figure 3 As shown in Figure 1, Figure (a) is a screenshot of the application running under the default zoom setting, and Figure (b) is a screenshot of the application running after adjusting the "font size" setting to increase the text. By comparison, it is found that the text "8:30" and "9:00" are not enlarged following the setting change; (2) Incomplete text: The content of the text view exceeds its displayable area, resulting in partial text being blocked, such as Figure 4 As shown in Figure 1, Figure (a) is a screenshot of the application running under the default zoom settings, and Figure (b) is a screenshot of the application running after increasing the "font size" and "display size" settings. By comparison, it is found that the text "ASSISTANT" is not fully displayed after the settings are increased; (3) Incomplete view: The size of the view exceeds the boundary of its parent view, resulting in part of the view being cropped or lost, such as Figure 5 As shown in Figure 1, Figure (a) is a screenshot of the application running under the default zoom settings, and Figure (b) is a screenshot of the application running after increasing the "font size" and "display size" settings. By comparison, it is found that the text "classic" disappears directly after the settings are increased; (4) Overlapping views: Two views overlap in the layout, resulting in incorrect display, such as Figure 5 As shown, Figure (a) is a screenshot of the application running under the default zoom settings, and Figure (b) is a screenshot of the application running after the "font size" and "display size" settings are increased. By comparison, it is found that some texts overlap each other after the settings are increased.
[0049] Step 3-2, traverse each node in the view tree, and check whether the coordinates and size of each node meet any of the above anti-patterns. If the coordinates, size or other attributes of a view node meet the conditions of an anti-pattern, the node is identified as an illegal view.
[0050] Step 3-3, generate detailed defect information for the illegal view determined in the previous step, including defect type, specific attributes of the defect view (such as resource-id, class name, coordinates, etc.), output it to the detection report file, and dump it to a local text file.
[0051] In summary, the present invention can effectively and efficiently detect display defects related to Android application zoom settings.
[0052] The above-described embodiments of the present application do not constitute a limitation on the protection scope of the present application.
Claims
1. An analysis and detection method for display defects related to Android application zoom settings, characterized in that: The method comprises: The method takes an Android application APK file and an interface view hierarchy file when the application is running as input, and takes detailed information of display defects related to the application zoom setting detected as output results; the method comprises: Step 1, preprocess the APK file to obtain a static resource file, and construct a complete view tree by combining the view hierarchy file and resource file when the Android application is running; Step 2, by writing measurement and calculation rules for common Android views, apply the Android view to the view tree constructed in step 1, and obtain the coordinates of the view after the zoom setting is changed; Step 3: Four anti-patterns are defined for the four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is identified as a violation view, and detailed defect information is generated and output to the report file.
2. The method according to claim 1, characterized in that Step 1: Preprocess the APK file to obtain static resource files, and construct a complete view tree by combining the view hierarchy file and resource files when the Android application is running, including: Step 1-1, decompile the APK file to obtain the .xml resource file therein, and analyze the resource file to obtain the interface definition, layout configuration, and string resources of the application; Step 1-2, traverse each view hierarchy file; for each view hierarchy file, traverse each node therein; by comparing the resource-id attribute value of each node with the id attribute value of the view node in the application layout resource file, identify the corresponding view node pair; Step 1-3, according to the view node pair set obtained in step 1-2, recursively add the parent node of each pair of view nodes to the node pair set; Steps 1-4, traverse each pair of view nodes in the collection, add the view node attributes in the layout file to the attribute collection of the corresponding node in the view hierarchy file, and finally build a view tree with complete structure and attributes.
3. The method according to claim 2, characterized in that Step 2, by writing measurement and calculation rules for common Android views and applying the Android views to the view tree constructed in step 1, obtain the coordinates of the view after the zoom setting is changed, including: Step 2-1 defines specific measurement and calculation rules for common view component types in Android, including text view, editable text view, button, linear layout, relative layout, and constraint layout; In a linear layout, child components are arranged in the horizontal or vertical direction according to the order in which they are defined; in a relative layout, child components can define their relative position relationship with each other or with the parent component; Step 2-2, in the view tree constructed in step 1, recursively apply the corresponding measurement and calculation rules to each view node to calculate the coordinates and size of the view node after the zoom setting is changed.
4. The method according to claim 3, characterized in that Step 3: Four anti-patterns are defined for the four types of display defects. If the node coordinates in the view tree meet the conditions of any anti-pattern, the node is marked as a violation view, and detailed defect information is generated and output to the report file, including: Step 3-1 defines corresponding anti-patterns for four common display defects. Anti-patterns are derived based on the relationship between the coordinates and properties of the view and common display problems. Each anti-pattern corresponds to a specific type of display defect, including:
1. Unresponsive text: the text size of the text view does not use the correct unit; 2. Incomplete text: the content of the text view exceeds the display area, resulting in partial text being blocked; 3. Incomplete view: the size of the view exceeds the boundaries of the parent view, resulting in partial view being cropped or lost; 4. Overlapping views: two views overlap in the layout, resulting in incorrect display; Step 3-2, traverse each node in the view tree, and check whether the coordinates and size of each node meet any of the anti-patterns; if the coordinates, size or other attributes of a view node meet the conditions of an anti-pattern, then mark the node as an illegal view; Step 3-3, generating detailed defect information for the determined illegal view, including defect type and specific attributes of the defect view, outputting it to the detection report file, and dumping it to a local text file.