Device in-place detection method, electronic device, and storage medium

By obtaining device information from external devices and parsing directory names to determine the physical interface name, the problem of Android devices being unable to detect the presence of USB interfaces was solved, thus achieving accurate physical interface identification.

CN115237688BActive Publication Date: 2026-07-14BOE TECHNOLOGY GROUP CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BOE TECHNOLOGY GROUP CO LTD
Filing Date
2022-06-20
Publication Date
2026-07-14

Smart Images

  • Figure CN115237688B_ABST
    Figure CN115237688B_ABST
Patent Text Reader

Abstract

The present disclosure provides a device in-place detection method, an electronic device and a storage medium. The method comprises: obtaining device information of a first external device; obtaining a device name and a device type of the first external device based on the device information, and generating a first directory name based on the device name and the device type; obtaining a device directory pointed to by the first directory name based on the first directory name, and obtaining a second directory name of the device directory; parsing the second directory name to obtain a physical interface name accessed by the first external device; and determining the physical interface accessed by the first external device based on the physical interface name and a pre-obtained current system total physical interface name. The device in-place detection method, the electronic device and the storage medium provided by the present disclosure can determine the physical interface accessed by the first external device, thereby judging the physical interface accessed by the external device and realizing the in-place detection function of the external device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method for detecting device in-situ, an electronic device, and a storage medium. Background Technology

[0002] Currently, Android devices generally provide multiple external USB physical ports, which can be seen on the device's exterior as named USB1, USB2, USB3, etc. When a user connects an external device to any of these ports, the Android system has already prepared the available path for that USB drive within the system by default.

[0003] However, for an external device, regardless of which interface it is connected to on the Android device, the available path within the Android system is the same after processing. Therefore, it is impossible to determine exactly which physical interface the external device is connected to on the Android device, and the presence detection function of the USB interface cannot be implemented. Summary of the Invention

[0004] In view of this, the purpose of this disclosure is to provide a device in-situ detection method, electronic device and storage medium.

[0005] To achieve the above objectives, this disclosure provides a method for in-situ device detection, comprising:

[0006] Obtain device information for the first external device;

[0007] Based on the device information, obtain the device name and device type of the first external device, and generate a first directory name based on the device name and device type;

[0008] Based on the first directory name, obtain the device directory pointed to by the first directory name, and obtain the second directory name of the device directory;

[0009] Parse the second directory name to obtain the physical interface name to which the first external device is connected;

[0010] Based on the physical interface name and the pre-acquired names of all physical interfaces in the current system, the physical interface to which the first external device is connected is determined.

[0011] Optionally, the external device includes an external storage device; obtaining the device information of the external device includes:

[0012] The system uses a query command to query the file system type used by the block devices in the current system, and obtains the device information based on the query results.

[0013] Optionally, generating the first directory name based on the device name and the device type includes:

[0014] The default path of the first external device in the current system is determined based on the device type;

[0015] The first directory name is generated by concatenating the default path of the first external device in the current system and the device name.

[0016] Optionally, the first directory name is a symbolic link; obtaining the device directory pointed to by the first directory name based on the first directory name includes:

[0017] The symbolic link pointing command is used to obtain the location pointed to by the first directory name, and the device directory is obtained based on the location pointed to by the first directory name.

[0018] Optionally, the method for obtaining the pre-acquired names of all physical interfaces of the current system includes:

[0019] In response to the insertion of a second external device into any physical interface of the current system, obtain the system directory name of the second external device in the system directory;

[0020] Parse the system directory name to obtain the physical interface name of the physical interface into which the second external device is inserted.

[0021] Optionally, after determining the physical interface to which the first external device is connected, the method further includes:

[0022] Based on the device information, obtain the first device number of the first external device;

[0023] Obtain the mount directory of the first external device in the current system, and obtain the second device number of the first external device in the mount directory based on the mount directory;

[0024] In response to the first device number being the same as the second device number, the physical interface is determined as the actual physical interface to which the first external device is connected, and the mount directory is determined as the available path of the first external device.

[0025] Optional, also includes:

