An Android application-oriented software aging defect black box detection method

By employing a pure black-box testing method, utilizing interface state standardization and resource-aware reward calculation, and combining reinforcement learning and linear regression analysis, the problem of low efficiency in detecting aging defects in Android applications was solved, achieving efficient and accurate identification and repair of aging defects.

CN122633588APending Publication Date: 2026-08-25NANJING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610687303.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing Android application aging defect detection technologies are inefficient, have weak targeting, are difficult to locate defects, and have poor reproducibility. Traditional testing is time-consuming and cannot accurately identify hidden resource leakage problems.

Method used

A pure black-box testing method without source code or code instrumentation is adopted. By standardizing the construction of interface states, calculating resource-aware rewards, and using reinforcement learning algorithms, a controllable sequence of resource-invariant events is generated. Combined with linear regression analysis, aging defects are identified, and a reproducible test report is generated.

Benefits of technology

It achieves efficient and accurate aging defect detection, improving detection efficiency by more than 80%, reducing testing time and computing power costs, and can accurately identify hidden aging defects and provide reproducible repair paths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122633588A_ABST
    Figure CN122633588A_ABST
Patent Text Reader

Abstract

The application discloses a kind of software aging defects of Android application-oriented black box detection method.The method is without obtaining application source code, by executing engine drive to-be-tested Android application, and the runtime index such as memory, communication, interface object, file and computing resource is collected;Utilize the reinforcement learning strategy of resource perception reward function guidance and preferentially explore the application state that resource change is remarkable;After reaching new state, based on the metamorphosis relationship of resource invariability, the event sequence of repeated execution is generated, and the trend analysis is carried out to resource use time sequence, to identify the aging related defects of continuous growth.The application can locate defect trigger state, event sequence and abnormal resource index in a short time, improve the efficiency, reproducibility and diagnosability of Android application aging defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software aging detection technology, specifically a black-box detection method for software aging defects in Android applications. Background Technology

[0002] Android applications are the core application platform for current mobile terminals, widely used in various terminals such as mobile phones, tablets, and smart wearable devices. The long-term stable operation of these applications directly determines the user experience and the overall reliability of the terminal system. Current Android automated testing technologies mostly focus on explicit functional defects such as crashes, freezes, and feature failures. They traverse the application interface and execution path through methods such as random testing, code coverage testing, and traditional reinforcement learning testing to detect explicit defects.

[0003] Unlike explicit functional defects, software aging defects are insidious, cumulative defects. Their core cause is a vulnerability in the application's resource management logic, leading to the inability to timely and completely reclaim various resources. These include memory objects, Binder communication objects, Socket handles, UI objects, Activity instances, and asynchronous task resources. These defects do not trigger exceptions after a single or few operations; rather, they accumulate resource consumption over long periods of repetitive user activity, eventually causing serious problems such as application lag, response delays, memory overflows, and process crashes. This is a core hidden danger affecting the long-term stability of Android applications.

[0004] Currently, the mainstream detection solution for Android application aging defects in the industry is long-term random stress testing based on the Monkey tool. This method generates a massive number of disordered random events to drive the application's operation and then roughly judges aging issues based on overall resource trends. This solution has four major drawbacks: First, the testing cycle is extremely long, usually requiring several hours or even more than ten hours to observe identifiable aging phenomena, resulting in extremely high testing computational and time costs; second, the test events are disordered and intertwined, making it impossible to isolate specific defect trigger paths, only determining that the application as a whole has aging issues, but not being able to pinpoint the root cause; third, it cannot generate standardized, reproducible short trigger sequences, making defect diagnosis and repair extremely difficult; fourth, traditional testing is centered on interface coverage and code coverage, and does not actively focus on high-risk states with abnormal resource fluctuations, resulting in poor test targeting and too many invalid traversals.

[0005] In summary, existing Android aging detection technologies suffer from shortcomings such as low efficiency, weak targeting, difficulty in defect localization, and poor reproducibility. There is an urgent need for an efficient, accurate, and traceable intelligent aging defect detection solution for black-box scenarios. Summary of the Invention

