Method for generating privacy protocol component based on swan gap system
Through the privacy protocol component generation method based on the Hongmeng system, the problem of repeated design of privacy protocol interfaces in different games is solved, and efficient generation and unified style interfaces are achieved, which improves development efficiency and user experience.
Patent Information
- Application Number
- CN202510424589.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-07-22
AI Technical Summary
In the prior art, the same company needs to independently design and develop a privacy protocol interface for each game when developing different games, resulting in low development efficiency and heavy repetitive work.
Provides a method for generating privacy protocol components based on the Hongmeng system. By building custom component classes, obtaining device screen sizes and converting them into virtual pixels, configuring interface layouts and controls, and realizing protocol content loading and interactive management.
It improves the efficiency of the game privacy protocol interface generation, so that the interface can be shared in the same series of games, with a unified style and a better user experience.
Smart Images

Figure CN120353456A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics technology, and particularly to a method for generating a privacy protocol component based on the HarmonyOS system. Background Art
[0002] With the rapid development of the mobile Internet, user privacy protection has become a core concern of global regulatory agencies. Countries have successively introduced regulations (such as the EU GDPR and China's "Personal Information Protection Law"), clearly requiring that applications must display a privacy protocol and obtain explicit consent from users before collecting user data. In this context, the privacy protocol interface has become an essential link in the startup of applications, especially in the game industry, where its importance is even more prominent.
[0003] In the prior art, when a company develops different games, it often needs to independently design and develop a privacy protocol interface for each game, and each game needs to write code from scratch, resulting in a large amount of repetitive labor and low development efficiency. Summary of the Invention
[0004] In order to solve the deficiencies of the prior art, the purpose of this application is to provide a method for generating a privacy protocol component based on the HarmonyOS system, so as to improve the generation efficiency of the game privacy protocol interface.
[0005] To achieve the above object, this application provides a method for generating a privacy protocol component based on the HarmonyOS system, including: Construct a class of the privacy protocol component, and the class of the privacy protocol component is configured as a custom component in the HarmonyOS system; In the life cycle function of the class of the privacy protocol component, obtain the width and height of the current device screen and convert them into the width and height of virtual pixels; Based on the width and height of the virtual pixels, configure the interface layout of the privacy protocol component; Configure a network control to load protocol content in the interface layout; Configure a button control to control the interaction and status management of the privacy protocol component.
[0006] Further, the specific steps of obtaining the width and height of the current device screen and converting them into the width and height of virtual pixels in the life cycle function of the class of the privacy protocol component include: Use the display.getDefaultDisplaySync() function to obtain the width and height of the current device screen; Based on the width and height of the current device screen, use the px2vp() function to convert them into the width and height of virtual pixels.
[0007] Further, the specific steps of configuring the interface layout of the privacy protocol component based on the width and height of the virtual pixels include: Based on the width and height of the virtual pixels, configure the interface layout of the privacy protocol component to be centered.
[0008] Further, the protocol content is configured on an html page.
[0009] Further, the button control includes an agree button control and a reject button control.
[0010] Further, the agree button control is configured to close the interface of the privacy protocol component and jump to the game login interface after being clicked.
[0011] Further, the reject button is configured to exit the game application after being clicked.
[0012] To achieve the above object, the electronic device provided by this application includes: A processor; A memory, on which one or more computer program instructions running on the processor are stored; Among them, when the processor runs the computer instructions, it executes the generation method of the privacy protocol component based on the HarmonyOS as described above.
[0013] To achieve the above object, the computer-readable storage medium provided by this application stores computer instructions, and when the computer instructions are run by a processor, the steps of the generation method of the privacy protocol component based on the HarmonyOS as described above are executed.
[0014] The generation method of the privacy protocol component based on the HarmonyOS of this application makes it easier and more efficient to write the privacy protocol interface of the game.
[0015] The generation method of the privacy protocol component based on the HarmonyOS of this application can generate privacy protocol components that can be used in multiple games of the same series at the same time, with a more unified style and better user experience.
[0016] Other features and advantages of this application will be described in the subsequent description, and part of them will become obvious from the description, or will be understood by implementing this application. Description of the Drawings
[0017] The drawings are used to provide a further understanding of this application, and constitute a part of the description, and together with the embodiments of this application, are used to explain this application, and do not constitute a limitation to this application. In the drawings: Figure 1 It is a schematic flowchart of the generation method of the privacy protocol component based on the HarmonyOS of this application; Detailed implementation manners
[0018] Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not used to limit the protection scope of the present application.
[0019] It should be understood that the various steps described in the method embodiments of the present application can be executed in different orders and / or executed in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this regard.
[0020] The term "including" and its variations used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0021] It should be noted that the modifications of "one" and "multiple" mentioned in the present application are illustrative rather than restrictive. Those skilled in the art should understand that unless clearly specified otherwise in the context, it should be understood as "one or more". "Multiple" should be understood as two or more.
[0022] HarmonyOS is a distributed operating system launched by Huawei, designed for full-scenario intelligent devices, and supports various terminals such as mobile phones, tablets, smart wearables, and in-vehicle infotainment systems. Its core features include a distributed architecture, low latency, high security, and cross-device collaboration capabilities. The newly released HarmonyOS version further optimizes the capabilities of ArkUI components, such as adding a text translation function, drag-and-drop preview image settings, and scroll component optimizations, and enhances performance and stability. This system realizes "one development, multi-terminal deployment" through a unified development framework (such as ArkUI), greatly reducing the development complexity.
[0023] Interface development: When developing interfaces in HarmonyOS, it is based on the ArkUI framework and adopts a declarative UI design pattern to build user interfaces through componentization. Developers can quickly build pages using system components (such as Text, Button), or implement complex interactions through custom components. Key features include: declarative syntax, using an HTML-like DSL to describe the interface structure and combining state management to achieve data-driven UI updates; flexible layout, supporting Flex layout and Grid layout to adapt to multiple screen sizes and dynamic changes (such as folding and split screens); lifecycle management, where components and pages control logic through lifecycle functions such as aboutToAppear (initialization), build (building the UI tree), and onPageShow (page display).
[0024] In HarmonyOS development, a class is the core structure for encapsulating functional units. For example, to create a custom component, one needs to inherit from the Component class and implement specific interfaces (such as EstimateSizeListener, DrawTask) to complete measurement, drawing, and event handling. System components (such as Web, Button) also provide predefined functions in the form of classes. The design of classes follows the principle of high cohesion. For example: The WebviewController class manages the loading, navigation, and security verification of Web controls. The Preferences class provides key-value pair storage and supports encrypting and persisting user states. The instantiation and lifecycle management of classes are automatically handled by the ArkUI framework, and developers only need to focus on implementing the business logic.
[0025] Next, embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0026] Embodiment 1 An embodiment of the present application provides a method for generating a privacy protocol component based on HarmonyOS, which improves the generation efficiency of the game privacy protocol interface.
[0027] Figure 1 The following is a schematic flowchart of the method for generating a privacy protocol component based on HarmonyOS of the present application. Next, reference will be made to Figure 1 The method for generating a privacy protocol component based on HarmonyOS of the present application will be described in detail, including: Step S101: Construct a class for the privacy protocol component, and the class of the privacy protocol component is configured as a custom component in HarmonyOS.
[0028] In this embodiment, the class AgreeComponent that uses HarmonyOS's declarative UI to build the privacy protocol component is a custom component class, implemented based on the @Component decorator of the HarmonyOS system. Its core goal is to encapsulate all functions of the privacy protocol interface, including UI layout, user interaction, data management, and dynamic adaptation.
[0029] It should be noted that custom components are the core means of HarmonyOS interface extension, allowing developers to encapsulate reusable UI modules. The implementation steps are as follows: Define the component structure, use @Component to modify struct, and implement the build() method description; Measure and layout, calculate the component size through onEstimateSize, and dynamically adapt in combination with Flex or Grid layout; Draw and interact, implement the DrawTask interface to draw graphics, and respond to events such as clicks and swipes through TouchEventListener; State management, use decorators such as @State and @Link to achieve data-driven updates.
[0030] In this embodiment, to achieve high cohesion and low coupling, when constructing the class AgreeComponent of the privacy protocol component, a three-layer architecture consisting of a view layer, a logic layer, and a data layer can be used.
[0031] Step S102: In the life cycle function of the class of the privacy protocol component, obtain the width and height of the current device screen and convert them into the width and height of virtual pixels.
[0032] In the HarmonyOS system, the life cycle function aboutToAppear() of the custom component is triggered before the component is about to be displayed on the screen. In this embodiment, in the aboutToAppear() function, use the display.getDefaultDisplaySync() function to obtain the width and height of the current device screen; then, based on the width and height of the current device screen, use the px2vp() function to convert them into the width and height of virtual pixels.
[0033] Step S103: Configure the interface layout of the privacy protocol component based on the width and height of virtual pixels.
[0034] In this embodiment, configure the interface layout of the privacy protocol component to be centered. Exemplarily, the external container uses a flex layout with the direction of FlexDirection.Column and is vertically centered.
[0035] In some other embodiments, the layout direction of the interface layout of the privacy protocol component can also be customized. In this embodiment, the interface layout consists of a web control (i.e., a network control) and two button controls. The height of the web control is configured to account for 80% of the screen, and the height of the button controls accounts for the remaining 20%.
[0036] Step S104: Configure the network control to load the protocol content in the interface layout; In this embodiment, the protocol content is configured in an html web page. When loading the protocol content, it can be loaded asynchronously to reduce the display delay.
[0037] When loading the protocol content, the hash value of the html web page can also be calculated to verify the integrity of the content of the html web page.
[0038] In this embodiment, protocol content in different languages can also be configured to load the corresponding language html file according to the system language setting (obtained through i18n.getSystemLanguage()).
[0039] Step S105: Configure the button control to control the interaction and state management of the privacy protocol component.
[0040] In this embodiment, the two button controls are divided into an agree button control and a reject button control. Among them, the agree button control is configured to close the interface of the privacy protocol component and jump to the game login interface after being clicked; the reject button is configured to exit the game application after being clicked.
[0041] Exemplarily, the event handling logic of the agree button control uses the router.back() or router.clear() function to close the interface of the privacy protocol component, and uses the router.replaceUrl({ url: 'pages / Login'}) function to jump to the login interface.
[0042] In this embodiment, after the agree button control is clicked, the agree result will also be saved to the preferences of the game so that the privacy protocol component will not be displayed again during the next login. On the contrary, after the reject button control is clicked, the privacy protocol component will be displayed again when the game is started next time.
[0043] Embodiment 2 In this embodiment, an electronic device is further provided. The electronic device includes a processor and a memory. The memory is used to store non-temporary computer-readable instructions (such as one or more computer program modules). The processor is used to run the non-temporary computer-readable instructions. When the non-temporary computer-readable instructions are run by the processor, one or more steps of the above-mentioned method for generating a privacy protocol component based on the HarmonyOS can be executed.
[0044] Example 3 In this embodiment, a computer-readable storage medium is further provided, and the storage medium is used to store non-transitory computer-readable instructions. For example, when the non-transitory computer-readable instructions are executed by a computer, one or more steps in the above-mentioned method for generating a privacy protocol component based on the HarmonyOS can be executed.
[0045] The above description is only part of the embodiments of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the (but not limited to) technical features with similar functions disclosed in the present application.
[0046] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present application. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0047] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms for implementing the claims.
Claims
1. A method for generating a privacy protocol component based on the HarmonyOS, characterized in that, Including: Construct a class for the privacy protocol component, and the class of the privacy protocol component is configured as a custom component in the HarmonyOS system; In the life cycle function of the class of the privacy protocol component, obtain the width and height of the current device screen and convert them into the width and height of virtual pixels; Based on the width and height of the virtual pixels, configure the interface layout of the privacy protocol component; Configure the network control to load the protocol content in the interface layout; Configure the button control to control the interaction and status management of the privacy protocol component.
2. The method for generating a privacy protocol component based on the HarmonyOS according to claim 1, wherein The specific steps of obtaining the width and height of the current device screen and converting them into the width and height of virtual pixels in the life cycle function of the class of the privacy protocol component include: Use the display.getDefaultDisplaySync() function to obtain the width and height of the current device screen; Based on the width and height of the current device screen, use the px2vp() function to convert them into the width and height of virtual pixels.
3. The method for generating a privacy protocol component based on the HarmonyOS according to claim 1, wherein The specific steps of configuring the interface layout of the privacy protocol component based on the width and height of the virtual pixels include: Based on the width and height of the virtual pixels, configure the interface layout of the privacy protocol component to be centered.
4. The generation method of the privacy protocol component based on the HarmonyOS according to claim 1, wherein, The protocol content is configured on an html page.
5. The method for generating a privacy protocol component based on the HarmonyOS according to claim 1, wherein, The button control includes an agree button control and a reject button control.
6. The method for generating a privacy protocol component based on the HarmonyOS according to claim 5, wherein, The agree button control is configured to close the interface of the privacy protocol component and jump to the game login interface after being clicked.
7. The method for generating a privacy protocol component based on the HarmonyOS according to claim 5, wherein The reject button is configured to exit the game application after being clicked.
8. An electronic device, characterized in that, Including: A processor; A memory, on which one or more computer program instructions running on the processor are stored; Wherein, when the processor runs the computer program instructions, it executes the method for generating a privacy protocol component based on the HarmonyOS system according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, On which computer instructions are stored, and when the computer instructions run, they execute the steps of the method for generating a privacy protocol component based on the HarmonyOS system according to any one of claims 1-7.