Service discovery method, apparatus, device, storage medium, and product
By registering service data in the target database and querying using service discovery parameters, service discovery is prioritized in the local database, thus solving the problem of low service discovery efficiency between electronic devices and achieving efficient and reliable service discovery.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2023-08-17
- Publication Date
- 2026-06-16
AI Technical Summary
In the era of the Internet of Everything, the efficiency of service discovery between electronic devices is low, and existing technologies are unable to efficiently discover remote devices and cloud system services.
By registering service data in the target database and querying directly based on service discovery parameters, service discovery is prioritized in the local database, and a priority strategy is used to query in the cloud database, thus shortening the service discovery process.
It improves the efficiency of service discovery, saves time and resources, and ensures the comprehensiveness and reliability of service discovery.
Smart Images

Figure CN119496813B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a service discovery method, apparatus, device, storage medium, and product. Background Technology
[0002] In the era of the Internet of Everything, electronic devices such as mobile phones, laptops, tablets, cars, and home appliances can seamlessly connect and communicate. Different electronic devices may be registered for different services, and they can communicate with each other to use services on other devices. When one electronic device uses a service on another, it needs to discover the services registered by that other device. Summary of the Invention
[0003] This application provides a service discovery method, apparatus, device, storage medium, and product, which can improve the efficiency of service discovery. The technical solution is as follows:
[0004] On the one hand, a service discovery method is provided, the method comprising:
[0005] A target database is determined, which includes at least one of a first database and a second database, wherein the first database is used to store end-side service data of a first electronic device, and the second database is used to store cloud-side service data of a cloud server.
[0006] Determine service discovery parameters, which are used to constrain the discovered services;
[0007] Based on the service discovery parameters, a service discovery operation is performed in the target database.
[0008] On the other hand, a service discovery apparatus is provided, the apparatus comprising:
[0009] The first determining module is used to determine the target database, which includes at least one of a first database and a second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server.
[0010] The second determining module is used to determine service discovery parameters, which are used to constrain the discovered services.
[0011] The discovery module is used to perform service discovery operations in the target database based on the service discovery parameters.
[0012] On the other hand, an electronic device is provided, comprising one or more processors and one or more memories, wherein at least one piece of program code is stored in the one or more memories, and the at least one piece of program code is loaded and executed by the one or more processors to implement the service discovery method described above.
[0013] On the other hand, a computer-readable storage medium is provided, wherein at least one piece of program code is stored therein, the at least one piece of program code being loaded and executed by a processor to implement the service discovery method described above.
[0014] On the other hand, a computer program product is provided, which stores at least one piece of program code for execution by a processor to implement the service discovery method described above.
[0015] In this embodiment of the application, by registering service data to the target database, service data can be directly queried from the target database based on service discovery parameters during service discovery, thereby shortening the service discovery process, saving service discovery time, and thus improving the efficiency of service discovery. Attached Figure Description
[0016] Figure 1 A schematic diagram illustrating the implementation environment of the service discovery method according to an exemplary embodiment of this application is shown;
[0017] Figure 2 A schematic diagram illustrating a service discovery database is shown in an exemplary embodiment of this application;
[0018] Figure 3 A schematic diagram illustrating a service discovery database is shown in an exemplary embodiment of this application;
[0019] Figure 4 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0020] Figure 5 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0021] Figure 6 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0022] Figure 7 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0023] Figure 8 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0024] Figure 9 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0025] Figure 10 A schematic diagram illustrating a service discovery method according to an exemplary embodiment of this application is shown;
[0026] Figure 11 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0027] Figure 12 A flowchart illustrating a service discovery method in an exemplary embodiment of this application is shown;
[0028] Figure 13 A block diagram illustrating a service discovery apparatus according to an exemplary embodiment of this application is shown;
[0029] Figure 14 A block diagram of an electronic device illustrated in an exemplary embodiment of this application is shown. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0031] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0032] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the data service discovery parameters and service data involved in this application were obtained with full authorization.
[0033] To more clearly describe the technical solutions of the embodiments of this application, the functions and definitions of the terms involved in the embodiments of this application will be described in detail below:
[0034] Service discovery: Service callers access the service discovery interface, passing in some or all of the specified query conditions (service discovery parameters). Service discovery can then be performed through a conditional service discoverer. The result of service discovery is a list of (service data + device identifier), which includes at least one service data entry with a device identifier. To increase the comprehensiveness of target services, service discovery can be performed not only on the client side (in the local database) but also, under certain conditions, by requesting the cloud service discovery interface to discover remote devices, cloud system services, and service marketplace services.
[0035] Service Registration: After service installation, service data needs to be inserted into the local database. Service registration is divided into two main categories: static service registration and dynamic service registration. Static registration refers to scanning for and registering valid services in the device's operating system during system startup or service installation; while dynamic registration occurs when the service is used externally, requiring it to be downloaded and installed locally. The service data from service registration forms part of the data source for service discovery.
[0036] Service synchronization: The process of sending a service registered on one device to other associated devices for storage is called synchronization. Its main purpose is to enable cross-device service discovery. Service synchronization ensures that cross-device queries are not performed during service discovery, thus improving the efficiency of service discovery. The service data synchronized is also part of the data source for service discovery.
[0037] Service Marketplace: Similar to an app store, the service marketplace is a place where services are listed and published. It allows users to discover various services developed by developers, enriching service discovery capabilities. The data in the service marketplace also constitutes a data source for service discovery.
[0038] Data DB: Service storage database, storing service data of registered services on each device and service data of services that are synchronized and filtered.
[0039] Data Source: The data warehouse that the service discovery module queries is collectively referred to as the data source. The data source includes the client-side data database (i.e., the first database mentioned below), the cloud-side data database (i.e., the first sub-database mentioned below), and the service marketplace (i.e., the second sub-database mentioned below). The client-side data database is used for client-side service registration and synchronous service insertion; the cloud-side data database is used for cloud-side service registration and synchronous service insertion; the service marketplace is used for service developers or service marketplace administrators to upload services, and the service marketplace parses the services and stores them in the repository.
[0040] Please refer to Figure 1This diagram illustrates an implementation environment for a service discovery method according to an exemplary embodiment of this application. See also... Figure 1 The implementation environment includes a first electronic device 101, a second electronic device 102, and a cloud server 103. In some embodiments, the first electronic device 101 and the second electronic device 102 establish a connection through the cloud server 103; for example, the first electronic device 101 and the second electronic device 102 log in to the same user account to establish a connection through the cloud server 103. In other embodiments, the first electronic device 101 and the second electronic device 102 can also establish a connection through near-field communication; for example, the first electronic device 101 and the second electronic device 102 establish a connection through Bluetooth or through Near Field Communication (NFC).
[0041] Please refer to Figure 2 Services can be registered in both the first electronic device 101 and the second electronic device 102, and services can be synchronized between them. For example, the first electronic device 101 can synchronize service data from the second electronic device 102, storing the service data registered by the first electronic device 101 and the synchronized service data in a first database. Similarly, services can be registered in the cloud server 103, and service data can also be synchronized from other electronic devices (the first electronic device 101 and the second electronic device 102). The second database of the cloud server 103 includes a first sub-database and a second sub-database. The cloud server 103 stores the service data registered by the cloud server 103 and the synchronized service data in the first sub-database, while the second sub-database is used to store service data in the storage service market. The first electronic device 101 performs service discovery operations in the first database; or the first electronic device 101 performs service discovery operations in either the first or second sub-database.
[0042] Based on the above, the service discovery data sources consist of three parts: the first part is the local first database, also known as the local database (DB); the second part is the cloud's first sub-database, also known as the cloud-side database (DB); and the third part is the cloud's second sub-database, also known as the service marketplace. For these three data sources, it is not necessary to perform queries on all of them to ensure service discovery. Therefore, this application embodiment can set two priority schemes: a local priority scheme and a cloud-side priority scheme. The local priority scheme means that service discovery is first performed in the first database. If the target service is not found in the first database, service discovery is then performed in the first sub-database. If the target service is not found in the first sub-database, service discovery is then performed in the second sub-database. If the target service is not found in the second sub-database, service discovery is then performed in the first database. The local priority scheme saves power consumption and bandwidth, while the cloud-side priority scheme ensures that services are discovered promptly, improving service discovery efficiency.
[0043] In some embodiments, for example, please refer to Figure 3 The first database (device-side data DB) of the first electronic device 101 mainly includes service data of the first electronic device 101 and service data of near-field devices. The service data of the first electronic device 101 includes service data of services scanned locally by the first electronic device 101 and service data of services downloaded from the cloud server 103, specifically services downloaded from the cloud repository of the cloud server 103. The service data of the first electronic device 101 is inserted into the first database through service registration, while the near-field device services are inserted into the first database through service synchronization. Similarly, the second electronic device 102 also has its corresponding first database, and the generation process of the first database of the second electronic device 102 is similar to that of the first electronic device 101, and will not be described again here. The first sub-database of the cloud server 103 mainly includes service data of the cloud server 103 and service data of the device-side devices. The service data of the cloud server 103 includes service data of services scanned locally by the cloud server 103 and service data of services downloaded from the cloud repository. The service data of the device-side devices is synchronized to the first sub-database by other electronic devices.
[0044] The first electronic device 101 can be any network-connected device; for example, the first electronic device 101 can be a mobile phone, laptop computer, desktop computer, tablet computer, in-vehicle terminal, home appliance, vehicle system, wearable device, or any other electronic device that supports service discovery function. Similarly, the second electronic device 102 can also be any network-connected device; for example, the second electronic device 102 can be a mobile phone, laptop computer, desktop computer, tablet computer, in-vehicle terminal, home appliance, vehicle system, wearable device, or any other electronic device that supports service discovery function.
[0045] Please refer to Figure 4 The diagram illustrates a flowchart of a service discovery method according to an exemplary embodiment of this application. The method is performed by a first electronic device, as shown in the reference diagram. Figure 4 The method includes:
[0046] Step 401: Determine the target database, which includes at least one of the first database and the second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server.
[0047] Service data includes service configuration information, such as service name, service identifier (ID), and service Uniform Resource Locator (URL). In some embodiments, the target database includes a first database, which is the device-side database of the first electronic device, meaning that this application can perform service discovery operations in the device-side database. In other embodiments, the target database includes a second database, which is a cloud database, meaning that this application can perform service discovery operations in the cloud database. In some embodiments, the target database includes both a first database and a second database, meaning that this application can perform service discovery operations in both the device-side database and the cloud-side database, improving the reliability of service discovery.
[0048] It should be noted that the executing entity in this application is the first electronic device. When the target database includes a second database, the first electronic device may only identify the object database for which service discovery operations are to be performed, without fetching the second database from the cloud server. Instead, it may utilize the cloud server for service discovery, thereby saving storage resources for the first electronic device. In other embodiments, the first electronic device may also fetch the second database from the cloud server, meaning that local service data can be expanded to include far-field service data, enabling faster and more convenient discovery of far-field services.
[0049] Step 402: Determine the service discovery parameters, which are used to constrain the discovered services.
[0050] The service discovery parameters include at least one of the following: target device identifier, target service identifier, target capability identifier, target service intent, target capability intent, and target assembly protocol; the target device identifier is used to represent the device identifier of the device to which the service to be discovered belongs, the target service identifier is used to represent the service identifier of the service to be discovered, the capability identifier is used to represent the capability identifier of the service to be discovered, the service intent is used to represent the service intent of the service to be discovered, the capability intent is used to represent the capability intent of the service to be discovered, and the target assembly protocol is used to represent the assembly protocol used by the service to be discovered.
[0051] Step 403: Perform service discovery operations in the target database based on the service discovery parameters.
[0052] The first electronic device queries the target database for target services that match the service discovery parameters. Additionally, the target database can store the corresponding device identifier. After identifying the target service, the first electronic device can also determine the device identifier of the device to which the target service belongs. Therefore, the service discovery result is service data + device identifier. Furthermore, there may be multiple target services; therefore, the service discovery result is a list of (service data + device identifier).
[0053] In this embodiment of the application, by registering service data to the target database, service data can be directly queried from the target database based on service discovery parameters during service discovery, thereby shortening the service discovery process, saving service discovery time, and thus improving the efficiency of service discovery.
[0054] Please refer to Figure 5 The diagram illustrates a service discovery method according to an exemplary embodiment of this application. (Reference) Figure 5 The method includes:
[0055] Step 501: The first electronic device determines the target database, which includes a first database and a second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server.
[0056] In some embodiments, this step is the same as step 401, and will not be described again here.
[0057] Step 502: The first electronic device determines the service discovery parameters, which are used to constrain the discovered services.
[0058] In some embodiments, this step is the same as step 402, and will not be described again here.
[0059] In this embodiment, the target database includes a first database and a second database. Therefore, the first electronic device performs service discovery operations in the first and second databases based on the priority levels of the first and second databases, using service discovery parameters. If the priority level of the first database is not lower than the priority level of the second database, steps 503-504 are executed; if the priority level of the first database is lower than the priority level of the second database, steps 505-506 are executed.
[0060] Step 503: If the priority level of the first database is not lower than that of the second database, the first electronic device performs a service discovery operation in the first database based on the service discovery parameters.
[0061] The first electronic device queries the first database for target services that match the service discovery parameters. Additionally, the target database can also store the corresponding device identifier. After identifying the target service, the first electronic device can also determine the device identifier of the device to which the target service belongs. Therefore, the service discovery result is service data + device identifier. Furthermore, there may be multiple target services; therefore, the service discovery result is a list of (service data + device identifier).
[0062] Step 504: If the target service is not found in the first database, the first electronic device performs a service discovery operation in the second database based on the service discovery parameters.
[0063] A first electronic device sends a service discovery request to a cloud server, the request carrying service discovery parameters. The cloud server receives the request, queries a second database for a target service matching the parameters, and sends a service discovery response to the first electronic device, carrying the target service's service data. The first electronic device receives the response and retrieves the target service data from it. Additionally, the cloud server can determine the device identifier of the device to which the target service belongs; this identifier is also carried in the service discovery response. In this embodiment, the access to the cloud server's second database ensures the discovery of both cloud-side and remote-field services, expanding the scope of service discovery and enabling users to remotely process service content.
[0064] The second database comprises a first sub-database and a second sub-database. The first sub-database stores service data related to cloud server registration and synchronization, while the second sub-database stores service data from the storage service marketplace. Correspondingly, the first electronic device performs service discovery operations in the second database based on service discovery parameters. This includes the first electronic device performing service discovery operations in both the first and second sub-databases based on their respective priority levels.
[0065] If the priority of the first sub-database is not lower than that of the second sub-database, the first electronic device performs service discovery operations in the first sub-database based on service discovery parameters; for example, the first electronic device queries the first sub-database for target services that match the service discovery parameters. If the priority of the first sub-database is lower than that of the second sub-database, the first electronic device performs service discovery operations in the second sub-database based on service discovery parameters; for example, the first electronic device queries the second sub-database for target services that match the service discovery parameters.
[0066] In some embodiments, if a service cannot be discovered in either the local first database or the cloud server's first sub-database, the service will be queried from the cloud server's service marketplace, i.e., service discovery will be performed in the second sub-database. Furthermore, after the target service data is found in the second sub-database, the first electronic device downloads the target service data to its local machine and stores the target service data in the first database, providing data for subsequent service discovery.
[0067] Step 505: If the priority of the first database is lower than that of the second database, the first electronic device performs service discovery operation in the second database based on the service discovery parameters.
[0068] In some embodiments, the process of the first electronic device performing service discovery operations in the second database based on service discovery parameters is the same as the process of the first electronic device performing service discovery operations in the second database based on service discovery parameters in step 504, and will not be described again here.
[0069] Step 506: If the target service is not found in the second database, the first electronic device performs a service discovery operation in the first database based on the service discovery parameters.
[0070] In some embodiments, the process of the first electronic device performing service discovery operations in the first database based on service discovery parameters is the same as the process of the first electronic device performing service discovery operations in the first database based on service discovery parameters in step 503, and will not be described again here.
[0071] In this embodiment, by registering service data to the target database, service discovery can be performed by directly querying the target database based on service discovery parameters. This shortens the service discovery process, saves time, and improves efficiency. Furthermore, by employing a priority strategy, both efficient and comprehensive service discovery can be ensured.
[0072] Please refer to Figure 6 This document illustrates a flowchart of a service discovery method according to an exemplary embodiment of this application. In this embodiment, the example is provided where the priority level of the first database is not lower than that of the second database, and the priority level of the first sub-database included in the second database is not lower than that of the second sub-database. (See reference...) Figure 6 The method includes:
[0073] Step 601: The first electronic device determines the service discovery parameters, which are used to constrain the discovered services.
[0074] In some embodiments, this step is the same as step 402, and will not be described again here.
[0075] Step 602: The first electronic device performs a service discovery operation in the first database based on the service discovery parameters.
[0076] In some embodiments, this step is the same as the process in step 503 where the first electronic device performs service discovery operations in the first database based on service discovery parameters, and will not be described again here. For example, please refer to Figure 7 The service caller invokes the service discovery interface, and the first electronic device performs a service discovery operation in the local first database based on the service discovery interface, that is, it queries the local database for a list of (service data + device identifier).
[0077] Step 603: If the target service is not found in the first database, the first electronic device performs a service discovery operation in the first sub-database based on the service discovery parameters.
[0078] In some embodiments, the process of the first electronic device performing service discovery operations in the first sub-database based on service discovery parameters is the same as the process of the first electronic device performing service discovery operations in the first sub-database based on service discovery parameters in step 504, and will not be repeated here. For example, please refer to... Figure 7 If the target service is not found in the local first database, the first electronic device requests the cloud server to perform service discovery; the cloud server performs service discovery in the first sub-database, that is, queries the cloud database for a list of (service data + device identifier).
[0079] Step 604: If the target service is not found in the first sub-database, the first electronic device performs a service discovery operation in the second sub-database based on the service discovery parameters.
[0080] In some embodiments, the process of the first electronic device performing service discovery operations in the second sub-database based on service discovery parameters is the same as the process in step 504 where the first electronic device performs service discovery operations in the second sub-database based on service discovery parameters, and will not be repeated here. For example, please refer to... Figure 7 If the target service is not found in the first sub-database, the cloud server performs service discovery in the second sub-database, that is, it queries the service market for a list of (service data + device identifier).
[0081] In this embodiment, during service discovery, the system prioritizes querying the local first database. Only if the service is not found in the first database is the system queryed in the cloud's second database. Since the target service is found in the local first database, there is no need to request service discovery from the cloud, thus saving power consumption and bandwidth for the first electronic device.
[0082] Please refer to Figure 8 This document illustrates a flowchart of a service discovery method according to an exemplary embodiment of this application. In this embodiment, the example is provided where the priority level of the first database is not lower than that of the second database, and the priority level of the first sub-database included in the second database is not lower than that of the second sub-database. (See reference...) Figure 8 The method includes:
[0083] Step 801: The first electronic device determines the service discovery parameters, which are used to constrain the discovered services.
[0084] In some embodiments, this step is the same as step 402, and will not be described again here.
[0085] Step 802: The first electronic device performs a service discovery operation in the first sub-database based on the service discovery parameters.
[0086] In some embodiments, the process of the first electronic device performing service discovery operations in the first sub-database based on service discovery parameters is the same as the process of the first electronic device performing service discovery operations in the first sub-database based on service discovery parameters in step 504, and will not be described again here.
[0087] Step 803: If the target service is not found in the first sub-database, the first electronic device performs a service discovery operation in the second sub-database based on the service discovery parameters.
[0088] In some embodiments, the process of the first electronic device performing service discovery operations in the second sub-database based on service discovery parameters is the same as the process of the first electronic device performing service discovery operations in the second sub-database based on service discovery parameters in step 504, and will not be described again here.
[0089] Step 804: If the target service is not found in the second sub-database, the first electronic device performs a service discovery operation in the first database based on the service discovery parameters.
[0090] In some embodiments, this step is the same as the process in step 503 where the first electronic device performs a service discovery operation in the first database based on service discovery parameters, and will not be described again here.
[0091] In this embodiment, during service discovery, queries are first performed in the first and second sub-databases in the cloud. Only when the service is not found in the cloud is a query performed in the first database on the local machine. Since the first and second sub-databases in the cloud contain more comprehensive service data, there is a higher probability that the target service can be found in the cloud, thereby improving the efficiency of service discovery.
[0092] Please refer to Figure 9 The diagram illustrates a service discovery method according to an exemplary embodiment of this application. (Reference) Figure 9 The method includes:
[0093] Step 901: The first electronic device determines the target database, which includes at least one of the first database and the second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server.
[0094] In some embodiments, this step is the same as step 401, and will not be described again here.
[0095] Step 902: The first electronic device determines the service discovery parameters, which are used to constrain the discovered services.
[0096] In some embodiments, this step is the same as step 402, and will not be described again here.
[0097] Step 903: The first electronic device configures the filtering conditions of the service filter based on the service discovery parameters.
[0098] The filtering conditions are used to filter services that do not conform to the service discovery parameters. The service discovery parameters include at least one of the following: target device identifier, target service identifier, target capability identifier, target service intent, target capability intent, and target assembly protocol. In this step, the first electronic device configuring the filtering conditions of the service filter based on the service discovery parameters can be as follows: the first electronic device sets the filtering conditions of the service filter to filter services whose device identifier is not the target device identifier, whose service identifier is not the target service identifier, whose capability identifier is not the target capability identifier, whose service intent is not the target service intent, whose capability intent is not the target capability intent, and whose assembly protocol is the target assembly protocol, at least one of the following:
[0099] The target device identifier is used to represent the device identifier of the device to which the service to be discovered belongs. When the service discovery parameters include the target device identifier, the service filter queries the service data of the device corresponding to the target device identifier. When the service discovery parameters do not include the target device identifier, the service filter queries the service data of all devices of the currently logged-in account in the target database. In some embodiments, before the first electronic device configures the filter conditions based on the target device identifier, it is first determined whether the target device identifier is the device identifier of the device to which the currently logged-in account belongs. If the target device identifier is the device identifier of the device to which the currently logged-in account belongs, the step of configuring the filter conditions based on the target device identifier is executed. If the target device identifier is not the device identifier of the device to which the currently logged-in account belongs, the target device identifier is discarded, that is, the filter conditions are not configured based on the target device identifier, thereby ensuring the security of service discovery.
[0100] The target service identifier represents the service identifier of the service to be discovered, i.e., it specifies a specific service ID. The capability identifier represents the capability of the service to be discovered, i.e., it specifies a specific capability ID. This capability identifier can be an identifier of a standard capability or an identifier of a specific service capability. If the capability identifier is an identifier of a standard capability, the first electronic device first converts the standard capability into a specific capability that supports the standard capability, and then configures the filtering conditions of the service filter based on the converted capability identifier.
[0101] Service intent is used to represent the service intent of the service to be discovered. Currently, services support intent matching by keyword (Action), and the object of intent matching is the intent field in the service data's config.json. That is, after the first electronic device configures the filtering conditions of the service filter based on the service intent, when the first electronic device filters services based on the configured service filter, it filters services that do not conform to the service intent by matching the intent field.
[0102] Capability intent is used to represent the capability intent of a service to be discovered; it is described by an Action, an input parameter list, and an output parameter list. After the first electronic device configures the filtering conditions of the service filter based on the capability intent, when filtering services based on the configured service filter, the first electronic device performs fuzzy matching between the Action and the tags in the capability implementation definition information, and then matches the input parameter type and output parameter type of the capability implementation based on the input parameter list and output parameter list, ultimately matching the target service.
[0103] The target assembly protocol is used to represent the assembly protocol used by the service to be discovered. Currently, services can be matched for intent by using the service assembly protocol, and the object matched by the assembly protocol is the service offering assembly protocol (offer) defined in the service data's config.json. That is, after the first electronic device configures the filtering conditions of the service filter based on the target assembly protocol, when the first electronic device filters services based on the configured service filter, it filters services that do not conform to the target assembly protocol by matching the assembly protocol.
[0104] In some embodiments, the service filter has the following format:
[0105] {
[0106] “filters”:[
[0107] {
[0108] "type": "DEVICE_ID",
[0109] "value":{"ids":["xxx"]}
[0110] },
[0111] {
[0112] "type":"SERVICE_ID",
[0113] "value":{"serviceId":"xxx"}
[0114] },
[0115] {
[0116] "type":"CAPABILITY_ID",
[0117] "value":{"capabilityId":"xxx"}
[0118] },
[0119] {
[0120] "type":"SERVICE_INTENT",
[0121] “value”:{
[0122] "actions": ["navigation"]
[0123] }
[0124] },
[0125] {
[0126] "type":"CAPABILITY_INTENT",
[0127] “value”:{
[0128] "actions":["navigation"],
[0129] "inputs":["String","Video"],
[0130] “outputs”:[“Video”]
[0131] }
[0132] },
[0133] {
[0134] "type": "USE_ACTION",
[0135] “value”:{
[0136] "actions":["pantanal.pidl.PIDL_STANDARD_ACTION"],
[0137] }
[0138] }, ]
[0140] }
[0141] In some embodiments, service discovery parameters can be set and changed as needed. The service discovery parameters above are just examples. Depending on the needs, the service discovery parameters may change, such as adding one or more service discovery parameters or changing to other service discovery parameters, thereby configuring service filters with other filtering conditions, and thus ensuring the adaptability of service filters in service discovery.
[0142] Step 904: The first electronic device filters out services in the target service database that do not meet at least one filtering condition through the configured service filter, and obtains at least one service set.
[0143] At least one service set includes at least one of the following: a first service set, a second service set, a third service set, a fourth service set, a fifth service set, and a sixth service set. The first service set includes at least one service whose device identifier is a target device identifier; the second service set includes at least one service whose service identifier is a target service identifier; the third service set includes at least one service whose capability identifier is a target capability identifier; the fourth service set includes at least one service whose service intent is a target service intent; the fifth service set includes at least one service whose capability intent is a target capability intent; and the sixth service set includes at least one service whose assembly protocol is a target assembly protocol.
[0144] Step 905: The first electronic device determines the union of at least one set of services to obtain the target service.
[0145] The first electronic device determines the intersection of at least one set of services to obtain a target set of services. The target set of services includes at least one record, and each record includes a target service data and a device identifier of the device to which the target service data belongs.
[0146] For example, please refer to Figure 10 The service discovery parameters determined by the first electronic device include the target device identifier, target service identifier, target capability identifier, target service intent, target capability intent, and target assembly protocol. A service filter is configured based on the target device identifier, target service identifier, target capability identifier, target service intent, target capability intent, and target assembly protocol. Based on the service filter, services in the target service database that do not meet at least one filtering condition are filtered, resulting in 6 query results. Each query result is a list of service data plus a list of device identifiers. Therefore, 6 lists are obtained. The intersection of the 6 lists is determined to obtain the target service.
[0147] In this embodiment, a service filter is configured based on at least one service discovery parameter input by the user, and the corresponding target service is obtained based on the configured service filter. When discovering a target, each service discovery parameter corresponds to a filter condition, allowing each filter condition to independently query the target service from the target database. These query results are then merged and their intersection is taken to obtain the target service that satisfies at least one service discovery condition. This simplifies the setting and discovery process of the service filter and improves service discovery efficiency.
[0148] Please refer to Figure 11 The diagram illustrates a service discovery method according to an exemplary embodiment of this application. (Reference) Figure 11 The method includes:
[0149] Step 1101: The first electronic device obtains the service data of the first electronic device registration service and stores the service data in the first database.
[0150] Service registration is divided into static service registration and dynamic service registration. Static service registration primarily involves scanning to retrieve services existing in the operating system of the first electronic device and parsing the service data to store it in the first database. Dynamic service registration occurs when a service is used; after the service is downloaded and installed, its data is stored in the first database. Accordingly, this step can include at least one of the following implementation methods:
[0151] Static service registration: The first electronic device obtains the first service existing in the first electronic device by scanning, parses the first service to obtain the service data of the first service, and stores the service data of the first service in the first database.
[0152] Service data includes service configuration information, which is mainly stored in files such as config.json. Therefore, the first electronic device obtains the service configuration information from files such as config.json. A simple example of config.json is shown below:
[0153] {
[0154] "identifier":{
[0155] "url":"com.pantanal.helloworld.train",
[0156] "id":"auto_generate", / / Distribute during deployment for easy management
[0157] "type":"apk", / / Extended field, refers to the service type, indicating Android APK
[0158] "name":"HelloAPK",
[0159] "version":"1.2.1", / / Major version number. Minor version number. Revision number
[0160] "versionCode":1002001 / / 001+002+001
[0161] },
[0162] "intent":{
[0163] "domain":"travel_preparation_service", / / The scenario or domain to which the intent belongs. "action":["pantanal.intent.action.TRAVE"] / / The intent under the domain; a customizable field used to query or trigger the service.
[0164] }
[0165] }
[0166] When the first electronic device operates on Android, it scans for these service apps using system-related methods of PackageManager and registers them in its local database. For example, please refer to... Figure 12 The first electronic device includes a packet scanning module, a service registration module, and a Package Manager Service (PMS) module. The packet scanning module sends a query request to the PMS (using `app_action` to query `queryIntentContentProviders`). The PMS receives the query request, obtains the metadata of the services existing on the first electronic device, and sends the service metadata to the packet scanning module. The packet scanning module receives the service metadata, retrieves the address information of the configuration file (config.json) from the metadata, and reads the configuration file based on the address information. It then reads the service data (including service configuration information) from the configuration file and sends the service data to the service registration module to complete service registration. When a new service is registered on the first electronic device, the packet scanning module broadcasts the service's installation status through the operating system, and the PMS detects this broadcast when the service's APP package changes. Furthermore, the scanning module determines whether the service APP's configuration file parsing process has been completed. If not, it continues to complete the parsing process to obtain the service data and registers the service in the service registration module based on this data. Additionally, during service uninstallation, the first electronic device also listens for system broadcasts. If it receives a service uninstallation broadcast, it will scan for services based on the above process and deregister the services. In some embodiments, if the operating system of the first electronic device is not Android, the first electronic device can scan for services via the Internet of Things (IoT) or similar methods.
[0167] Dynamic service registration: When the first electronic device uses a second service, it downloads the second service from the cloud server, registers the second service in the first electronic device, parses the second service to obtain its service data, and stores the service data in the first database. In this embodiment, after dynamic service registration is completed, the dynamically registered service also becomes part of the first database. Subsequent service discovery can then be performed directly in the local first database without needing to perform dynamic registration again, thus improving the efficiency of service discovery.
[0168] Step 1102: The first electronic device synchronizes the service data of the second electronic device registration service and stores the service data of the second electronic device registration service in the first database.
[0169] The second electronic device is a device that establishes a connection with the first electronic device; the service data of the registration service of the first electronic device can also be synchronized to the second electronic device; and the service data of dynamic registration and service data of static registration both constitute part of the local first database and can be synchronized to the second electronic device; they can also be synchronized to the cloud server.
[0170] In this embodiment, the first electronic device can insert service data into a local first database through dynamic and static service registration. Furthermore, after dynamic service registration is completed, the dynamically registered services also become part of the first database. Subsequent service discovery can then be performed directly within the local first database without requiring further dynamic registration, thus improving service discovery efficiency. Additionally, the first electronic device can synchronize service data from other electronic devices to enrich the service data in the first database, thereby enhancing the reliability of service discovery based on the first database.
[0171] Please refer to Figure 12 The diagram illustrates a service discovery method according to an exemplary embodiment of this application. (Reference) Figure 12 The method includes:
[0172] Step 1201: The cloud server obtains the service data of the cloud server registration service and stores the service data in the second database.
[0173] The second database includes a first sub-database and a second sub-database. The first sub-database stores service data registered and synchronized on the cloud server, while the second sub-database stores service data from the service storage market. Similar to the first database on the client side, the cloud server also has a service discovery system, and some services are deployed and run on the cloud server. Therefore, the first sub-database of the cloud server also consists of two parts: service registration data and service synchronization data. Step 1201 is the process of obtaining service registration data, and step 1202 is the process of obtaining service synchronization data.
[0174] Step 1202: The cloud server synchronizes the service data of the registration services of other electronic devices and stores the service data of the registration services of other electronic devices in the second database. Other electronic devices are devices that have established a connection with the cloud server.
[0175] In this embodiment, the service synchronization data of the first database on the device side only includes service information of near-field devices, while the first sub-database of the cloud server contains the service data of all devices. This is because the service data on the device side is uniformly deployed to the first sub-database of the cloud server. Therefore, the first sub-database of the cloud server stores the service data of all electronic devices, which means that a more comprehensive discovery of related services can be achieved based on the first sub-database.
[0176] Please refer to Figure 13 This document illustrates a block diagram of a service discovery apparatus according to an exemplary embodiment of this application. The apparatus includes:
[0177] The first determining module 1301 is used to determine the target database, which includes at least one of a first database and a second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server.
[0178] The second determining module 1302 is used to determine service discovery parameters, which are used to constrain the discovered services.
[0179] Discovery module 1303 is used to perform service discovery operations in the target database based on service discovery parameters.
[0180] In some embodiments, the target database includes a first database and a second database;
[0181] The discovery module 1303 is used to perform service discovery operations in the first database and the second database based on the priority level of the first database and the priority level of the second database, through service discovery parameters.
[0182] In some embodiments, the discovery module 1303 is configured to perform service discovery operations in the first database based on service discovery parameters if the priority level of the first database is not lower than that of the second database; and to perform service discovery operations in the second database based on service discovery parameters if no target service is found in the first database.
[0183] The discovery module 1303 is used to perform service discovery operations in the second database based on service discovery parameters when the priority level of the first database is lower than that of the second database; and to perform service discovery operations in the first database based on service discovery parameters when no target service is found in the second database.
[0184] In some embodiments, the second database includes a first sub-database and a second sub-database, wherein the first sub-database is used to store service data for cloud server registration and synchronization, and the second database is used to store service data in the storage service market;
[0185] The discovery module 1303 is used to perform service discovery operations in the first and second sub-databases based on the priority levels of the first and second sub-databases and through service discovery parameters.
[0186] In some embodiments, the discovery module 1303 is configured to configure the filtering conditions of the service filter based on the service discovery parameters. The filtering conditions are used to filter services that do not conform to the service discovery parameters. The configured service filter filters out services in the target database that do not conform to the service discovery parameters to obtain the target service.
[0187] In some embodiments, the number of service discovery parameters is at least one, the filtering conditions of the service filter are also at least one, and one service discovery parameter corresponds to one filtering condition.
[0188] The discovery module 1303 is used to filter services in the target service database that do not meet at least one filtering condition through the configured service filter, determine at least one set of services, and determine the union of at least one set of services to obtain the target service.
[0189] At least one of the following filtering conditions is a service whose device identifier is not the target device identifier, a service whose service identifier is not the target service identifier, a service whose capability identifier is not the target capability identifier, a service whose service intent is not the target service intent, a service whose capability intent is not the target capability intent, or a service whose assembly protocol is the target assembly protocol.
[0190] In some embodiments, the apparatus further includes at least one of the following;
[0191] The first acquisition module is used to acquire service data of the first electronic device registration service and store the service data of the first electronic device registration service in the first database.
[0192] The first synchronization module is used to synchronize the service data of the second electronic device registration service and store the service data of the second electronic device registration service in the first database. The second electronic device is a device that establishes a connection with the first electronic device.
[0193] In some embodiments, the first acquisition module is configured to acquire a first service existing in the first electronic device by scanning, and parse the first service to obtain service data of the first service; or...
[0194] The first acquisition module is used to download the second service from the cloud server, register the second service in the first electronic device, and parse the second service to obtain the service data of the second service when using the second service of the first electronic device.
[0195] In some embodiments, the apparatus further includes at least one of the following:
[0196] The second acquisition module is used to acquire service data of cloud server registration service and store the service data in the second database.
[0197] The second synchronization module is used to synchronize the service data of other electronic devices' registration services and store the service data of other electronic devices' registration services in the second database. Other electronic devices are devices that have established a connection with the cloud server.
[0198] In this embodiment of the application, by registering service data to the target database, service data can be directly queried from the target database based on service discovery parameters during service discovery, thereby shortening the service discovery process, saving service discovery time, and thus improving the efficiency of service discovery.
[0199] It should be noted that the service discovery device provided in the above embodiments is only illustrated by the division of the above functional modules when performing service discovery. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the user terminal can be divided into different functional modules to complete all or part of the functions described above. In addition, the service discovery device and service discovery method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0200] Please refer to Figure 14 This diagram illustrates a block diagram of an electronic device 1400 according to an exemplary embodiment of this application. The electronic device 1400 in this application may include one or more components such as a processor 1410, a memory 1420, and a display screen 1430.
[0201] Processor 1410 may include one or more processing cores. Processor 1410 connects to various parts within the electronic device 1400 using various interfaces and lines, and performs various functions and processes data of the electronic device 1400 by running or executing instructions, programs, code sets, or instruction sets stored in memory 1420, and by calling data stored in memory 1420. Optionally, processor 1410 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 1410 may integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Neural-network Processing Unit (NPU), and modem. Specifically, the CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required to be displayed on the display screen 1430; the NPU is used to implement Artificial Intelligence (AI) functions; and the modem is used to handle wireless communication. It is understandable that the aforementioned modem may not be integrated into the processor 1410, but may be implemented as a separate chip.
[0202] The memory 1420 may include random access memory (RAM) or read-only memory. Optionally, the memory 1420 may include a non-transitory computer-readable storage medium. The memory 1420 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 1420 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described below, etc.; the data storage area may store data created based on the use of the electronic device 1400 (such as audio data, telephone directory, etc.).
[0203] Display screen 1430 is a display component used to display a user interface. Optionally, the display screen 1430 is a touch-enabled display screen, through which users can use their fingers, styluses, or any suitable object to perform touch operations on the display screen 1430.
[0204] The display screen 1430 is typically located on the front panel of the electronic device 1400. The display screen 1430 can be designed as a full-screen, curved screen, irregularly shaped screen, dual-sided screen, or foldable screen. The display screen 1430 can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen, etc., but this embodiment does not limit it in this way.
[0205] In addition, those skilled in the art will understand that the structure of the electronic device 1400 shown in the above figures does not constitute a limitation on the electronic device 1400. The electronic device 1400 may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device 1400 may also include audio acquisition devices, speakers, radio frequency circuits, input units, sensors, audio circuits, wireless Fidelity (Wi-Fi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.
[0206] This application also provides a computer-readable medium storing at least one piece of program code, which is loaded and executed by the processor to implement the service discovery method shown in the above embodiments.
[0207] This application also provides a computer program product that stores at least one piece of program code, which is loaded and executed by the processor to implement the service discovery method shown in the above embodiments.
[0208] In some embodiments, the computer program product involved in this application may be deployed and executed on a user electronic device, or on multiple user electronic devices located in one location, or on multiple user electronic devices distributed in multiple locations and interconnected through a communication network. Multiple user electronic devices distributed in multiple locations and interconnected through a communication network may form a blockchain system.
[0209] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0210] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A service discovery method, characterized in that, The method includes: A target database is determined, which includes at least one of a first database and a second database, wherein the first database is used to store end-side service data of a first electronic device, and the second database is used to store cloud-side service data of a cloud server. Determine service discovery parameters, which are used to constrain the discovered services; Based on the service discovery parameters, a service discovery operation is performed in the target database; The method further includes: obtaining service data of the first electronic device registration service and storing the service data of the first electronic device registration service in the first database; The service data for obtaining the registration service of the first electronic device includes: The first service present in the first electronic device is obtained by scanning, and the service data of the first service is obtained by parsing the first service; or... When using the second service of the first electronic device, the second service is downloaded from the cloud server, the second service is registered in the first electronic device, and the service data of the second service is obtained by parsing the second service; The step of obtaining the first service present in the first electronic device by scanning and parsing the first service to obtain the service data of the first service includes: Obtain the metadata of the services existing in the first electronic device, obtain the address information of the configuration file from the metadata, read the configuration file based on the address information of the configuration file, and read the service data of the first service from the configuration file.
2. The method according to claim 1, characterized in that, The target database includes the first database and the second database; The service discovery operation in the target database based on the service discovery parameters includes: Based on the priority levels of the first database and the second database, service discovery operations are performed in the first database and the second database using the service discovery parameters.
3. The method according to claim 2, characterized in that, The step of performing service discovery operations in the first database and the second database based on the priority levels of the first database and the second database, using the service discovery parameters, includes: If the priority level of the first database is not lower than that of the second database, a service discovery operation is performed in the first database based on the service discovery parameters; if no target service is found in the first database, a service discovery operation is performed in the second database based on the service discovery parameters. If the priority level of the first database is lower than that of the second database, a service discovery operation is performed in the second database based on the service discovery parameters; if no target service is found in the second database, a service discovery operation is performed in the first database based on the service discovery parameters.
4. The method according to claim 3, characterized in that, The second database includes a first sub-database and a second sub-database. The first sub-database is used to store service data registered and synchronized by the cloud server, and the second sub-database is used to store service data in the storage service market. The service discovery operation in the second database based on the service discovery parameters includes: Based on the priority levels of the first sub-database and the second sub-database, service discovery operations are performed in the first sub-database and the second sub-database using the service discovery parameters.
5. The method according to claim 1, characterized in that, The service discovery operation in the target database based on the service discovery parameters includes: Based on the service discovery parameters, configure the filtering conditions of the service filter, which are used to filter services that do not conform to the service discovery parameters; By using the configured service filter, services in the target database that do not conform to the service discovery parameters are filtered out to obtain the target service.
6. The method according to claim 5, characterized in that, The number of service discovery parameters is at least one, and the filtering conditions of the service filter are also at least one, with one service discovery parameter corresponding to one filtering condition. The step of filtering services in the target database that do not conform to the service discovery parameters through the configured service filter to obtain the target service includes: By using the configured service filter, services in the target service database that do not meet at least one filtering condition are filtered out to determine at least one set of services. Determine the union of the at least one set of services to obtain the target service; The at least one filtering condition is at least one of the following: services whose device identifier is not the target device identifier, services whose service identifier is not the target service identifier, services whose capability identifier is not the target capability identifier, services whose service intent is not the target service intent, services whose capability intent is not the target capability intent, and services whose assembly protocol is the target assembly protocol.
7. The method according to claim 1, characterized in that, The method further includes at least one of the following: The service data of the second electronic device registration service is synchronized and stored in the first database. The second electronic device is a device that establishes a connection with the first electronic device.
8. The method according to claim 1, characterized in that, The method further includes at least one of the following: Obtain the service data of the cloud server registration service and store the service data in the second database; Synchronize the service data of other electronic device registration services and store the service data of the other electronic device registration services in the second database. The other electronic devices are devices that have established a connection with the cloud server.
9. A service discovery device, characterized in that, The device includes: The first determining module is used to determine the target database, which includes at least one of a first database and a second database. The first database is used to store the end-side service data of the first electronic device, and the second database is used to store the cloud-side service data of the cloud server. The second determining module is used to determine service discovery parameters, which are used to constrain the discovered services. The discovery module is used to perform service discovery operations in the target database based on the service discovery parameters. The first acquisition module is used to acquire the service data of the first electronic device registration service and store the service data of the first electronic device registration service in the first database. The first acquisition module is used to acquire a first service existing in the first electronic device by scanning, and to parse the first service to obtain service data of the first service; or, The first acquisition module is used to download the second service from the cloud server and register the second service in the first electronic device when using the second service of the first electronic device, and parse the second service to obtain the service data of the second service; The first acquisition module is used to acquire metadata of services existing in the first electronic device, acquire address information of configuration files from the metadata, read the configuration files based on the address information of the configuration files, and read service data of the first service from the configuration files.
10. An electronic device, characterized in that, The electronic device includes one or more processors and one or more memories, wherein at least one piece of program code is stored in the one or more memories, and the at least one piece of program code is loaded and executed by the one or more processors to implement the service discovery method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the service discovery method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, The computer program product stores at least one line of program code, which is executed by a processor to implement the service discovery method as described in any one of claims 1 to 8.