[0006] The purpose of this invention is to provide a black-box detection method for software aging defects in Android applications, which solves the technical problems of low efficiency, weak ability to explore high-risk states, inability to accurately locate defects, and poor reproducibility in the prior art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: The technical solution provided by this invention is: A black-box detection method for software aging defects in Android applications is provided. This method automates the detection of aging defects in Android applications under a pure black-box testing scenario without source code or code instrumentation. The method includes the following steps: S1. Test environment initialization: Start the Android test terminal, install and initialize the Android application to be tested, clear the application cache, reset the initial running state, and initialize the reinforcement learning parameters, Q table, set of accessed interface states, defect storage set and resource indicator collection parameters. S2. Standardized construction of interface state: The Activity information and interactive control hierarchy of the current foreground interface of the application under test are captured by automated testing tools to construct a standardized state vector that uniquely represents the current page. S3. State Novelty Determination: By comparing the current state vector with the historical state vectors in the visited state set using a similarity algorithm, new application interface states that have not been traversed are identified. S4. Runtime resource data collection: Before and after each interface interaction event, multi-dimensional runtime resource indicators of the application process under test are collected synchronously, and resource change data corresponding to adjacent state transitions are calculated. S5. Resource-aware reward calculation and strategy iteration: Based on the state exploration results, resource fluctuation changes and defect identification, a resource-aware reward function is constructed. The event selection strategy is iteratively optimized through reinforcement learning algorithm to prioritize the exploration of application interface states with significant resource fluctuations and high aging risk. S6. Generation of metamorphic relationship event sequence: For each interface determined to be in a new state, match the preset resource immutability metamorphic event sequence to generate a standardized source event sequence and follow event sequence that can be executed repeatedly. S7. Automated determination of aging defects: The system continuously collects resource time series data by looping through the following event sequence and uses statistical trend analysis algorithms to determine whether the resources have a continuous positive growth trend. If there is a significant positive growth trend, the system determines that the current interface and the corresponding operation sequence have software aging defects. S8. Defect Report Output: Summarize the defect trigger interface status, standardized event sequence, abnormal resource indicators, and trend statistical parameters to generate a reproducible and traceable standardized aging defect detection report.

[0008] Furthermore, in step S2, the expression for the standardized state vector is: ;in, It is a one-dimensional valid code for the current foreground Activity, uniquely identifying the page type; It encodes the availability of all interactive controls on the current screen, representing the operable state of the page controls.

[0009] Furthermore, in step S3, the method for determining the novelty of the state is as follows: calculate the Jaccard distance between the current interface control vector and all historical control vectors in the visited state set, select the minimum distance as the state difference degree, and determine that the current interface is a completely new unvisited state when the state difference degree is greater than a preset similarity threshold.

[0010] Furthermore, in step S5, the formula for calculating the total reward of the resource-aware reward function is as follows: in, The reward for exploring states is used to incentivize traversing entirely new states and to penalize visits to duplicate states. Rewards for resource changes are used to quantify the risk of resource fluctuations. A defect discovery reward is provided to incentivize test paths that can detect aging defects.

[0011] Furthermore, the resource change reward The calculation steps include: 5.1 Calculation of Time-Series Changes in Single Resource Types: In the formula, Let be the occupancy value of the i-th type of resource at time t. Let be the occupancy value of the i-th type of resource at time t+1; 5.2 Weighted summation of original resource rewards: In the formula, Let be the weight coefficient of the i-th type of resource. This represents the total number of resource indicators. 5.3 Smooth noise reduction for sliding windows: ; In the formula, K is the order of the sliding window; 5.4 Z-score standardization and dimensional unification: ; In the formula, μ is the mean of the smoothed reward. The smoothed standard deviation of the reward; 5.5. Tanh-bounded scaling yields the final resource reward: Furthermore, in step S6, the resource invariance degradation event sequence includes five types of standardized closed-loop operation sequences: screen rotation recovery sequence, return to desktop application recovery sequence, system notification bar on / off sequence, text input clearing sequence, and interface bidirectional sliding sequence; all five types of event sequences can complete a complete resource allocation and release closed loop, satisfying the resource invariance detection conditions.

[0012] Furthermore, in step S7, the statistical trend analysis adopts linear regression analysis, with a preset significance level threshold of 0.05; when the regression slope of the resource time series is positive and the significance P value is less than 0.05, it is determined that the resource has a significant and continuous positive growth and there is a software aging defect.

[0013] Furthermore, in step S5, the reinforcement learning adopts a decay ε-greedy strategy, retaining a high probability of random exploration in the early stage of the test iteration to achieve full traversal of interface states; in the later stage of the test iteration, the probability of random exploration is gradually decayed, and test paths with high resource risk and high reward are reused first.

[0014] Furthermore, in step S4, the multi-dimensional runtime resource metrics include five categories: memory, communication, interface object, file, and computing. Specifically, these include Java heap memory, native heap memory, process resident set size, local Binder object, proxy Binder object, Parcel object, Socket handle, View object, Activity instance, number of application resource files, and CPU utilization.

