Component sharing method and apparatus, electronic device, and computer-readable storage medium

By identifying shareable components in the current application and encapsulating them into plugins, generating and loading shared plugins, the problem of poor reusability of component resources between different applications is solved, enabling the sharing of components and efficient utilization of resources across different applications.

CN122284989APending Publication Date: 2026-06-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411943192.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Developers of different applications often develop components that implement the same functions when developing their own applications, resulting in poor reusability of application resources.

Method used

A component sharing method is provided, which identifies shareable components in the current application, encapsulates them into plugins, generates a shared plugin, installs it into the current application, controls the loading of the current application, and notifies external applications to obtain the shared plugin, so as to realize the sharing of components between different applications.

Benefits of technology

It enables the sharing of the same component across different applications, improves the reusability of application resources, and reduces the need for repeated development of the same component.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122284989A_ABST
    Figure CN122284989A_ABST
Patent Text Reader

Abstract

This application discloses a component sharing method, apparatus, electronic device, and computer-readable storage medium, relating to the field of computer technology. The method involves: identifying a shareable component in the current application that can be shared with an external application; encapsulating the shareable component into a plugin to obtain a first shared plugin; installing the first shared plugin into the current application and controlling the current application to load the first shared plugin; and notifying the external application to obtain the first shared plugin, which is used by the external application after installation. This application enables the sharing of the same component between different applications, thereby improving the reusability of application resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a component sharing method, a component sharing device, an electronic device, and a computer-readable storage medium. Background Technology

[0002] With the continuous development of computer technology, people can obtain the applications they need from various channels and install them on electronic devices such as computers, smartphones, and IoT devices, thereby greatly expanding the functions of electronic devices. For example, one can download game applications to expand the gaming function of electronic devices, and one can also download instant messaging applications to expand the instant messaging function, and so on.

[0003] Typically, applications are composed of components that implement different specific functions, such as components for button functionality, components for form functionality, and components for network data download functionality. However, developers of different applications often develop their own components that implement the same functions, resulting in poor reusability of application resources. Summary of the Invention

[0004] This application provides a component sharing method, component sharing device, electronic device, and computer-readable storage medium, which can realize the sharing of the same component between different applications, thereby improving the reusability of application resources.

[0005] Firstly, the component sharing method provided in this application includes:

[0006] Identify shareable components in the current application that can be shared with external applications;

[0007] The shareable component is encapsulated into a plugin to obtain a first shared plugin;

[0008] Install the first shared plugin into the current application, and control the current application to load the first shared plugin;

[0009] The external application is notified to obtain the first shared plugin, which is used by the external application to load after installation.

[0010] Secondly, the component-sharing device provided in this application includes:

[0011] The component determination module is used to determine the shareable components in the current application that can be shared with external applications;

[0012] A plug-in encapsulation module is used to encapsulate the shareable component into a plug-in to obtain a first shared plug-in.

[0013] The plugin application module is used to install the first shared plugin into the current application and control the current application to load the first shared plugin;

[0014] The plugin sharing module is used to notify the external application to obtain the first shared plugin, which is loaded by the external application after installation.

[0015] Optionally, in one embodiment, during the process of encapsulating a shareable component into a first shared plugin, the plugin encapsulation module is used to compile resources corresponding to the shareable component according to a preset starting value of the resource identifier, wherein the preset starting value is outside the range of resource identifiers used by external applications for resource compilation.

[0016] Optionally, in one embodiment, the plug-in encapsulation module is further configured to update the first shared plug-in to obtain the second shared plug-in in response to an update of the shareable component;

[0017] The plugin application module is also used to install the second shared plugin into the current application and control the current application to load the second shared plugin;

[0018] The plugin sharing module is also used to disable the first shared plugin and notify external applications to obtain the second shared plugin, which is loaded after the external application installs it.

[0019] Optionally, in one embodiment, the plugin sharing module is further configured to notify an external application to enable the local component corresponding to the shareable component in response to an exception occurring in the second shared plugin.

[0020] Optionally, in one embodiment, the plugin sharing module is used to disable the second shared plugin, so that when an external application finds that there is no available shared plugin in the current application, it receives a notification to enable the local component corresponding to the shareable component.

[0021] Optionally, in one embodiment, the plugin application module is further configured to enable the first shared plugin and control the current application to load the first shared plugin.

[0022] Optionally, in one embodiment, the plug-in sharing module is further configured to determine the external dependencies of the shareable component; and to notify external applications to establish a dependency relationship with the external dependencies.

[0023] Thirdly, the electronic device provided in this application includes a memory and a processor. The memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in the component sharing method provided in this application.

[0024] Fourthly, the computer-readable storage medium provided in this application stores a computer program adapted for processor execution to implement the steps in the component sharing method provided in this application.

[0025] The component sharing scheme provided in this application first identifies shareable components that can be shared with external applications from the current application. Then, it encapsulates these shareable components into a plugin to obtain a shared plugin. The shared plugin is then installed into the current application, and the current application is controlled to load it, enabling the current application to use the functionality of the shared plugin encapsulated in the shared plugin. In addition, the external application is notified to obtain the shared plugin, so that after obtaining the shared plugin from the current application, the external application can install and load the shared plugin, thereby using the functionality of the shareable components encapsulated in the shared plugin. This achieves the sharing of the same component between different applications, thereby improving the reusability of application resources. Attached Figure Description

[0026] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1a This is a schematic diagram of a component sharing system provided in an embodiment of this application;

[0028] Figure 1b This is a flowchart illustrating the component sharing method provided in an embodiment of this application;

[0029] Figure 1c This is a schematic diagram illustrating the preset starting value of the resource identifier during the resource compilation process in this application embodiment;

[0030] Figure 1d This is an example diagram illustrating the precautions for plug-in encapsulation in the embodiments of this application;

[0031] Figure 1e This is a schematic diagram of the notification strategy in an embodiment of this application;

[0032] Figure 1f This is an example diagram illustrating the sharing of the same component among different applications in embodiments of this application;

[0033] Figure 1g This is a schematic diagram of the process of reverting the plugin version when an error occurs after the plugin is updated, as described in this application embodiment.

[0034] Figure 2 This is another flowchart illustrating the component sharing method provided in the embodiments of this application;

[0035] Figure 3 This is a schematic diagram of the component sharing device provided in an embodiment of this application;