[0026] Receive control commands for the first external device, and control the first external device based on the control commands and the available paths.

[0027] Optionally, the system includes an Android system, and the physical interface includes a USB interface.

[0028] This disclosure also provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any of the preceding descriptions.

[0029] This disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform any of the methods described above.

[0030] As can be seen from the above description, the device presence detection method, electronic device, and storage medium provided in this disclosure, when an external device is connected to the system, obtain the device information of the external device to obtain the device name and device type of the external device, generate a first directory name based on the device name and device type, obtain a second directory name based on the location pointed to by the first directory name, and then obtain the physical interface name of the first external device recorded in the second directory name. The physical interface name is compared with all the physical interface names of the system obtained in advance to determine the physical interface of the first external device, thereby enabling the determination of the physical interface of the external device and realizing the presence detection function of the external device. Attached Figure Description

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

[0032] Figure 1 This is a schematic flowchart of the device in-situ detection method according to an embodiment of this disclosure;

[0033] Figure 2 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.

[0035] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this disclosure should have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms "first," "second," and similar terms used in the embodiments of this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0036] As described in the background section, after an external device is plugged into an Android device, the Android system automatically processes it and provides the user with the external device's mount path within the system. This process requires no user intervention; the user only needs to listen for the system's external device plug-in / plug-out event broadcast. Upon receiving the broadcast, the user can obtain the current mount path of the external device through the system's StorageManager service. Taking the Mstar platform as an example, this mount path is typically " / mnt / usb / UUID". Since a universally unique identifier (UUID) for an external device is fixed, the mount path of the external device in the system also remains unchanged. Therefore, when an Android device has multiple physical interfaces, it cannot determine which physical interface is currently connected to the external device.

[0037] For example, when an Android device's two physical ports, USB1 and USB2, are each connected to an external device, the user only knows that two external devices are connected to the Android system, but cannot determine which external device is connected to USB1 and which is connected to USB2. In this situation, when the user wants to operate on files on the external device connected to USB1, they cannot directly know which device in the Android system is connected to USB1. The user has to open both external devices separately to view their contents before finding the external device connected to USB1, which is inconvenient for the user.

[0038] In view of this, this disclosure proposes a device in-situ detection method to solve the problem of in-situ detection of external devices. For example... Figure 1 As shown, the method includes:

[0039] Step S101: Obtain device information of the first external device.

[0040] The device presence detection method described in this embodiment can be applied to electronic devices, such as mobile phones, tablets, personal computers, large screens, and smart display devices. The electronic device has an operating system installed and provides multiple physical interfaces for connecting external devices. After connecting to the electronic device through these physical interfaces, the external device can be operated and controlled through the electronic device's built-in operating system.

[0041] External devices may include input devices, display devices, printing devices, external storage devices, and network devices.

[0042] In this embodiment, when an external device is connected, the newly connected external device can be identified by listening to the plug-in / plug-out events of the external device in the current system, and then the device information of the external device can be obtained; alternatively, the devices in the system can be detected at predetermined intervals, and the current detection result can be compared with the previous detection result to obtain the connected external device and then the device information of the external device; alternatively, any other method can be used to obtain the connected external device and then the device information of the external device. This embodiment does not limit this.

[0043] Step S102: Obtain the device name and device type of the first external device based on the device information, and generate a first directory name based on the device name and device type.

[0044] The device information for external devices includes the device name and device type.

[0045] In this embodiment, when an external device is connected to the system, a directory corresponding to the external device is generated in a default directory of the system. This directory includes the default path of the external device in the default directory and the device name of the external device. For external devices of the same type, when connected to the same type of system, a directory corresponding to the external device is generated in the same default directory. Therefore, in this embodiment, the default path of the first external device in the default directory of the current system can be obtained based on the device type of the first external device. Combined with the device name of the first external device, the first directory name of the directory of the first external device in the default directory of the current system can be generated.

[0046] Step S103: Obtain the device directory pointed to by the first directory name based on the first directory name, and obtain the second directory name of the device directory.