[0015] Furthermore, in step S7, an early termination optimization mechanism is added: after executing a preset proportion of the follow event sequence, if all resource indicators do not show a positive growth trend, the defect detection process in the current state is terminated in advance, saving test computing power and time costs.

[0016] The beneficial effects of this technical solution are: (1) Breaking through the limitations of traditional coverage-oriented testing, optimizing testing strategies with resource fluctuation risk as the core, actively focusing on interface states with high aging risk, avoiding a large number of invalid state traversals, and significantly improving the speed of defect induction. Compared with traditional stress testing, the detection efficiency is improved by more than 80%.

[0017] (2) Based on the transformation relationship of resource invariance, a standardized short event closed-loop sequence is designed. Through controllable repeated operations, the accumulation of resource leakage is accelerated, replacing the traditional disordered and ultra-long-term random stress test, which greatly reduces the test time and computing power cost.

[0018] (3) Based on linear regression trend analysis, an automated test prediction is constructed. Without the need for explicit anomalies such as application crashes, freezes, and errors, it can accurately identify hidden aging defects corresponding to continuous resource growth and cover hidden problems that traditional testing cannot identify.

[0019] (4) The detection results fully record the defect triggering interface, standardized triggering event sequence, abnormal resource indicators, growth slope, and significance parameters. Developers can directly reproduce the defect and locate the root cause of the vulnerability, which greatly reduces the cost of defect repair.

[0020] (5) Pure black box is compatible with all Android applications without customization or modification; it is compatible with the detection of multiple resources such as memory, communication, interface, file and computing, supports various user interaction modes, and can flexibly expand event sequences and detection indicators to meet the testing needs of different types of Android applications. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of the system module composition of a black-box detection method for software aging defects in Android applications proposed in this invention. Figure 2 This is the content of the resource index table for a black-box detection method for software aging defects in Android applications proposed in this invention. Detailed Implementation

[0022] In view of the shortcomings of the prior art, the inventors of this invention, through long-term research and extensive practice, have proposed the technical solution of this invention. The technical solution, its implementation process, and principles will be further explained below with reference to the accompanying drawings and specific implementation examples in the embodiments of this application.

[0023] It should be noted that the embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention. The described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, the present invention covers any substitutions, modifications, equivalent methods and solutions made on the spirit, principles and scope of the present invention as defined by the claims. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] In the description of this application, the terms "first," "second," "third," and similar words do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "a" or "one," and similar words, do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "comprising" or "including," and similar words, mean that the elements or objects preceding "comprising" or "including" encompass the elements or objects listed following "comprising" or "including," and their equivalents, but do not exclude other elements or objects. The terms "connected" or "linked," and similar words, are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.

[0025] In the description of this application, the terms "center," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used solely for the convenience of describing this application and for simplification, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. Furthermore, when using positional terms such as "both sides," "outer side," and "upper and lower," it should be understood that they are used only for ease of understanding and description, taking into account that the structure may be oriented to other positions.

[0026] In the description of this application, unless otherwise expressly specified and limited, the technical or scientific terms used shall have the ordinary meaning understood by a person with ordinary skills in the art to which this application pertains. Terms such as “installation,” “connection,” and “joining” shall be interpreted broadly, for example, as fixed connection, detachable connection, mating connection, or integral connection. For a person skilled in the art, the specific meaning of the above terms in this application can be understood according to the specific circumstances.

[0027] The specific implementation process is as follows: Example 1: Please see Figure 1-2This invention provides a technical solution: a black-box detection method for software aging defects in Android applications. This embodiment is the most complete and optimal implementation case of this invention, fully covering all core technical modules, including interface state vector construction, state novelty determination algorithm, complete resource-aware reward calculation logic, decaying ε-greedy reinforcement learning strategy, five types of resource invariance transformation event sequences, full-dimensional resource indicator collection, linear regression trend determination mechanism, and early termination optimization mechanism. It is a complete implementation process without any missing technologies. The test object in this embodiment is a mainstream Android email application on the market. Such applications have long-term background persistence, frequent foreground / background switching, and repeated reconstruction of page lifecycles, which easily leads to memory, Binder communication, UI interface, and Activity instance resource leaks. This is a typical high-incidence test scenario for Android software aging defects.