[0036] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0037] It should be noted that the principles of this application are illustrated by example in a suitable computing environment. The following description is based on the specific embodiments of this application that are illustrated, and should not be regarded as limiting other specific embodiments not detailed herein.

[0038] In the following description of this application, "some embodiments" are referred to, which describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subset of all possible embodiments, and may be combined with each other without conflict.

[0039] In the following description of this application, the terms "first, second, third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0040] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0041] To improve the reusability of application resources, this application provides a component sharing method, a component sharing device, an electronic device, and a computer-readable storage medium. The component sharing method can be executed by the component sharing device or by an electronic device integrating the component sharing device.

[0042] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] Please refer to the reference. Figure 1aThis application also provides a component sharing system, which includes an electronic device 100 for executing the component sharing method provided in this application. The electronic device 100 can be a device equipped with a processor and having data processing capabilities, such as a smartphone, tablet, PDA, laptop, or other mobile device with a processor; a desktop computer, server, or other fixed device with a processor; or a smart appliance, smart home device, or other IoT device with a processor, etc. When executing the component sharing method provided in this application, a shareable component that can be shared with external applications in the current application is determined. This shareable component is then encapsulated into a first shared plugin. The first shared plugin is installed in the current application, and the current application is controlled to load the first shared plugin. Furthermore, the external application is notified to obtain the first shared plugin, which is used by the external application after installation.

[0044] In addition, such as Figure 1a As shown, the component sharing system may also include a memory 200 for storing relevant data during the component sharing process, such as process data during the encapsulation of shareable components, the first shared plugin obtained from the encapsulation, and so on.

[0045] It should be noted that the component sharing system described above is merely an example, intended to more clearly illustrate the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of component sharing systems and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0046] The following sections provide detailed descriptions of each example. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0047] Please refer to Figure 1b This embodiment provides a component sharing method, such as... Figure 1b As shown, the flow of the shared method of this component can be as follows:

[0048] In step 110, identify the shareable components in the current application that can be shared with external applications.

[0049] It should be noted that "current application" is used to refer to an application that can provide components for sharing, rather than referring to a specific application. "Current application" can be any application in an electronic device.

[0050] In this embodiment, the components that can be shared with external applications are first determined according to the configured shareable component determination strategy, and these components are recorded as shareable components. External applications can be other applications installed on the electronic device besides the current application. For example, if the electronic device has applications A, B, and C installed, and application A is determined to be the current application, then applications B and C are external applications of the current application (application A).

[0051] Furthermore, the configuration of the shareable component determination strategy in this application embodiment is not limited. For example, the shareable component determination strategy can be configured as follows: a data table is used to record the identification information of whether different components in the current application can be shared with external applications. Accordingly, when determining the components in the current application that can be shared with external applications, the components in the current application that are identified as shareable can be determined by looking up the table.

[0052] In step 120, the shareable component is encapsulated into a plugin to obtain the first shared plugin.

[0053] As described above, after identifying the shareable components in the current application that can be shared with external applications, these shareable components are further encapsulated into plugins to obtain shared plugins for sharing these components. This shared plugin is designated as the first shared plugin. It should be noted that, compared to ordinary components, plugins can be understood as pluggable components. Plugins can be dynamically loaded at runtime to extend the application's functionality. For example, they can extend social features to a music application, or data analysis features to a video application, and so on.

[0054] The main process of encapsulating shareable components as plugins can be summarized as follows:

[0055] Define the plugin interface: First, define the plugin interface based on the functionality of the shareable component, and add the interface code to the current application. This allows the interface code to be referenced by both the current application (which is also the host application) and the plugin, serving as a communication bridge between the current application and the plugin. It should be noted that the interface code should not be obfuscated. Obfuscation refers to transforming the original code into obscure symbols using certain rules to improve code security. The plugin interface can be used with dynamic proxies, that is, a proxy object for the plugin interface is created at runtime to proxy calls to the plugin interface and handle exceptions when calls fail. This way, even if the plugin interface call fails, the current application can gracefully handle the error instead of crashing.

[0056] Creating plugin metadata: Plugins typically need metadata to describe themselves, such as name, version, author, and dependency information. This metadata can be stored in configuration files or specific classes.

[0057] Plugin encapsulation: Package the shareable components and their dependencies into a standalone plugin package, which can be a JAR file or ZIP or other suitable format. It is necessary to ensure that all classes and resources are in the correct package and directory structure.

[0058] Following the above process, the shareable components in the current application can be packaged into an independent plugin package that can be used to install the first shared plugin.

[0059] It is understandable that in an application, different resources have their own resource identifiers. These resource identifiers are assigned to resources during the resource compilation phase and are unique, used to distinguish different resources. However, different applications may assign resource identifiers differently during resource compilation. For example, when a resource is used by application A, the resource identifier obtained after resource compilation is 0x11, but when the same resource is used by application B, the resource identifier obtained after resource compilation is 0x12. In an optional embodiment, to ensure that the shareable component functionality encapsulated by the first shared plugin runs normally in different applications, an optional resource compilation method is provided to encapsulate the shareable component into a plugin, resulting in the first shared plugin, including:

[0060] In the process of encapsulating a shareable component into a first shared plugin, the resources corresponding to the shareable component are compiled according to the preset starting value of the resource identifier. The preset starting value is outside the range of resource identifiers used by external applications for resource compilation.

[0061] In this embodiment, the resource compilation process—a sub-process in the plugin encapsulation process—is restricted. The configuration specifies that resource compilation is performed on the resources corresponding to the shareable component according to a preset starting value of the resource identifier. This preset starting value is outside the range of resource identifiers used by the external application for resource compilation. This ensures that after the encapsulated first shared plugin is installed and loaded by the external application, the resource identifiers of its resources will not conflict with the resource identifiers of the external application's own resources, thus enabling the shareable component encapsulated by the first shared plugin to function correctly. The preset starting value of the resource identifier is not specifically restricted here; it is constrained by the fact that this preset starting value is outside the range of resource identifiers used by the external application for resource compilation. The value can be chosen according to actual needs; for example, the preset starting value can be configured to be 0x70.

[0062] It should be noted that during the above resource compilation process, the resource class of the first shared plugin is independent of the current application; that is, the resource class of the first shared plugin does not inherit the resource class of the current application.

