Device access method and electronic device
By mapping the device node of a USB device to the guest machine in a multi-operating system environment, a virtual device node is generated. The host machine and the guest machine perform I/O operations respectively, which solves the problem of low efficiency of USB device access and realizes more efficient and reliable USB device access.
Patent Information
- Application Number
- CN202510673500.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2026-11-24
AI Technical Summary
In a multi-operating system environment, access efficiency for USB devices is low, mainly because data needs to pass through front-end drivers, back-end drivers, and hardware drivers, which increases latency and affects bandwidth.
By creating a USB device node in the host machine and mapping it to the guest machine, a virtual device node is generated, enabling the guest machine to directly access the USB device, reducing the forwarding of front-end and back-end drivers. The host machine and the guest machine perform I/O operations through the device node and the virtual device node, respectively.
It improves the access efficiency of USB devices, reduces the possibility of write errors, and enhances system reliability and user experience.
Smart Images

Figure CN123157271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to a device access method and an electronic device. Background Technology
[0002] Multi-operating system integration technology can effectively address complex application needs that traditional single systems cannot meet. Driven by today's diversified application demands, deploying multiple operating systems on electronic devices such as mobile phones and laptops has become an important means of improving system flexibility and performance.
[0003] The integration of multiple operating systems is mainly achieved through virtualization technology. Specifically, guest machines can be built on the host machine based on virtual machine technology. The host machine can provide virtual devices to the guest machine through backend drivers. The guest machine can interact with the backend drivers through frontend drivers, and then access hardware devices, such as Universal Serial Bus (USB) devices, by calling hardware drivers through the backend drivers.
[0004] However, in the above scheme, the access data of the hardware device needs to go through the front-end driver, back-end driver and hardware driver, resulting in low access efficiency. Summary of the Invention
[0005] This application provides a device access method and an electronic device for improving the access efficiency of USB devices.
[0006] In a first aspect, a device access method is provided, applied to an electronic device, the electronic device including a host and a client. The method includes: in response to a USB device insertion operation, the host creates a device node corresponding to the USB device; the host maps the device node to the client, generating a virtual device node corresponding to the device node; the host performs I / O operations on the USB device based on the device node, and the client performs I / O operations on the USB device based on the virtual device node.
[0007] The host machine can call the corresponding USB driver based on the device node to perform I / O operations on the USB device, and the guest machine can call the USB driver based on the virtual device node to perform I / O operations on the USB device.
[0008] When the host and client access a USB device, the I / O operations performed on the USB device can include write operations or read operations.
[0009] In this scheme, the host machine can access the USB device based on the device node, and the guest machine can access the USB device based on the virtual device node. The access data transmitted between the guest machine and the USB device does not need to be forwarded by the front-end driver and the back-end driver, thus effectively improving the access efficiency of the USB device.
[0010] In one possible implementation of the first aspect, after generating the virtual device node corresponding to the device node, the method further includes: the client sending first pop-up metadata to the host; and the host displaying the pop-up after receiving the first pop-up metadata. The first pop-up metadata indicates a first application on the client machine used to respond to a USB device insertion operation; the pop-up indicates the first application, and the pop-up is used by the user to perform access authorization operations.
[0011] In the above implementation, the client sends the first pop-up metadata to the host machine, so that the host machine can manage the pop-ups uniformly and integrate the applications in each system that respond to USB device insertion operations into one pop-up for display, thereby facilitating user access authorization operations and improving user experience.
[0012] In one possible implementation of the first aspect, the client includes multiple clients, and the pop-up window indicates the first application corresponding to each client.
[0013] In this implementation, when there are multiple clients, the pop-up window indicates the first application corresponding to each client, which makes it more convenient for users to perform access authorization operations.
[0014] In one possible implementation of the first aspect, the pop-up also indicates a second application, which is an application on the host machine used to respond to a USB device insertion operation.
[0015] In this implementation, if a second application exists on the host machine, the pop-up window will simultaneously indicate the second application, making it more convenient for users to perform access authorization operations.
[0016] In one possible implementation of the first aspect, the first application is determined by the client based on the device information reported by the virtual device node, and the second application is determined by the host based on the device information reported by the device node.
[0017] In one possible implementation of the first aspect, the I / O operation includes a write operation, with the host write operation and the client write operation executed sequentially. This reduces the likelihood of write errors occurring when write operations are performed on the USB device simultaneously, thereby improving the reliability of USB device access.
[0018] In one possible implementation of the first aspect, the write operations corresponding to the host machine and the write operations corresponding to the client machine are executed sequentially in descending order of priority; the write operations corresponding to the host machine have a higher priority than the write operations corresponding to the client machine.
[0019] The host machine is responsible for managing and scheduling the resources of the entire system. In the above implementation, priority is given to executing write operations corresponding to the host machine, which can better ensure the execution efficiency of the host machine, thereby helping to improve system reliability and overall system performance.
[0020] In one possible implementation of the first aspect, in response to inserting a USB device, the method further includes: the host machine loading a USB driver corresponding to the USB device; wherein the host machine sends an I / O request to the USB driver based on a device node, the client machine sends an I / O request to the USB driver based on a virtual device node, and the USB driver performs a corresponding I / O operation on the USB device in response to the received I / O request; if the I / O request to be processed by the USB driver includes a first write request and a second write request, the USB driver responds to the first write request and the second write request in sequence, wherein the first write request is an I / O request sent by the host machine, and the second write request is an I / O request sent by the client machine.
[0021] In the above implementation, controlling the execution order of write requests through the USB driver can reduce the complexity of implementing I / O request control.
[0022] In a second aspect, an electronic device is provided, comprising: a memory and a processor, wherein the memory is used to store a program; and the processor is used to execute the method described in the first aspect or any embodiment thereof when the program is invoked.
[0023] Thirdly, a readable storage medium is provided having a program stored thereon, which, when executed by a processor, implements the method described in the first aspect or any embodiment of the first aspect.
[0024] Fourthly, a program product is provided that, when run on a device, causes the device to perform the method described in the first aspect or any embodiment thereof.
[0025] Fifthly, a chip system is provided, including a processor coupled to a memory, the processor executing a program stored in the memory to implement the method described in the first aspect or any embodiment thereof. The chip system may be a single chip or a chip module composed of multiple chips.
[0026] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0027] Figure 1 This application provides a multi-operating system convergence architecture.
[0028] Figure 2A schematic diagram of the system architecture of the electronic device provided in the embodiments of this application;
[0029] Figure 3 A flowchart illustrating the device access method provided in an embodiment of this application;
[0030] Figure 4 This is a schematic diagram of the device access path provided in the embodiments of this application;
[0031] Figure 5 A schematic diagram illustrating the execution logic of IO operations corresponding to the native application and the client application provided in the embodiments of this application;
[0032] Figure 6 This application provides a schematic diagram of a pop-up window display process.
[0033] Figure 7 This is a schematic diagram of another pop-up window display process provided in an embodiment of this application;
[0034] Figure 8 This is a schematic diagram of a pop-up interface provided in an embodiment of this application;
[0035] Figure 9 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation
[0036] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is only for explaining specific embodiments and is not intended to limit the application. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0037] To facilitate understanding of the technical solutions in the embodiments of this application, a brief introduction to some of the terms involved in this solution is provided below:
[0038] Client computer: refers to a virtual computer created by abstracting, dividing, and combining the physical resources of an electronic device through virtualization technology. A virtual computer is a general term for a runtime environment virtualized using virtualization technology; specifically, it can be a virtual machine or a container. The operating system installed on the client computer is called the client OS. Applications adapted to the client OS can be installed on the client computer; these applications are also called client applications.
[0039] The host machine is used to manage and allocate hardware resources, presenting a virtual hardware platform to the client machines. The operating system (OS) installed on the host machine is called the host OS. The host OS is compatible with the hardware devices in the electronic devices (such as processors, memory, USB devices, etc.) and can directly control these hardware devices (referred to as hardware). Applications (APPs) compatible with the host OS can be installed on the host machine; these APPs (referred to as applications) can also be called native applications. The host machine can also be called the host machine.
[0040] Device nodes are virtual files corresponding to hardware devices. They provide an interface that allows applications to communicate with device drivers in the kernel through standard file operations (such as reading and writing), thereby enabling access control to hardware devices through device drivers.
[0041] The following is combined with Figure 1 The data access process of USB devices in related technologies is explained.
[0042] Figure 1 This demonstrates a multi-operating system convergence architecture, such as Figure 1 As shown, in this architecture, the host machine builds the backend driver for the USB device in the kernel of the host OS (i.e., the host kernel), and the guest machine builds the frontend driver for the USB device in the kernel of the guest OS (i.e., the guest kernel). Native applications in the host machine can directly call the USB driver to access the USB device at the hardware layer; when the guest application in the guest machine accesses the USB device, it interacts with the backend driver through the frontend driver, and then calls the USB driver through the backend driver to access the USB device.
[0043] The host or client machine can access the USB device by sending input output (IO) requests, which can be read or write requests; the USB device can return corresponding response data to the host or client machine (such as the data read in response to a read request).
[0044] For example, see the section on transmitting I / O requests. Figure 1 As shown by the solid arrow, I / O requests sent by native applications in the host machine to access USB devices are routed through the USB driver to the USB device. See also Figure 1 As shown by the dashed arrow, the I / O requests sent by the client application in the client machine are first transmitted to the front-end driver, then to the back-end driver. The back-end driver transmits the I / O requests to the USB driver via inter-process communication, and the USB driver then transmits the I / O requests to the USB device. The transmission path of the USB device returning data to the host or client is the reverse of the transmission path of the corresponding I / O request, which will not be elaborated here.
[0045] As can be seen, when a client accesses a USB device, the data transmission path (including IO request and response data) has two more driver layers compared to the host machine. On the one hand, the latency will increase significantly, and on the other hand, the bandwidth of the entire transmission path will be affected by the transmission speed of the two driver layers. Therefore, the overall access efficiency of USB devices is relatively low.
[0046] Based on this, this application provides a device access method that maps the device node of a USB device in the host machine to the client machine, enabling the client machine to access the USB device through the virtual device node mapped to the client machine, thereby improving the access efficiency of the USB device.
[0047] The system architecture involved in this solution will be explained below.
[0048] Figure 2 A schematic diagram of the system architecture of the electronic device provided in the embodiments of this application, such as Figure 2 As shown, an electronic device may include a host, a client, and a hardware layer.
[0049] The host machine can install the host OS and native applications, while the guest machine can install the guest OS and guest applications. The host OS and guest OS can be... system, system, system, system, Systems, wearable systems, in-vehicle systems, or smart home systems, etc. In some examples, the host OS and the guest OS can be different types of operating systems; for example, the host OS is... The system, the guest OS is System. In some examples, the host OS and the guest OS can also be the same type of operating system; for example, both the host OS and the guest OS are... system.
[0050] Both native applications and client applications can include one or more apps, such as camera, gallery, calendar, call, Bluetooth, music, video, browser, etc. For example, native applications include APP01, APP02, and APP03, and client applications include APP11, APP12, and APP13.
[0051] Guest machines can be implemented using virtual machine technology or container technology. When a guest machine is implemented using container technology, the guest OS can be a complete operating system or a simplified operating system, which includes all the resources that applications depend on for running. An electronic device may include one or more guest machines. Figure 2 This example uses a single client machine as an illustration; the operating systems of each client machine can be the same or different.
[0052] The hardware layer can include one or more USB devices, such as cameras, microphones, speakers, drones, mice, keyboards, network cards, USB flash drives, hard drives, etc. The hardware layer may also include other hardware devices, such as monitors, Bluetooth modules, etc.
[0053] The host OS can include user space and kernel space (referred to as the kernel). The kernel can include USB drivers for USB devices, as well as hardware drivers for other hardware devices, such as display drivers and Bluetooth drivers. In some examples, the guest machine can include a guest kernel; for example, the guest machine is implemented based on virtual machine technology and includes a virtual machine kernel. In other examples, the guest machine can also share the host OS kernel; for example, the guest machine is implemented based on container technology and can share the host OS kernel.
[0054] When a new USB device is plugged in, the kernel can detect the USB device, load the corresponding device driver, and then notify the host OS to create a device node in user space. After the device node is created, the native application can open the device node, obtain the file descriptor (fd) corresponding to the device node, and then access the USB device by calling the USB driver through the fd of the device node.
[0055] See Figure 2 In this embodiment of the application, after the host OS creates a device node, it can map the device node of the USB device to the guest OS to form a virtual device node, so that the guest can access the USB device through the virtual device node, thereby improving the access efficiency of the guest to access the USB device.
[0056] See also Figure 2 The host OS and guest OS may include a USB management system, which may include a USB management module, an I / O operation module, and a pop-up authorization module.
[0057] The USB management module, also known as a USB manager, is used to obtain device information of USB devices, monitor device status, and manage device configuration information. Specifically, the USB management module can obtain device information through the device node of the USB device, which may include device descriptors, configuration descriptors, interface descriptors, and endpoint descriptors. For the USB management module on the client machine, the device node of the USB device is the virtual device node mapped from the host machine; that is, the USB management module on the client machine can obtain device information through the virtual device node of the USB device.
[0058] The I / O operation module is responsible for managing I / O operations between the application and the USB device, such as scheduling I / O requests (e.g., processing them according to priority) and passing response data to the corresponding application. These I / O operations can include write and read operations; correspondingly, I / O requests include read and write requests. The application can communicate with the USB driver through the I / O operation module to perform read and write operations on the USB device. The processing procedure corresponding to this module is the basic flow of USB device access; for ease of explanation, the processing procedure related to this module will not be described further.
[0059] The pop-up authorization module is primarily responsible for handling the process of requesting authorization from the user via a pop-up window when a new USB device is plugged in, thereby improving system security. Specifically, when a new USB device is plugged in, the USB management module can construct pop-up metadata after obtaining the device information. Then, the pop-up authorization module can generate a pop-up based on the pop-up metadata and can call the notification management module (not shown) in the system to display the pop-up.
[0060] In some embodiments, the USB management module may further include a pop-up fusion module. The client can send the pop-up metadata corresponding to the insertion of the USB device to the pop-up fusion module in the host machine through the pop-up fusion module. The USB management module on the host machine side then merges the pop-up metadata of the host machine and the client machine into a single pop-up window for display.
[0061] In some embodiments, the USB management system may also include other modules not shown, such as a port management module, for managing and controlling the use of USB ports and enabling switching between ports.
[0062] As described above, the host machine can map the device node of a USB device to the client machine. Thus, native applications on the host machine can access the USB device based on this device node, and client applications on the client machine can access the USB device based on the virtual device node mapped to the client machine. To improve the reliability of accessing the USB device, in some embodiments, such as... Figure 2As shown, the USB driver may include an IO concurrency control module, which controls the processing order of IO requests received by the USB driver, so as to avoid the situation where native applications and client applications perform write operations on the USB device at the same time.
[0063] The process of the host and client accessing USB devices is described in detail below.
[0064] Figure 3 This is a flowchart illustrating the device access method provided in an embodiment of this application, as shown below. Figure 3 As shown, the method may include the following steps:
[0065] S110. In response to the USB device insertion operation, the host creates a device node corresponding to the USB device.
[0066] When a new USB device is plugged in, the USB subsystem in the host kernel can detect the device, load the corresponding device driver, and then instruct the host OS to create a device node for the USB device in user space. For example, as shown... Figure 4 As shown, when a user inserts a USB device "usb01", the host machine creates the corresponding device node " / dev / usb / usb01".
[0067] The USB device can be any type of USB device, such as a camera, microphone, drone, or keyboard.
[0068] S120. The host machine maps the device node to the client machine and generates the virtual device node corresponding to the device node.
[0069] After the host machine creates a device node for a USB device, it can map that device node to the client machine. The device node mapped to the client machine is a virtual device node (here referred to as a virtual device node).
[0070] When there are multiple clients, the host machine can map device nodes to some or all of the clients respectively.
[0071] Optionally, the host machine can mount the device node of the USB device to the guest OS through the mount-bind operation to achieve node mapping of the device node.
[0072] In some implementations, the host machine can mount the USB device's device node to the guest OS via the mount-bind operation after creating the device node. For example, the host machine can mount the device node " / dev / usb / usb01" to the guest machine.
[0073] In some implementations, the host machine can mount the file directory (i.e., the parent directory) containing the device nodes of each USB device into the guest OS during the guest machine's boot process using the `mount-bind` operation. After the guest machine creates the device nodes of the USB devices, these device nodes can be automatically mapped to the guest OS. For example, the USB device directory " / dev / usb / " on the host machine can be mounted on the guest machine. Then, each device node under this USB device directory on the host machine, such as the device node " / dev / usb / usb01" of a newly inserted USB device, will be automatically mounted on the guest machine (see [link to documentation]). Figure 4 ).
[0074] The above-described implementation of node mapping after device node creation allows for selection of the mapped device nodes as needed, offering greater flexibility. The implementation of node mapping before device node creation allows for convenient mapping of multiple device nodes, resulting in higher efficiency. In specific implementations, the choice can be made as needed; this embodiment does not impose any particular limitation.
[0075] Furthermore, the above-described method of using mount-bind operations to implement node mapping is merely an example and is not intended to limit this application; in other examples, other methods can also be used to implement device node mapping, and this embodiment does not impose any particular limitations on this.
[0076] S130: The host performs I / O operations on the USB device based on the device node, and the client performs I / O operations on the USB device based on the virtual device node.
[0077] After the host OS creates the device node for the USB device, the native application can open the device node and obtain its file descriptor (fd) using the open system call. The native application can then use this fd to perform I / O operations on the USB device, such as read or write operations.
[0078] After a device node in the host machine is mapped to a client machine, the client application in the client machine can also open the virtual device node corresponding to that device node through the open system call, obtain the file descriptor (fd) of that device node, and then use that fd to perform I / O operations on the USB device.
[0079] Specifically, native applications on the host machine and client applications on the client machine can use file descriptors (fds) to initiate I / O requests. The host machine can send I / O requests to the USB driver based on device nodes, and the client machine can send I / O requests to the USB driver based on virtual device nodes. The USB driver can then respond to the received I / O requests by performing corresponding I / O operations on the USB device.
[0080] See Figure 4As shown by the solid arrow, I / O requests initiated by native applications on the host machine can be passed to the USB driver through the device node. The USB driver can then respond to these I / O requests and perform I / O operations on the USB device at the hardware layer. Similarly, see... Figure 4 As shown by the dashed arrow, I / O requests initiated by client applications in the client machine can be passed to the USB driver through virtual device nodes. The USB driver can respond to the I / O request and perform I / O operations on the USB device at the hardware layer. The path for the USB device to return response data to the host or client is the reverse of the path for the corresponding I / O request, which will not be elaborated here.
[0081] Compared to Figure 1 The USB device access method shown in this embodiment allows native applications to call the USB driver to access USB devices. The access data transmitted between the client application and the USB driver does not need to be forwarded by the front-end driver and the back-end driver, thus effectively improving the access efficiency of USB devices.
[0082] As mentioned earlier, the I / O operations performed on the USB node by the native application in the host machine and the client application in the client machine can include read operations and write operations. The native application and the client application may initiate I / O requests simultaneously. In some examples, at least one of the two I / O requests may be a read request. In this case, the USB driver can respond to both I / O requests in parallel; that is, the native application and the client application can perform read operations on the USB device simultaneously, or one of them can perform a read operation on the USB device while the other performs a write operation.
[0083] In some examples, both the native application and the client application initiate write requests. In such cases, the USB driver can respond to the two write requests sequentially. That is, the write operations performed by the native application on the host machine and the client application on the guest machine on the USB device can be executed sequentially. This reduces the possibility of write errors caused by simultaneous write operations on the USB device, thereby improving the reliability of USB device access.
[0084] Figure 5 The diagram illustrates the execution logic of IO operations for native and client applications, as shown below. Figure 5 As shown, native applications and client applications can perform read operations on the USB device simultaneously; or, the native application can perform a read operation on the USB device while the client application performs a write operation; or, the native application can perform a write operation on the USB device while the client application performs a read operation. Native applications and client applications cannot perform write operations on the USB device simultaneously; that is, write operations performed by the native application and write operations performed by the client application are mutually exclusive.
[0085] It is understandable that the host OS and guest OS can have their own concurrency control logic to allow an application process within their own system to perform write operations on the USB device at the same time. For example, the I / O operation module in the USB management system can be used to control the I / O concurrency within the system.
[0086] Specifically, such as Figure 4 As shown, the USB driver can control the response order of IO requests through the IO concurrency control module, so that only one application process on the entire electronic device can perform write operations on the USB device at a time, while read operations on the USB device can be executed concurrently.
[0087] In some implementations, write operations on the host machine and write operations on the client machine can be executed sequentially in descending order of priority, with the write operations on the host machine having a higher priority than those on the client machine.
[0088] That is, when the USB driver receives an I / O request to be processed that includes both a first write request (an I / O request sent by the host machine) and a second write request (an I / O request sent by the client machine), the USB driver can respond to the first write request first. At this time, the second write request is suspended and waits for the write operation corresponding to the first write request to be completed before the USB driver responds to the second write request.
[0089] In some examples, where there are multiple clients, the IO requests pending processing by the USB driver may include multiple second write requests sent by clients. In this case, the USB driver may respond to the second write requests in a random order or in order of priority from high to low.
[0090] That is, different priorities can be set for each client machine, with each client machine having a lower priority than the host machine. The USB driver can respond to write requests sent by the host machine and each client machine in descending order of priority.
[0091] As mentioned above, in this embodiment of the application, the USB management module in the host machine and the client machine can respond to the USB device insertion operation and construct pop-up metadata to display the pop-up.
[0092] In some embodiments, a target operating system that responds to USB device insertion operations can be pre-configured. When a new USB device is inserted, the target operating system responds to the USB device insertion operation, constructs corresponding pop-up metadata, and displays the pop-up. For example, if the pre-configured target operating system is the host OS, the host OS will display the pop-up; if the pre-configured target operating system is a guest OS, the guest OS will display the pop-up.
[0093] To facilitate user operation, in some embodiments, the client can send pop-up metadata to the host machine, which then merges the pop-up metadata from both the host machine and the client machine into a single pop-up for display.
[0094] Specifically, after the host machine maps the device node to the client machine, see [link to documentation]. Figure 6 The device access method provided in this application embodiment may further include the following steps:
[0095] S210. In response to the USB device insertion operation, the client generates the first pop-up metadata.
[0096] The client machine can generate the first pop-up metadata through its internal USB management system.
[0097] like Figure 7 As shown, when a new USB device is plugged in, the USB management module in the client can read the device information reported by the device node of the USB device (step S1.1). This device information may include a device descriptor, configuration descriptor, interface descriptor, and endpoint descriptor, etc. Among them, the device descriptor is used to describe the basic information of the USB device, which may include the device type code, device subtype code, device protocol code, etc.
[0098] After obtaining the device information of the USB device, the USB management module can determine the device type of the USB device based on the device type code in the device information, and then determine the target APP (referred to as the first application) to respond to the USB device insertion operation. For example, if the inserted USB device is a drone, the corresponding first application can be a drone application; as another example, if the inserted USB device is a camera, the corresponding first application can be a camera application.
[0099] After identifying the first application, the USB management module can construct the corresponding pop-up metadata, namely the first pop-up metadata (step S2.1). The first pop-up metadata can indicate the relevant information of the first application, such as the name, icon, and startup parameters of the first application.
[0100] S220. In response to the USB device insertion operation, the host machine generates a second pop-up metadata window.
[0101] Similar to the client machine, the host machine can generate a second pop-up metadata through its internal USB management system.
[0102] like Figure 7As shown, when a new USB device is inserted, the USB management module in the host machine can read the device information reported by the device node of the USB device (step S1.2). Then, it can determine the device type of the USB device based on the device type code in the device information, and determine the target APP (referred to as the second application) to respond to the USB device insertion operation. After that, the USB management module can construct the pop-up metadata corresponding to the second application, namely the second pop-up metadata (step S2.2). The second pop-up metadata can indicate the relevant information of the second application, such as the name, icon, and startup parameters of the second application.
[0103] S230, The client sends the first pop-up metadata to the host machine.
[0104] After generating the first pop-up metadata, the client can send it to the host machine.
[0105] Specifically, such as Figure 7 As shown, after the USB management module in the client generates the first pop-up metadata, it can pass the first pop-up metadata to the pop-up fusion module (step S3.1), and then the pop-up fusion module sends the first pop-up metadata to the pop-up fusion module on the host side (step S3.2).
[0106] S240, the host machine displays a pop-up window based on the first pop-up window metadata and the second pop-up window metadata.
[0107] After receiving the first pop-up metadata from the client, the host machine can merge the first and second pop-up metadata, displaying the target apps corresponding to each pop-up metadata in a single pop-up window. In other words, a single pop-up window indicates both the first and second applications. Users can then authorize access through this pop-up window.
[0108] Specifically, see Figure 7 After receiving the first pop-up metadata, the pop-up fusion module on the host side can pass the first pop-up metadata to the USB management module (step S4). The USB management module can then pass the first and second pop-up metadata to the pop-up authorization module (step S5). The pop-up authorization module can draw the pop-up based on the first and second pop-up metadata (step S6). Finally, the pop-up authorization module can call the notification management module in the host OS to display the pop-up (step S7).
[0109] The above description primarily uses a single client as an example. When there are multiple clients, each client can respond to a USB device insertion operation, construct the corresponding first pop-up metadata, and send the generated first pop-up metadata to the host machine. Correspondingly, the pop-up window displayed on the host machine can indicate the first application corresponding to multiple clients.
[0110] It is understandable that for any client machine, if the first application does not exist on that client machine, the client machine may not need to execute the above steps S210 and S230. Similarly, if the second application does not exist on the host machine, the host machine may also not need to execute the above step S220. Correspondingly, in step S240, when the host machine displays the pop-up window, the pop-up window metadata it uses may not include the first pop-up window metadata or the second pop-up window metadata; that is, the pop-up window may only indicate the first application or only indicate the second application.
[0111] For example, the first application is APP11, and the second application is APP01, such as... Figure 8 As shown in (a), the pop-up window displayed on the host machine indicates the options corresponding to APP11 and APP01, allowing the user to select which APP will access the USB device. For example, if the user selects the option corresponding to APP12, the host machine can open APP11, and APP11 will currently access the USB device. If the user selects the option corresponding to APP01, the host machine can open APP01, and APP01 will currently access the USB device.
[0112] The host machine can open APP11 on the client machine through network interface or application programming interface (API).
[0113] Taking APP11 as an example, after opening APP11, APP11 can perform read and write operations on the USB device, and users can also set the configuration information of the USB device through APP11.
[0114] Optionally, such as Figure 8 As shown in (a), the pop-up window can also display text prompts, such as "Allow the application to access this USB device?", and can also display a "Cancel" option, which the user can choose to deny the application access to the plugged-in USB device.
[0115] Optionally, the pop-up window can also indicate the operating system information corresponding to each target APP. For example, it can be marked in the option corresponding to APP01. The system is marked in the options corresponding to APP11. system.
[0116] In other examples, there are multiple clients, where the first application corresponding to client 1 is APP11, the first application corresponding to client 2 is APP21, and the first application corresponding to client 3 is APP31; there is no corresponding second application on the host machine. For example... Figure 8As shown in (b), the pop-up window displayed on the host machine indicates APP11, APP21, and APP31. The user can select which APP should access the USB device, and the host machine can open the corresponding APP. The user can also select the "Cancel" option to deny the application access to the inserted USB device.
[0117] Understandable Figure 8 The pop-up interfaces shown are just examples and are not intended to display this application. In specific implementations, the interface elements in the pop-up interface can be designed as needed, and this embodiment does not impose any special limitations on this.
[0118] Those skilled in the art will understand that the above embodiments are exemplary and not intended to limit this application. Where possible, the execution order of one or more of the above steps can be adjusted or selectively combined to obtain one or more other embodiments. For example, there is no strict temporal relationship between steps S210 and S220; they can be executed simultaneously or sequentially. In some embodiments, steps S210 and S230 may not be executed; in some embodiments, step S220 may not be executed. Those skilled in the art can arbitrarily select and combine the above steps as needed, and all combinations that do not depart from the essence of this application fall within the protection scope of this application.
[0119] In this embodiment, the host machine aggregates the pop-up metadata corresponding to USB devices in each operating system, and merges the target APPs in each operating system that respond to USB device insertion operations into a unified pop-up window for display. This makes it easier for users to perform access authorization operations and improves the user experience.
[0120] The above describes the device access method provided by the embodiments of this application. In the various embodiments of this application, unless otherwise specified or logically conflicting, the terms and / or descriptions between the various embodiments are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationship.
[0121] The following is combined with Figure 9 This application provides a detailed description of the electronic device provided in its embodiments. It should be understood that the electronic device in this embodiment can implement all the content of the foregoing method embodiments. For ease of reading, this embodiment will not repeat the details of the foregoing method embodiments one by one.
[0122] Figure 9 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application, such as... Figure 9As shown, the electronic device may include: processor 110, memory 120, display screen 130, power module 140, communication module 150, and USB interface 160, etc.
[0123] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or arrange the components differently. The functional characteristics of the illustrated components may be implemented in hardware, in software, or in a combination of software and hardware.
[0124] Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. Processor 110 may also include memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory.
[0125] The memory 120 can be used to store executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 120. The memory 120 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc. The data storage area may store data created during the use of the electronic device (such as image data, etc.). Furthermore, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, Universal Flash Storage (UFS), etc.
[0126] The display screen 130 is used to display human-computer interaction interfaces, images, videos, etc.
[0127] The power module 140 may include a battery, a power management unit, etc. The power management unit is used to manage the charging of the battery and the power supply from the battery to other modules.
[0128] The communication module 150 can provide solutions for wireless communication technologies such as 2G / 3G / 4G / 5G applied to electronic devices. The communication module 150 can also provide solutions for wireless communication technologies such as wireless local area networks (WLANs) (e.g., wireless fidelity, Wi-Fi), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), sparklink, and ultra-wideband (UWB). The communication module 150 can be one or more devices integrating at least one communication processing module. In some embodiments, at least some functional modules of the communication module 150 can be located in the processor 110. In some embodiments, at least some functional modules of the communication module 150 and at least some modules of the processor 110 can be located in the same device. The electronic device can communicate with networks and other devices through wireless communication technologies.
[0129] The communication module 150 can be used in conjunction with an antenna (not shown) of an electronic device to receive electromagnetic waves, demodulate and filter the electromagnetic wave signals, and send the processed signals to the processor 110. The communication module 150 can also receive signals to be transmitted from the processor 110, frequency modulate and amplify them, and then convert them into electromagnetic waves for radiation via the antenna.
[0130] USB interface 160 is an interface that conforms to the USB standard specification, specifically it can be a Mini USB interface, Micro USB interface, USB Type C interface, etc. USB interface 160 can be used to connect a charger to charge electronic device 100, and it can also be used for electronic device 100 to transfer data with other USB devices.
[0131] This application also provides a readable storage medium (also known as a computer-readable storage medium) storing a program thereon, which, when executed by a processor, implements the method described in the above-described method embodiments.
[0132] This application also provides a program product (also known as a computer program product) that, when run on a device, causes the device to implement the method described in the above-described method embodiments.
[0133] This application also provides a chip system including a processor coupled to a memory. The processor executes a program stored in the memory to implement the method described in the above embodiments. The chip system may be a single chip or a chip module composed of multiple chips.
[0134] In the above embodiments, each processing step or functional feature can be implemented, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a program product. The program product includes one or more instructions. When the instructions are loaded and executed on the device, the process or function described in accordance with the embodiments of this application is generated, in whole or in part. The instructions can be stored in a readable storage medium or transmitted through the readable storage medium.
[0135] The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time / logical order indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effect can be achieved.
[0136] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0137] In the embodiments provided in this application, it should be understood that the disclosed apparatus / devices and methods can be implemented in other ways. For example, the apparatus / device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0138] It should be understood that in the description of this application and the appended claims, the terms "comprising," "including," "having," and any variations thereof are intended to cover a non-exclusive inclusion and mean "including but not limited to," unless otherwise specifically emphasized. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not necessarily limited to those steps or modules that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to such process, method, product, or apparatus.
[0139] In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can mean A or B. "And / or" in this application is used to describe the relationship between the related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural.
[0140] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0141] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0142] Furthermore, in the description of this application and the appended claims, the terms "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein; features defined as "first" or "second" may explicitly or implicitly include at least one of those features.
[0143] In the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0144] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A device access method, characterized in that, Applied to an electronic device, the electronic device including a host and a client, the method includes: In response to a USB device insertion operation, the host machine creates a device node corresponding to the USB device; The host machine maps the device node to the client machine, generating a virtual device node corresponding to the device node; The host machine performs I / O operations on the USB device based on the device node, and the client machine performs I / O operations on the USB device based on the virtual device node.
2. The method according to claim 1, characterized in that, After generating the virtual device node corresponding to the device node, the method further includes: The client sends a first pop-up metadata to the host machine; the first pop-up metadata indicates a first application in the client machine used to respond to the USB device insertion operation; After receiving the first pop-up metadata, the host machine displays a pop-up window, which indicates the first application and is used by the user to perform access authorization operations.
3. The method according to claim 2, characterized in that, The client includes multiple clients, and the pop-up window indicates the first application corresponding to each client.
4. The method according to claim 2 or 3, characterized in that, The pop-up window also indicates a second application, which is an application in the host machine used to respond to the USB device insertion operation.
5. The method according to claim 4, characterized in that, The first application is determined by the client based on the device information reported by the virtual device node, and the second application is determined by the host based on the device information reported by the device node.
6. The method according to any one of claims 1-5, characterized in that, The I / O operation includes a write operation, and the write operation corresponding to the host machine and the write operation corresponding to the client machine are executed sequentially.
7. The method according to claim 6, characterized in that, The write operations corresponding to the host machine and the write operations corresponding to the client machine are executed sequentially in descending order of priority; The write operation corresponding to the host machine has a higher priority than the write operation corresponding to the client machine.
8. The method according to claim 6 or 7, characterized in that, The response to inserting a USB device further includes: the host machine loading the USB driver corresponding to the USB device; The host machine sends an I / O request to the USB driver based on the device node, the client machine sends an I / O request to the USB driver based on the virtual device node, and the USB driver performs the corresponding I / O operation on the USB device in response to the received I / O request; When the pending I / O requests of the USB driver include a first write request and a second write request, the USB driver responds to the first write request and the second write request in sequence, wherein the first write request is an I / O request sent by the host machine and the second write request is an I / O request sent by the client machine.
9. An electronic device, characterized in that, include: A memory and a processor, the memory being used to store a computer program; the processor being used to execute the method as described in any one of claims 1-8 when the computer program is invoked.
10. A program product, characterized in that, When the program product is run on the device, the device performs the method as described in any one of claims 1-8.