[0028] Test hardware environment: Android 11.0 emulator, 4-core CPU, 4GB RAM, 64GB storage space; Test software tool stack: Appium automation engine paired with UIAutomator interface parsing tool to achieve interface capture, control recognition, and full-category user event simulation; Resource data acquisition tool: ADB debugging tool + Android system underlying performance monitoring interface to collect process-level resource usage data with high precision.

[0029] All global fixed hyperparameters are configured as follows: Jaccard distance threshold for interface state similarity 0.85, order of smooth sliding window for reward K=5, significance level for aging defect judgment α=0.05, number of times a single detection of metamorphosis event sequence is repeated 30 times, initial random exploration probability of reinforcement learning 0.9, exploration probability iteration decay coefficient 0.95, and early termination ratio threshold 60%.

[0030] The unified preprocessing process for testing is as follows: install the email application to be tested, clear all cached data of the application, reset the application to its factory default running state, disable background auto-start and push permissions, eliminate historical running remnants and system variable interference, and ensure that the initial environment of each round of testing is completely consistent.

[0031] After the test initialization is complete, the automation engine automatically starts the application under test, traversing all core interfaces layer by layer, including the splash screen, email homepage, email list page, email details page, user center page, and settings page. For each page, it constructs a unique, standardized state vector. The complete vector structure is as follows: .in, It serves as a one-dimensional valid code for the current foreground Activity, distinguishing different page types through a unique code; It encodes the availability of all interactive controls on the current interface, accurately records the operable states of buttons, input boxes, sliding components, and pop-up controls, and fully represents the real-time interactive features of the page.

[0032] The state novelty assessment is fully implemented using the Jaccard minimum distance matching algorithm: frame-by-frame, the Jaccard distance between the current interface control vector and all historical control vectors in the visited state set is calculated, and the minimum value among all distances is taken as the true state difference between the current page and historical pages. When the state difference value is greater than a preset threshold of 0.85, the current interface is strictly determined to be a completely new, untraversed interface and included in the high-priority detection set. In the initial testing phase of this embodiment, the system accurately identified the email homepage as a completely new, high-risk state. This page has a large number of dynamic controls, frequent network data refreshes, dense page lifecycle callbacks, significant resource fluctuation characteristics, and a high probability of triggering aging defects.

[0033] This embodiment fully implements the original multi-level resource awareness reward calculation system of this invention. The total reward consists of three linearly superimposed parts: state exploration reward, resource change reward, and defect discovery reward. It fully realizes the intelligent testing orientation of "exploring new states, focusing on high risks, and incentivizing defect discovery". The total reward calculation formula is as follows: In the formula, The core function of the state exploration reward is to guide the diversity of state traversal, giving positive rewards when visiting a brand new untraversed interface and negative penalty rewards when repeatedly visiting a previously traversed interface. Incentives are provided for defect discovery, with high positive rewards awarded for successfully identifying new aging defects, thus reinforcing the reuse priority of high-risk defect paths; The reward for changes in core resources, used to quantify the resource fluctuation risk of a single operation, is the core innovation of this invention that distinguishes it from traditional coverage testing. The complete calculation process is as follows: Step 1: Calculation of temporal changes in single-type resources. To eliminate instantaneous resource fluctuations and noise interference in the Android system, a logarithmic difference method is used to smoothly calculate resource fluctuations between adjacent time points. The formula is as follows: In the formula, Let be the real-time occupancy value of the i-th type of resource at time t. To capture the real-time resource occupancy value for the next moment, logarithmic compression is used to weaken extreme data interference and accurately capture minute, continuous cumulative changes in resources.

[0034] Step 2: Calculate the original reward using a weighted summation of multiple resources. Integrate the fluctuation characteristics of resources across all dimensions, and combine the aging risk weights of different resources to generate the original reward, as shown in the following formula: In this embodiment, the total number of resources It covers all detection resource indicators across five major categories; initial weights for all resources. The system assigns equal values ​​and adaptively optimizes weights during test iterations, automatically increasing the weight coefficients of high-frequency defective resources such as memory, Binder, and Activity, and strengthening the exploration priority of high-risk resources.

[0035] Step 3: Sliding window smoothing and noise reduction. A K=5 order sliding window is used to perform mean filtering on the original reward to eliminate random noise from a single operation and ensure the stability of the reward iteration. The formula is as follows: Step 4: Z-score standardization and unification. Data standardization is performed based on the recent reward mean and standard deviation to eliminate differences in the units of different resource metrics and adapt to the iterative needs of reinforcement learning. The formula is as follows: In the formula, This represents the recent smoothed reward average. This represents the recent smoothed reward standard deviation.

