Resource access method and device, storage medium and electronic equipment

By receiving resource access requests, obtaining the target proxy object and accessing the target resource based on the object, the problem of adaptation in traditional technology due to different operating systems is solved, and cross-platform resource access universality is achieved.

CN120144544APending Publication Date: 2025-06-13GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311709983.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-12
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

Traditional inter-process communication methods rely on the operating system, resulting in different interfaces and parameters of different operating systems, and need to be adapted to access the resources on the server.

Method used

By receiving resource access requests, open the target file corresponding to the target proxy object, obtain the target file descriptor, and obtain the target proxy object through the descriptor, accessing the target resource based on the target proxy object, so that there is no need to adapt due to different operating systems.

Benefits of technology

It realizes adaptability when accessing server resources on different operating systems, supports multiple IPC methods, such as binder communication in Android system and socket communication in Linux system, improving the universality of cross-platform resource access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144544A_ABST
    Figure CN120144544A_ABST
Patent Text Reader

Abstract

The invention discloses a resource access method and device, a storage medium and electronic equipment. The method comprises the steps that a resource access request is received, the resource access request is used for requesting to access a target resource, and the target resource corresponds to a target proxy object; in response to the resource access request, opening a target file corresponding to the target proxy object, and obtaining a target file descriptor; obtaining a target proxy object through the target file descriptor; and accessing the target resource based on the target proxy object. According to the method and the device, when the resources of the server side are accessed, adaptation does not need to be carried out due to different operating systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of electronic technology, and particularly relates to a resource access method, apparatus, computer-readable storage medium, and electronic device. Background Art

[0002] Traditional Inter-Process Communication (IPC) methods rely on the operating system for implementation. The interfaces and parameters of different operating systems may vary, so when accessing the resources of the server, adaptation is required due to different operating systems. Summary of the Invention

[0003] Embodiments of this application provide a resource access method, apparatus, storage medium, and electronic device, which can avoid adaptation due to different operating systems when accessing the resources of the server.

[0004] In a first aspect, an embodiment of this application provides a resource access method, including:

[0005] Receiving a resource access request for requesting access to a target resource, where the target resource corresponds to a target proxy object;

[0006] In response to the resource access request, opening a target file corresponding to the target proxy object to obtain a target file descriptor;

[0007] Obtaining the target proxy object through the target file descriptor;

[0008] Accessing the target resource based on the target proxy object.

[0009] In a second aspect, an embodiment of this application provides a resource access apparatus, including:

[0010] A request receiving module for receiving a resource access request for requesting access to a target resource, where the target resource corresponds to a target proxy object;

[0011] A descriptor obtaining module for, in response to the resource access request, opening a target file corresponding to the target proxy object to obtain a target file descriptor;

[0012] An object obtaining module for obtaining the target proxy object through the target file descriptor;

[0013] A resource access module for accessing the target resource based on the target proxy object.

[0014] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is caused to execute the resource access method provided by the embodiment of the present application.

[0015] In a fourth aspect, an embodiment of the present application further provides an electronic device, including a memory and a processor. The processor is configured to execute the resource access method provided by the embodiment of the present application by calling a computer program stored in the memory.

[0016] In the embodiment of the present application, by receiving a resource access request for requesting access to a target resource, where the target resource corresponds to a target proxy object; in response to the resource access request, opening a target file corresponding to the target proxy object and obtaining a target file descriptor; obtaining the target proxy object through the target file descriptor; and accessing the target resource based on the target proxy object. Thus, on the client side, obtaining a proxy object of a resource on the server side by using a file descriptor can support IPC methods provided by different operating systems, and there is no need to perform adaptation due to different operating systems when accessing resources on the server side. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The technical solutions and their beneficial effects of the present application will become apparent by describing the specific embodiments of the present application in detail with reference to the accompanying drawings.

[0018] Figure 1 is a flowchart of the resource access method provided by the embodiment of the present application.

[0019] Figure 2 is an interaction diagram of the resource access method provided by the embodiment of the present application.

[0020] Figure 3 is a scenario diagram of opening a file in the svc directory and obtaining a file descriptor provided by the embodiment of the present application.

[0021] Figure 4 is a scenario diagram of obtaining a proxy object provided by the embodiment of the present application.

[0022] Figure 5 is a structural diagram of the resource access device provided by the embodiment of the present application.

[0023] Figure 6 is a structural diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0024] It should be noted that the terms "first", "second", "third", etc. in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the listed steps or modules, but some embodiments also include steps or modules that are not listed, or some embodiments also include other steps or modules inherent to these processes, methods, products, or devices.

[0025] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0026] An embodiment of the present application provides a resource access method, a resource access device, a storage medium, and an electronic device. The execution subject of the resource access method can be the resource access device provided by the embodiment of the present application, or an electronic device integrated with the resource access device, where the resource access device can be implemented in a hardware or software manner. Among them, the electronic device can be a device with resource access capabilities configured with a processor, such as a smart phone, a tablet computer, a handheld computer, a notebook computer, etc.