[0047] In this embodiment, the device directory is the actual directory corresponding to the first external device in the first directory name. After obtaining the actual directory corresponding to the first external device, its corresponding directory name, i.e., the second directory name, can be obtained.

[0048] Step S104: Parse the second directory name to obtain the physical interface name to which the first external device is connected.

[0049] In this embodiment, the second directory name includes the device directory of the first external device, which stores the name of the physical interface to which the first external device is connected. Therefore, the name of the physical interface to which the first external device is connected can be obtained by parsing the second directory name.

[0050] Step S105: Based on the physical interface name and the pre-acquired names of all physical interfaces of the current system, determine the physical interface to which the external device is connected.

[0051] In this embodiment, all physical interface names in the current system can be obtained in advance, and these physical interface names correspond one-to-one with the interface names displayed on the electronic device. By matching the physical interface names obtained in step S104 with the pre-obtained physical interface names in the current system, the physical interface to which the first external device is connected can be determined.

[0052] The device presence detection method described in this embodiment obtains the device information of the external device when it is connected to the system, thereby obtaining the device name and device type of the external device. A first directory name is generated based on the device name and device type, and a second directory name is obtained based on the location pointed to by the first directory name. Then, the physical interface name of the first external device recorded in the second directory name is obtained. The physical interface name is compared with all the physical interface names of the system obtained in advance to determine the physical interface connected to the first external device. This enables the determination of the physical interface connected to the external device and realizes the presence detection function of the external device.

[0053] In some embodiments, the external device includes an external storage device, which may be a USB flash drive, hard drive, SD card, or other storage device.

[0054] In this embodiment, before performing the presence detection of the external storage device, it is necessary to first determine the names of all physical interfaces in the current system. The method for obtaining the pre-acquired names of each physical interface in the current system includes:

[0055] Step S201: In response to the second external device being inserted into any physical interface of the current system, obtain the system directory name of the second external device in the system directory.

[0056] Step S202: Parse the system directory name to obtain the physical interface name of the physical interface into which the second external device is inserted.

[0057] In this embodiment, the second external device can be inserted into each physical interface in sequence. Each time it is inserted, the operation of steps S201-S202 is executed to obtain the name of each physical interface. This allows the interface names displayed on the electronic device, such as USB1, USB2, USB3, etc., to be matched with the physical interface names of each physical interface in the system, so that it can be directly determined in the system which physical interface the second external device is inserted into.

[0058] Specifically, taking the example of inserting a second external device into a physical interface named USB1 on the external display of an electronic device, when the second external device is inserted into the physical interface USB1, the system directory name of the second external device under the system directory sys is obtained. For example, the system directory name corresponding to the physical interface USB1 is sys / bus / usb / devices / 4-1.5. Parsing the system directory name will reveal that the physical interface name of the physical interface USB1 into which the second external device is inserted is 4-1.5.

[0059] When the second external device is plugged into the physical interface USB2, the system directory name of the second external device under the system directory sys is obtained. For example, the system directory name corresponding to the physical interface USB2 is sys / bus / usb / devices / 2-1. Parsing the system directory name will reveal that the physical interface name of the physical interface USB1 into which the second external device is plugged is 2-1.

[0060] In this embodiment, by inserting the second external device into only one physical interface at a time and then observing the changes in the system directory name sys / bus / usb / devices / under the system directory of the second external device, the system directory name and physical interface name corresponding to the current physical interface are determined.

[0061] Once the names of all physical interfaces in the current system are obtained, the device's presence detection function can be implemented.

[0062] In some embodiments, obtaining device information of an external device in step S101 includes: querying the file system type used by the block device in the current system using a query command, and obtaining the device information based on the query results.

[0063] The query commands can include the blkid command. The blkid command is used to query information such as the file system type, LABEL, and UUID used by the system's block devices.

[0064] In this embodiment, the blkid command is used to query the file system type used by the block device in the current system. The query results include the partition name, label, UUID, and file system type. For example, when the external storage device is a USB flash drive, the query result using the blkid command is: / dev / block / sda:LABEL="AAA (USB flash drive label)"UUID="1C11-62AF"TYPE="vfat".