[0063] For example, please refer to Figure 1cTaking an electronic device using the Android system as an example, the main process of configuring resource compilation according to the preset starting value of the resource identifier can be as follows:

[0064] Creating a Gradle custom plugin: First, create a Gradle custom plugin to modify the resource offset (resOffset) property of resource management tasks. Then, apply this Gradle custom plugin to the current application's build.gradle file.

[0065] Configure the starting value of the resource identifier for the shared plugin: In the build.gradle file of the shared plugin, configure the preset starting value of the resource identifier (for example, configure it to 0x70) to ensure that the resource identifier is assigned from this preset starting value.

[0066] Reflection Resource Management Tasks: Using reflection, tasks for resource management can be located.

[0067] Configure resource offset attribute: Modify the resource offset attribute in the internal attributes of the resource management task to the preset starting value configured above, thereby achieving the purpose of customizing the prefix of the resource identifier.

[0068] After completing the above process, when compiling resources for the shared plugin, resource identifiers can be allocated according to the resource offset attribute (which has now been configured as the preset starting value of the resource identifier). In this way, when the encapsulated first shared plugin is installed and loaded into an external application, the resource identifiers of the resources in the first shared plugin will not duplicate the resource identifiers of the external application's local resources. This allows the correct resource to be indexed through the resource identifier, ensuring the normal operation of the first shared plugin.

[0069] In summary, please refer to Figure 1d When encapsulating shareable components into plugins, the following considerations should be followed:

[0070] (1) Interface decoupling: Shared plugins need to maintain a highly cohesive and loosely coupled code architecture. The interface layer (including the plugin interface of the shared plugin) is separated out and used specifically for dependency communication with the outside. The interface layer is not packaged into the shared plugin, but added to the host application as a communication bridge between the shared plugin and the host application.

[0071] (2) Code obfuscation configuration: Since the code obfuscation rules of different applications are not consistent, if application 1 obfuscates the add interface of the interface layer as a, while application 2 obfuscates the add interface of the interface layer as b, then when the shared plugin of application 1 is copied and installed to application 2, the obfuscated add interface of the interface layer will not be found. Therefore, it is necessary to ensure that the interface layer code is not obfuscated.

[0072] (3) Runtime Environment Configuration: The shared plugin relies on external dependencies (i.e., the external dependencies of the shareable components encapsulated by the shared plugin), such as basic components like network components and reporting components. These external dependencies are also directly depended upon by the host application. Therefore, if the external application does not establish dependency relationships with these external dependencies, the shared plugin cannot run properly within that external application. Accordingly, it is necessary to notify the external application to establish dependency relationships with the shared plugin's external dependencies and ensure that the code of the external dependencies is not obfuscated.

[0073] (4) Resource conflict resolution: The resource classes of the shared plugin no longer inherit from the resource classes of the original host. This is because the shared plugin will have multiple host applications after sharing. If it still depends on the resource classes of the original host, then when it is shared with external applications (i.e., other host applications), the resource classes of the original host will not be found. Therefore, the resource classes of the shared plugin need to be independent of the original host application.

[0074] In step 130, the first shared plugin is installed into the current application, and the current application is controlled to load the first shared plugin.

[0075] As shown above, by encapsulating the shareable components into plugins, the plugin package of the first shared plugin is obtained. At this point, the first shared plugin can be installed into the current application.

[0076] The process of installing the first shared plugin into the current application is as follows:

[0077] Place plugin: Based on the requirements of the current application, copy the plugin data (including code, resources, etc. of shareable components) from the plugin package of the first shared plugin to the plugin directory of the current application.

[0078] Activate Plugin: Verify the installation of the first shared plugin to ensure it is installed correctly and all plugin data is in the correct location; configure any settings or parameters required by the first shared plugin to suit the current application's usage environment.

[0079] By following the above steps, the first shared plugin can be installed into the current application.

[0080] Furthermore, when the current application requires the use of a shareable component, the process of controlling the current application to load the first installed shared plugin can be as follows:

[0081] Memory loading: Loads the code and resources of the first shared plugin (that is, the code and resources of the shareable components) into the memory area corresponding to the current application.

[0082] Integration Functionality: Integrates the functionality provided by the first shared plugin (i.e., the functionality provided by the shareable component) into the current application.

[0083] By following the above process, the current application can load the first shared plugin, thereby enabling it to use the functions of the shareable components encapsulated by the first shared plugin.

[0084] In step 140, the external application is notified to obtain the first shared plugin, which is used by the external application to load after installation.

[0085] In addition, according to the configured notification policy, external applications are notified to obtain the first shared plugin from the current application. After obtaining the first shared plugin from the current application, the external application can install and load the first shared plugin, thereby using the functions of the shareable components encapsulated by the first shared plugin to achieve the reuse of shareable components in the current application.

[0086] In this application embodiment, there are no restrictions on the configuration of the notification policy. For example, taking an electronic device using the Android system as an example, please refer to... Figure 1e The notification policy can be configured as follows:

[0087] Registration Broadcast: External applications that need to use the first optional component in the current application can register a change broadcast for the shared plugin.

[0088] Change Notification: After the current application finishes loading the shared plugin, it actively releases a content provider for the shared plugin, through which a query interface for the first shared plugin is provided. In addition, a change broadcast for the shared plugin is sent, which will be received by external applications that have registered for this broadcast. Conversely, in response to this change broadcast, external applications query the shared plugin through the query interface provided by the content provider. The content provider, in response to the query, returns the file descriptor of the currently available shared plugin (in this case, the first shared plugin).

[0089] As described above, the external application will obtain the file descriptor of the first shared plugin. Based on this file descriptor, the external application can copy the plugin package of the first shared plugin corresponding to the file descriptor to its own plugin directory. Based on the plugin package of the first shared plugin, the external application can install and load the first shared plugin. For details, please refer to the relevant description of the current application installing and loading the first shared plugin in the above embodiment, which will not be repeated here.

[0090] For example, please refer to Figure 1fComponent A in the current application is identified as a shareable component. By encapsulating component A as a first shared plugin and installing and loading it by the current application, and notifying external application 1 and external application 2 to obtain the first shared plugin containing component A from the current application, external application 2 and external application 3 can use component A shared by the current application 1 in addition to using their own local components after installing and loading the first shared plugin, thereby realizing the sharing of the same component between different applications.