[0027] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the resource access method provided by the embodiment of the present application. The process may include:

[0028] In 101, a resource access request is received. The resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object.

[0029] Among them, one or more JS runtimes (JS Runtime) can run in an application program in the electronic device, and one ubiquitous service can run in one JS Runtime. The JS Runtime also provides an encapsulation layer to provide corresponding resource access interfaces for the ubiquitous service. The ubiquitous service accesses the corresponding resources on the server side by calling the corresponding resource access interfaces, rather than directly accessing the resources. The specific resource access process is executed by this encapsulation layer.

[0030] Ubiquitous services are software units that can run independently, be assembled, and be transferred. As the most basic execution units, services are widely used in the system to meet user scenarios or system operation requirements. For example, ubiquitous services can be "navigation services" that users can directly use; ubiquitous services can also be "decision-making services" that users are not aware of during the operation of the mobile phone system, etc.

[0031] The resource manager in the electronic device records proxy objects. The proxy object is the representation of the real resources on the server side in the resource manager. The so-called proxy object actually creates a "reference" to the server side. This proxy object has the functions of the server side, enabling it to access the methods of the server side just like accessing local methods.

[0032] Real resources can include files stored on disk, hardware such as speakers, microphones, cameras, etc. It should be noted that in the embodiments of the present application, resources and target resources both refer to real resources.

[0033] The proxy object can include a resource interface. This resource interface provides an interface for accessing resources, and accessing the corresponding resource can be achieved by calling the corresponding resource interface.

[0034] The proxy object can also include status information, such as whether the real resource corresponding to the proxy object is available and which device it is on.

[0035] The resource access interfaces can be mapped one-to-one with the proxy objects in the resource manager. For example, if the resource manager includes proxy object PO1, proxy object PO2, and proxy object PO3, then the encapsulation layer of the JS Runtime where the ubiquitous service is located will provide the ubiquitous service with a resource access interface RAI1 corresponding to proxy object PO1, a resource access interface RAI2 corresponding to proxy object PO2, and a resource access interface RAI3 corresponding to proxy object PO3.

[0036] In this embodiment, if the ubiquitous service wants to access a target proxy object, such as the real resource corresponding to proxy object PO1, such as calling the camera of another device, since proxy object PO1 corresponds to resource access interface RAI1, the ubiquitous service can call resource access interface RAI1, so that the encapsulation layer receives a resource access request for accessing the real resource corresponding to proxy object PO1, that is, the target resource.

[0037] Among them, the server side is the end that provides real resources, and the client side is the end that accesses the real resources provided by the server side.

[0038] In 102, in response to the resource access request, open the target file corresponding to the target proxy object and obtain the target file descriptor.

[0039] In this embodiment, after receiving a resource access request for a ubiquitous service, the encapsulation layer can determine a target file corresponding to a target proxy object, open the target file, and obtain a target file descriptor.

[0040] In some embodiments of the present application, opening a target file corresponding to a target proxy object includes:

[0041] Determining a target file corresponding to a target proxy object from multiple files in a namespace, where one file corresponds to one proxy object;

[0042] Opening the target file.

[0043] Among them, after the ubiquitous service is started, the namespace file system will create a directory in the namespace in the JS Runtime where the ubiquitous service is located, such as the " / svc" directory. The files in this directory are mapped one-to-one with the proxy objects in the resource manager. For example, if the resource manager includes proxy object PO1, proxy object PO2, and proxy object PO3, then this directory may include file F1 corresponding to proxy object PO1, file F2 corresponding to proxy object PO2, and file F3 corresponding to proxy object PO3.

[0044] Among them, the namespace file system is a client file system implemented in an electronic device based on FUSE. Among them, FUSE is a user-space file system under Linux, and its full English name is Filesystem in Userspace.

[0045] It can be understood that when the proxy objects in the resource manager are updated, the namespace file system will also perform addition and deletion operations on the files in this directory. For example, if proxy object PO1 is deleted in the resource manager, the namespace file system can delete file F1. If a new proxy object PO4 is added to the resource manager, the namespace file system can create file F4 in the " / svc" directory in the namespace.

[0046] It should be noted that one ubiquitous service corresponds to one directory. Different ubiquitous services have different capabilities, so the directories corresponding to different ubiquitous services created by the namespace file system are also different, thus realizing the isolation of different ubiquitous services.

[0047] For example, assuming that the target resource is the real resource corresponding to proxy object PO1, the encapsulation layer can determine that the target file is file F1. Then, the encapsulation layer can open file F1 and obtain the target file descriptor.

[0048] For another example, assume that the target resource is the real resource corresponding to the proxy object PO2. Then, the encapsulation layer can determine that the target file is file F2. In this case, the encapsulation layer can open file F2 and obtain the target file descriptor.

[0049] For still another example, assume that the target resource is the real resource corresponding to the proxy object PO3. Then, the encapsulation layer can determine that the target file is file F3. In this case, the encapsulation layer can open file F3 and obtain the target file descriptor.