[0036] Step 5: Use tanh bounded scaling to output the final resource reward. Constrain the reward value range to avoid extreme values ​​causing algorithmic oscillations. The formula is as follows: Through the above complete set of closed-loop formulas, the system can accurately quantify the aging risk of each interface operation, continuously guide the reinforcement learning strategy to prioritize traversing high-risk interfaces, and avoid traversing ineffective static pages.

[0037] This embodiment fully implements the five categories and 13 runtime resource indicators of this invention, collecting them synchronously throughout the entire process and participating in reward calculation and defect determination, with no indicators omitted. The specific collection indicators are detailed below: Memory metrics: Java heap memory (KB), Native heap memory (KB), process resident set size (KB); Communication metrics: Number of local Binder objects, number of proxy Binder objects, number of Parcel objects, number of Socket handles; UI object metrics: Number of View control objects, number of application context instances, number of live Activity instances; File metrics: Number of loaded resource files; Computation metrics: CPU utilization (%).

[0038] This embodiment fully configures the five types of standardized resource closed-loop transformation event sequences of the present invention. All sequences have a complete resource allocation and release lifecycle, meet the resource invariance detection conditions, and can automatically match and adapt according to different interface states. 1. Screen rotation recovery sequence: After rotating the screen 90°, immediately rotate it in the opposite direction to restore the original state, triggering the complete destruction and reconstruction lifecycle of the Activity, and detecting resource leaks during page reconstruction; 2. Return to desktop application recovery sequence: When the application is running in the foreground, it jumps to the desktop, remains still for 2 seconds, and then resumes running in the foreground to detect resource leaks during the foreground / background switching lifecycle; 3. System notification bar toggle sequence: Pull down to open the system notification bar and immediately collapse it to detect resource retention defects in scenarios where the application foreground is briefly interrupted; 4. Text Input Clear Sequence: Enter a random string into an editable text box, and immediately clear the text after input is complete to detect resource leaks in text interaction callback logic; 5. Two-way scrolling sequence: After performing a one-way scroll on a scrollable list or page, immediately reverse the scrolling and reset it to detect resource leaks in the scroll component refresh callback.

[0039] For the high-risk state of the email homepage in this embodiment, the system automatically matches the optimal adaptation sequence: return to desktop - restore application sequence, which accurately adapts to the lifecycle characteristics of the page. Unified stabilization processing is performed before testing: before each execution of the event sequence, the Android system's GC garbage collection is actively triggered, and a 2-second pause is allowed to eliminate interference from historical resource residues; the target sequence is executed 30 times consecutively, and all 13 resource indicators are collected after each execution to construct a complete time-series dataset.

[0040] This embodiment employs a decaying ε-greedy strategy throughout the event selection and strategy iteration process: In the early stages of the test iteration, a high random exploration probability of 0.9 is maintained to ensure that all interface states are fully traversed and to avoid missing potentially high-risk states; as the number of iterations increases, the exploration probability continuously decays with a coefficient of 0.95, gradually reducing the proportion of random exploration, prioritizing the reuse of high-reward, high-aging-risk high-quality test paths from historical tests, and achieving a dynamic balance of "comprehensive exploration in the early stage and precise in-depth cultivation in the later stage".

[0041] This embodiment uses linear regression statistical trend analysis to determine defects, with a preset significance level. =0.05, complete judgment criteria: Perform linear regression fitting on the resource time series. When the fitting slope is positive and the significance P value is less than 0.05, it is judged that the resource has a continuous and significant positive growth, and the current interface and corresponding event sequence are identified as having software aging defects; if there is no significant growth, the resource is judged to be operating normally.

[0042] The actual test results of this embodiment show that six indicators, namely Java heap memory, Native heap memory, resident set memory, local Binder objects, View controls, and Activity instances, have shown significant positive growth, with P values ​​all less than 0.05, meeting the criteria for aging defect judgment; the remaining indicators such as Socket, Parcel, and CPU show no significant fluctuations and no risk of aging.

[0043] This embodiment fully utilizes the early termination optimization mechanism, setting the sequence execution ratio threshold to 60%. During 30 repeated sequence executions, a pre-judgment is performed after 18 executions. If all 13 resource indicators show no positive growth trend, the current state detection is terminated directly, eliminating the need to complete all iterations and significantly saving time spent on ineffective testing. In this embodiment, high-risk states did not trigger early termination, and all 30 iterations were completed, ensuring defect detection accuracy.