[0091] It is understandable that applications continue to be updated after their release, and component updates are a crucial part of this process. Typically, component updates involve functional improvements, performance enhancements, and bug fixes. Of course, other factors can also necessitate component updates. To ensure that shareable components maintain version consistency across different applications, an optional embodiment also provides a shareable component update scheme. This scheme, after notifying external applications to obtain the first shared plugin, further includes:

[0092] In response to an update of the shareable component, the first shared plugin is updated based on the updated shareable component to obtain the second shared plugin;

[0093] Install the second shared plugin into the current application and control the current application to load the second shared plugin;

[0094] Disable the first shared plugin and notify external applications to obtain the second shared plugin, which is used by external applications to load after installation.

[0095] In this embodiment of the application, after sharing the shareable component to an external application through the first shared plugin, if an update to the shareable component is detected, the first shared plugin is updated according to the updated shareable component to obtain the second shared plugin. Specifically, the second shared plugin can be obtained by incrementally updating the first shared plugin based on the differences between the shareable component and the updated shareable component; alternatively, the updated shareable component can be repackaged into a plugin to obtain the second shared plugin.

[0096] As described above, after obtaining the second shared plugin that encapsulates the updated shareable components, the second shared plugin is installed into the current application, and the current application is controlled to load the second shared plugin. The specific implementation can be referred to the above method of installing the first shared plugin into the current application and controlling the current application to load the first shared plugin. It will not be repeated here.

[0097] In addition, the first shared plugin is disabled, and external applications are notified to obtain the second shared plugin. After obtaining the second shared plugin from the current application, the external application can install and load the second shared plugin, thereby using the functions of the updated shareable component encapsulated by the second shared plugin to update the shareable component in different applications.

[0098] For example, by publishing a change broadcast through the current application, external applications that have registered for change broadcasts will receive the broadcast. In response to the change broadcast, the external application queries the shared plugin through the query interface provided by the content provider. Since the first shared plugin is disabled at this time, the content provider returns the file descriptor of the currently available shared plugin (in this case, the second shared plugin) in response to the query. Based on this file descriptor, the external application can copy the plugin package of the second shared plugin corresponding to the file descriptor to its own plugin directory. Based on the plugin package of the second shared plugin, the external application can install and load the second shared plugin. For details, please refer to the relevant description of the current application installing and loading the first shared plugin in the above embodiment, which will not be repeated here.

[0099] It should be noted that disabling a plugin refers to marking an installed plugin as unavailable within an application, thereby preventing it from being loaded and used at runtime. This process typically does not delete the plugin's files; it only temporarily prevents its functionality from being activated. For example, you can set the plugin's status to disabled by modifying its configuration file (such as plugins.xml or manifest.json), or you can disable the plugin via command-line tools or scripts, and so on.

[0100] The update scheme for shareable components provided in the above embodiments of this application only requires the original host application of the shareable component (i.e., the current application mentioned above) to be responsible for updating and maintaining it. When the shareable component is updated, the original host application that is maintaining it updates and encapsulates the shareable component's shared plugin accordingly, and actively notifies its external applications, so that the external applications can actively synchronize the updated shared plugin. In this way, the shareable components of multiple different applications only need to be updated once to make them effective for multiple external applications.

[0101] Optionally, in one embodiment, before notifying the external application to obtain the first shared plugin, the method further includes:

[0102] Identify the external dependencies of shareable components;

[0103] Notify external applications to establish dependencies with external dependencies.

[0104] It should be noted that, for components, external dependencies refer to code or resources that the component depends on but are not provided by the component or application itself. These dependencies typically come from third-party libraries, frameworks, or other external resources. External dependencies are an indispensable part of modern software development because they can provide ready-made functionality, reduce development time, and improve code quality. For example, the normal operation of a component depends on some external basic components, such as network components or reporting components provided by the system.

[0105] In this embodiment of the application, in order to ensure that the shareable component can run normally in the external application when it is shared to the external application in the form of a plugin, the external dependencies of the shareable component are also identified. These external dependencies may be external components, code, and resources that the shareable component depends on. Then, the external application is further notified to establish a dependency relationship with these external dependencies, thereby providing a runtime environment for the shareable component.

[0106] It is understandable that nothing is perfect, and due to various factors, plugins may malfunction during operation. To prevent the spread of malfunctioning plugins, in an optional embodiment, after notifying external applications to obtain the second shared plugin, the following steps are also included:

[0107] In response to an exception in the second shared plugin, notify external applications to enable the local component corresponding to the shareable component.

[0108] In this embodiment, an anomaly detection strategy is used to identify whether the second shared plugin has malfunctioned. The configuration of the anomaly detection strategy is not specifically limited here. For example, the anomaly detection strategy can be configured as follows: count the number of crashes of the second shared plugin, and determine that the second shared plugin has malfunctioned when the cumulative number of crashes reaches a threshold.

[0109] If an exception is detected in the second shared plugin, the external application is notified to enable the local component corresponding to the shareable component in response to the exception. No specific restrictions are placed on how the external application is notified to enable the local component corresponding to the shareable component.

[0110] As shown above, after receiving the notification, if an external application has a local component corresponding to the shareable component, it will enable the local component to achieve the same function as the shareable component. If no local component corresponding to the shareable component exists, it can continue to load the first shared plugin and still use the shareable component encapsulated by the first shared plugin that has not encountered any exceptions.

[0111] Optionally, in one embodiment, notifying an external application to enable the local component corresponding to the shareable component includes:

[0112] Disabling the second sharing plugin allows external applications to receive a notification to enable the local component corresponding to the shareable component when they find that no sharing plugin is available in the current application.

[0113] This application provides a passive notification method, that is, notification is achieved without actively sending information.

[0114] Based on the above description, it can be understood that in the above embodiments, in order to enable external applications to obtain the second shared plugin from the current application, the first shared plugin is disabled, so that only the second shared plugin is available. In this way, when external applications query the shared plugin in response to change broadcasts, they will be able to query the second shared plugin, but will not be able to query the first shared plugin. After obtaining the second shared plugin, it can be installed and loaded.