[0065] In this embodiment, when the external storage device includes multiple partitions, the query result of the blkid command is the query result of the corresponding partition, for example, / dev / block / sda1:LABEL="AAA(USB flash drive label)"UUID="1C11-62AF"TYPE="vfat".

[0066] Based on the above query results, the partition of the USB drive is / dev / block / sda1, so the device name of the USB drive is sda. The device type can be determined by combining the partition name, label, UUID, and file system type.

[0067] After obtaining the device information, the device name and device type of the first external device can be obtained based on the device information, and a first directory name can be generated based on the device name and device type. Specifically, step S102, generating the first directory name based on the device name and device type, includes:

[0068] Step S301: Determine the default path of the first external device in the current system based on the device type.

[0069] In this embodiment, when external devices of the same type are connected to the same type of system, a directory corresponding to the external device will be generated in the same default directory. For example, in the system of this application, when the first external device is a USB flash drive, its default path is: / sys / block / device name.

[0070] Step S302: Generate the first directory name by concatenating the default path of the first external device in the current system and the device name.

[0071] When the device name obtained in step S102 is sda, the first directory name generated by concatenation is / sys / block / sda.

[0072] In some embodiments, the first directory name is a symbolic link, which contains a reference to another file or directory in the form of an absolute path or relative path. In this embodiment, the first directory name points to the actual device directory of the first external device.

[0073] The step S103 of obtaining the device directory pointed to by the first directory name based on the first directory name includes: obtaining the location pointed to by the first directory name using a symbolic link pointing command, and obtaining the device directory based on the location pointed to by the first directory name.

[0074] In this embodiment, the symbolic link pointing command can be the `readlink` command. In this embodiment, the location pointed to by the first directory name corresponding to the symbolic link is obtained by calling the `readlink` command, and the device directory is obtained based on the location pointed to by the first directory name, and then the second directory name of the device directory is obtained. In some embodiments, the second directory name of the device directory can be:

[0075] / devices / Mstar-ehci-4 / usb4 / 4-1 / 4-1.5 / 4-1.5:1.0 / host1 / target1:0:0 / 1:0:0:0 / block / sda.

[0076] Parse the second directory name to obtain the physical interface name 4-1.5. Since the names of all physical interfaces in the current system have already been determined, including: the physical interface name corresponding to physical interface USB1 is 4-1.5, and the physical interface name corresponding to physical interface USB2 is 2-1; therefore, based on the physical interface name 4-1.5 obtained from the second directory name and the pre-obtained names of all physical interfaces in the current system, it can be determined that the physical interface to which the first external device is connected is physical interface USB1.

[0077] In some embodiments, after determining the physical interface to which the first external device is connected, the method further includes:

[0078] Step S401: Obtain the first device number of the first external device based on the device information.

[0079] In this embodiment, the device information also includes the first device number of the first external device. The first device number can be a Universally Unique Identifier (UUID) for the external device. When the device information, i.e., the query result using the blkid command, is / dev / block / sda1:LABEL="AAA (USB drive label)"UUID="1C11-62AF"TYPE="vfat", then the first device number is UUID="1C11-62AF".

[0080] Step S402: Obtain the mount directory of the first external device in the current system, and obtain the second device number of the first external device in the mount directory based on the mount directory.

[0081] In this embodiment, the system's StorageManager service can be used to obtain the mount directory of the first external device in the current system, such as / mnt / usb / 1C11-62AF. Then, parsing this mount directory yields the second device number of the first external device within the mount directory, i.e., UUID = "1C11-62AF".

[0082] Step S403: In response to the first device number being the same as the second device number, the physical interface is determined as the actual physical interface accessed by the first external device, and the mount directory is determined as the available path of the first external device.

[0083] In this embodiment, it is determined whether the first device number and the second device number are the same. When the first device number and the second device number are the same, the physical interface USB1 obtained in step S105 is determined as the real physical interface to which the first external device is connected, and the mount directory / mnt / usb / 1C11-62AF is determined as the available path of the first external device. Subsequently, the first external device inserted on the physical interface USB1 can be operated based on the mount directory.