[0050] In some embodiments of the present application, opening the target file corresponding to the target proxy object and obtaining the target file descriptor includes:

[0051] Opening the target file corresponding to the target proxy object, triggering the namespace file system to construct a target file object when it determines that there is a target resource interface included in the target proxy object in the resource manager, and returning the file descriptor of the target file object;

[0052] Using the file descriptor of the target file object as the target file descriptor.

[0053] Specifically, the encapsulation layer can open the target file corresponding to the target proxy object through the open function provided by libc, and finally enter the namespace file system through FUSE. The namespace file system can check whether there is a target resource interface included in the target proxy object in the resource manager. If there is a target resource interface included in the target proxy object in the resource manager, the namespace file system can construct a target file object and return the file descriptor of the target file object to the encapsulation layer. The encapsulation layer can then use the received file descriptor of the target file object as the target file descriptor. If there is no resource interface included in the target proxy object in the resource manager, an ENOENT error message is returned to the encapsulation layer.

[0054] Herein, libc is short for Stantard C Library, which is a standard function library compliant with the ANSI C standard and is implemented by the operating system.

[0055] It should be noted that when the namespace file system creates a file corresponding to a proxy object in the resource manager, it uses the interface name of the resource interface included in the proxy object as the file name of the created file. Therefore, when there is a resource interface in the resource manager whose interface name is the same as the file name of the target file, the namespace file system determines that there is a target resource interface included in the target proxy object in the resource manager. When there is no resource interface in the resource manager whose interface name is the same as the file name of the target file, the namespace file system determines that there is no target resource interface included in the target proxy object in the resource manager.

[0056] For example, assume that the interface name of the resource interface RI1 included in the proxy object PO1 is AN1, the interface name of the resource interface RI2 included in the proxy object PO2 is AN2, and the interface name of the resource interface RI3 included in the proxy object PO3 is AN3. After the ubiquitous service is started, the file name of the file F1 included in the directory created in the namespace of the JS Runtime where the ubiquitous service is located by the namespace file system can be AN1, the file name of the file F2 can be AN2, and the file name of the file F3 can be AN3. If the target file is the file F1, and the file name of the file F1 is AN1, and the interface name of the resource interface RI1 is also AN1, then the target resource interface can be determined to be the resource interface RI1; if the target file is the file F2, and the file name of the file F2 is AN2, and the interface name of the resource interface RI2 is also AN2, then the target resource interface can be determined to be the resource interface RI2; if the target file is the file F3, and the file name of the file F3 is AN3, and the interface name of the resource interface RI3 is also AN3, then the target resource interface can be determined to be the resource interface RI3.

[0057] When it is determined that there is a target resource interface in the resource manager, the namespace file system can construct a target file object and return the file descriptor of the target file object to the encapsulation layer. The encapsulation layer can determine the received file descriptor of the target file object as the target file descriptor. Among them, the target file object corresponds to the target proxy object where the target resource interface is located.

[0058] Among them, libc is the abbreviation of Stantard C Library, which is a standard function library that conforms to the ANSI C standard and is implemented by the operating system.

[0059] In 103, the target proxy object is obtained through the target file descriptor.

[0060] In this embodiment, after obtaining the target file descriptor, the encapsulation layer can obtain the target proxy object through the target file descriptor.

[0061] In some embodiments of the present application, obtaining the target proxy object through the target file descriptor includes:

[0062] Transfer the target file descriptor to the namespace file system, and trigger the namespace file system to return the target proxy object based on the target file descriptor.

[0063] For example, after obtaining the target file descriptor, the encapsulation layer can transfer the target file descriptor to the namespace file system. The namespace file system can return the target proxy object to the encapsulation layer based on the target file descriptor, so that the encapsulation layer obtains the target proxy object.

[0064] In an alternative embodiment, the encapsulation layer can pass the target file descriptor to the namespace file system through the getProxy interface (getProxy interface).

[0065] In an alternative embodiment, triggering the namespace file system to return a target proxy object based on the target file descriptor includes:

[0066] Trigger the namespace file system to determine a target file object based on the target file descriptor, and obtain a target proxy object corresponding to the target file object from the resource manager.

[0067] Specifically, after receiving the target file descriptor passed by the encapsulation layer, the namespace file system can determine the target file object corresponding to the target file descriptor. Among them, the file descriptor of a file object corresponds to the file object.

[0068] After determining the target file object corresponding to the target file descriptor, the namespace file system can determine the proxy object corresponding to the target file object from the resource manager, and determine the proxy object as the target proxy object. Then the namespace file system can return the target proxy object to the encapsulation layer, and the encapsulation layer obtains the target proxy object.

[0069] In some embodiments of the present application, triggering the namespace file system to return a target proxy object based on the target file descriptor includes:

[0070] Trigger the namespace file system to return a target proxy object based on the target file descriptor when it determines that the target file descriptor is legal.