[0115] In this embodiment of the application, when it is necessary to notify an external application to enable the local component corresponding to the shareable component, the second shared plugin is further disabled in addition to the first shared plugin being disabled. In this way, when the external application queries the shared plugin in response to the change broadcast, since both the first and second shared plugins are disabled at this time, the external application will not be able to find the available shared plugin. Based on the query result that no shared plugin is available, the external application obtains the notification to enable the local component corresponding to the shareable component.

[0116] By adopting the passive notification method provided in the embodiments of this application, the direction of information loss or mutation during the transmission of active notification can be eliminated, and the external application can be ensured to accurately obtain the notification of enabling the local component corresponding to the shareable component.

[0117] Understandably, in practical applications, external applications may or may not have a corresponding local component for the shareable component. In the scenario where an external application has a corresponding local component, this local component can exist as the original component or as a plugin.

[0118] For example, if an external application has a local component corresponding to the shareable component, referring to the method of encapsulating the shareable component as a first shared plugin in the above embodiments, the external application encapsulates the local component as a local plugin, installs the local plugin, and then loads and uses it. After receiving a notification from the current application to obtain the first shared plugin, the application queries and obtains the first shared plugin from the current application, installs the first shared plugin, and then loads and uses it. Furthermore, after receiving a notification from the current application to obtain the second shared plugin, since both the first and second shared plugins are disabled, no available shared plugins can be found. At this time, a notification to enable the local component corresponding to the shareable component is received, and the local plugin encapsulated with the local component is reloaded, thereby using the local component.

[0119] Optionally, in one embodiment, after notifying the external application to enable the local component corresponding to the shareable component, the method further includes:

[0120] Enable the first shared plugin and control the current application to load the first shared plugin.

[0121] In this embodiment of the application, in order for the current application to provide services normally, the first shared plugin is re-enabled and the current application is controlled to load the first shared plugin, so as to continue to use the functions of the shareable components encapsulated by the first shared plugin, thereby realizing the rollback of the plugin version (i.e., from the second shared plugin to the first shared plugin).

[0122] Please refer to Figure 1g The following example illustrates the entire process of reverting to the previous plugin version when an error occurs after a plugin update:

[0123] At the initial moment, the current application has installed and loaded the first shared plugin that encapsulates the shareable components.

[0124] Because the shareable component has been updated, the current application installs and loads a second sharing plugin that encapsulates the updated shareable component, while disabling the first sharing plugin and sending a change broadcast. Figure 1g (Not shown in the image).

[0125] Due to some factor, the second shared plugin repeatedly crashed during operation.

[0126] When the cumulative number of crashes of the second shared plugin reaches a threshold, the second shared plugin is considered to be abnormal.

[0127] If an error is detected in the second shared plugin, disable the second shared plugin.

[0128] After receiving the change notification, the external application queries the content provider for available shared plugins. Since both the first and second shared plugins are disabled at this time, no shared plugins are available, and the content provider returns an empty value. Accordingly, based on the empty value returned by the content provider, the external application determines that no shared plugins are available and receives a notification to enable the local component corresponding to the shareable component. If the local component exists, it is enabled accordingly.

[0129] In addition, the first shared plugin is re-enabled, and the current application is controlled to load the first shared plugin.

[0130] As shown above, this not only enables automatic reverting of plugin versions when an error occurs after a plugin update, but also prevents the spread of abnormal plugins.

[0131] In addition, in other embodiments, since the second shared plugin cannot function properly, operations such as adding the second shared plugin to the blacklist and deleting the second shared plugin can also be performed.

[0132] As can be seen from the above, the component sharing method provided in this application first identifies shareable components that can be shared with external applications from the current application, then encapsulates the selectable shareable components into a plugin to obtain a shared plugin, then installs the shared plugin into the current application and controls the current application to load it, so that the current application can use the functions of the shared plugin encapsulated by the shared plugin. In addition, it notifies external applications to obtain the shared plugin, so that after obtaining the shared plugin from the current application, the external applications can install and load the shared plugin, thereby using the functions of the shareable components encapsulated by the shared plugin, thus realizing the sharing of the same component between different applications, and achieving the goal of improving the reusability of application resources.

[0133] Please refer to Figure 2 Taking an electronic device as an example, the execution subject of the component sharing method provided in this application can also be as follows:

[0134] In section 201, the electronic device identifies shareable components in the current application that can be shared with external applications.

[0135] It should be noted that "current application" is used to refer to an application that can provide components for sharing, rather than referring to a specific application. "Current application" can be any application in an electronic device.

[0136] In this embodiment, the electronic device first determines, according to the configured shareable component determination strategy, the components in the current application's local components that can be shared with external applications, and records these components as shareable components. External applications can be applications other than the current application installed on the electronic device. For example, if the electronic device has applications A, B, and C installed, and application A is determined to be the current application, then applications B and C are external applications of the current application (application A).

[0137] Furthermore, the configuration of the shareable component determination strategy in this application embodiment is not limited. For example, the shareable component determination strategy can be configured as follows: a data table is used to record the identification information of whether different components in the current application can be shared with external applications. Accordingly, when determining the components in the current application that can be shared with external applications, the components in the current application that are identified as shareable can be determined by looking up the table.

[0138] In 202, the electronic device encapsulates the shareable component into a plug-in to obtain the first shared plug-in.

[0139] As described above, after identifying the shareable components that can be shared with external applications within the current application, the electronic device further encapsulates these shareable components into a plugin, resulting in a shared plugin for sharing the shareable components. This shared plugin is designated as the first shared plugin. It should be noted that, compared to ordinary components, plugins can be understood as pluggable components. Plugins can be dynamically loaded during application runtime to extend the application's functionality. For example, they can extend social features to a music application, or data analysis features to a video application, and so on.

[0140] The main process of encapsulating shareable components as plugins can be summarized as follows:

[0141] Define the plugin interface: First, define the plugin interface based on the functionality of the shareable component, and add the interface code to the current application. This allows the interface code to be referenced by both the current application (which is also the host application) and the plugin, serving as a communication bridge between the current application and the plugin. It should be noted that the interface code should not be obfuscated. Obfuscation refers to transforming the original code into obscure symbols using certain rules to improve code security. The plugin interface can be used with dynamic proxies, that is, a proxy object for the plugin interface is created at runtime to proxy calls to the plugin interface and handle exceptions when calls fail. This way, even if the plugin interface call fails, the current application can gracefully handle the error instead of crashing.