[0084] In some embodiments, the method further includes: receiving a control command for the first external device, and controlling the first external device based on the control command and the available path. In this embodiment, once the presence detection of the first external device is completed and its available path is obtained, the first external device connected to the specified physical interface can be operated.

[0085] Optionally, in the above embodiments, the system includes an Android system, and the physical interface includes a USB interface.

[0086] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.

[0087] It should be noted that the above description describes some embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0088] Based on the same inventive concept, corresponding to any of the above embodiments, this disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in any of the above embodiments.

[0089] Figure 2 This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, memory 1020, input / output interface 1030, and communication interface 1040 are interconnected internally via the bus 1050.

[0090] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0091] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.

[0092] The input / output interface 1030 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.

[0093] The communication interface 1040 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0094] Bus 1050 includes a pathway for transmitting information between various components of the device, such as processor 1010, memory 1020, input / output interface 1030, and communication interface 1040.

[0095] It should be noted that although the above-described device only shows the processor 1010, memory 1020, input / output interface 1030, communication interface 1040, and bus 1050, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.

[0096] The electronic devices described above are used to implement the corresponding methods in any of the foregoing embodiments and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0097] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this disclosure also provides a non-transitory computer-readable storage medium that stores computer instructions for causing the computer to perform the methods described in any of the above embodiments.

[0098] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0099] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to perform the methods described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0100] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this disclosure (including the claims) is limited to these examples; within the framework of this disclosure, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this disclosure as described above, which are not provided in detail for the sake of brevity.

[0101] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this disclosure, the provided drawings may or may not show well-known power / ground connections to integrated circuit (IC) chips and other components. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this disclosure, and this also takes into account the fact that the details of implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this disclosure will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuitry) have been set forth to describe exemplary embodiments of this disclosure, it will be apparent to those skilled in the art that the embodiments of this disclosure may be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0102] Although this disclosure has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0103] This disclosure is intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for detecting equipment in-situ, characterized in that, include: Obtain device information of the first external device connected to the current system, wherein the current system includes multiple physical interfaces; Based on the device information, obtain the device name and device type of the first external device, and generate a first directory name based on the device name and device type; Based on the first directory name, obtain the device directory pointed to by the first directory name, and obtain the second directory name of the device directory; Parse the second directory name to obtain the physical interface name to which the first external device is connected; Based on the physical interface name and the pre-acquired names of all physical interfaces in the current system, the physical interface to which the first external device is connected is determined. The first directory name is a symbolic link; The step of obtaining the device directory pointed to by the first directory name based on the first directory name includes: obtaining the location pointed to by the first directory name using a symbolic link pointing command, and obtaining the device directory based on the location pointed to by the first directory name; The method for obtaining the pre-acquired names of all physical interfaces of the current system includes: in response to the insertion of a second external device into any physical interface of the current system, obtaining the system directory name of the second external device in the system directory; parsing the system directory name to obtain the physical interface name of the physical interface into which the second external device is inserted.

2. The method according to claim 1, characterized in that, The external device includes an external storage device; obtaining the device information of the external device includes: The system uses a query command to query the file system type used by the block devices in the current system, and obtains the device information based on the query results.

3. The method according to claim 1, characterized in that, The step of generating a first directory name based on the device name and the device type includes: The default path of the first external device in the current system is determined based on the device type; The first directory name is generated by concatenating the default path of the first external device in the current system and the device name.

4. The method according to any one of claims 1-3, characterized in that, After determining the physical interface to which the first external device is connected, the method further includes: Based on the device information, obtain the first device number of the first external device; Obtain the mount directory of the first external device in the current system, and obtain the second device number of the first external device in the mount directory based on the mount directory; In response to the first device number being the same as the second device number, the physical interface is determined as the actual physical interface to which the first external device is connected, and the mount directory is determined as the available path of the first external device.

5. The method according to claim 4, characterized in that, Also includes: Receive control commands for the first external device, and control the first external device based on the control commands and the available paths.

6. The method according to claim 1, characterized in that, The system includes the Android operating system, and the physical interface includes a USB interface.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 6.

8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 6.