[0071] To prevent other applications from forging file descriptors to obtain proxy objects, after receiving the target file descriptor, the namespace file system will also detect whether the target file descriptor is legal. If the target file descriptor is legal, the namespace file system can obtain the target proxy object based on the target file descriptor and return it to the encapsulation layer. If the target file descriptor is illegal, the namespace file system can do nothing.

[0072] In an alternative embodiment, the namespace file system can detect whether the target file descriptor is legal through the fdtat function.

[0073] In 104, access the target resource based on the target proxy object.

[0074] It can be understood that obtaining the target proxy object means obtaining the IPC method related to the operating system. Therefore, after obtaining the target proxy object, the encapsulation layer can perform IPC communication with the server by calling the target resource interface of the target proxy object, so as to access the resources of the server. Therefore, after obtaining the target proxy object, the encapsulation layer can obtain the target resources of the server based on the target proxy object and return them to the ubiquitous service, so as to realize the access to the target resources.

[0075] For example, the encapsulation layer can request to access the target resource from the server by calling the target resource interface of the target proxy object. The server obtains the target resource and returns it to the target resource interface, and the encapsulation layer can obtain the target resource. The encapsulation layer returns the target resource to the ubiquitous service, so that the ubiquitous service can obtain the real resources of the server by calling the resource access interface provided by the encapsulation layer, without paying attention to the underlying IPC implementation logic.

[0076] In this embodiment, by receiving a resource access request, which is used to request access to a target resource, and the target resource corresponds to a target proxy object; in response to the resource access request, opening a target file corresponding to the target proxy object to obtain a target file descriptor; obtaining the target proxy object through the target file descriptor; accessing the target resource based on the target proxy object. Thus, obtaining the proxy object of the server's resources with a file descriptor on the client side can support the IPC methods provided by different operating systems, such as the binder communication method of the Android system and the socket communication method of the Linux system. When accessing the resources of the server, there is no need to adapt due to different operating systems, and it can be more generally deployed on different operating systems.

[0077] Please refer to Figure 2 , Figure 2 which is an interaction schematic diagram of the resource access method provided by the embodiment of the present application.

[0078] In 201, the encapsulation layer receives a resource access request sent by the ubiquitous service. The resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object.

[0079] Among them, one or more JS runtimes (JS Runtime) can run in the application installed in the electronic device, and one ubiquitous service can run in one JS Runtime. The JS Runtime also provides an encapsulation layer to provide corresponding resource access interfaces for the ubiquitous service. The ubiquitous service accesses the corresponding resources of the server by calling the corresponding resource access interfaces, rather than directly accessing the resources. The specific resource access process is executed by this encapsulation layer.

[0080] Ubiquitous service is an independently running, assemblable, and transferable software unit. As the most basic execution unit, services are widely used in the system to meet user scenarios or system operation requirements. For example, the ubiquitous service can be the "navigation service" that users can directly use; the ubiquitous service can also be the "decision-making service" that users are not aware of during the operation of the mobile phone system, etc.

[0081] The resource manager in the electronic device records proxy objects. The proxy object is the representation of the real resources on the server side in the resource manager. The so-called proxy object actually establishes a "reference" to the server side. This proxy object has the functions of the server side, making it access the methods of the server side just like accessing local methods.

[0082] The real resources can include files stored on the disk, hardware such as speakers, microphones, cameras, etc. It should be noted that in the embodiments of the present application, resources and target resources both refer to real resources.

[0083] The proxy object can include a resource interface. This resource interface is an interface for providing access to resources. By calling the corresponding resource interface, access to the corresponding resources can be achieved.

[0084] The proxy object can also include status information, such as whether the real resource corresponding to the proxy object is available and which device it is on.

[0085] The resource access interfaces can be mapped one-to-one with the proxy objects in the resource manager. For example, if the resource manager includes proxy object PO1, proxy object PO2, and proxy object PO3, then the encapsulation layer of the JS Runtime where the ubiquitous service is located will provide the ubiquitous service with resource access interface RAI1 corresponding to proxy object PO1, resource access interface RAI2 corresponding to proxy object PO2, and resource access interface RAI3 corresponding to proxy object PO3.

[0086] In this embodiment, if the ubiquitous service wants to access a target proxy object, such as the real resource corresponding to proxy object PO1, such as calling the camera of another device, since proxy object PO1 corresponds to resource access interface RAI1, the ubiquitous service can call resource access interface RAI1, so that the encapsulation layer receives a resource access request for accessing the real resource corresponding to proxy object PO1, that is, the target resource.

[0087] Among them, the server side is the end that provides real resources, and the client side is the end that accesses the real resources provided by the server side.

[0088] In 202, in response to the resource access request, the encapsulation layer determines the target file corresponding to the target proxy object from multiple files in the namespace, and one file corresponds to one proxy object.

[0089] In 203, the encapsulation layer opens the target file.