[0142] Creating plugin metadata: Plugins typically need metadata to describe themselves, such as name, version, author, and dependency information. This metadata can be stored in configuration files or specific classes.

[0143] Plugin encapsulation: Package the shareable components and their dependencies into a standalone plugin package, which can be a JAR file or ZIP or other suitable format. It is necessary to ensure that all classes and resources are in the correct package and directory structure.

[0144] Following the above process, the shareable components in the current application can be packaged into an independent plugin package that can be used to install the first shared plugin.

[0145] It should be noted that, in order to ensure that the shareable component encapsulated as a plugin can function properly, the following precautions should be taken when encapsulating the shareable component as a plugin:

[0146] (1) Interface decoupling: Shared plugins need to maintain a highly cohesive and loosely coupled code architecture. The interface layer (including the plugin interface of the shared plugin) is separated out and used specifically for dependency communication with the outside. The interface layer is not packaged into the shared plugin, but added to the host application as a communication bridge between the shared plugin and the host application.

[0147] (2) Code obfuscation configuration: Since the code obfuscation rules of different applications are not consistent, if application 1 obfuscates the add interface of the interface layer as a, while application 2 obfuscates the add interface of the interface layer as b, then when the shared plugin of application 1 is copied and installed to application 2, the obfuscated add interface of the interface layer will not be found. Therefore, it is necessary to ensure that the interface layer code is not obfuscated.

[0148] (3) Runtime Environment Configuration: The shared plugin relies on external dependencies (i.e., the external dependencies of the shareable components encapsulated by the shared plugin), such as basic components like network components and reporting components. These external dependencies are also directly depended upon by the host application. Therefore, if the external application does not establish dependency relationships with these external dependencies, the shared plugin cannot run properly within that external application. Accordingly, it is necessary to notify the external application to establish dependency relationships with the shared plugin's external dependencies and ensure that the code of the external dependencies is not obfuscated.

[0149] (4) Resource conflict resolution: The resource classes of the shared plugin no longer inherit from the resource classes of the original host. This is because the shared plugin will have multiple host applications after sharing. If it still depends on the resource classes of the original host, then when it is shared with external applications (i.e., other host applications), the resource classes of the original host will not be found. Therefore, the resource classes of the shared plugin need to be independent of the original host application.

[0150] In step 203, the electronic device installs the first shared plugin into the current application and controls the current application to load the first shared plugin.

[0151] As shown above, by encapsulating the shareable components into plugins, the plugin package of the first shared plugin is obtained. At this point, the electronic device can install the first shared plugin into the current application.

[0152] The process of installing the first shared plugin into the current application is as follows:

[0153] Place plugin: Based on the requirements of the current application, copy the plugin data (including code, resources, etc. of shareable components) from the plugin package of the first shared plugin to the plugin directory of the current application.

[0154] Activate Plugin: Verify the installation of the first shared plugin to ensure it is installed correctly and all plugin data is in the correct location; configure any settings or parameters required by the first shared plugin to suit the current application's usage environment.

[0155] By following the above steps, the first shared plugin can be installed into the current application.

[0156] Furthermore, when the current application requires the use of a shareable component, the process of controlling the current application to load the first installed shared plugin can be as follows:

[0157] Memory loading: Loads the code and resources of the first shared plugin (that is, the code and resources of the shareable components) into the memory area corresponding to the current application.

[0158] Integration Functionality: Integrates the functionality provided by the first shared plugin (i.e., the functionality provided by the shareable component) into the current application.

[0159] By following the above process, the current application can load the first shared plugin, thereby enabling it to use the functions of the shareable components encapsulated by the first shared plugin.

[0160] In 204, the electronic device identifies the external dependencies of the shareable components and notifies the external applications to establish a dependency relationship with the external dependencies.

[0161] It should be noted that, for components, external dependencies refer to code or resources that the component depends on but are not provided by the component or application itself. These dependencies typically come from third-party libraries, frameworks, or other external resources. External dependencies are an indispensable part of modern software development because they can provide ready-made functionality, reduce development time, and improve code quality. For example, the normal operation of a component depends on some external basic components, such as network components or reporting components provided by the system.

[0162] In this embodiment of the application, in order to ensure that the shareable component can run normally in the external application when it is shared to the external application in the form of a plug-in, the electronic device also determines the external dependencies of the shareable component. The external dependencies may be external components, code and resources that the shareable component depends on. Then, the external application is further notified to establish a dependency relationship with these external dependencies, thereby providing the runtime environment for the shareable component.

[0163] In step 205, the electronic device notifies an external application to obtain a first shared plugin, which is used by the external application to load after installation.

[0164] Furthermore, the electronic device, according to a configured notification policy, notifies external applications to obtain the first shared plugin from the current application. This allows the external application to install and load the first shared plugin, thereby enabling the reuse of the shareable components encapsulated within it. For example, when the electronic device uses the Android system, a broadcast mechanism can be used to facilitate the transmission of information between different applications.

[0165] In 206, the electronic device updates the first shared plugin to obtain the second shared plugin in response to an update of the shareable component.

[0166] Understandably, applications continue to be updated after their release, and component updates are a crucial part of this process. Typically, component updates involve improvements to functionality, increased performance, and bug fixes, but other factors can also necessitate updates.

[0167] In this embodiment of the application, after the electronic device shares a shareable component to an external application through a first shared plugin, if it detects that the shareable component has been updated, it updates the first shared plugin according to the updated shareable component to obtain a second shared plugin. Specifically, the second shared plugin can be obtained by incrementally updating the first shared plugin based on the difference between the shareable component and the updated shareable component; alternatively, the updated shareable component can be repackaged into a plugin to obtain the second shared plugin.

[0168] In step 207, the electronic device installs the second shared plugin into the current application and controls the current application to load the second shared plugin.

[0169] As described above, after obtaining the second shared plugin that encapsulates the updated shareable component, the electronic device installs the second shared plugin into the current application and controls the current application to load the second shared plugin. The specific implementation can be referred to the above method of installing the first shared plugin into the current application and controlling the current application to load the first shared plugin, which will not be repeated here.

[0170] In step 208, the electronic device disables the first shared plugin and notifies the external application to obtain the second shared plugin, which is used by the external application to load after installation.