[0044] The system automatically generates a complete standardized defect report, including information about the application under test, the defect triggering interface, a standardized trigger event sequence, 13 resource indicator data, the growth slope of abnormal indicators, the significance P-value, page screenshots, and complete reproduction steps. Developers can reproduce the defect 100% stably based on the short sequence, pinpointing the root cause as a vulnerability in the application's task stack management logic. This vulnerability stems from the failure to promptly destroy Activity instances and release Binder communication and UI control resources during foreground / background switching, leading to continuous resource accumulation. After the vulnerability is fixed and testing is repeated, all abnormal indicator growth trends completely disappear, the P-value is >0.05, the defect is completely fixed, and the detection accuracy and effectiveness of this invention are verified.

[0045] Example 2: Please see Figure 1-2 The present invention provides a technical solution: a black-box detection method for software aging defects in Android applications. This embodiment fully verifies the technical necessity of the core modules of the resource-aware reward algorithm, smoothing and noise reduction mechanism, and decay exploration strategy of the present invention through three sets of controlled ablation experiments. All experimental environments and parameters are completely consistent with those in Embodiment 1. The test object is also an Android email application, only a single variable is replaced to quantify the technical gains of each module.

[0046] Control group 1: The resource-aware reward mechanism was removed, and a traditional pure interface coverage-oriented Q-learning strategy was adopted, with new state access as the sole reward criterion. Control group 2: The complete resource reward calculation formula is retained, the sliding window smoothing and standardization are cancelled, and the original reward value is directly used for iteration; Experimental group: The complete technical solution of this invention is adopted, including all formula derivation, smoothing and noise reduction, normalization scaling, attenuation ε-greedy strategy, and early termination mechanism.

[0047] The complete results of the control experiment are as follows: Control group 1: The test failed traversal of 82% of the interfaces. A large amount of computing power was consumed on static, risk-free pages such as settings and about pages. It was unable to actively focus on high-risk interfaces with resource fluctuations. On average, it took 3.8 hours to detect only minor resource fluctuations. It was unable to pinpoint the precise defect trigger sequence, and the defects were not reproducible. Control group 2: The original reward data was extremely noisy, the algorithm iteration oscillated frequently, the exploration priority of high-risk states was unstable, sometimes traversing high-risk pages and sometimes traversing static pages, the detection stability was poor, the average detection time was 45 minutes, the defect false judgment rate was high and the results were unreliable. Experimental group: The algorithm has stable iteration and precise strategy guidance. It can actively focus on high-risk interfaces of aging. The invalid traversal rate is less than 10%. The average accurate detection time is 9.5 minutes. The defect false judgment rate is 0. The trigger sequence is 100% reproducible.

[0048] This embodiment fully verifies that the multi-level resource perception reward calculation formula, smoothing noise reduction and standardization mechanism, and decay exploration strategy independently designed in this invention are the core keys to achieving efficient, accurate and stable aging detection. The absence of any module will lead to a significant decrease in detection effect.

[0049] Example 3: Please see Figure 1-2 The present invention provides a technical solution: a black-box detection method for software aging defects in Android applications. To fully verify the universality and scalability of the technical solution of the present invention, this embodiment selects three mainstream Android applications—video, social, and e-commerce—to conduct full-process black-box detection. Based on the core technical framework of the present invention, it adapts to the business characteristics of each application category, expands the exclusive transformation event sequence, and completely replicates the entire detection process of the present invention without the need for source code or instrumentation.

[0050] Based on the core logic of resource invariance in this invention, a customized closed-loop event sequence adapted for video applications is developed: a video playback-pause-exit sequence. This sequence is used to detect leaks in video decoding threads, playback handles, cached resources, and asynchronous rendering resources. The testing process fully executes the entire process of state construction, resource collection, reward iteration, repeated execution, and trend analysis. Real-world testing shows that it can accurately detect aging defects in some video applications where cached resources and decoding threads cannot be reclaimed after prolonged playback and exit. The resource sequence shows a significant growth trend, meeting the defect judgment criteria of this invention.

[0051] A customized transformation sequence specifically for social applications: Login-Logout-Clear Cache sequence, adapted to the resource lifecycle characteristics of social application account login, session connection, and data caching, used to detect cumulative leakage issues of user session resources, network connection handles, and local cache resources. Testing can effectively identify hidden resource aging defects after social applications have been running in the background for a long time, and the detection results are stable and reproducible.

[0052] Customized transformation sequence for e-commerce applications: List refresh-page return sequence, adapted to the business characteristics of high-frequency list loading, image rendering, and network requests in e-commerce applications. It is used to detect leakage issues of View rendering objects, image cache, and network request resources, and can accurately identify UI resource accumulation and aging defects caused by frequent page refreshes.