[0090] After the ubiquitous service is started, the namespace file system creates a directory in the namespace of the JS Runtime where the ubiquitous service is located, such as the " / svc" directory. The files in this directory are mapped one-to-one with the proxy objects in the resource manager. For example, if the resource manager includes proxy object PO1, proxy object PO2, and proxy object PO3, then this directory may include file F1 corresponding to proxy object PO1, file F2 corresponding to proxy object PO2, and file F3 corresponding to proxy object PO3.

[0091] The namespace file system is a client file system implemented in the electronic device based on FUSE. Among them, FUSE is a user-space file system under Linux, and its full English name is Filesystem in Userspace.

[0092] It can be understood that when the proxy objects in the resource manager are updated, the namespace file system will also perform addition and deletion operations on the files in this directory. For example, if proxy object PO1 is deleted in the resource manager, the namespace file system can delete file F1. If a new proxy object PO4 is added to the resource manager, the namespace file system can create file F4 in the " / svc" directory in the namespace.

[0093] It should be noted that a ubiquitous service corresponds to a directory. Different ubiquitous services have different capabilities, so the directories created by the namespace file system for different ubiquitous services are also different, thus realizing the isolation of different ubiquitous services.

[0094] For example, assuming that the target resource is the real resource corresponding to proxy object PO1, the encapsulation layer can determine that the target file is file F1, then the encapsulation layer can open file F1.

[0095] Another example, assuming that the target resource is the real resource corresponding to proxy object PO2, the encapsulation layer can determine that the target file is file F2, then the encapsulation layer can open file F2.

[0096] Still another example, assuming that the target resource is the real resource corresponding to proxy object PO3, the encapsulation layer can determine that the target file is file F3, then the encapsulation layer can open file F3.

[0097] Specifically, the encapsulation layer can open the target file corresponding to the target proxy object through the open function provided by libc.

[0098] Among them, libc is short for Standard C Library. It is a standard function library that conforms to the ANSI C standard and is implemented by the operating system.

[0099] In 204, the namespace file system constructs a target file object when it determines that there is a target resource interface in the resource manager whose interface name is the same as the file name of the target file.

[0100] In 205, the namespace file system returns the file descriptor of the target file object to the encapsulation layer.

[0101] The encapsulation layer opens the target file corresponding to the target proxy object through the open function provided by libc, and finally enters the namespace file system through FUSE. The namespace file system can check whether there is a target resource interface included in the target proxy object in the resource manager. If there is a target resource interface included in the target proxy object in the resource manager, the namespace file system can construct a target file object and return the file descriptor of the target file object to the encapsulation layer. The encapsulation layer can then use the received file descriptor of the target file object as the target file descriptor. If there is no resource interface included in the target proxy object in the resource manager, an ENOENT error message is returned to the encapsulation layer.

[0102] It should be noted that when the namespace file system creates a file corresponding to a proxy object in the resource manager, it uses the interface name of the resource interface included in the proxy object as the file name of the created file. Therefore, when there is a resource interface in the resource manager whose interface name is the same as the file name of the target file, the namespace file system determines that there is a target resource interface included in the target proxy object in the resource manager. When there is no resource interface in the resource manager whose interface name is the same as the file name of the target file, the namespace file system determines that there is no target resource interface included in the target proxy object in the resource manager.

[0103] For example, assume that the interface name of the resource interface RI1 included in the proxy object PO1 is AN1, the interface name of the resource interface RI2 included in the proxy object PO2 is AN2, and the interface name of the resource interface RI3 included in the proxy object PO3 is AN3. After the ubiquitous service is started, the file name of the file F1 included in the directory created in the namespace of the JS Runtime where the ubiquitous service is located by the namespace file system can be AN1, the file name of the file F2 can be AN2, and the file name of the file F3 can be AN3. If the target file is the file F1, and the file name of the file F1 is AN1 and the interface name of the resource interface RI1 is also AN1, then the target resource interface can be determined to be the resource interface RI1; if the target file is the file F2, and the file name of the file F2 is AN2 and the interface name of the resource interface RI2 is also AN2, then the target resource interface can be determined to be the resource interface RI2; if the target file is the file F3, and the file name of the file F3 is AN3 and the interface name of the resource interface RI3 is also AN3, then the target resource interface can be determined to be the resource interface RI3.

[0104] When it is determined that there is a target resource interface in the resource manager, the namespace file system can construct a target file object and return the file descriptor of the target file object to the encapsulation layer. Among them, the target file object corresponds to the target proxy object where the target resource interface is located.

[0105] In 206, the encapsulation layer passes the file descriptor of the target file object to the namespace file system through the proxy acquisition interface.

[0106] In this embodiment, the encapsulation layer can call the proxy acquisition interface (getProxy interface) and pass it to the namespace file system by using the file descriptor of the target file object as a parameter of the proxy acquisition interface.

[0107] In 207, when the namespace file system determines that the file descriptor of the target file object is legal, it obtains the target proxy object from the resource manager based on the file descriptor of the target file object and returns it to the encapsulation layer.

