A runtime-based global watermarking method and apparatus
By deploying window-level and view controller-level probes to monitor and adjust the watermark mask position in real time, the problem of unstable global watermark display in the iOS system was solved, and the stable display of global watermark and information traceability function were realized.
Patent Information
- Application Number
- CN202210447042.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-26
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-04-26
AI Technical Summary
Implementing a global watermark in iOS is difficult, especially when the watermark is obscured by screen recording or user interaction modules, which makes it hard to maintain the watermark display and affects information traceability and copyright statements.
By deploying window-level and view controller-level probes, changes in the window and view hierarchy are monitored in real time, and the position of the watermark mask is dynamically adjusted to ensure that the watermark is always displayed on the screen without affecting user operation.
It achieves stable display of global watermarks in the iOS system, supports information traceability and copyright statement functions, and avoids the problem of watermarks being obscured or covered.
Smart Images

Figure CN114756836B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, and in particular to a runtime-based global watermark processing method and device. BACKGROUND
[0002] At present, in the iOS system, some APPs can add a watermark effect to the lower right corner of some pictures to determine the ownership of a specific picture, and some APPs can add a watermark effect to the content of files such as Word files and PDF files. However, on the one hand, in some specific scenarios, local watermarks cannot meet the actual needs, such as when screen recording, the specific watermark of a specific module may not be able to be tracked, at which time a global watermark needs to be presented on the entire screen of the phone; or if an enterprise internal APP itself does not have global watermark processing, sensitive information is leaked out by being screened or photographed, it is difficult to trace the source. On the other hand, in terms of the characteristics of the APP itself in the iOS system, various application internal view switching, shielding, pop-up boxes or pop-up keyboards can easily cause the watermarks originally deployed on the page to be shielded and covered, disappear with the page, or cause the watermarks to appear on top of the user interaction modules such as buttons and keyboards, making it difficult to achieve the function of global watermarking in the iOS system on the market.
[0003] For example, many people are used to adding a custom floating view to the keyWindow, that is, the general implementation principle of the watermark. However, when the windowLevel of other custom UIWindow is raised by oneself or other third-party frameworks, or other UIWindow with the same windowLevel changes the display state (such as.hidden = NO, makeKeyAndVisible, etc.) later, and is not set as the keyWindow, the result is that the UIWindow being displayed is not the keyWindow, so that the custom view added to the keyWindow is covered and cannot be displayed.
[0004] For another example, in the operating system after iOS9, the pop-up keyboard is in another window UIRemoteKeyboardWindow, which is on top of all other windows. It has always been a problem to display the watermark in the presence of the keyboard without affecting the keyboard tapping. In addition, when using general static watermarks to cover the view, because the page hierarchy has been fixed, when the system-level input box, album selection box or sharing pop-up box and other system-level higher pages are popped up, either the page hierarchy will be affected, or the normal tapping touch of the user will be affected. SUMMARY
[0005] An object of the present application is to provide a runtime-based global watermark processing method and device to ensure that a watermark is always kept on the screen by applying a global watermark, without affecting the user's operation, so as to realize information tracing and copyright declaration functions through the global watermark.
[0006] According to an aspect of the present application, a runtime-based global watermark processing method, wherein the method comprises:
[0007] deploying a window-level probe to monitor the creation of a window in real time, and notifying a watermark management module to create a corresponding watermark mask and add the watermark mask to the newly created window when a new window creation action is monitored;
[0008] deploying a view controller-level probe to monitor the change of the view hierarchy of a window in real time, and notifying the watermark management module to adjust the view hierarchy of the watermark mask in the new window when a change of the view hierarchy is monitored.
[0009] Further, in the above-mentioned runtime-based global watermark processing method, wherein the deploying a window-level probe to monitor the creation of a window in real time comprises:
[0010] implanting a set root view function of a window into a first probe to monitor the creation of a window in real time through the first probe, wherein the set root view function is used for the creation of the new window.
[0011] Further, in the above-mentioned runtime-based global watermark processing method, wherein the deploying a view controller-level probe to monitor the change of the view hierarchy of a window in real time comprises:
[0012] implanting a set view function of a view controller into a second probe to monitor the change of the view hierarchy of a window in real time through the second probe.
[0013] Further, in the above-mentioned runtime-based global watermark processing method, wherein the adding the watermark mask to the newly created window comprises:
[0014] traversing the view hierarchy of the new window, and adding the watermark mask above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window.
[0015] Further, in the above-mentioned runtime-based global watermark processing method, wherein the notifying the watermark management module to adjust the view hierarchy of the watermark mask in the new window comprises:
[0016] adjusting the position of the watermark mask in the view hierarchy of the new window, so that the watermark mask is always above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window.
[0017] According to another aspect of the present application, there is also provided a non-transitory storage medium having stored thereon computer readable instructions, which, when executed by a processor, cause the processor to implement a runtime-based global watermark processing method as described above.
[0018] According to another aspect of the present application, there is also provided a runtime-based global watermark processing device, wherein the device comprises:
[0019] one or more processors;
[0020] a non-transitory storage medium for storing one or more computer readable instructions,
[0021] when the one or more computer readable instructions are executed by the one or more processors, cause the one or more processors to implement a runtime-based global watermark processing method as described above.
[0022] Compared with the prior art, in the present application, a window-level probe is deployed, the creation of a window is monitored in real time by the window-level probe, and when the creation of a new window is monitored, a watermark management module is notified to create a corresponding watermark mask, and the watermark mask is added to the created new window; a view controller-level probe is deployed, the change of the view hierarchy of a window is monitored in real time by the view controller-level probe, and when the change of the view hierarchy is monitored, the watermark management module is notified to adjust the view hierarchy in which the watermark mask is located in the new window, so as to monitor the creation of a new window and the change of the view hierarchy when a global watermark is applied, ensure that the watermark is always kept on the screen, and at the same time, do not affect the operation of the user, so that the function of tracing the source of information and declaring the copyright can be realized through the global watermark. BRIEF DESCRIPTION OF DRAWINGS
[0023] Other features, objects, and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments made with reference to the attached drawings:
[0024] Figure 1 showing a flowchart of a runtime-based global watermark processing method according to an aspect of the present application;
[0025] Figure 2A view hierarchy diagram showing a runtime-based global watermarking method according to an aspect of the present application;
[0026] Figure 3 A method call diagram before Runtime probe implantation showing a runtime-based global watermarking method according to an aspect of the present application;
[0027] Figure 4 A method call diagram after Runtime probe implantation showing a runtime-based global watermarking method according to an aspect of the present application;
[0028] Figure 5 A global watermarking effect diagram showing a runtime-based global watermarking method according to an aspect of the present application.
[0029] The same or similar reference numerals in the drawings denote the same or similar components. DETAILED DESCRIPTION
[0030] The present application is described in further detail below with reference to the accompanying drawings.
[0031] In one typical configuration of the present application, the terminal, the device of the service network and the trusted party each include one or more processors (CPUs), input / output interfaces, network interfaces and memories.
[0032] The memory can include non-persistent memory in the computer readable medium, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer readable media.
[0033] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer readable media does not include non-transitory computer readable media such as modulated data signals and carriers.
[0034] As Figure 1 shown, a flowchart of a runtime-based global watermark processing method according to an aspect of the present application. The method includes steps S11 and S12, which include the following steps:
[0035] Step S11, deploying a window-level probe, monitoring the creation of a window in real time through the window-level probe, and when a new window creation action is monitored, notifying the watermark management module to create a corresponding watermark mask, and adding the watermark mask to the created new window.
[0036] Here, based on the working principle of the Runtime probe, the window-level probe is deployed to monitor the creation of a new window, and the watermark mask creation logic is added to the creation logic of the new window, so that when a new window creation action is monitored, the watermark management module can be notified to create a corresponding watermark mask. The process of creating a watermark mask is as follows: first, text to picture contour, converting watermark text for display into a picture, converting string type watermark content data that needs to be displayed on the screen into a picture, and determining the picture boundary according to the text content outline; second, color filling, setting the RGB value in advance according to the display requirement, and determining the color value within the watermark picture boundary based on the RGB value set in advance and filling it, completing a single watermark picture; third, screen adaptation, obtaining the size of the mobile terminal screen, determining the maximum and minimum values of the text watermark, rotating the watermark picture by 1 / 4π to ensure the display effect and aesthetics; finally, making a watermark mask, constructing a full-transparent picture of the size of the mobile terminal screen, and evenly deploying the prepared watermark text on the transparent picture according to the 3*4 specification to complete the watermark picture substrate making. After the watermark mask is created, the prepared watermark mask is deployed to the keyWindow of the IOS system application through the keyWindow.
[0037] Step S12, deploying a view controller-level probe, monitoring the change of the view hierarchy of the window in real time through the view controller-level probe, and when the view hierarchy changes, notifying the watermark management module to adjust the view hierarchy of the watermark mask in the new window.
[0038] Here, based on the working principle of the Runtime probe, the view controller-level probe is deployed to monitor the change of the view hierarchy in the window through the view controller-level probe, so as to dynamically adjust the position of the watermark mask in the view hierarchy when the view hierarchy changes. As Figure 2As shown, one window can contain multiple views, and the change in view hierarchy in the window will affect the position of the watermark mask in the view hierarchy in the window. Therefore, in order to ensure that the watermark can be normally displayed, it is necessary to monitor the change in view hierarchy.
[0039] It should be noted that the working principle of the Runtime probe is as follows: calling a method in Objective-C actually sends a message to an object, and the only basis for finding the message is the name of the selector. By using the dynamic characteristics of Objective-C, the method implementation corresponding to the selector can be replaced at runtime, achieving the purpose of hooking the method, and each class has a method list storing the mapping relationship between the name of the selector and the method (Method) implementation. IMP is similar to a function pointer, which points to a specific method (Method) implementation. For example, Figure 3 As shown, before the Runtime probe is implanted, the mapping relationship between the name of the selector and the method implementation cannot be hooked at will; as Figure 4 As shown, after the Runtime probe is implanted, the mapping relationship between the name of the selector and the method implementation can be hooked as needed. Based on the working principle of the Runtime probe, the present application implants the Runtime probe in the target method that needs to be monitored, that is, modifies the original system method, and before the specific method implanted with the probe executes according to the established logic, sends a notification message to the watermark management module, so that the watermark management module processes its own logic first, and then allows the specific method to be monitored to execute according to the system established logic sequence.
[0040] Through the above steps S11 to S12, in the present application, a window-level probe is deployed to monitor the creation of a window in real time through the window-level probe, and when the creation action of a new window is monitored, the watermark management module is notified to create a corresponding watermark mask, and the watermark mask is added to the created new window; a view controller-level probe is deployed to monitor the change in view hierarchy of the window in real time through the view controller-level probe, and when the change in view hierarchy is monitored, the watermark management module is notified to adjust the view hierarchy in the new window where the watermark mask is located, so as to monitor the creation of a new window and the change in view hierarchy when adding a global watermark through an application in an IOS system, ensure that the watermark always remains on the screen, and at the same time, do not affect the operation of the user, so as to be able to realize the functions of information tracing and copyright declaration through the global watermark.
[0041] For example, in a preferred embodiment of the present application, an application includes a login registration system and a user use system, wherein the login registration system corresponds to Window A, and the user use system corresponds to Window B. When a user registers or logs in through Window A, the user needs to switch to Window B. When the window switches from Window A to Window B, the watermark originally created based on Window A will be covered or destroyed along with Window A, affecting the display effect of the watermark. Therefore, a new watermark mask is recreated when a new window Window B is created, and a watermark based on the new window Window B is finally obtained, so that the switching of the window cannot affect the display of the watermark. The user use system corresponds to Window B, wherein Window B includes views View A, View B, and View C. If a new view View C is opened after adding a watermark in the opened View A and View B, or the views are switched among View A, View B, and View C after adding the watermark, the previously added watermark cannot be normally displayed. Therefore, the view hierarchy is monitored through the Runtime probe when the view hierarchy of View A, View B, and View C changes, so as to adjust the view hierarchy where the watermark mask is located, such as Figure 5 The effect diagram of adding a global watermark through an application APP in the present application is shown in FIG. 8.
[0042] In the above embodiment, the step S11 of deploying the window-level probe is used to monitor the window creation in real time through the window-level probe, including:
[0043] The set-root-view function of the window is implanted into the first probe, and the creation of the window is monitored in real time through the first probe, wherein the set-root-view function is used for the creation of the new window.
[0044] Here, the creation of the new window is realized through the set-root-view function of the window UIWindow, and the set-root-view function of the UIWindow is monitored to realize the monitoring of the window creation action.
[0045] For example, in a preferred embodiment of the present application, the implementation process of implanting the set-root-view function of the window into the first probe can be realized through the following code:
[0046]
[0047] Then in the above embodiment, in step S12, the view controller level probe is deployed, and the view hierarchy change of the window is monitored in real time through the view controller level probe, including:
[0048] The set view function of the view controller is implanted into the second probe, and the view hierarchy change of the window is monitored in real time through the second probe.
[0049] Here, the set view function of the view controller UIViewcontroller can make the view hierarchy of the window change. When the set view function of the view controller is executed, it means that the view hierarchy changes. The set view function of the view controller is monitored to monitor the view hierarchy change of the window.
[0050] For example, in a preferred embodiment of the present application, after the second probe detects that the view setting view function of the view controller is executed, the implementation process of the watermark management module notified by the second monitoring probe can be implemented by the following code:
[0051]
[0052] Then in the above embodiment, in step S11, the watermark mask is added to the created new window, including:
[0053] The view hierarchy of the new window is traversed, and the watermark mask is added above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window.
[0054] Here, in order to make the watermark normally displayed, when adding the watermark mask, the watermark mask needs to be added to the top of the view hierarchy, but at the same time, it cannot affect the user's touch operation. Therefore, when adding the watermark mask, the position of the view hierarchy where the watermark mask is located needs to be determined to ensure that the view hierarchy of the watermark mask is above all non-touch-aware views and below all touch-aware views.
[0055] For example, in a preferred embodiment of the present application, when the action of creating a new window is monitored, and the watermark mask is created through the watermark management module, the implementation process of adding the watermark can be implemented by the following code:
[0056]
[0057]
[0058] Then in the above embodiment, in step S12, the view controller level probe is deployed, and the view hierarchy change of the window is monitored in real time through the view controller level probe, including:
[0059] The watermark management module re-traverses the view hierarchy of the new window, and adjusts the position of the watermark mask so that the watermark mask is always above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window.
[0060] For example, in a preferred embodiment of the present application, a monitoring probe is inserted in the presentViewController method of UIViewcontroller, and when the method is called, the watermark management module is notified to re-traverse the view hierarchy and raise the watermark mask above the new UIViewcontroller, so as to update the view hierarchy of the watermark mask.
[0061] According to another aspect of the present application, there is also provided a non-volatile storage medium having stored thereon computer readable instructions that, when executed by a processor, cause the processor to implement a runtime-based global watermark processing method as described above.
[0062] According to another aspect of the present application, there is also provided a runtime-based global watermark processing device, wherein the device comprises:
[0063] one or more processors;
[0064] a non-volatile storage medium for storing one or more computer readable instructions,
[0065] when the one or more computer readable instructions are executed by the one or more processors, cause the one or more processors to implement a runtime-based global watermark processing method as described above.
[0066] Here, the details of each embodiment of the runtime-based global watermark processing device can be found in the corresponding part of the embodiments of the runtime-based global watermark processing method described above, and will not be repeated here.
[0067] In summary, in the present application, a window-level probe is deployed to monitor the creation of a window in real time, and when a new window is created, a watermark mask is created and added to the new window. A view controller-level probe is deployed to monitor the changes in the view hierarchy of a window in real time, and when a change in the view hierarchy is detected, the watermark mask is adjusted in the view hierarchy in the new window. In the IOS system, the creation of a new window and the changes in the view hierarchy are monitored when a global watermark is added by an application, ensuring that the watermark is always on the screen, without affecting the user's operation, so that the global watermark can be used to trace the source of information and declare the copyright.
[0068] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including related data structures) can be stored in a computer readable recording medium, such as a RAM memory, a magnetic or optical drive or a floppy disk and the like. In addition, some steps or functions of the present application can be implemented in hardware, for example, as a circuit cooperating with the processor to perform the respective steps or functions.
[0069] In addition, part of the present application can be applied as a computer program product, for example, computer program instructions, when executed by a computer, through the operation of the computer, the method and / or technical solutions according to the present application can be called or provided. The program instructions calling the method of the present application can be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal bearing medium, and / or stored in the working memory of the computer device running according to the program instructions. Here, according to one embodiment of the present application, the device includes a memory for storing computer program instructions and a processor for executing program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to run the method and / or technical solutions based on the above-mentioned embodiments according to the present application.
[0070] It will be obvious to a person skilled in the art that the application is not limited to the details of the above-described exemplary embodiments but can be implemented in other embodiments without departing from the scope of the application. The application is therefore not limited by the described examples but can vary within the scope of the claims and their equivalents. No reference signs in the claims should be considered as limiting the scope of the claims. Furthermore, it is obvious that the wording "comprising" does not exclude other parts and does not exclude other steps. Singularity is not excluded with respect to plurality and vice versa. Multiple units or devices recited in a device claim can also be implemented by one unit or device by means of software or hardware. The terms first, second and the like do not denote any ordering, but rather serve as names.
Claims
1. A method of run-time based global watermarking processing, wherein, The method comprises: deploying a window-level probe, monitoring the creation of a window in real time through the window-level probe, and when a new window creation action is monitored, notifying a watermark management module to create a corresponding watermark mask, and traversing the view hierarchy of the new window, adding the watermark mask above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window; deploying a view controller-level probe, monitoring the change of the view hierarchy of the window in real time through the view controller-level probe, and when the view hierarchy changes are monitored, traversing the view hierarchy of the new window again through the watermark management module, adjusting the position of the watermark mask, so that the watermark mask is always above all non-touch-aware views and below all touch-aware views in the view hierarchy of the new window.
2. The method of claim 1, wherein, The deployment of the window-level probe for real-time monitoring of window creation comprises: implanting a set root view function of a window into a first probe to monitor the creation of a window in real time through the first probe, wherein the set root view function is used for the creation of the new window.
3. The method of claim 1, wherein, The deployment of the view controller-level probe for real-time monitoring of the change of the view hierarchy of the window comprises: implanting a set view function of a view controller into a second probe to monitor the change of the view hierarchy of the window in real time through the second probe.
4. A non-volatile storage medium having stored thereon computer readable instructions, which, when executed by a processor, cause the processor to implement the method of any one of claims 1 to 3.
5. A runtime-based global watermarking processing device, wherein, The device comprises: one or more processors; a non-volatile storage medium for storing one or more computer readable instructions, when the one or more computer readable instructions are executed by the one or more processors, the one or more processors implement the method of any one of claims 1 to 3.
Citation Information
Patent Citations
Method and device for realizing virtual keyboard
CN101853103A
A method of adding a watermark to an IOS application
CN109544437A
Browser watermark displaying method and device, and electronic equipment
CN111783003A
Process watermarking method and system and electronic equipment
CN112257037A