[0053] All three types of applications use a pure black-box detection method, requiring no specific program modification, and can all be adapted to the complete set of algorithms and judgment rules of this invention, fully demonstrating that this invention has universal detection capabilities for all types of Android applications.

[0054] Example 4: Please see Figure 1-2 The present invention provides a technical solution: a black-box detection method for software aging defects in Android applications. This embodiment specifically verifies the early termination optimization mechanism. Based on the complete technical solution of embodiment 1, all parameters remain unchanged, only the early termination logic is enabled, and a 60% sequence execution ratio threshold is set to quantify the optimization effect of the mechanism on test efficiency.

[0055] The experiment employed large-scale page traversal testing, covering various scenarios including high-risk dynamic pages, low-risk static pages, and blank configuration pages. Batch test results showed that for static pages without aging risk, the system could terminate testing early after completing 60% of the sequence execution, eliminating the need for 30 unnecessary full iterations, thus reducing the average invalid test time per page by 62%. In large-scale automated testing scenarios, the overall test time was reduced by more than 58%, with no missed or false detections for any defect samples, maintaining 100% detection accuracy. This embodiment demonstrates that this optimization mechanism can significantly reduce testing computational power and time costs without sacrificing detection accuracy, making it suitable for industrial-scale automated batch testing scenarios.

[0056] To visually demonstrate the technical advantages of this invention, a comparative experiment was conducted between the complete technical solution of this invention and the mainstream Monkey random stress test in the industry. The test application, defect detection criteria, and testing environment were standardized. The experimental data are as follows: Traditional Monkey stress testing: It uses random and unordered event traversal, with an average effective defect detection time of 4.2 hours and an invalid and redundant operation rate of 87%. It can only roughly determine that the application as a whole has aging problems, and cannot output precise trigger states and event sequences, so defects cannot be accurately reproduced and located. The technical solution of this invention is based on resource-aware intelligent targeted traversal. The average effective defect detection time is 9.5 minutes, the invalid operation rate is less than 10%, and it can output standardized, 100% reproducible trigger states and short event sequences. It can accurately locate abnormal resource indicators and defect root causes, and improve the overall detection efficiency by more than 80%.

[0057] The core technical framework of this invention has good replaceability and scalability. Without changing the core detection principle, resource invariance degradation logic, and intelligent exploration mechanism, the following equivalent substitutions can be made, all of which can achieve the same aging detection effect: 1. Reinforcement learning algorithm replacement: The core Q-Learning algorithm can be equivalently replaced by various policy learning algorithms such as SARSA, Deep Q-Network (DQN), and PPO policy gradient algorithm; 2. State similarity algorithm replacement: Jaccard distance can be replaced by state matching algorithms such as tree edit distance, cosine distance, and feature embedding similarity; 3. Trend detection algorithm replacement: Linear regression trend analysis can be replaced by high-precision statistical test methods such as Mann-Kendall monotonicity test and Theil-Sen slope estimation; 4. Replacement of testing tools and equipment: The Appium automation engine can be replaced with native Android testing frameworks such as UIAutomator and Espresso, and the emulator can be replaced with a real Android testing terminal; 5. Expanded detection content: Custom resource metrics such as thread count, file handle, and asynchronous task count can be added, and various resource closed-loop operation sequences can be expanded according to business scenarios.

[0058] The above descriptions are merely embodiments of the present invention, and common knowledge regarding specific technical solutions or characteristics is not elaborated upon here. It should be noted that those skilled in the art can make various modifications and improvements without departing from the technical solutions of the present invention, and these should also be considered within the scope of protection of the present invention. These modifications and improvements will not affect the effectiveness of the implementation of the present invention or the practicality of the patent. The scope of protection claimed in this application should be determined by the content of its claims, and the specific embodiments described in the specification can be used to interpret the content of the claims.

Claims