[0108] To prevent other application programs from forging file descriptors to obtain proxy objects, after receiving the file descriptor of the target file object, the namespace file system will detect whether the file descriptor of the target file object is legal. If the file descriptor of the target file object is legal, the namespace file system can obtain the target proxy object based on the file descriptor of the target file object and return it to the encapsulation layer. If the file descriptor of the target file object is illegal, the namespace file system can do nothing.

[0109] Specifically, if the file descriptor of the target file object is legal, the namespace file system can determine the target file object corresponding to the file descriptor of the target file object. The file descriptor of a certain file object corresponds to the file object.

[0110] After determining the target file object corresponding to the file descriptor of the target file object, the namespace file system can determine the proxy object corresponding to the target file object from the resource manager and determine the proxy object as the target proxy object. Then the namespace file system can return the target proxy object to the encapsulation layer, and the encapsulation layer can obtain the target proxy object.

[0111] In 208, the encapsulation layer accesses the target resource based on the target proxy object.

[0112] In 209, the encapsulation layer returns the target resource to the ubiquitous service.

[0113] It can be understood that obtaining the target proxy object means obtaining the IPC method related to the operating system. Therefore, after obtaining the target proxy object, the encapsulation layer can obtain the target resource of the server based on the target proxy object and return it to the ubiquitous service, so as to realize the access to the target resource.

[0114] For example, the encapsulation layer can request to access the target resource from the server by calling the target resource interface of the target proxy object. The server obtains the target resource and returns it to the target resource interface, and the encapsulation layer can obtain the target resource. The encapsulation layer returns the target resource to the ubiquitous service, so that the ubiquitous service can obtain the real resource of the server by calling the resource access interface provided by the encapsulation layer without paying attention to the underlying IPC implementation logic.

[0115] In this embodiment, through the above interaction process, the proxy object of the server's resources is obtained with a file descriptor on the client side, which can support the IPC methods provided by different operating systems, such as the binder communication method of the Android system and the socket communication method of the Linux system. When accessing the server's resources, there is no need to adapt due to different operating systems, and it can be more generally deployed on different operating systems.

[0116] Please refer to Figure 3 , Figure 3 is a schematic diagram of the scenario of opening a file in the svc directory and obtaining a file descriptor provided by the embodiment of the present application. Among them, in Figure 3Among them, Userspace represents the user space, Kernel represents the kernel, App represents the application, Runtime represents the runtime, namespace represents the namespace, svc represents the svc directory, F1 - F3 represent the files under the svc directory, the file names of F1 - F3 are AN1, AN2, and AN3 respectively, libc represents the standard function library, Runtime Manager represents the runtime manager, namespacefs represents the namespace file system, libfuse is used to implement the main framework of the file system, Resource Service Manager represents the resource manager, Service Table represents the resource table, interface / name represents the resource interface name column, handle represents the proxy object column. The resource interface name column records the interface names of each resource interface, and the proxy object column records the proxy objects where each resource interface is located. VFS represents the virtual file system, and FUSE represents the user - space file system under linux.

[0117] (1) The svc directory under the namespace is provided by the namespace file system.

[0118] (2) When the encapsulation layer opens the files under the svc directory through the open function provided by libc, it finally enters the namespace file system through FUSE.

[0119] (3) The namespace file system takes the file name to be opened as the interface name and checks whether there is a resource interface that can be called by the encapsulation layer in the Service Table of the Resource Service Manager. If it exists, a file object is constructed and its file descriptor is returned. If it does not exist, an ENOENT error is returned.

[0120] (4) The namespace file system returns the file descriptor or ENOENT to the encapsulation layer.

[0121] Please refer to Figure 4 , Figure 4 which is the schematic diagram of the scenario for obtaining the proxy object provided by the embodiment of this application. Among them, in Figure 4 , U - Service represents the ubiquitous service, Runtime represents the runtime, namespace represents the namespace, svc represents the svc directory, F1 - F3 represent the files under the svc directory, the file names of F1 - F3 are AN1, AN2, and AN3 respectively, libbinder represents the binder communication, getProxy <fd>Indicates that the file descriptor fd is passed through the getProxy interface, <get resourceproxy> indicates obtaining a proxy object, nsfs represents the namespace file system, Resource Service Manager represents the resource manager, Service Table represents the resource table, interface / name represents the resource interface name list, and handle represents the proxy object column. The resource interface name list records the interface names of each resource interface, and the proxy object column records the proxy objects where each resource interface is located.

[0122] The ubiquitous service opens the file in the svc directory through the encapsulation layer, obtains the file descriptor, and obtains the proxy object through the file descriptor. Here, the Android system is taken as an example:

[0123] (1) The encapsulation layer passes the file descriptor to the namespace file system through the getProxy interface.

[0124] (2) The namespace file system determines whether the file descriptor is legal. If the file descriptor is legal, it returns the corresponding proxy object from the Service Table.

[0125] Please refer to Figure 5 , Figure 5 , which is the structural schematic diagram of the resource access device provided by the embodiment of the present application. The resource access device 300 includes: a request receiving module 301, a descriptor obtaining module 302, an object obtaining module 303, and a resource access module 304.

