Interface switching method and device, equipment, medium and product
By detecting the communication protocol of the debugging equipment and switching the USB interface mode of the terminal device, the problem of the inability to flexibly switch the USB interface in the existing technology is solved, realizing flexible switching of the USB interface and improving stability, thus meeting the debugging needs in complex scenarios.
Patent Information
- Application Number
- CN202510764592.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-10-17
AI Technical Summary
The existing technology cannot flexibly switch the debug bridge connection of multiple USB interfaces in the terminal device, resulting in reduced debugging and development convenience and poor user experience.
By detecting the communication protocol of the debugging device, an interface switching command is initiated to switch the USB interface of the terminal device from the first mode to the second mode, and the driver of the first USB interface is uninstalled and the driver of the second USB interface is started to support the establishment of a debugging bridge with the debugging device through the second USB interface.
It enables flexible switching of USB interfaces, improves the compatibility and stability of terminal devices in multi-interface environments, meets the debugging needs in complex scenarios, and enhances the user experience.
Smart Images

Figure CN120803980A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronic control, and particularly relates to an interface switching method and device, equipment, medium and product. BACKGROUND
[0002] At present, when a terminal device is connected with an external debugging device through a universal serial bus (USB) interface, a first USB interface (such as USB1) is used as a USB interface for debugging bridge connection by default. However, when there are multiple USB slave modes in the terminal device, the existing scheme cannot flexibly switch the USB port used for debugging bridge connection, which limits the convenience of debugging and development, and thus reduces the user experience. SUMMARY
[0003] An object of the present application is to provide an interface switching method applied to a terminal device, wherein at least two universal serial bus (USB) interfaces are arranged on the terminal device. The method has the advantage that, in response to a first USB interface detecting a debugging device, information of the debugging device is acquired, and the information includes a communication protocol. In response to the communication protocol being used, the terminal device is forced to be in a first mode, an interface switching instruction is started, the interface switching instruction is used to switch an interface for establishing a debugging bridge with the debugging device from the first USB interface to a second USB interface. In response to the interface switching instruction, a driver of the first USB interface is unloaded, the first mode of the first USB interface is closed, and the first mode of the second USB interface is started and the driver of the second USB interface is started, so that the terminal device supports establishing a debugging bridge with the debugging device through the second USB interface. The first mode represents that the terminal device supports being a slave device when a debugging bridge is established through a USB interface. By closing the slave mode of the first USB interface, if the first USB interface and the second USB interface are both in the first mode, the system cannot correctly distinguish to which interface the debugging device is connected, causing the problem of communication confusion. The flexible switching of the debugging bridge interface is realized. In the prior art, when a specific protocol is used in a USB interface, the communication protocol is used to force the vehicle machine to be in a slave mode, which causes the vehicle machine to be unable to enumerate other USB devices, thereby enhancing the compatibility and stability of the terminal device in a multi-interface environment, and meeting the debugging requirements in a complex scenario. In this way, when a debugging bridge is established through a USB interface, any USB port can be switched for connection, the flexibility of debugging bridge connection based on a USB is improved, and the user experience is improved.
[0004] Another object of the present application is to provide an interface switching method, applied to a terminal device, wherein at least two universal serial bus (USB) interfaces are arranged on the terminal device, and the method has the advantage that the first USB interface is set to a second mode, the second mode indicating that data interaction between the terminal device and a debugging device through the first USB interface is prohibited, the first USB interface is set to a third mode, and the third mode indicates that the terminal device supports being a host device when a debugging bridge is established between the terminal device and the debugging device through the first USB interface. In this way, the first USB interface is set to the second mode or the third mode, and the USB interface used by the Android debug bridge (ADB) can be dynamically switched. In this way, conflicts caused by multiple USB interfaces being in a device state at the same time can be avoided, the stability of the debugging process can be ensured, and the demand of a developer for a debugging interface in different scenarios can be met, thereby improving the debugging efficiency and system compatibility.
[0005] Another object of the present application is to provide an interface switching method, applied to a terminal device, wherein at least two universal serial bus (USB) interfaces are arranged on the terminal device, and the method has the advantage that, in response to starting of the terminal device, driver data of each USB interface is loaded into a memory, and starting of a driver of the second USB interface includes starting the driver corresponding to the second USB interface based on the driver data corresponding to the second USB interface in the memory. In this way, the driver data of each USB interface is loaded into the memory when the terminal device starts. In this way, quick binding between the USB interface and the ADB debugging function can be implemented, the ADB debugging function of different USB ports can be dynamically switched, and the debugging efficiency can be improved and the demand for multi-port debugging can be met.
[0006] Another object of the present application is to provide an interface switching method, applied to a terminal device, wherein at least two universal serial bus (USB) interfaces are arranged on the terminal device, and the method has the advantage that, in response to loading of driver data of each USB interface into a memory, a driver corresponding to a default USB interface is started, so that the terminal device supports establishment of a debugging bridge between the terminal device and a debugging device through the default USB interface. In this way, in response to loading of the driver data of each USB interface into the memory, the driver corresponding to the default USB interface is started. In this way, when the terminal device and the debugging device establish the debugging bridge through the USB interface for the first time, the debugging bridge can be established between the terminal device and the debugging device through the default interface among the at least two USB interfaces of the terminal device, and the debugging and development efficiency in a multi-USB interface environment can be improved.
[0007] Another object of the present application is to provide an interface switching method, applied to a terminal device having at least two Universal Serial Bus (USB) interfaces. The method advantageously establishes a debug bridge with the debug device based on a driver of the second USB interface in response to an event to establish a debug bridge with the debug device. Thus, by responding to the debug bridge event and establishing a debug bridge based on the driver of the second USB interface, dynamic switching of the ADB communication interface can be achieved, allowing the user to freely select different USB ports for debugging, thereby improving debugging efficiency and system compatibility.
[0008] Another object of the present application is to provide an interface switching method, applied to a terminal device having at least two Universal Serial Bus (USB) interfaces. The method advantageously disconnects the debug bridge established between the terminal device and the debug device via the first USB interface in response to an interface switching instruction, provided that the debug bridge has already been established between the terminal device and the debug device via the first USB interface. This ensures that the old debug bridge is released before the interface is switched, thereby ensuring that the new debug bridge can be stably established on the target USB interface, thereby supporting flexible debugging requirements in a multi-USB port environment.
[0009] Another object of the present application is to provide an interface switching device, which is applied to a terminal device, wherein the terminal device is provided with at least two Universal Serial Bus (USB) interfaces, and has the advantage of receiving an interface switching instruction through a receiving module; the interface switching instruction is used to switch the interface for establishing a debug bridge with a debug device from a first USB interface to a second USB interface; an uninstall module is used to uninstall the driver of the first USB interface in response to the interface switching instruction, and start the driver of the second USB interface, so that the terminal device supports establishing a debug bridge with the debug device through the second USB interface. Flexible switching of the debug bridge interface is achieved, and compared with the prior art that only supports debugging with a single USB interface, the compatibility and stability of the terminal device in a multi-interface environment are enhanced, meeting the debugging requirements in complex scenarios. In this way, when establishing a debug bridge through a USB interface, any USB port can be switched for connection, which improves the flexibility of USB-based debug bridge connection and improves user experience.
[0010] Another object of the present application is to provide a terminal device comprising at least two Universal Serial Bus (USB) interfaces, a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0011] Another object of the present application is to provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements some or all of the steps of the above method.
[0012] Another object of the present application is to provide a computer program product comprising a computer program or instructions which, when executed by a processor, implements some or all of the steps of the above method.
[0013] To achieve the above objects, the technical scheme of the embodiments of the present application is as follows:
[0014] In one aspect, the embodiments of the present application provide an interface switching method applied to a terminal device, at least two universal serial bus (USB) interfaces being provided on the terminal device, the method comprising: in response to a first USB interface detecting a debugging device, obtaining information of the debugging device, the information comprising a communication protocol; in response to the communication protocol being used to force the terminal device to be in a first mode, starting an interface switching instruction, the interface switching instruction being used to switch an interface for establishing a debugging bridge with the debugging device from the first USB interface to a second USB interface; in response to the interface switching instruction, uninstalling a driver of the first USB interface, closing the first mode of the first USB interface, and starting the first mode of the second USB interface and starting a driver of the second USB interface, so as to enable the terminal device to support establishing the debugging bridge with the debugging device through the second USB interface; wherein the first mode represents that the terminal device is supported to be a slave device when establishing the debugging bridge with the debugging device through the USB interface.
[0015] In another aspect, the embodiments of the present application provide an interface switching device applied to a terminal device, at least two universal serial bus (USB) interfaces being provided on the terminal device, the device comprising: a first response module configured to, in response to a first USB interface detecting a debugging device, obtain information of the debugging device, the information comprising a communication protocol; a second response module configured to, in response to the communication protocol being used to force the terminal device to be in a first mode, start an interface switching instruction, the interface switching instruction being used to switch an interface for establishing a debugging bridge with the debugging device from the first USB interface to a second USB interface; and a third response module configured to, in response to the interface switching instruction, uninstall a driver of the first USB interface, close the first mode of the first USB interface, and start the first mode of the second USB interface and start a driver of the second USB interface, so as to enable the terminal device to support establishing the debugging bridge with the debugging device through the second USB interface; wherein the first mode represents that the terminal device is supported to be a slave device when establishing the debugging bridge with the debugging device through the USB interface.
[0016] In another aspect, an embodiment of the present application provides a terminal device, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the processor implements the steps in the above method when executing the program.
[0017] In another aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps in the above method.
[0018] In another aspect, an embodiment of the present application provides a computer program product, which comprises a computer program or instructions, and the computer program or instructions are executed by a processor to implement some or all of the steps in the above method.
[0019] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the technical solutions of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings incorporated in the description below and forming a part of it illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the description.
[0021] Figure 1 An implementation flowchart of an interface switching method provided by an embodiment of the present application;
[0022] Figure 2 An implementation flowchart of an interface switching method provided by an embodiment of the present application;
[0023] Figure 3 A component structure diagram of an interface switching device provided by an embodiment of the present application;
[0024] Figure 4 A hardware entity diagram of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further described in detail below with reference to the drawings and embodiments, and the described embodiments should not be regarded as limiting the present application, and all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0026] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" can be the same subset or different subsets as each other and can be combined with each other as long as there is no conflict. The terms "first / second / third" referred to only distinguish similar objects, do not represent a specific order for the objects, and it is understood that "first / second / third" can be interchanged in a specific order or sequence as long as it is allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing the present application only and is not intended to be limiting of the present application.
[0028] At present, when there are multiple interfaces (such as USB1, USB2, USB3, etc.) supporting USB device functions in a terminal device, the terminal device can use the first USB interface (such as USB1) as the USB interface for ADB connection by default when the terminal device establishes an ADB connection with an external debugging device through the USB interface. In the USB communication mode, there are usually master and slave devices, for example, in the automotive field, when the car machine and the mobile phone are connected, some mobile phone screen projection protocols, such as carplay protocol, usually force the car machine to be a slave device, and other devices connected to the car machine are master devices, which means that if a new device is connected to the car machine through the USB interface of the car machine, the car machine cannot normally identify the new device, and the user's original expectation of realizing the function through the connection of the new device cannot be achieved. The existing scheme cannot flexibly switch the USB port used for ADB connection, which limits the convenience of debugging and development, thereby reducing the user experience.
[0029] To solve the above technical problems, the embodiment of the present application provides an interface switching method, which is applied to a terminal device, and at least two universal serial bus (USB) interfaces are arranged on the terminal device. The method comprises the following steps: in response to detecting a debugging device by a first USB interface, obtaining information of the debugging device, wherein the information comprises a communication protocol; in response to the communication protocol using a first mode, starting an interface switching instruction, wherein the interface switching instruction is used to switch an interface for establishing a debugging bridge with the debugging device from the first USB interface to a second USB interface; in response to the interface switching instruction, uninstalling a driver of the first USB interface, closing the first mode of the first USB interface, starting the first mode of the second USB interface, and starting a driver of the second USB interface, so that the terminal device supports establishing the debugging bridge with the debugging device through the second USB interface; and wherein the first mode represents that the terminal device supports being a slave device when establishing the debugging bridge with the debugging device through the USB interface. Thus, the ADB connection using USB interface is dynamically switched, so that the terminal device establishes the ADB connection with the debugging device through the USB interface, and the flexible switching of the USB interface is realized, and the user experience is improved.
[0030] The interface switching method provided by the embodiment of the present application can be executed by a processor of a terminal device. The terminal device can be a vehicle-mounted device (for example, a vehicle-mounted central control device), a server, a notebook computer, a tablet computer, a desktop computer, a smart television, a set-top box, a mobile device (for example, a mobile phone, a portable video player, a personal digital assistant, a dedicated message device, a portable game device), or any device with data processing capability.
[0031] Figure 1 The implementation flowchart of the interface switching method provided by the embodiment of the present application can be executed by a processor of a terminal device. As shown in Figure 1 , the method comprises the following steps S101 to S103, which will be described in combination with the steps. Figure 1
[0032] In step S101, in response to detecting a debugging device by a first USB interface, information of the debugging device is obtained, wherein the information comprises a communication protocol.
[0033] In some embodiments, at least two universal serial bus (USB) interfaces are arranged on the terminal device. For example, two USB interfaces, such as USB1 and USB2, can be arranged on the terminal device, or multiple USB interfaces, such as USB1, USB2, USB3, USB4, etc., can be arranged.
[0034] In some embodiments, the terminal device continuously detects the connection state of the first USB interface, and in the case that a device is detected to be connected to the first USB interface, the device is detected, and if the device is a debugging device, information of the debugging device is acquired.
[0035] In some embodiments, the terminal device determines whether there is a device access by detecting whether there is an insertion operation on the first USB interface.
[0036] For example, the terminal device detects the voltage signal of the first USB interface, and in the case that the voltage signal of the first USB interface changes, it is indicated that a device is connected to the first USB interface.
[0037] In some embodiments, the terminal device sends a request for acquiring basic information of the device to the device, and determines whether the device is a debugging device based on the basic information returned by the device.
[0038] For example, the terminal device acquires the device descriptor of the device, and in the case that the device descriptor of the device indicates that the device is a communication device (such as a serial debugging device), it is indicated that the device is a debugging device.
[0039] In some embodiments, in the case that the device is a debugging device, the information of the debugging device is acquired by reading the description information of the debugging device. The information of the debugging device can include the communication protocol, working mode, communication characteristics, and driving type adopted by the debugging device.
[0040] For example, in the case that the device is a debugging device, the configuration descriptor of the debugging device is read to acquire the working mode, other working modes adapted by the debugging device, and the number of USB interfaces; and the communication protocol adopted by the debugging device is determined by analyzing the interface descriptor of the debugging device.
[0041] In step S102, in response to the communication protocol, the terminal device is forced to be in the first mode, and an interface switching instruction is started; the interface switching instruction is used to switch the interface for establishing a debugging bridge with the debugging device from the first USB interface to the second USB interface.
[0042] In some embodiments, if the communication protocol of the debugging device is a specific protocol, the terminal device is usually forced to be in the slave mode, and during this period, the terminal device cannot enumerate other USB devices and connect with the debugging device, thereby reducing the user experience.
[0043] Exemplarily, in a scenario where the terminal device is a car machine, in a case where the communication protocol used by the debugging device is a specific protocol, the car machine is forced to be in slave mode; in response to the use of the communication protocol, the embodiment of the application forces the terminal device to be in the first mode, and starts an interface switching instruction to switch the interface for establishing the debugging bridge with the debugging device from the first USB interface to the second USB interface.
[0044] In the scenario where the terminal device is a car machine, the specific protocol can be a CARPLAY protocol, a serial wire debug (SWD) protocol, a local interconnect network (LIN), etc.
[0045] In some embodiments, a debugging bridge (Debug Bridge) is a bridge mechanism for establishing a communication connection between a terminal device and a debugging device. Through this mechanism, the debugging device can access the system resources of the terminal device, execute debugging commands, obtain log information, etc., for example, in the development and debugging process of an Android system, the debugging bridge can be an Android debugging bridge (ADB).
[0046] In some embodiments, a universal serial bus interface (USB Interface) is a hardware interface standard for connecting a terminal device and an external device (such as a PC). In the embodiments of the application, a plurality of USB interfaces supporting the USB Device function are provided on the terminal device, and each interface can be used as a physical channel of the debugging bridge.
[0047] In some embodiments, a plurality of USB interfaces supporting the USB Device function are usually provided on the terminal device, such as USB1, USB2, USB3, etc. By default, the system uses the first available USB interface (such as USB1) to establish the debugging bridge. When the user or the system needs to switch to another USB interface, an interface switching instruction can be issued in a specific manner (such as a command script, a system service call, etc.). The instruction contains target switching information, for example, specifying to switch the current debugging bridge interface from USB1 to USB2.
[0048] In some embodiments, the interface switching instruction is an instruction issued by the user or the system, which is used to instruct the terminal device to switch the USB interface currently used for the debugging bridge from one interface to another interface. After the instruction is triggered, the subsequent driver uninstallation and loading process is triggered, thereby completing the interface switching operation.
[0049] In some embodiments, the interface switching instruction can be manually input by a user or triggered by an automated script. Illustratively, in an Android system, a user can execute a sys.usb.adb.config=usb2 command in a terminal device to trigger the interface switching process.
[0050] In some embodiments, after the terminal device receives the manually triggered or automatically triggered interface switching instruction, the interface switching instruction needs to be verified to ensure that the target USB interface to be switched is in an available state, that is, the target interface meets the condition for establishing a debugging bridge with the debugging device; if the verification is passed, the switching operation is performed.
[0051] In some embodiments, the first mode refers to the slave mode used by the terminal device when establishing a debugging bridge with the debugging device through the USB interface. In this mode, the terminal device is in a passive receiving state, that is, the terminal device acts as a slave device and allows the debugging device to control and interact with it.
[0052] Step S103, in response to the interface switching instruction, uninstalling the driver of the first USB interface, closing the first mode of the first USB interface, and starting the first mode of the second USB interface and starting the driver of the second USB interface to enable the terminal device to support establishing a debugging bridge with the debugging device through the second USB interface.
[0053] In some embodiments, when it is necessary to establish a debugging bridge between the terminal device and the debugging device, the first USB interface of the on-board device is usually used by default; when the interface switching instruction is received to switch the interface for establishing a debugging bridge with the debugging device from the first USB interface to the second USB interface, the driver of the first USB interface is first uninstalled.
[0054] Among them, the USB driver will occupy specific system resources (such as port number, interrupt request line), when switching to the second USB interface to establish a debugging bridge with the debugging device, if the driver of the first USB interface is not uninstalled, the second interface driver may not be able to normally bind to the system resources, resulting in conflicts. And if two USB drivers of the same type are activated at the same time, the system cannot correctly distinguish which interface the debugging device is connected to, causing communication confusion.
[0055] In some embodiments, the driver of the first USB interface can be uninstalled based on the system-provided driver management mechanism, including: stopping all services and processes related to the interface; and releasing the system resources occupied by the interface, disconnecting the debugging bridge between the terminal device and the debugging device.
[0056] In some embodiments, when the first USB interface is in the slave mode and the first USB interface is to be switched to establish the debug bridge with the debug device, the working mode of the first USB interface needs to be switched to another working mode, such as the master mode or the none mode.
[0057] In some embodiments, each serial bus USB interface includes a plurality of working modes, each working mode representing a working way or a working role of the serial bus interface; for example, the working modes can include the slave mode, the master mode, and the none mode. If the USB interface is in the slave mode, the terminal device supports the slave device. If the USB interface is in the master mode, the terminal device supports the master device. If the USB interface is in the none mode, the terminal device is prohibited from interacting with the external device through the USB interface.
[0058] In some embodiments, after the driver of the first USB interface is unloaded, the first mode of the first USB interface needs to be closed and the first mode of the second USB interface needs to be started.
[0059] In some embodiments, the first mode is the slave mode, which represents that the terminal device supports the slave device when the debug bridge is established with the debug device through the USB interface. When the terminal device is the slave device, the terminal device can receive the instruction from the debug device through the USB interface and return the debug information to the debug device.
[0060] In some embodiments, the disconnect signal is sent to the debug device to stop all data transmission of the debug device; at the same time, the function endpoints are disabled, including emptying the endpoint first-in-first-out buffer, disabling the interrupt endpoint and the bulk endpoint, to close the first mode of the terminal device.
[0061] In some embodiments, the DEVICE_MODE bit of the USB controller corresponding to the second USB interface is set to 1 to start the slave mode of the second USB interface.
[0062] In the embodiments of the present application, in response to the interface switching instruction of switching the first USB interface to the second USB interface to establish the debug bridge with the debug device, the slave mode of the first USB interface is closed. If the first USB interface and the second USB interface are both in the first mode, the system cannot correctly distinguish which interface the debug device is connected to, causing the problem of communication confusion. Therefore, the accuracy and flexibility of the debugging based on the USB interface are improved, thereby improving the user experience.
[0063] In some embodiments, after the unloading of the driver of the first USB interface, the closing of the first mode of the first USB interface, and the starting of the first mode of the second USB interface are completed, the driver of the second USB interface is started to establish the debugging bridge based on the driver of the second USB interface and the debugging device.
[0064] The starting of the driver of the second USB interface comprises: firstly loading the driver of the second USB interface, not initializing the driver to configure required parameters, and allocating necessary system resources (such as port number) for the driver to establish the debugging bridge.
[0065] In some embodiments, when the debugging bridge is established through the second USB interface and the debugging device, the terminal device acts as a slave device, and thus the working mode of the second USB interface needs to be switched to a slave mode to support the terminal device as a slave device.
[0066] In some embodiments, after the driver of the second USB interface is started, the debugging bridge can be established through the second USB interface and the debugging device.
[0067] In the embodiments of the present application, the interface switching instruction is received, the interface switching instruction is used to switch the interface for establishing the debugging bridge with the debugging device from the first USB interface to the second USB interface, the driver of the first USB interface is unloaded, and the driver of the second USB interface is started in response to the interface switching instruction, so that the terminal device supports the establishment of the debugging bridge through the second USB interface and the debugging device. The flexible switching of the debugging bridge interface is realized, compared with the prior art which only supports a single USB interface for debugging, the compatibility and stability of the terminal device in a multi-interface environment are enhanced, and the debugging requirements in a complex scenario are met. In this way, when the debugging bridge is established through the USB interface, any USB port can be switched for connection, the flexibility of the debugging bridge connection based on the USB is improved, and the user experience is improved.
[0068] In some embodiments, the closing of the first mode of the first USB interface comprises at least one of the following implementation manners:
[0069] The first USB interface is set to a second mode, and the second mode represents that data interaction with the debugging device through the first USB interface is prohibited.
[0070] In some embodiments, the second mode refers to setting the first USB interface to a non-device mode, that is, a non-slave mode, so as to avoid the first USB interface being used for data communication with the debugging device, and thus the conflict problem caused by multiple USB interfaces being in the device state at the same time.
[0071] In some embodiments, the second mode is usually none mode, in which the first USB interface cannot establish a debugging bridge with the debugging device as a device port. In this mode, if the first USB interface still maintains a physical connection with the debugging device, but disables the function of communicating with the first USB interface and the debugging device; if the driver of the first USB interface is not unloaded, it does not process any debugging protocol, the terminal device cannot send or receive debugging commands of the debugging device through the interface, and system resources (such as ports and interrupts) are still occupied but in a silent state.
[0072] The first USB interface is set to a third mode, and the third mode represents that the terminal device is supported as a master device when establishing a debugging bridge with the debugging device through the first USB interface.
[0073] In the embodiments of the present application, when the terminal device establishes a debugging bridge with the debugging device, the terminal device is set as a slave device by default, and the debugging device is set as a master device.
[0074] If the terminal device is to be set as a slave device, the USB interface connected with the debugging device in the terminal device needs to be in slave mode. Therefore, if the interface for establishing a debugging bridge with the debugging device needs to be switched from the first USB interface to the second USB interface, in order to avoid the conflict problem caused by the first USB interface and the second USB interface being in slave mode at the same time, the first USB interface needs to be set to non-mode.
[0075] In some embodiments, the third mode represents that the first USB interface is set to host mode, in which the terminal device is supported as a master device instead of a slave device. When the terminal device is a master device, it actively controls the debugging process, such as sending commands to the debugging device, obtaining logs, etc., instead of relying on external devices to initiate connection. Thus, the conflict problem of the terminal device being a slave device with the first USB interface is avoided.
[0076] In the embodiments of the present application, by setting the first USB interface to the second mode or the third mode, the USB interface used by ADB can be dynamically switched. In this way, the conflict caused by multiple USB interfaces being in device state at the same time can be avoided, so as to ensure the stability of the debugging process, and thus the needs of developers for debugging interfaces in different scenarios can be met, and the debugging efficiency and system compatibility can be improved.
[0077] In some embodiments, before the above process is executed, the following implementation is further included:
[0078] In response to the start of the terminal device, the driver data of each USB interface is loaded into the memory.
[0079] In some embodiments, the drive data refers to a set of program codes and parameter information loaded by the operating system to support the normal operation of a specific hardware device.
[0080] In the embodiments of the present application, each USB interface corresponds to a set of drive data, and each USB interface drive data determines whether the USB interface can be configured as an ADB debugging function. When the terminal device starts, by loading these drive data into the memory in advance, the use permission of the USB interface can be quickly switched in subsequent operations, so as to realize the dynamic allocation of the ADB debugging function.
[0081] In some embodiments, the memory refers to a temporary storage space in the terminal device, used to store the currently running programs and data. By loading the drive data of each USB interface into the memory in advance, the recognition and control speed of the system to the USB interface state can be accelerated, and the problem of function switching failure or debugging interruption caused by loading delay can be reduced.
[0082] In some embodiments, when the terminal device starts, the system detects all available USB interfaces and loads the corresponding drive data for each interface into the memory.
[0083] In some embodiments, the step S102 of starting the drive of the second USB interface includes the following implementation:
[0084] Based on the drive data of the second USB interface in the memory, the drive corresponding to the second USB interface is started.
[0085] In some embodiments, if it is necessary to establish a debugging bridge based on the second USB interface and the debugging device, the drive data of the second USB interface loaded into the memory when the terminal device starts is directly called to establish the debugging bridge based on the drive data of the second USB interface.
[0086] In some embodiments, after reading the drive data corresponding to the second USB interface from the memory, the drive of the second USB interface is first initialized, then the drive of the second USB interface is allocated system resources (such as port number, interrupt, etc.) and is bound with the second USB interface; finally, after enabling the second USB interface, the debugging bridge can be established between the second USB interface and the debugging device.
[0087] In the embodiments of the present application, the drive data of each USB interface is loaded into the memory when the terminal device starts. In this way, the quick binding between the USB interface and the ADB debugging function can be realized, so that the ADB debugging function of different USB ports can be dynamically switched, and thus the debugging efficiency can be improved and the multi-port debugging demand can be met.
[0088] In some embodiments, after the above-mentioned loading of the drive data of each of the USB interfaces into the memory, the following implementation is further included:
[0089] In response to the loading of the drive data of each of the USB interfaces into the memory, the drive corresponding to the default USB interface is started; so that the terminal device supports establishing a debugging bridge with the debugging device through the default USB interface.
[0090] In some embodiments, when the terminal device and the debugging device first establish a debugging bridge through a USB interface, the debugging bridge is established through a first USB interface of the at least two USB interfaces of the terminal device by default. Thus, when the terminal device first establishes a debugging bridge with the debugging device through a USB interface, the drive corresponding to the first USB interface is obtained from the drive data loaded into the memory when the terminal device is started, so that the terminal device establishes a debugging bridge with the debugging device through the first USB interface.
[0091] In some embodiments, when the terminal device is started, drive data is configured for each of the at least two USB interfaces of the terminal device, and the drive data of each of the USB interfaces is loaded into the memory. After the drive data of all USB interfaces is loaded into the memory, the drive data corresponding to the first USB interface that establishes a debugging bridge with the debugging device by default is matched from the memory, and the drive corresponding to the first USB interface is started, so that the terminal device can establish a debugging bridge with the debugging device based on the default first USB interface when it first establishes a debugging bridge with the debugging device through a USB interface.
[0092] In some embodiments, after reading the drive data corresponding to the first USB interface from the memory, the drive of the first USB interface is first initialized, then the drive of the first USB interface is allocated system resources (such as port number, interrupt, etc.) and is bound with the first USB interface; and finally, after enabling the first USB interface, a debugging bridge can be established with the debugging device through the second USB interface.
[0093] In the embodiments of the present application, in response to the loading of the drive data of each of the USB interfaces into the memory, the drive corresponding to the default USB interface is started. In this way, when the terminal device and the debugging device first establish a debugging bridge through a USB interface, the debugging bridge can be established with the debugging device through the default interface of the at least two USB interfaces of the terminal device, thereby improving the debugging and development efficiency in a multi-USB interface environment.
[0094] In some embodiments, after the above-mentioned starting of the drive of the second USB interface in step S103, the following implementation is further included:
[0095] In response to the event of establishing a debugging bridge with the debugging device, a debugging bridge is established with the debugging device based on the drive of the second USB interface.
[0096] In some embodiments, the debugging bridge event refers to a system-level event triggered when the terminal device attempts to establish a communication connection with the debugging device through the USB interface. The debugging bridge event can be triggered by manually inserting a USB cable by a user, or triggered when the system detects a change in the connection state; it can also be triggered by the debugging device actively sending a connection request to the terminal device through the debugging tool.
[0097] In some embodiments, the second USB interface refers to a USB interface other than the first USB interface among at least two USB interfaces of the terminal device, for example, the terminal device includes USB1, USB2, USB3, etc. If the first USB interface is USB1, the second USB interface is any one of USB2 and USB3.
[0098] In some embodiments, the state of the USB interface other than the first USB interface is detected. If it is detected that the debugging device is connected through the target USB interface, the debugging bridge event is triggered, and the target USB interface is determined as the second USB interface. The driving data corresponding to the second USB interface is obtained from the driving data loaded into the memory when the terminal device starts, and the driving corresponding to the second USB interface is driven. The data channel between the terminal device and the debugging device is established based on the driving of the second USB interface, and the debugging protocol handshake is performed with the debugging device based on the data, thereby establishing the debugging bridge between the terminal device and the debugging device through the second USB interface.
[0099] In the embodiments of the present application, by responding to the debugging bridge event and establishing the debugging bridge based on the driving of the second USB interface, the dynamic switching of the ADB communication interface can be realized, so that different USB ports can be freely selected for debugging, thereby improving the debugging efficiency and system compatibility.
[0100] In some embodiments, before the debugging bridge is established between the second USB interface and the debugging device, the following implementation is further included:
[0101] In the case where the terminal device has established a debugging bridge with the debugging device through the first USB interface; in response to the interface switching instruction, the debugging bridge established by the terminal device through the first USB interface with the debugging device is disconnected.
[0102] In some embodiments, when the terminal device and the debugging device first establish the debugging bridge through the USB interface, the debugging bridge is established through the first USB interface of the at least two USB interfaces of the terminal device by default; if the interface switching instruction for switching from the first USB interface to the second USB interface to establish the debugging bridge with the debugging device is received, if the terminal device has established the debugging bridge with the debugging device through the first USB interface at present, the debugging bridge established by the terminal device through the first USB interface with the debugging device needs to be disconnected, and the debugging bridge is established with the debugging device through the second USB interface.
[0103] In some embodiments, disconnecting the debugging bridge established by the terminal device through the first USB interface with the debugging device comprises: first, sending a disconnection signal to the debugging device through the data channel between the first USB interface and the debugging device; second, setting the working mode of the first USB interface to the second mode or the third mode (i.e. none mode or host mode); and third, uninstalling the driver of the first USB interface and releasing the system resources allocated to the first USB interface.
[0104] In some other embodiments, if the terminal device has not established the debugging bridge with the debugging device through the first USB interface at present, the first USB interface needs to be switched to the second mode or the third mode, and the driver of the first USB interface needs to be uninstalled to avoid affecting the establishment of the debugging bridge with the debugging device through the second USB interface.
[0105] In the embodiments of the present application, the debugging bridge is disconnected in response to the interface switching instruction when the terminal device has established the debugging bridge with the debugging device through the first USB interface. In this way, the release of the old debugging bridge can be completed before the interface is switched, so that the new debugging bridge can be stably established on the target USB interface, thereby supporting flexible debugging requirements in a multi-USB port environment.
[0106] The following describes an exemplary application of the interface switching method provided by the embodiments of the present application in an actual scenario.
[0107] In the existing Android debugging tool ADB, the device is usually connected through the USB or WIFI mode for debugging and data grabbing. Most of them establish ADB connection with external debugging devices through USB interface; by setting the USB interface of the terminal device to slave mode, the terminal device is used as a slave device; by connecting the USB interface of the terminal device in slave mode with the USB interface of the external debugging device in master mode, the ADB connection between the terminal device and the external debugging device is realized.
[0108] Currently, when a terminal device establishes an ADB connection with an external debugging device through a USB interface, a first USB interface (such as USB1, corresponding to the first USB interface in the above embodiment) is used by default as the USB interface for the ADB connection. However, when there are multiple interfaces (such as USB2, USB3, and the like) supporting the USB device function in the terminal device, the existing solution cannot flexibly switch the USB port used for the ADB connection, which limits the convenience of debugging and development.
[0109] To solve the above technical problems, embodiments of the present application provide an interface switching method. In the case that there are multiple USB interfaces in a terminal device and each USB interface supports the USB slave mode, the USB interface used for the ADB connection is dynamically switched, so that the terminal device establishes an ADB connection with a debugging device through a USB interface, thereby realizing flexible switching of the USB interface.
[0110] In some embodiments, when the terminal device needs to establish an ADB connection with an external debugging device, the first USB interface of the terminal device is generally used. When it is required to use other USB interfaces (USB2, USB3, corresponding to the second USB interface in the above embodiment), the device (slave mode, corresponding to the first mode in the above embodiment) of USB1 is first closed, and USB1 is switched to the host (master mode, corresponding to the third mode in the above embodiment) or none mode (corresponding to the second mode in the above embodiment), and then the driver of USB1 is unloaded to close the ADB established by the terminal device through USB1 and the external debugging device. USB2 is switched to the device mode (slave mode), and the driver of USB2 is started to enable the ADB connection between USB2 and the external debugging device. When the terminal device is connected through the first port of the USB harness and the debugging device is connected through the second port, the ADB connection between USB2 and the external debugging device is established.
[0111] In some embodiments, the adb driver of each USB interface is added in the terminal device, and the system service for switching the USB interfaces is added, such as sys.usb.adb.config=usb1 or usb2. When it is required to establish an ADB connection with a debugging device, the system establishes the ADB connection through usb1 adb by default. In the case that the service sys.usb.adb.config=usb2 is executed, the service is triggered to be switched to usb2 adb, the adb switching of the USB interface is realized, and the system can be dynamically switched at any time.
[0112] Figure 2An implementation flowchart of an interface switching method provided in an embodiment of the present application is shown, which can be executed by a processor of a terminal device. The method comprises steps S201 to S203, which will be described in combination with the steps shown in the figure. Figure 2
[0113] Step S201, in response to the start of the terminal device, loading the drivers of the USB interfaces into the memory.
[0114] In some embodiments, when the terminal device starts, the drivers of the USB interfaces determine whether the USB interfaces can be configured as ADB debugging functions. By loading the driver data into the memory in advance, the use permission of the USB interface can be quickly switched in subsequent operations, thereby realizing the dynamic allocation of the ADB debugging function.
[0115] Step S202, starting the switching service of the USB interface, and establishing an ADB connection with the debugging device through USB1 by default.
[0116] In some embodiments, when it is necessary to establish an ADB connection with the debugging device, USB1 is used by default; if it is necessary to switch to USB2 to establish an ADB connection with the debugging device, the switching service of the USB interface can be used for switching. For example, when the service sys.usb.adb.config=usb2 is executed, the service is triggered to switch to usb2 adb, thereby realizing the ADB switching of the USB interface.
[0117] Step S203, in the case where a switching instruction of the USB interface is received, establishing an ADB connection with the debugging device through USB2.
[0118] In the embodiment of the present application, the switching service and the script control mechanism are used to realize the dynamic switching of the ADB connection interface in the multi-USB interface environment, thereby improving the flexibility and convenience of debugging and development. The method is not only applicable to the vehicle-mounted Android system, but also can be popularized to other embedded systems that need to support multi-USB interface debugging.
[0119] Based on the foregoing embodiments, an interface switching apparatus is provided in an embodiment of the present application, which comprises units and modules included in the units, and can be realized by a processor in a terminal device. Of course, the apparatus can also be realized by a specific logic circuit. In the implementation process, the processor can be a central processing unit (CPU), a micro processing unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA).
[0120] Figure 3 A component structure diagram of an interface switching device provided by an embodiment of the present application is shown in FIG. 3. As shown in FIG. 3, the interface switching device 300 includes a first response module 301, a second response module 302, and a third response module 303, wherein: Figure 3 The first response module 301 is configured to, in response to the first USB interface detecting a debugging device, acquire information of the debugging device, the information including a communication protocol. The second response module 302 is configured to, in response to the communication protocol being used, forcibly set the terminal device to a first mode, start an interface switching instruction, and use the interface switching instruction to switch an interface for establishing a debugging bridge with the debugging device from the first USB interface to a second USB interface. The third response module 303 is configured to, in response to the interface switching instruction, unload a driver of the first USB interface, close the first mode of the first USB interface, start the first mode of the second USB interface, and start a driver of the second USB interface, so as to enable the terminal device to support establishing the debugging bridge with the debugging device through the second USB interface. The first mode indicates that the terminal device supports being a slave device when establishing the debugging bridge with the debugging device through the USB interface.
[0121] In some embodiments, the second response module 302 is further configured to set the first USB interface to a second mode, and set the first USB interface to a third mode. The second mode indicates that data interaction between the first USB interface and the debugging device is prohibited. The third mode indicates that the terminal device supports being a master device when establishing the debugging bridge with the debugging device through the first USB interface.
[0122] In some embodiments, the interface switching device 300 further includes a loading module (not shown in the figure). The loading module is configured to, in response to starting of the terminal device, load driver data of each USB interface into a memory. The starting of the driver of the second USB interface includes starting the driver corresponding to the second USB interface based on the driver data corresponding to the second USB interface in the memory.
[0123] In some embodiments, the loading module is further configured to, in response to loading the driver data of each USB interface into the memory, start a driver corresponding to a default USB interface, so as to enable the terminal device to support establishing the debugging bridge with the debugging device through the default USB interface.
[0124] In some embodiments, the loading module is further configured to, in response to loading the driver data of each USB interface into the memory, start a driver corresponding to a default USB interface, so as to enable the terminal device to support establishing the debugging bridge with the debugging device through the default USB interface.
[0125] In some embodiments, the interface switching apparatus 300 further comprises an establishing module (not shown in the figure), configured to, in response to establishing a debugging bridge event with the debugging device, establish a debugging bridge with the debugging device based on the driver of the second USB interface.
[0126] In some embodiments, the establishing module is further configured to, in a case where the terminal device has established a debugging bridge with the debugging device through the first USB interface; in response to the interface switching instruction, disconnect the debugging bridge established by the terminal device with the debugging device through the first USB interface.
[0127] The above apparatus embodiments are similar to the above method embodiments in description, and have similar beneficial effects to the method embodiments. In some embodiments, the apparatus provided by the embodiments of the present application has functions or comprises modules that can be used to execute the methods described in the above method embodiments. For technical details of the present application that are not disclosed in the apparatus embodiments of the present application, please refer to the description of the method embodiments of the present application.
[0128] It should be noted that, in the embodiments of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product in essence or the part that contributes to the related art, which is stored in a storage medium, includes a number of instructions to make a terminal device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various program code storage media. Thus, the embodiments of the present application are not limited to any specific hardware, software or firmware, or any combination of hardware, software and firmware.
[0129] The embodiments of the present application provide a terminal device, comprising a memory and a processor, the memory stores a computer program capable of running on the processor, and the processor implements part or all of the steps in the above method when executing the program.
[0130] The embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement part or all of the steps in the above method. The computer readable storage medium can be transitory or non-transitory.
[0131] The embodiment of the present application provides a computer program, including computer readable code, wherein the processor in the terminal device executes part or all steps of the above method when the computer readable code runs in the terminal device.
[0132] The embodiment of the present application provides a computer program product, including a non-transitory computer readable storage medium storing a computer program, wherein the computer program is read and executed by a computer to implement part or all steps of the above method. The computer program product can be implemented by hardware, software or a combination thereof. In some embodiments, the computer program product is embodied as a computer storage medium, and in some other embodiments, the computer program product is embodied as a software product, such as a software development kit (SDK) or the like.
[0133] It should be noted that the above description of the various embodiments tends to emphasize the differences between the various embodiments, and the same or similar parts can be referred to each other. The above description of the device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the device, storage medium, computer program and computer program product embodiments of the present application, please refer to the description of the method embodiments of the present application.
[0134] Figure 4 A hardware entity schematic diagram of a terminal device provided by the embodiment of the present application is shown in FIG. 4, which includes a processor 401, a memory 402 and at least two universal serial bus (USB) interfaces 403. The memory 402 stores a computer program executable on the processor 401, and the processor 401 implements the steps of the method of any of the above embodiments when executing the program. Figure 4
[0135] The memory 402 stores a computer program executable on the processor, and the memory 402 is configured to store instructions and applications executable by the processor 401, and can also cache data (for example, image data, audio data, voice communication data and video communication data) to be processed by the processor 401 and modules in the terminal device 400, which can be realized by a flash memory (FLASH) or a random access memory (RAM).
[0136] The processor 401 executes the program to implement the steps of the method of any of the above embodiments. The processor 401 generally controls the overall operation of the terminal device 400
[0137] The universal serial bus (USB) interface 403 is configured to establish a debug bridge with a debugging device.
[0138] The embodiment of the present application provides a computer storage medium, and the computer storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the method in any of the above embodiments.
[0139] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects to the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0140] The processor can be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, or a microprocessor. It can be understood that the electronic device for realizing the function of the processor can also be other electronic devices, and the embodiment of the present application is not limited specifically.
[0141] The computer storage medium / memory can be a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Ferromagnetic Random Access Memory (FRAM), a Flash Memory, a magnetic surface storage, an optical disc, a Compact Disc Read-Only Memory (CD-ROM), or the like memory; or can be various terminals including one or any combination of the above memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, and the like.
[0142] It should be understood that every monetary term referred to throughout the specification means that the specific feature, structure or characteristic related to the embodiment is included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that the size of the serial number of each step / process described above does not mean the order of execution, and the execution order of each step / process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The serial number of the above embodiments of the present application is only for description, not representing the advantages and disadvantages of the embodiments.
[0143] It should be noted that in this document, the terms "comprise", "comprising", or any other variant thereof are intended to cover non-exclusive inclusions, so that processes, methods, articles or devices that include a series of elements not only include those elements, but also include other elements not explicitly listed, or include elements inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0144] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other manners. The described device embodiments are merely schematic. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling, or direct coupling or communication connection between the components can be indirect coupling or communication connection through some interfaces, devices, or units, and can be electrical, mechanical, or in other forms.
[0145] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units; they can be located in one place, or distributed on multiple network units; and some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0146] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be realized in the form of hardware, or in the form of hardware plus software functional units. Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program is executed to perform the steps of the above-mentioned method embodiments; and the foregoing storage medium includes mobile storage devices, read-only memories (ReadOnly Memory, ROM), magnetic discs or optical discs, and various storage media that can store program codes.
[0147] Alternatively, the integrated units of the present application, if implemented in the form of software functional modules and sold or used as independent products, can also be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products, and the computer software products are stored in a storage medium, including a number of instructions to make a terminal device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the methods described in the embodiments of the present application. The foregoing storage medium includes mobile storage devices, ROM, magnetic discs or optical discs, and various storage media that can store program codes.
[0148] The above merely provides the implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of the change or replacement within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.
Claims
1. An interface switching method, applied to a terminal device, wherein the terminal device is provided with at least two Universal Serial Bus (USB) interfaces, the method comprising: In response to the first USB interface detecting a debugging device, obtaining information of the debugging device, the information including a communication protocol; In response to forcing the terminal device to the first mode when the communication protocol is used, starting an interface switching instruction, the interface switching instruction being used to switch the interface for establishing a debug bridge with the debug device from the first USB interface to the second USB interface; In response to the interface switching instruction, uninstall the driver of the first USB interface, disable the first mode of the first USB interface, and enable the first mode of the second USB interface and the driver of the second USB interface, so that the terminal device supports establishing a debug bridge with the debugging device through the second USB interface; The first mode represents that the terminal device is supported as a slave device when a debug bridge is established with a debug device via a USB interface.
2. The method according to claim 1, wherein the first mode of shutting down the first USB interface comprises any one of the following: Setting the first USB interface to a second mode; wherein the second mode indicates that data interaction with the debugging device through the first USB interface is prohibited; The first USB interface is set to a third mode; the third mode indicates that the terminal device is supported as a master device when a debugging bridge is established with a debugging device through the first USB interface.
3. The method according to any one of claims 1 or 2, further comprising: In response to the startup of the terminal device, loading the driver data of each USB interface into the memory; The starting of the driver of the second USB interface includes: Based on the driver data corresponding to the second USB interface in the memory, the driver corresponding to the second USB interface is started.
4. The method according to claim 3, further comprising: In response to loading the driver data of each USB interface into the memory, starting the driver corresponding to the default USB interface; This enables the terminal device to support establishing a debugging bridge with the debugging device through the default USB interface.
5. The method according to any one of claims 1 or 2, further comprising: In response to an event of establishing a debugging bridge with the debugging device, a debugging bridge is established with the debugging device based on a driver of the second USB interface.
6. The method according to claim 5, further comprising: In a case where the terminal device has established a debugging bridge with the debugging device through the first USB interface; In response to the interface switching instruction, the debugging bridge established between the terminal device and the debugging device through the first USB interface is disconnected.
7. An interface switching device, applied to a terminal device, wherein the terminal device is provided with at least two Universal Serial Bus (USB) interfaces, the device comprising: A first response module, configured to obtain information of the debugging device in response to the first USB interface detecting the debugging device, the information including a communication protocol; a second response module, configured to initiate an interface switching instruction in response to forcing the terminal device to be in the first mode when the communication protocol is used, wherein the interface switching instruction is configured to switch the interface for establishing a debugging bridge with the debugging device from the first USB interface to the second USB interface; A third response module is used to respond to the interface switching instruction, uninstall the driver of the first USB interface, turn off the first mode of the first USB interface, and start the first mode of the second USB interface and start the driver of the second USB interface, so that the terminal device supports establishing a debugging bridge with the debugging device through the second USB interface; wherein, the first mode represents supporting the terminal device as a slave device when establishing a debugging bridge with the debugging device through the USB interface.
8. A terminal device comprising at least two universal serial bus (USB) interfaces, a memory, and a processor, wherein: The memory stores a computer program executable on the processor; When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented; The universal serial bus (USB) interface is used to establish a debugging bridge with a debugging device.
9. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program or instructions, wherein when the computer program or instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.