1. A black-box detection method for software aging defects in Android applications, characterized in that, To automate the detection of aging defects in Android applications in a pure black-box testing scenario with no source code and no code instrumentation, the following steps are included: S1. Test environment initialization: Start the Android test terminal, install and initialize the Android application to be tested, clear the application cache, reset the initial running state, and initialize the reinforcement learning parameters, Q table, set of accessed interface states, defect storage set and resource indicator collection parameters. S2. Standardized construction of interface state: The Activity information and interactive control hierarchy of the current foreground interface of the application under test are captured by automated testing tools to construct a standardized state vector that uniquely represents the current page. S3. State Novelty Determination: By comparing the current state vector with the historical state vectors in the visited state set using a similarity algorithm, new application interface states that have not been traversed are identified. S4. Runtime resource data collection: Before and after each interface interaction event, multi-dimensional runtime resource indicators of the application process under test are collected synchronously, and resource change data corresponding to adjacent state transitions are calculated. S5. Resource-aware reward calculation and strategy iteration: Based on the state exploration results, resource fluctuation changes and defect identification, a resource-aware reward function is constructed. The event selection strategy is iteratively optimized through reinforcement learning algorithm to prioritize the exploration of application interface states with significant resource fluctuations and high aging risk. S6. Generation of metamorphic relationship event sequence: For each interface determined to be in a new state, match the preset resource immutability metamorphic event sequence to generate a standardized source event sequence and follow event sequence that can be executed repeatedly. S7. Automated determination of aging defects: The system continuously collects resource time series data by looping through the following event sequence and uses statistical trend analysis algorithms to determine whether the resources have a continuous positive growth trend. If there is a significant positive growth trend, the system determines that the current interface and the corresponding operation sequence have software aging defects. S8. Defect Report Output: Summarize the defect trigger interface status, standardized event sequence, abnormal resource indicators, and trend statistical parameters to generate a reproducible and traceable standardized aging defect detection report.

2. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S2, the expression for the standardized state vector is: ;in, It is a one-dimensional valid code for the current foreground Activity, uniquely identifying the page type; It encodes the availability of all interactive controls on the current screen, representing the operable state of the page controls.

3. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S3, the method for determining the novelty of the state is as follows: calculate the Jaccard distance between the current interface control vector and all historical control vectors in the visited state set, select the minimum distance as the state difference degree, and determine that the current interface is a brand new unvisited state when the state difference degree is greater than the preset similarity threshold.

4. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S5, the formula for calculating the total reward of the resource-aware reward function is as follows: in, The reward for exploring states is used to incentivize traversing entirely new states and to penalize visits to duplicate states. Rewards for resource changes are used to quantify the risk of resource fluctuations. A defect discovery reward is provided to incentivize test paths that can detect aging defects.

5. A black-box detection method for software aging defects in Android applications according to claim 4, characterized in that, The resource change reward The calculation steps include: 5.1 Calculation of Time-Series Changes in Single Resource Types: In the formula, Let be the occupancy value of the i-th type of resource at time t. Let be the occupancy value of the i-th type of resource at time t+1; 5.2 Weighted summation of original resource rewards: In the formula, Let be the weight coefficient of the i-th type of resource. This represents the total number of resource indicators. 5.3 Smooth noise reduction for sliding windows: ; In the formula, K is the order of the sliding window; 5.4 Z-score standardization and dimensional unification: ; In the formula, μ is the mean of the smoothed reward. The smoothed standard deviation of the reward; 5.

5. Tanh-bounded scaling yields the final resource reward: .

6. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S6, the resource invariance transformation event sequence includes five types of standardized closed-loop operation sequences: screen rotation recovery sequence, return to desktop application recovery sequence, system notification bar on / off sequence, text input clearing sequence, and interface bidirectional sliding sequence; all five types of event sequences can complete the complete resource allocation and release closed loop, satisfying the resource invariance detection conditions.

7. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S7, the statistical trend analysis adopts linear regression analysis, with a preset significance level threshold of 0.

05. When the regression slope of the resource time series is positive and the significance P value is less than 0.05, it is determined that the resource has a significant and continuous positive growth and there is a software aging defect.

8. The black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S5, the reinforcement learning adopts a decay ε-greedy strategy. In the early stage of the test iteration, a high probability of random exploration is retained to achieve full traversal of the interface states. In the later stage of the test iteration, the probability of random exploration is gradually decayed, and test paths with high resource risk and high reward are reused first.

9. A black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S4, the multi-dimensional runtime resource metrics include five categories: memory, communication, interface object, file, and computing. Specifically, they include Java heap memory, native heap memory, process resident set size, local Binder object, proxy Binder object, Parcel object, Socket handle, View object, Activity instance, number of application resource files, and CPU utilization.

10. A black-box detection method for software aging defects in Android applications according to claim 1, characterized in that, In step S7, an early termination optimization mechanism is added: after executing a preset proportion of the follow event sequence, if all resource indicators do not show a positive growth trend, the defect detection process in the current state is terminated in advance, saving test computing power and time costs.