[0126] The request receiving module 301 is configured to receive a resource access request, where the resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object.

[0127] The descriptor obtaining module 302 is configured to, in response to the resource access request, open a target file corresponding to the target proxy object, and obtain a target file descriptor.

[0128] The object obtaining module 303 is configured to obtain the target proxy object through the target file descriptor.

[0129] The resource access module 304 is configured to access the target resource based on the target proxy object.

[0130] In an optional embodiment, the descriptor obtaining module 302 may be configured to: open a target file corresponding to the target proxy object, trigger the namespace file system to construct a target file object when it is determined that a target resource interface included in the target proxy object exists in the resource manager, and return the file descriptor of the target file object; use the file descriptor of the target file object as the target file descriptor.

[0131] In an optional embodiment, the object acquisition module 303 may be configured to: pass the target file descriptor to the namespace file system, and trigger the namespace file system to return a target proxy object based on the target file descriptor.

[0132] In an optional embodiment, the object acquisition module 303 may be configured to: trigger the namespace file system to determine the target file object based on the target file descriptor, and obtain a target proxy object corresponding to the target file object from the resource manager.

[0133] In an optional embodiment, the object acquisition module 303 may be configured to: pass the target file descriptor to the namespace file system through a proxy acquisition interface.

[0134] In an optional embodiment, the object acquisition module 303 may be configured to: trigger the namespace file system to return a target proxy object based on the target file descriptor when it determines that the target file descriptor is legal.

[0135] In an optional embodiment, the descriptor acquisition module 302 may be configured to: determine a target file corresponding to the target proxy object from multiple files in the namespace, where one file corresponds to one proxy object; and open the target file.

[0136] In this embodiment, a resource access request is received by the request receiving module 301, where the resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object; in response to the resource access request, the descriptor acquisition module 302 opens a target file corresponding to the target proxy object to obtain a target file descriptor; the object acquisition module 303 obtains the target proxy object through the target file descriptor; and the resource access module 304 accesses the target resource based on the target proxy object. Thus, when the client obtains a proxy object of the server's resource with a file descriptor, it can support IPC methods provided by different operating systems, such as the binder communication method of the Android system and the socket communication method of the Linux system. When accessing the server's resource, there is no need to adapt due to different operating systems, and it can be more generally deployed on different operating systems.

[0137] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, it causes the computer to execute the resource access method provided in this embodiment.

[0138] An embodiment of the present application further provides an electronic device, including a memory and a processor. The processor is configured to execute the resource access method provided in this embodiment by calling a computer program stored in the memory.

[0139] For example, the above-mentioned electronic device may be a mobile terminal such as a tablet computer or a smart phone. Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of the electronic device provided in the embodiment of the present application.

[0140] The electronic device 400 may include components such as a processor 401 and a memory 402. Those skilled in the art can understand that Figure 6 the structure of the electronic device shown in

[0141] does not limit the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. For example, the electronic device 400 may further include a screen.

[0142] The processor 401 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and lines. By running or executing application programs stored in the memory 402 and calling data stored in the memory 402, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.

[0143] In this embodiment, the processor 401 in the electronic device will, according to the following instructions, load the executable code corresponding to the processes of one or more application programs into the memory 402, and the processor 401 will run the application programs stored in the memory 402, so as to achieve:

[0144] Receiving a resource access request for requesting access to a target resource, where the target resource corresponds to a target proxy object;

[0145] In response to the resource access request, opening a target file corresponding to the target proxy object and obtaining a target file descriptor;

[0146] Obtaining the target proxy object through the target file descriptor;

[0147] Accessing the target resource based on the target proxy object.

[0148] In an optional embodiment, when the processor 401 executes opening the target file corresponding to the target proxy object and obtaining the target file descriptor, it may execute: opening the target file corresponding to the target proxy object, triggering the namespace file system to construct a target file object when determining that there is a target resource interface included in the target proxy object in the resource manager, and returning the file descriptor of the target file object; using the file descriptor of the target file object as the target file descriptor.

[0149] In an optional embodiment, when the processor 401 executes obtaining the target proxy object through the target file descriptor, it may execute: passing the target file descriptor to the namespace file system, triggering the namespace file system to return a target proxy object based on the target file descriptor.

[0150] In an optional embodiment, when the processor 401 executes triggering the namespace file system to return a target proxy object based on the target file descriptor, it may execute: triggering the namespace file system to determine the target file object based on the target file descriptor, and obtaining the target proxy object corresponding to the target file object from the resource manager.

[0151] In an optional embodiment, when the processor 401 executes passing the target file descriptor to the namespace file system, it may execute: passing the target file descriptor to the namespace file system through a proxy acquisition interface.

[0152] In an optional embodiment, when the processor 401 executes triggering the namespace file system to return a target proxy object based on the target file descriptor, it may execute: triggering the namespace file system to return a target proxy object based on the target file descriptor when determining that the target file descriptor is legal.