[0171] In addition, the electronic device disables the first shared plugin and notifies external applications to obtain the second shared plugin. After obtaining the second shared plugin from the current application, the external application can install and load the second shared plugin, thereby using the functions of the updated shareable component encapsulated by the second shared plugin to update the shareable component in different applications.

[0172] For example, by publishing a change broadcast through the current application, external applications that have registered for change broadcasts will receive the broadcast. In response to the change broadcast, the external application queries the shared plugin through the query interface provided by the content provider. Since the first shared plugin is disabled at this time, the content provider returns the file descriptor of the currently available shared plugin (in this case, the second shared plugin) in response to the query. Based on this file descriptor, the external application can copy the plugin package of the second shared plugin corresponding to the file descriptor to its own plugin directory. Based on the plugin package of the second shared plugin, the external application can install and load the second shared plugin. For details, please refer to the relevant description of the current application installing and loading the first shared plugin in the above embodiment, which will not be repeated here.

[0173] It should be noted that disabling a plugin refers to marking an installed plugin as unavailable within an application, thereby preventing it from being loaded and used at runtime. This process typically does not delete the plugin's files; it only temporarily prevents its functionality from being activated. For example, you can set the plugin's status to disabled by modifying its configuration file (such as plugins.xml or manifest.json), or you can disable the plugin via command-line tools or scripts, and so on.

[0174] The update scheme for shareable components provided in the above embodiments of this application only requires the original host application of the shareable component (i.e., the current application mentioned above) to be responsible for updating and maintaining it. When the shareable component is updated, the original host application that is maintaining it updates and encapsulates the shareable component's shared plugin accordingly, and actively notifies its external applications, so that the external applications can actively synchronize the updated shared plugin. In this way, the shareable components of multiple different applications only need to be updated once to make them effective for multiple external applications.

[0175] In 209, the electronic device responds to an anomaly in the second shared plugin by disabling the second shared plugin, so that when an external application finds that no shared plugin is available in the current application, it receives a notification to enable the local component corresponding to the shareable component.

[0176] In this embodiment, the electronic device identifies whether the second shared plugin has malfunctioned according to a configured anomaly detection strategy. The configuration of the anomaly detection strategy is not specifically limited here; for example, the anomaly detection strategy can be configured as follows: count the number of crashes of the second shared plugin, and determine that the second shared plugin has malfunctioned when the cumulative number of crashes reaches a threshold.

[0177] If an anomaly is detected in the second shared plugin, the electronic device further disables the second shared plugin. Thus, when an external application queries for shared plugins in response to a change broadcast, since both the first and second shared plugins are disabled at this time, the external application will not be able to find any available shared plugins. Based on the query result that no shared plugins are available, the external application receives a notification to enable the local component corresponding to the shareable component.

[0178] As shown above, after receiving the notification, if an external application has a local component corresponding to the shareable component, it will enable the local component to achieve the same function as the shareable component. If no local component corresponding to the shareable component exists, it can continue to load the first shared plugin and still use the shareable component encapsulated by the first shared plugin that has not encountered any exceptions.

[0179] In scenarios where there is a local component corresponding to a shareable component in an external application, the local component can exist as an original component or as a plugin.

[0180] For example, if an external application has a local component corresponding to the shareable component, referring to the method of encapsulating the shareable component as a first shared plugin in the above embodiments, the external application encapsulates the local component as a local plugin, installs the local plugin, and then loads and uses it. After receiving a notification from the current application to obtain the first shared plugin, the application queries and obtains the first shared plugin from the current application, installs the first shared plugin, and then loads and uses it. Furthermore, after receiving a notification from the current application to obtain the second shared plugin, since both the first and second shared plugins are disabled, no available shared plugins can be found. At this time, a notification to enable the local component corresponding to the shareable component is received, and the local plugin encapsulated with the local component is reloaded, thereby using the local component.

[0181] In 210, the electronic device enables the first shared plugin and controls the current application to load the first shared plugin.

[0182] In this embodiment of the application, in order for the current application to provide services normally, the first shared plugin is re-enabled and the current application is controlled to load the first shared plugin, so as to continue to use the functions of the shareable components encapsulated by the first shared plugin, thereby realizing the rollback of the plugin version (i.e., from the second shared plugin to the first shared plugin).

[0183] As shown above, by encapsulating components as plugins, the same component can be shared across different applications. Furthermore, multiple shared components from different applications can be updated once to take effect on multiple external applications. In addition, automatic rollback of plugin versions is implemented when an exception occurs after a plugin update, while preventing the spread of abnormal plugins.

[0184] To facilitate better implementation of the above component sharing method, this application also provides a corresponding component sharing device. The meanings of the terms used are the same as in the above component sharing method; for specific implementation details, please refer to the descriptions in the above method embodiments.

[0185] Please refer to Figure 3 , Figure 3 This is a schematic diagram of the structure of the component sharing device provided in the embodiments of this application. The component sharing device may include a component determination module 310, a plug-in encapsulation module 320, a plug-in application module 330, and a plug-in sharing module 340, wherein...

[0186] The component determination module 310 is used to determine the shareable components in the current application that can be shared with external applications.

[0187] The plug-in encapsulation module 320 is used to encapsulate the shareable component into a plug-in to obtain the first shared plug-in;

[0188] The plugin application module 330 is used to install the first shared plugin into the current application and control the current application to load the first shared plugin;

[0189] The plugin sharing module 340 is used to notify external applications to obtain the first shared plugin, which is then loaded by the external application after installation.

[0190] Optionally, in one embodiment, during the process of encapsulating a shareable component into a first shared plugin, the plugin encapsulation module 320 is used to compile the resources corresponding to the shareable component according to a preset starting value of the resource identifier, wherein the preset starting value is outside the range of resource identifiers used by external applications for resource compilation.

[0191] Optionally, in one embodiment, the plug-in encapsulation module 320 is further configured to update the first shared plug-in to obtain the second shared plug-in in response to an update of the shareable component;

[0192] The plugin application module 330 is also used to install the second shared plugin into the current application and control the current application to load the second shared plugin;

[0193] The plugin sharing module 340 is also used to disable the first shared plugin and notify external applications to obtain the second shared plugin, which is loaded after the external application is installed.

[0194] Optionally, in one embodiment, the plug-in sharing module 340 is further configured to notify an external application to enable the local component corresponding to the shareable component in response to an exception occurring in the second shared plug-in.

[0195] Optionally, in one embodiment, the plugin sharing module 340 is used to disable the second shared plugin, so that when an external application finds that there is no available shared plugin in the current application, it receives a notification to enable the local component corresponding to the shareable component.

[0196] Optionally, in one embodiment, the plug-in application module 330 is further configured to enable the first shared plug-in and control the current application to load the first shared plug-in.

[0197] Optionally, in one embodiment, the plug-in sharing module 340 is further configured to determine the external dependencies of the shareable component; and to notify the external application to establish a dependency relationship with the external dependency.

[0198] As can be seen from the above, the component sharing device provided in this application first determines the shareable components in the current application that can be shared with external applications through the component determination module 310. Then, the plug-in encapsulation module 320 encapsulates the shareable components into plug-ins to obtain shared plug-ins. Next, the plug-in application module 330 installs the shared plug-in into the current application and controls the current application to load the shared plug-in. Finally, the plug-in sharing module 340 notifies the external application to obtain the shared plug-in so that after obtaining the shared plug-in from the current application, the external application can install and load the shared plug-in, thereby enabling it to use the functions of the shareable components encapsulated by the shared plug-in. This achieves the sharing of shareable components between the current application and external applications, thereby improving the reusability of application resources.

[0199] For details on the implementation of each of the above modules, please refer to the previous examples, which will not be repeated here.

[0200] This application also provides an electronic device, including a memory and a processor, wherein the processor executes the steps in the component sharing method provided in the above embodiments by calling a computer program stored in the memory.

[0201] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0202] The electronic device may include components such as a processor 101 with one or more processing cores, a memory 102 with one or more computer-readable storage media, a power supply 103, and an input unit 104. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0203] The processor 101 is the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It executes software programs and / or modules stored in the memory 102, and calls data stored in the memory 102, to perform various functions and process data. Optionally, the processor 101 may include one or more processing cores; alternatively, the processor 101 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 101.

[0204] The memory 102 can be used to store software programs and modules. The processor 101 executes various functional applications and data processing by running the software programs and modules stored in the memory 102. The memory 102 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 102 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 102 may also include a memory controller to provide the processor 101 with access to the memory 102.

[0205] The electronic device also includes a power supply 103 that supplies power to the various components. Optionally, the power supply 103 can be logically connected to the processor 101 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 103 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0206] The electronic device may also include an input unit 104, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0207] Although not shown, the electronic device may also include a display unit, an image acquisition component, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 101 loads one or more executable codes corresponding to computer programs into the memory 102, and the processor 101 executes the steps in the component sharing method provided in this application, such as:

[0208] Identify shareable components in the current application that can be shared with external applications;

[0209] The shareable component is encapsulated into a plugin to obtain the first shared plugin;

[0210] Install the first shared plugin into the current application and control the current application to load the first shared plugin;

[0211] Notify external applications to obtain the first shared plugin, which is used by external applications to load after installation.

[0212] It should be noted that the electronic device provided in this application embodiment and the component sharing method in the above embodiment belong to the same concept, and the specific implementation process can be found in the above related embodiments, which will not be repeated here.

[0213] This application also provides a computer-readable storage medium storing a computer program thereon. When the computer program stored thereon is executed on the processor of the electronic device provided in the embodiments of this application, the processor of the electronic device implements the steps in the component sharing method provided in this application. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0214] This application also provides a computer program product comprising a computer program that, when executed on a processor, causes the processor to implement the steps in the component sharing method provided in this application.

[0215] The component sharing method, component sharing device, electronic device, computer-readable storage medium, and computer program product provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

[0216] It should be noted that when the above embodiments of this application are applied to specific products or technologies, user-related data is involved, and user permission or consent is required. Furthermore, the collection, use, and processing of such data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

Claims

1. A component sharing method, characterized in that, include: Identify shareable components in the current application that can be shared with external applications; The shareable component is encapsulated into a plugin to obtain a first shared plugin; Install the first shared plugin into the current application, and control the current application to load the first shared plugin; The external application is notified to obtain the first shared plugin, which is used by the external application to load after installation.

2. The component sharing method according to claim 1, characterized in that, The step of encapsulating the shareable component into a first shared plugin includes: In the process of encapsulating the shareable component into a first shared plugin, the resources corresponding to the shareable component are compiled according to the preset starting value of the resource identifier, wherein the preset starting value is outside the range of the resource identifier used by the external application for resource compilation.

3. The component sharing method according to claim 1, characterized in that, After notifying the external application to obtain the first shared plugin, the method further includes: In response to an update of the shareable component, the first shared plugin is updated according to the updated shareable component to obtain the second shared plugin; Install the second shared plugin into the current application, and control the current application to load the second shared plugin; The first shared plugin is disabled, and the external application is notified to obtain the second shared plugin, which is loaded by the external application after installation.

4. The component sharing method according to claim 3, characterized in that, After notifying the external application to obtain the second shared plugin, the method further includes: In response to an error occurring in the second shared plugin, the external application is notified to enable the local component corresponding to the shareable component.

5. The component sharing method according to claim 4, characterized in that, The notification to the external application to enable the local component corresponding to the shareable component includes: Disabling the second shared plugin enables the external application to receive a notification to enable the local component corresponding to the shareable component when it finds that no shared plugin is available in the current application.

6. The component sharing method according to claim 4, characterized in that, After notifying the external application to enable the local component corresponding to the shareable component, the method further includes: Enable the first shared plugin and control the current application to load the first shared plugin.

7. The component sharing method according to claim 1, characterized in that, Before notifying the external application to obtain the first shared plugin, the method further includes: Determine the external dependencies of the shareable component; The notification establishes a dependency relationship between the external application and the external dependency.

8. A component sharing device, characterized in that, include: The component determination module is used to determine the shareable components in the current application that can be shared with external applications; A plug-in encapsulation module is used to encapsulate the shareable component into a plug-in to obtain a first shared plug-in. The plugin application module is used to install the first shared plugin into the current application and control the current application to load the first shared plugin; The plugin sharing module is used to notify the external application to obtain the first shared plugin, which is loaded by the external application after installation.

9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, implements the steps of the component sharing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for execution by a processor to implement the steps of the component sharing method according to any one of claims 1 to 7.