[0153] In an optional embodiment, when the processor 401 executes opening the target file corresponding to the target proxy object, it may execute: determining the target file corresponding to the target proxy object from multiple files in the namespace, with one file corresponding to one proxy object; opening the target file.

[0154] The electronic device provided in this embodiment receives a resource access request for requesting access to a target resource, where the target resource corresponds to a target proxy object. In response to the resource access request, it opens a target file corresponding to the target proxy object and obtains a target file descriptor. It obtains the target proxy object through the target file descriptor and accesses the target resource based on the target proxy object. Thus, on the client side, obtaining the proxy object of the server-side resource with a file descriptor can support IPC methods provided by different operating systems, such as the binder communication method of the Android system and the socket communication method of the Linux system. When accessing the server-side resource, there is no need to adapt due to different operating systems, and it can be more generally deployed on different operating systems.

[0155] In the above embodiments, the descriptions of each embodiment have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the detailed description of the resource access method above, and details are not repeated here.

[0156] The resource access device provided in the embodiments of this application belongs to the same concept as the resource access method in the above embodiments. Any method provided in the embodiments of the resource access method can be run on the resource access device. The specific implementation process is detailed in the embodiments of the resource access method, and details are not repeated here.

[0157] It should be noted that for the resource access method of the embodiments of this application, those of ordinary skill in the art can understand that all or part of the process of implementing the resource access method of the embodiments of this application can be controlled by a computer program to complete relevant hardware. The computer program can be stored in a computer-readable storage medium, such as stored in a memory and executed by at least one processor. During the execution process, it can include the process of the embodiments of the resource access method. Among them, the computer-readable storage medium can be a magnetic disk, an optical disc, a read-only memory (ROM, Read Only Memory), a random access memory (RAM, Random Access Memory), etc.

[0158] It can be understood that in the specific implementation of this application, it involves user information, such as data related to application usage behavior data, logs, etc. When the above embodiments of this application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards in relevant countries and regions.

[0159] For the resource access device according to the embodiments of the present application, its various functional modules can be integrated in a processing chip, or each module can exist physically alone, or two or more modules can be integrated in one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk or an optical disc, etc.

[0160] The above has introduced in detail a resource access method, device, storage medium and electronic device provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.< / fd>

Claims

1. A resource access method, characterized in that, it includes: Receiving a resource access request, where the resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object; In response to the resource access request, opening a target file corresponding to the target proxy object and obtaining a target file descriptor; Obtaining the target proxy object through the target file descriptor; Accessing the target resource based on the target proxy object.

2. The resource access method according to claim 1, characterized in that, The step of opening a target file corresponding to the target proxy object and obtaining a target file descriptor includes: Opening a target file corresponding to the target proxy object, triggering the namespace file system to construct a target file object when it determines that there is a target resource interface included in the target proxy object in the resource manager, and returning the file descriptor of the target file object; Using the file descriptor of the target file object as the target file descriptor.

3. The resource access method according to claim 2, characterized in that, The step of obtaining the target proxy object through the target file descriptor includes: Transmitting the target file descriptor to the namespace file system, triggering the namespace file system to return a target proxy object based on the target file descriptor.

4. The resource access method according to claim 3, characterized in that, The step of triggering the namespace file system to return a target proxy object based on the target file descriptor includes: Triggering the namespace file system to determine the target file object based on the target file descriptor, and obtaining the target proxy object corresponding to the target file object from the resource manager.

5. The resource access method according to claim 3, characterized in that, The step of transmitting the target file descriptor to the namespace file system includes: Transmitting the target file descriptor to the namespace file system through a proxy acquisition interface.

6. The resource access method according to claim 3, characterized in that, The step of triggering the namespace file system to return a target proxy object based on the target file descriptor includes: Triggering the namespace file system to return a target proxy object based on the target file descriptor when it determines that the target file descriptor is legal.

7. The resource access method according to claim 1, characterized in that, The step of opening a target file corresponding to the target proxy object includes: Determining a target file corresponding to the target proxy object from multiple files in the namespace, where one file corresponds to one proxy object; Opening the target file.

8. A resource access device, characterized in that, it includes: A request receiving module, configured to receive a resource access request, where the resource access request is used to request access to a target resource, and the target resource corresponds to a target proxy object; A descriptor obtaining module, configured to, in response to the resource access request, open a target file corresponding to the target proxy object and obtain a target file descriptor; An object acquisition module, configured to acquire the target proxy object through the target file descriptor; A resource access module, configured to access the target resource based on the target proxy object.

9. A computer-readable storage medium, characterized in that, a computer program is stored in the storage medium, and when the computer program runs on a computer, the computer is caused to execute the resource access method according to any one of claims 1 to 7.

10. An electronic device, characterized in that, the electronic device includes a processor and a memory, a computer program is stored in the memory, and the processor is configured to execute the resource access method according to any one of claims 1 to 7 by calling the computer program stored in the memory.